Revision a3758ab2

b/daemons/ganeti-confd
69 69

  
70 70
  # this method is overriding a daemon.AsyncUDPSocket method
71 71
  def handle_datagram(self, payload_in, ip, port):
72
    payload_out =  self.processor.ExecQuery(payload_in, ip, port)
73
    if payload_out is not None:
72

  
73
    if len(payload_in) < len(constants.CONFD_MAGIC_FOURCC):
74
      logging.debug("Received a query which is too short to be true")
75
      return
76

  
77
    magic_number = payload_in[:4]
78
    query = payload_in[4:]
79

  
80
    if magic_number != constants.CONFD_MAGIC_FOURCC:
81
      logging.debug("Received a query with an unknown magic number")
82
      return
83

  
84
    answer =  self.processor.ExecQuery(query, ip, port)
85
    if answer is not None:
86
      payload_out = ''.join([constants.CONFD_MAGIC_FOURCC, answer])
74 87
      self.enqueue_send(ip, port, payload_out)
75 88

  
76 89

  
b/lib/constants.py
682 682
# to serve more requests.
683 683
CONFD_CONFIG_RELOAD_RATELIMIT = 2
684 684

  
685
# Magic number prepended to all confd queries.
686
# This allows us to distinguish different types of confd protocols and handle
687
# them. For example by changing this we can move the whole payload to be
688
# compressed, or move away from json.
689
CONFD_MAGIC_FOURCC = 'plj0'
690

  
685 691
# Maximum UDP datagram size.
686 692
# On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
687 693
# On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487

Also available in: Unified diff