notify_out.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. # Copyright (C) 2010 Internet Systems Consortium.
  2. #
  3. # Permission to use, copy, modify, and distribute this software for any
  4. # purpose with or without fee is hereby granted, provided that the above
  5. # copyright notice and this permission notice appear in all copies.
  6. #
  7. # THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
  8. # DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
  9. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
  10. # INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
  11. # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
  12. # FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  13. # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  14. # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. import select
  16. import sys
  17. import random
  18. import socket
  19. import threading
  20. import time
  21. import errno
  22. from isc.datasrc import sqlite3_ds
  23. from isc.datasrc import DataSourceClient
  24. from isc.net import addr
  25. import isc
  26. from isc.log_messages.notify_out_messages import *
  27. logger = isc.log.Logger("notify_out")
  28. # there used to be a printed message if this import failed, but if
  29. # we can't import we should not start anyway, and logging an error
  30. # is a bad idea since the logging system is most likely not
  31. # initialized yet. see trac ticket #1103
  32. from isc.dns import *
  33. ZONE_NEW_DATA_READY_CMD = 'zone_new_data_ready'
  34. ZONE_XFRIN_FAILED = 'zone_xfrin_failed'
  35. _MAX_NOTIFY_NUM = 30
  36. _MAX_NOTIFY_TRY_NUM = 5
  37. _EVENT_NONE = 0
  38. _EVENT_READ = 1
  39. _EVENT_TIMEOUT = 2
  40. _NOTIFY_TIMEOUT = 1
  41. # define the rcode for parsing notify reply message
  42. _REPLY_OK = 0
  43. _BAD_QUERY_ID = 1
  44. _BAD_QUERY_NAME = 2
  45. _BAD_OPCODE = 3
  46. _BAD_QR = 4
  47. _BAD_REPLY_PACKET = 5
  48. SOCK_DATA = b's'
  49. # borrowed from xfrin.py @ #1298. We should eventually unify it.
  50. def format_zone_str(zone_name, zone_class):
  51. """Helper function to format a zone name and class as a string of
  52. the form '<name>/<class>'.
  53. Parameters:
  54. zone_name (isc.dns.Name) name to format
  55. zone_class (isc.dns.RRClass) class to format
  56. """
  57. return zone_name.to_text() + '/' + str(zone_class)
  58. class NotifyOutDataSourceError(Exception):
  59. """An exception raised when data source error happens within notify out.
  60. This exception is expected to be caught within the notify_out module.
  61. """
  62. pass
  63. class ZoneNotifyInfo:
  64. '''This class keeps track of notify-out information for one zone.'''
  65. def __init__(self, zone_name_, class_):
  66. self._notify_current = None
  67. self._slave_index = 0
  68. self._sock = None
  69. self.notify_slaves = []
  70. self.zone_name = zone_name_
  71. self.zone_class = class_
  72. self.notify_msg_id = 0
  73. # Absolute time for next notify reply. When the zone is preparing for
  74. # sending notify message, notify_timeout_ is set to now, that means
  75. # the first sending is triggered by the 'Timeout' mechanism.
  76. self.notify_timeout = None
  77. self.notify_try_num = 0 # Notify times sending to one target.
  78. def set_next_notify_target(self):
  79. if self._slave_index < (len(self.notify_slaves) - 1):
  80. self._slave_index += 1
  81. self._notify_current = self.notify_slaves[self._slave_index]
  82. else:
  83. self._notify_current = None
  84. def prepare_notify_out(self):
  85. '''Set notify timeout time to now'''
  86. self.notify_timeout = time.time()
  87. self.notify_try_num = 0
  88. self._slave_index = 0
  89. if len(self.notify_slaves) > 0:
  90. self._notify_current = self.notify_slaves[0]
  91. def finish_notify_out(self):
  92. if self._sock:
  93. self._sock.close()
  94. self._sock = None
  95. self.notify_timeout = None
  96. def create_socket(self, dest_addr):
  97. self._sock = socket.socket(addr.IPAddr(dest_addr).family,
  98. socket.SOCK_DGRAM)
  99. return self._sock
  100. def get_socket(self):
  101. return self._sock
  102. def get_current_notify_target(self):
  103. return self._notify_current
  104. class NotifyOut:
  105. '''This class is used to handle notify logic for all zones(sending
  106. notify message to its slaves). notify service can be started by
  107. calling dispatcher(), and it can be stoped by calling shutdown()
  108. in another thread. '''
  109. def __init__(self, datasrc_file, verbose=True):
  110. self._notify_infos = {} # key is (zone_name, zone_class)
  111. self._waiting_zones = []
  112. self._notifying_zones = []
  113. self._serving = False
  114. self._read_sock, self._write_sock = socket.socketpair()
  115. self._read_sock.setblocking(False)
  116. self.notify_num = 0 # the count of in progress notifies
  117. self._verbose = verbose
  118. self._lock = threading.Lock()
  119. self._db_file = datasrc_file
  120. self._init_notify_out(datasrc_file)
  121. # Use nonblock event to eliminate busy loop
  122. # If there are no notifying zones, clear the event bit and wait.
  123. self._nonblock_event = threading.Event()
  124. def _init_notify_out(self, datasrc_file):
  125. '''Get all the zones name and its notify target's address.
  126. TODO, currently the zones are got by going through the zone
  127. table in database. There should be a better way to get them
  128. and also the setting 'also_notify', and there should be one
  129. mechanism to cover the changed datasrc.
  130. '''
  131. self._db_file = datasrc_file
  132. for zone_name, zone_class in sqlite3_ds.get_zones_info(datasrc_file):
  133. zone_id = (zone_name, zone_class)
  134. self._notify_infos[zone_id] = ZoneNotifyInfo(zone_name, zone_class)
  135. slaves = self._get_notify_slaves_from_ns(Name(zone_name),
  136. RRClass(zone_class))
  137. for item in slaves:
  138. self._notify_infos[zone_id].notify_slaves.append((item, 53))
  139. def add_slave(self, address, port):
  140. for zone_name, zone_class in sqlite3_ds.get_zones_info(self._db_file):
  141. zone_id = (zone_name, zone_class)
  142. if zone_id in self._notify_infos:
  143. self._notify_infos[zone_id].notify_slaves.append((address, port))
  144. def send_notify(self, zone_name, zone_class='IN'):
  145. '''Send notify to one zone's slaves, this function is
  146. the only interface for class NotifyOut which can be called
  147. by other object.
  148. Internally, the function only set the zone's notify-reply
  149. timeout to now, then notify message will be sent out.
  150. Returns False if the zone/class is not known, True if it is
  151. (even if there are no slaves)'''
  152. if zone_name[len(zone_name) - 1] != '.':
  153. zone_name += '.'
  154. zone_id = (zone_name, zone_class)
  155. if zone_id not in self._notify_infos:
  156. return False
  157. # Has no slave servers, skip it.
  158. if (len(self._notify_infos[zone_id].notify_slaves) <= 0):
  159. return True
  160. with self._lock:
  161. if (self.notify_num >= _MAX_NOTIFY_NUM) or (zone_id in self._notifying_zones):
  162. if zone_id not in self._waiting_zones:
  163. self._waiting_zones.append(zone_id)
  164. else:
  165. self._notify_infos[zone_id].prepare_notify_out()
  166. self.notify_num += 1
  167. self._notifying_zones.append(zone_id)
  168. if not self._nonblock_event.isSet():
  169. self._nonblock_event.set()
  170. return True
  171. def _dispatcher(self, started_event):
  172. started_event.set() # Let the master know we are alive already
  173. while self._serving:
  174. replied_zones, not_replied_zones = self._wait_for_notify_reply()
  175. for name_ in replied_zones:
  176. self._zone_notify_handler(replied_zones[name_], _EVENT_READ)
  177. for name_ in not_replied_zones:
  178. if not_replied_zones[name_].notify_timeout <= time.time():
  179. self._zone_notify_handler(not_replied_zones[name_], _EVENT_TIMEOUT)
  180. def dispatcher(self, daemon=False):
  181. """Spawns a thread that will handle notify related events.
  182. If one zone get the notify reply before timeout, call the
  183. handle to process the reply. If one zone can't get the notify
  184. before timeout, call the handler to resend notify or notify
  185. next slave.
  186. The thread can be stopped by calling shutdown().
  187. Returns the thread object to anyone interested.
  188. """
  189. if self._serving:
  190. raise RuntimeError(
  191. 'Dispatcher already running, tried to start twice')
  192. # Prepare for launch
  193. self._serving = True
  194. started_event = threading.Event()
  195. # Start
  196. self._thread = threading.Thread(target=self._dispatcher,
  197. args=[started_event])
  198. if daemon:
  199. self._thread.daemon = daemon
  200. self._thread.start()
  201. # Wait for it to get started
  202. started_event.wait()
  203. # Return it to anyone listening
  204. return self._thread
  205. def shutdown(self):
  206. """Stop the dispatcher() thread. Blocks until the thread stopped."""
  207. if not self._serving:
  208. raise RuntimeError('Tried to stop while not running')
  209. # Ask it to stop
  210. self._serving = False
  211. if not self._nonblock_event.isSet():
  212. # set self._nonblock_event to stop waiting for new notifying zones.
  213. self._nonblock_event.set()
  214. self._write_sock.send(SOCK_DATA) # make self._read_sock be readable.
  215. # Wait for it
  216. self._thread.join()
  217. # Clean up
  218. self._write_sock.close()
  219. self._write_sock = None
  220. self._read_sock.close()
  221. self._read_sock = None
  222. self._thread = None
  223. def _get_rdata_data(self, rr):
  224. return rr[7].strip()
  225. def _get_notify_slaves_from_ns(self, zone_name, zone_class):
  226. '''Get all NS records, then remove the primary master from ns rrset,
  227. then use the name in NS record rdata part to get the a/aaaa records
  228. in the same zone. the targets listed in a/aaaa record rdata are treated
  229. as the notify slaves.
  230. Note: this is the simplest way to get the address of slaves,
  231. but not correct, it can't handle the delegation slaves, or the CNAME
  232. and DNAME logic.
  233. TODO. the function should be provided by one library.
  234. '''
  235. # Prepare data source client. This should eventually be moved to
  236. # an earlier stage of initialization and also support multiple
  237. # data sources.
  238. datasrc_config = '{ "database_file": "' + self._db_file + '"}'
  239. try:
  240. ds_client = DataSourceClient('sqlite3', datasrc_config)
  241. except isc.datasrc.Error as ex:
  242. logger.error(NOTIFY_OUT_DATASRC_ACCESS_FAILURE, ex)
  243. return []
  244. result, finder = ds_client.find_zone(zone_name)
  245. if result is not DataSourceClient.SUCCESS:
  246. logger.error(NOTIFY_OUT_DATASRC_ZONE_NOT_FOUND,
  247. format_zone_str(zone_name, zone_class))
  248. return []
  249. result, ns_rrset, _ = finder.find(zone_name, RRType.NS())
  250. if result is not finder.SUCCESS or ns_rrset is None:
  251. logger.warn(NOTIFY_OUT_ZONE_NO_NS,
  252. format_zone_str(zone_name, zone_class))
  253. return []
  254. result, soa_rrset, _ = finder.find(zone_name, RRType.SOA())
  255. if result is not finder.SUCCESS or soa_rrset is None or \
  256. soa_rrset.get_rdata_count() != 1:
  257. logger.warn(NOTIFY_OUT_ZONE_BAD_SOA,
  258. format_zone_str(zone_name, zone_class))
  259. return [] # broken zone anyway, stop here.
  260. soa_mname = Name(soa_rrset.get_rdata()[0].to_text().split(' ')[0])
  261. addrs = []
  262. for ns_rdata in ns_rrset.get_rdata():
  263. ns_name = Name(ns_rdata.to_text())
  264. if soa_mname == ns_name:
  265. continue
  266. ns_result, ns_finder = ds_client.find_zone(ns_name)
  267. if ns_result is DataSourceClient.SUCCESS or \
  268. ns_result is DataSourceClient.PARTIALMATCH:
  269. result, rrset, _ = ns_finder.find(ns_name, RRType.A())
  270. if result is ns_finder.SUCCESS and rrset is not None:
  271. addrs.extend([a.to_text() for a in rrset.get_rdata()])
  272. result, rrset, _ = ns_finder.find(ns_name, RRType.AAAA())
  273. if result is ns_finder.SUCCESS and rrset is not None:
  274. addrs.extend([aaaa.to_text()
  275. for aaaa in rrset.get_rdata()])
  276. return addrs
  277. def _prepare_select_info(self):
  278. '''
  279. Prepare the information for select(), returned
  280. value is one tuple
  281. (block_timeout, valid_socks, notifying_zones)
  282. block_timeout: the timeout for select()
  283. valid_socks: sockets list for waiting ready reading.
  284. notifying_zones: the zones which have been triggered
  285. for notify.
  286. '''
  287. valid_socks = []
  288. notifying_zones = {}
  289. min_timeout = None
  290. for info in self._notify_infos:
  291. sock = self._notify_infos[info].get_socket()
  292. if sock:
  293. valid_socks.append(sock)
  294. # If a non null timeout is specified notify has been scheduled
  295. # (in which case socket is still None) or sent (with a valid
  296. # socket). In either case we need add the zone to notifying_zones
  297. # so that we can invoke the appropriate event for the zone after
  298. # select.
  299. tmp_timeout = self._notify_infos[info].notify_timeout
  300. if tmp_timeout is not None:
  301. notifying_zones[info] = self._notify_infos[info]
  302. if min_timeout is not None:
  303. if tmp_timeout < min_timeout:
  304. min_timeout = tmp_timeout
  305. else:
  306. min_timeout = tmp_timeout
  307. block_timeout = None
  308. if min_timeout is not None:
  309. block_timeout = min_timeout - time.time()
  310. if block_timeout < 0:
  311. block_timeout = 0
  312. return (block_timeout, valid_socks, notifying_zones)
  313. def _wait_for_notify_reply(self):
  314. '''
  315. Receive notify replies in specified time. returned value
  316. is one tuple:(replied_zones, not_replied_zones). ({}, {}) is
  317. returned if shutdown() was called.
  318. replied_zones: the zones which receive notify reply.
  319. not_replied_zones: the zones which haven't got notify reply.
  320. '''
  321. (block_timeout, valid_socks, notifying_zones) = \
  322. self._prepare_select_info()
  323. # This is None only during some tests
  324. if self._read_sock is not None:
  325. valid_socks.append(self._read_sock)
  326. # Currently, there is no notifying zones, waiting for zones to send notify
  327. if block_timeout is None:
  328. self._nonblock_event.clear()
  329. self._nonblock_event.wait()
  330. # has new notifying zone, check immediately
  331. block_timeout = 0
  332. try:
  333. r_fds, w, e = select.select(valid_socks, [], [], block_timeout)
  334. except select.error as err:
  335. if err.args[0] != errno.EINTR:
  336. return {}, {}
  337. if self._read_sock in r_fds: # user has called shutdown()
  338. try:
  339. # Noone should write anything else than shutdown
  340. assert self._read_sock.recv(len(SOCK_DATA)) == SOCK_DATA
  341. return {}, {}
  342. except socket.error as e: # Workaround around rare linux bug
  343. if e.errno != errno.EAGAIN and e.errno != errno.EWOULDBLOCK:
  344. raise
  345. not_replied_zones = {}
  346. replied_zones = {}
  347. for info in notifying_zones:
  348. if notifying_zones[info].get_socket() in r_fds:
  349. replied_zones[info] = notifying_zones[info]
  350. else:
  351. not_replied_zones[info] = notifying_zones[info]
  352. return replied_zones, not_replied_zones
  353. def _zone_notify_handler(self, zone_notify_info, event_type):
  354. '''Notify handler for one zone. The first notify message is
  355. always triggered by the event "_EVENT_TIMEOUT" since when
  356. one zone prepares to notify its slaves, its notify_timeout
  357. is set to now, which is used to trigger sending notify
  358. message when dispatcher() scanning zones. '''
  359. tgt = zone_notify_info.get_current_notify_target()
  360. if event_type == _EVENT_READ:
  361. reply = self._get_notify_reply(zone_notify_info.get_socket(), tgt)
  362. if reply is not None:
  363. if self._handle_notify_reply(zone_notify_info, reply, tgt):
  364. self._notify_next_target(zone_notify_info)
  365. elif event_type == _EVENT_TIMEOUT and zone_notify_info.notify_try_num > 0:
  366. logger.info(NOTIFY_OUT_TIMEOUT, tgt[0], tgt[1])
  367. tgt = zone_notify_info.get_current_notify_target()
  368. if tgt:
  369. zone_notify_info.notify_try_num += 1
  370. if zone_notify_info.notify_try_num > _MAX_NOTIFY_TRY_NUM:
  371. logger.warn(NOTIFY_OUT_RETRY_EXCEEDED, tgt[0], tgt[1],
  372. _MAX_NOTIFY_TRY_NUM)
  373. self._notify_next_target(zone_notify_info)
  374. else:
  375. # set exponential backoff according rfc1996 section 3.6
  376. retry_timeout = _NOTIFY_TIMEOUT * pow(2, zone_notify_info.notify_try_num)
  377. zone_notify_info.notify_timeout = time.time() + retry_timeout
  378. self._send_notify_message_udp(zone_notify_info, tgt)
  379. def _notify_next_target(self, zone_notify_info):
  380. '''Notify next address for the same zone. If all the targets
  381. has been notified, notify the first zone in waiting list. '''
  382. zone_notify_info.notify_try_num = 0
  383. zone_notify_info.set_next_notify_target()
  384. tgt = zone_notify_info.get_current_notify_target()
  385. if not tgt:
  386. zone_notify_info.finish_notify_out()
  387. with self._lock:
  388. self.notify_num -= 1
  389. self._notifying_zones.remove((zone_notify_info.zone_name,
  390. zone_notify_info.zone_class))
  391. # trigger notify out for waiting zones
  392. if len(self._waiting_zones) > 0:
  393. zone_id = self._waiting_zones.pop(0)
  394. self._notify_infos[zone_id].prepare_notify_out()
  395. self.notify_num += 1
  396. self._notifying_zones.append(zone_id)
  397. if not self._nonblock_event.isSet():
  398. self._nonblock_event.set()
  399. def _send_notify_message_udp(self, zone_notify_info, addrinfo):
  400. msg, qid = self._create_notify_message(
  401. Name(zone_notify_info.zone_name),
  402. RRClass(zone_notify_info.zone_class))
  403. render = MessageRenderer()
  404. render.set_length_limit(512)
  405. msg.to_wire(render)
  406. zone_notify_info.notify_msg_id = qid
  407. try:
  408. sock = zone_notify_info.create_socket(addrinfo[0])
  409. sock.sendto(render.get_data(), 0, addrinfo)
  410. logger.info(NOTIFY_OUT_SENDING_NOTIFY, addrinfo[0],
  411. addrinfo[1])
  412. except (socket.error, addr.InvalidAddress) as err:
  413. logger.error(NOTIFY_OUT_SOCKET_ERROR, addrinfo[0],
  414. addrinfo[1], err)
  415. return False
  416. except addr.InvalidAddress as iae:
  417. logger.error(NOTIFY_OUT_INVALID_ADDRESS, addrinfo[0],
  418. addrinfo[1], iae)
  419. return False
  420. return True
  421. def _create_notify_message(self, zone_name, zone_class):
  422. msg = Message(Message.RENDER)
  423. qid = random.randint(0, 0xFFFF)
  424. msg.set_qid(qid)
  425. msg.set_opcode(Opcode.NOTIFY())
  426. msg.set_rcode(Rcode.NOERROR())
  427. msg.set_header_flag(Message.HEADERFLAG_AA)
  428. msg.add_question(Question(zone_name, zone_class, RRType.SOA()))
  429. msg.add_rrset(Message.SECTION_ANSWER, self._get_zone_soa(zone_name,
  430. zone_class))
  431. return msg, qid
  432. def _get_zone_soa(self, zone_name, zone_class):
  433. # We create (and soon drop) the data source client here because
  434. # clients should be thread specific. We could let the main thread
  435. # loop (_dispatcher) create and retain the client in order to avoid
  436. # the overhead when we generalize the interface (and we may also
  437. # revisit the design of notify_out more substantially anyway).
  438. datasrc_config = '{ "database_file": "' + self._db_file + '"}'
  439. result, finder = DataSourceClient('sqlite3',
  440. datasrc_config).find_zone(zone_name)
  441. if result is not DataSourceClient.SUCCESS:
  442. raise NotifyOutDataSourceError('_get_zone_soa: Zone ' +
  443. zone_name.to_text() + '/' +
  444. zone_class.to_text() + ' not found')
  445. result, soa_rrset, _ = finder.find(zone_name, RRType.SOA())
  446. if result is not finder.SUCCESS or soa_rrset is None or \
  447. soa_rrset.get_rdata_count() != 1:
  448. raise NotifyOutDataSourceError('_get_zone_soa: Zone ' +
  449. zone_name.to_text() + '/' +
  450. zone_class.to_text() +
  451. ' is broken: no valid SOA found')
  452. return soa_rrset
  453. def _handle_notify_reply(self, zone_notify_info, msg_data, from_addr):
  454. '''Parse the notify reply message.
  455. rcode will not checked here, If we get the response
  456. from the slave, it means the slaves has got the notify.'''
  457. msg = Message(Message.PARSE)
  458. try:
  459. msg.from_wire(msg_data)
  460. if not msg.get_header_flag(Message.HEADERFLAG_QR):
  461. logger.warn(NOTIFY_OUT_REPLY_QR_NOT_SET, from_addr[0],
  462. from_addr[1])
  463. return _BAD_QR
  464. if msg.get_qid() != zone_notify_info.notify_msg_id:
  465. logger.warn(NOTIFY_OUT_REPLY_BAD_QID, from_addr[0],
  466. from_addr[1], msg.get_qid(),
  467. zone_notify_info.notify_msg_id)
  468. return _BAD_QUERY_ID
  469. question = msg.get_question()[0]
  470. if question.get_name() != Name(zone_notify_info.zone_name):
  471. logger.warn(NOTIFY_OUT_REPLY_BAD_QUERY_NAME, from_addr[0],
  472. from_addr[1], question.get_name().to_text(),
  473. Name(zone_notify_info.zone_name).to_text())
  474. return _BAD_QUERY_NAME
  475. if msg.get_opcode() != Opcode.NOTIFY():
  476. logger.warn(NOTIFY_OUT_REPLY_BAD_OPCODE, from_addr[0],
  477. from_addr[1], msg.get_opcode().to_text())
  478. return _BAD_OPCODE
  479. except Exception as err:
  480. # We don't care what exception, just report it?
  481. logger.error(NOTIFY_OUT_REPLY_UNCAUGHT_EXCEPTION, err)
  482. return _BAD_REPLY_PACKET
  483. return _REPLY_OK
  484. def _get_notify_reply(self, sock, tgt_addr):
  485. try:
  486. msg, addr = sock.recvfrom(512)
  487. except socket.error as err:
  488. logger.error(NOTIFY_OUT_SOCKET_RECV_ERROR, tgt_addr[0],
  489. tgt_addr[1], err)
  490. return None
  491. return msg