BIND 10 trac2222, updated. d591857e687fc1f21796a2fb80c5b356c2c6c6b3 [2222] Merge branch 'trac2158' of git://git.bind10.isc.org/bind10 into trac2222

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Sep 18 07:57:47 UTC 2012


The branch, trac2222 has been updated
       via  d591857e687fc1f21796a2fb80c5b356c2c6c6b3 (commit)
       via  2c05e5b0d8011671469ab20aa5c0c5f9325bc8f3 (commit)
      from  87e52b48844ab6e51b2b7e811eae8d8913e4a982 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit d591857e687fc1f21796a2fb80c5b356c2c6c6b3
Merge: 87e52b4 2c05e5b
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Tue Sep 18 15:54:11 2012 +0900

    [2222] Merge branch 'trac2158' of git://git.bind10.isc.org/bind10 into trac2222
    
    Conflicts:
    	src/bin/xfrout/xfrout.py.in
    
    Do not set a noop callable(lambda: x: None) when omitting setting
    counter handler as a result of reviewing on #2158

-----------------------------------------------------------------------

Summary of changes:
 src/bin/xfrout/tests/xfrout_test.py.in             |   23 +++++++++++++
 src/bin/xfrout/xfrout.py.in                        |    4 +--
 src/lib/python/isc/notify/notify_out.py            |   16 ++++-----
 src/lib/python/isc/notify/tests/notify_out_test.py |   36 ++++++++++++++++++++
 4 files changed, 68 insertions(+), 11 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/xfrout/tests/xfrout_test.py.in b/src/bin/xfrout/tests/xfrout_test.py.in
index d9cb78f..c519b90 100644
--- a/src/bin/xfrout/tests/xfrout_test.py.in
+++ b/src/bin/xfrout/tests/xfrout_test.py.in
@@ -502,6 +502,15 @@ class TestXfroutSession(TestXfroutSessionBase):
         self.check_transfer_acl(acl_setter)
         self.assertGreater(self.get_counter('xfrrej'), 0)
 
+    def test_transfer_acl_with_notcallable_xfrrej(self):
+        # ACL checks only with the default ACL and not callable xfrrej
+        # counter
+        def acl_setter(acl):
+            self.xfrsess._acl = acl
+        self.xfrsess._counter_xfrrej = 'NOT CALLABLE'
+        self.assertRaises(TypeError,
+                          self.check_transfer_acl, acl_setter)
+
     def test_transfer_zoneacl(self):
         # ACL check with a per zone ACL + default ACL.  The per zone ACL
         # should match the queryied zone, so it should be used.
@@ -883,6 +892,20 @@ class TestXfroutSession(TestXfroutSessionBase):
         self.assertEqual(self.sock.readsent(), b"success")
         self.assertGreater(self.get_counter('xfrreqdone'), 0)
 
+    def test_dns_xfrout_start_with_notcallable_xfrreqdone(self):
+        def noerror(msg, name, rrclass):
+            return Rcode.NOERROR()
+        self.xfrsess._xfrout_setup = noerror
+
+        def myreply(msg, sock):
+            self.sock.send(b"success")
+
+        self.xfrsess._reply_xfrout_query = myreply
+        self.xfrsess._counter_xfrreqdone = 'NOT CALLABLE'
+        self.assertRaises(TypeError,
+                          self.xfrsess.dns_xfrout_start, self.sock,
+                          self.mdata)
+
     def test_reply_xfrout_query_axfr(self):
         self.xfrsess._soa = self.soa_rrset
         self.xfrsess._iterator = [self.soa_rrset]
diff --git a/src/bin/xfrout/xfrout.py.in b/src/bin/xfrout/xfrout.py.in
index c7421f7..805e2c4 100755
--- a/src/bin/xfrout/xfrout.py.in
+++ b/src/bin/xfrout/xfrout.py.in
@@ -175,9 +175,7 @@ class XfroutSession():
         for (k, v) in counters.items():
             if k.find('counter_') == 0 or k.find('inc_') == 0 \
                     or k.find('dec_') == 0:
-                setattr(self, "_%s" % k, lambda x: None)
-                if hasattr(v, '__call__'):
-                    setattr(self, "_%s" % k, v)
+                setattr(self, "_%s" % k, v)
         self._handle()
 
     def create_tsig_ctx(self, tsig_record, tsig_key_ring):
diff --git a/src/lib/python/isc/notify/notify_out.py b/src/lib/python/isc/notify/notify_out.py
index 8d632d0..46bb00b 100644
--- a/src/lib/python/isc/notify/notify_out.py
+++ b/src/lib/python/isc/notify/notify_out.py
@@ -145,12 +145,8 @@ class NotifyOut:
         self._nonblock_event = threading.Event()
         # Set counter handlers for counting notifies. An argument is
         # required for zone name.
-        self._counter_notifyoutv4 = lambda x: None
-        if hasattr(counter_notifyoutv4, '__call__'):
-            self._counter_notifyoutv4 = counter_notifyoutv4
-        self._counter_notifyoutv6 = lambda x: None
-        if hasattr(counter_notifyoutv6, '__call__'):
-            self._counter_notifyoutv6 = counter_notifyoutv6
+        self._counter_notifyoutv4 = counter_notifyoutv4
+        self._counter_notifyoutv6 = counter_notifyoutv6
 
     def _init_notify_out(self, datasrc_file):
         '''Get all the zones name and its notify target's address.
@@ -488,9 +484,13 @@ class NotifyOut:
             sock = zone_notify_info.create_socket(addrinfo[0])
             sock.sendto(render.get_data(), 0, addrinfo)
             # count notifying by IPv4 or IPv6 for statistics
-            if zone_notify_info.get_socket().family == socket.AF_INET:
+            if zone_notify_info.get_socket().family \
+                    == socket.AF_INET \
+                    and self._counter_notifyoutv4 is not None:
                 self._counter_notifyoutv4(zone_notify_info.zone_name)
-            elif zone_notify_info.get_socket().family == socket.AF_INET6:
+            elif zone_notify_info.get_socket().family \
+                    == socket.AF_INET6 \
+                    and self._counter_notifyoutv6 is not None:
                 self._counter_notifyoutv6(zone_notify_info.zone_name)
             logger.info(NOTIFY_OUT_SENDING_NOTIFY, addrinfo[0],
                         addrinfo[1])
diff --git a/src/lib/python/isc/notify/tests/notify_out_test.py b/src/lib/python/isc/notify/tests/notify_out_test.py
index 8343d0b..b9183e0 100644
--- a/src/lib/python/isc/notify/tests/notify_out_test.py
+++ b/src/lib/python/isc/notify/tests/notify_out_test.py
@@ -289,6 +289,42 @@ class TestNotifyOut(unittest.TestCase):
         self.assertIsNone(self._notifiedv4_zone_name)
         self.assertEqual(self._notifiedv6_zone_name, 'example.net.')
 
+    def test_send_notify_message_udp_ipv4_with_nonetype_notifyoutv4(self):
+        example_com_info = self._notify._notify_infos[('example.net.', 'IN')]
+        example_com_info.prepare_notify_out()
+        self.assertIsNone(self._notifiedv4_zone_name)
+        self.assertIsNone(self._notifiedv6_zone_name)
+        self._notify._counter_notifyoutv4 = None
+        self._notify._send_notify_message_udp(example_com_info,
+                                              ('192.0.2.1', 53))
+        self.assertIsNone(self._notifiedv4_zone_name)
+        self.assertIsNone(self._notifiedv6_zone_name)
+
+    def test_send_notify_message_udp_ipv4_with_notcallable_notifyoutv4(self):
+        example_com_info = self._notify._notify_infos[('example.net.', 'IN')]
+        example_com_info.prepare_notify_out()
+        self._notify._counter_notifyoutv4 = 'NOT CALLABLE'
+        self.assertRaises(TypeError,
+                          self._notify._send_notify_message_udp,
+                          example_com_info, ('192.0.2.1', 53))
+
+    def test_send_notify_message_udp_ipv6_with_nonetype_notifyoutv6(self):
+        example_com_info = self._notify._notify_infos[('example.net.', 'IN')]
+        self.assertIsNone(self._notifiedv4_zone_name)
+        self.assertIsNone(self._notifiedv6_zone_name)
+        self._notify._counter_notifyoutv6 = None
+        self._notify._send_notify_message_udp(example_com_info,
+                                              ('2001:db8::53', 53))
+        self.assertIsNone(self._notifiedv4_zone_name)
+        self.assertIsNone(self._notifiedv6_zone_name)
+
+    def test_send_notify_message_udp_ipv6_with_notcallable_notifyoutv6(self):
+        example_com_info = self._notify._notify_infos[('example.net.', 'IN')]
+        self._notify._counter_notifyoutv6 = 'NOT CALLABLE'
+        self.assertRaises(TypeError,
+                          self._notify._send_notify_message_udp,
+                          example_com_info, ('2001:db8::53', 53))
+
     def test_send_notify_message_with_bogus_address(self):
         example_com_info = self._notify._notify_infos[('example.net.', 'IN')]
 



More information about the bind10-changes mailing list