Merge "Send both gratuitous ARP REQUESTs and REPLYs" into stable/newton

This commit is contained in:
Jenkins 2017-05-27 04:48:12 +00:00 committed by Gerrit Code Review
commit c62543545c
2 changed files with 35 additions and 27 deletions

View File

@ -1051,26 +1051,33 @@ def _arping(ns_name, iface_name, address, count, log_exception):
time.sleep(2) time.sleep(2)
first = False first = False
# Pass -w to set timeout to ensure exit if interface removed while # some Linux kernels* don't honour REPLYs. Send both gratuitous REQUEST
# running # and REPLY packets (REQUESTs are left for backwards compatibility for
arping_cmd = ['arping', '-A', '-I', iface_name, '-c', 1, # in case if some network peers, vice versa, honor REPLYs and not
'-w', 1.5, address] # REQUESTs)
try: #
ip_wrapper = IPWrapper(namespace=ns_name) # * https://patchwork.ozlabs.org/patch/763016/
# Since arping is used to send gratuitous ARP, a response is not for arg in ('-U', '-A'):
# expected. In some cases (no response) and with some platforms arping_cmd = ['arping', arg, '-I', iface_name, '-c', 1,
# (>=Ubuntu 14.04), arping exit code can be 1. # Pass -w to set timeout to ensure exit if interface
ip_wrapper.netns.execute(arping_cmd, extra_ok_codes=[1]) # removed while running
except Exception as exc: '-w', 1.5, address]
msg = _("Failed sending gratuitous ARP " try:
"to %(addr)s on %(iface)s in namespace %(ns)s: %(err)s") ip_wrapper = IPWrapper(namespace=ns_name)
logger_method = LOG.exception # Since arping is used to send gratuitous ARP, a response is
if not log_exception: # not expected. In some cases (no response) and with some
logger_method = LOG.warning # platforms (>=Ubuntu 14.04), arping exit code can be 1.
logger_method(msg, {'addr': address, ip_wrapper.netns.execute(arping_cmd, extra_ok_codes=[1])
'iface': iface_name, except Exception as exc:
'ns': ns_name, msg = _("Failed sending gratuitous ARP to %(addr)s on "
'err': exc}) "%(iface)s in namespace %(ns)s: %(err)s")
logger_method = LOG.exception
if not log_exception:
logger_method = LOG.warning
logger_method(msg, {'addr': address,
'iface': iface_name,
'ns': ns_name,
'err': exc})
def send_ip_addr_adv_notif( def send_ip_addr_adv_notif(

View File

@ -1407,13 +1407,14 @@ class TestArpPing(TestIPCmdBase):
ip_wrapper = mIPWrapper(namespace=mock.sentinel.ns_name) ip_wrapper = mIPWrapper(namespace=mock.sentinel.ns_name)
# Just test that arping is called with the right arguments # Just test that arping is called with the right arguments
arping_cmd = ['arping', '-A', for arg in ('-A', '-U'):
'-I', mock.sentinel.iface_name, arping_cmd = ['arping', arg,
'-c', 1, '-I', mock.sentinel.iface_name,
'-w', mock.ANY, '-c', 1,
address] '-w', mock.ANY,
ip_wrapper.netns.execute.assert_any_call(arping_cmd, address]
extra_ok_codes=[1]) ip_wrapper.netns.execute.assert_any_call(arping_cmd,
extra_ok_codes=[1])
@mock.patch('eventlet.spawn_n') @mock.patch('eventlet.spawn_n')
def test_no_ipv6_addr_notif(self, spawn_n): def test_no_ipv6_addr_notif(self, spawn_n):