diff --git a/autocertkit/network_tests.py b/autocertkit/network_tests.py index a9c5cfa..65ab038 100644 --- a/autocertkit/network_tests.py +++ b/autocertkit/network_tests.py @@ -142,17 +142,6 @@ def configure_routes(self): """Ensure that the routing table is setup correctly in the client""" log.debug("Configuring routes...") - # Make a plugin call to ensure the server is going to recieve - # packets over the correct interface - - self.plugin_call('reset_arp', - {'vm_ref': self.client, 'mip': self.vm_info[self.client]['ip_m'] - }) - - self.plugin_call('reset_arp', - {'vm_ref': self.server, 'mip': self.vm_info[self.server]['ip_m'] - }) - # Make a plugin call to add a route to the client self.plugin_call('add_route', {'vm_ref': self.client, @@ -424,9 +413,6 @@ def test_vlan_high_port(self, session): vm2_test_dev, _, vm2_test_ip = get_context_test_ifs(vm2_ref)[0] - call_ack_plugin(session, 'reset_arp', {'vm_ref': vm1_ref, 'mip': get_context_vm_mip(vm1_ref)}) - call_ack_plugin(session, 'reset_arp', {'vm_ref': vm2_ref, 'mip': get_context_vm_mip(vm2_ref)}) - # Make certain the VMs are available for vm_ref in [vm1_ref, vm2_ref]: check_vm_ping_response(session, vm_ref, get_context_vm_mip(vm_ref)) diff --git a/autocertkit/utils.py b/autocertkit/utils.py index 9a74a0a..408b896 100644 --- a/autocertkit/utils.py +++ b/autocertkit/utils.py @@ -1033,7 +1033,7 @@ def get_context(): def clean_context(): global __context - __context = {'vms': {}} + __context = {'vms': {}, 'arp_mode': '0'} return __context @@ -1067,6 +1067,14 @@ def set_context_vm_ifs(vm_ref, ifs): vms[vm_ref]['ifs'] = ifs +def get_context_arp_mode(): + return get_context()['arp_mode'] + + +def set_context_arp_mode(mode='0'): + get_context()['arp_mode'] = mode + + def get_context_test_ifs(vm_ref): mdevice = get_context_vm_mif(vm_ref)[0] return [test_if for test_if in get_context_vm_ifs(vm_ref) if test_if[0] != mdevice] @@ -1773,6 +1781,8 @@ def deploy_common_droid_vms_on_hosts(session, host_refs, network_refs, vm_count, start_droid_vms(session, host_vm_list) + config_arp(session, all_vms) + return host_vms @@ -1920,9 +1930,6 @@ def init_droid_vm_first_run(session, vm_ref, vifs_info): call_ack_plugin(session, 'inject_ssh_key', {'vm_ref': vm_ref, 'mip': mip, 'username': 'root', 'password': DEFAULT_PASSWORD}) - # Ensure that we make sure the switch accesses IP addresses by - # their own interfaces (avoid interface forwarding). - call_ack_plugin(session, 'reset_arp', {'vm_ref': vm_ref, 'mip': mip}) disable_vm_static_ip_service(session, get_context_vm_mip(vm_ref)) init_ifs_ip_addressing(session, vm_ref, vifs_info) @@ -1934,6 +1941,13 @@ def init_droid_vm_vifs(session, vm_ref, network_ref, sms, ids=[1]): return vm_vifs_info +def config_arp(session, vms): + for vm in vms: + call_ack_plugin(session, 'reset_arp', + {'vm_ref': vm, 'mip': get_context_vm_mip(vm), + 'mode': get_context_arp_mode()}) + + def shutdown_droid_vms(session, vms, async=True): """Shutdown VMs""" @@ -2062,6 +2076,8 @@ def deploy_two_droid_vms_for_sriov_inter_host_test(session, vf_driver, network_r start_droid_vms( session, [(host_master_ref, vm1_ref), (host_slave_ref, vm2_ref)]) + config_arp(session, [vm1_ref, vm2_ref]) + return vm1_ref, vm2_ref @@ -2111,6 +2127,8 @@ def deploy_droid_vms_for_sriov_intra_host_test_vf_to_vf(session, vf_driver, netw start_droid_vms(session, host_vm_list, False) + config_arp(session, vm_list) + return vm_list, vif_list, vif_group diff --git a/plugins/autocertkit b/plugins/autocertkit index 605bb92..d704f36 100755 --- a/plugins/autocertkit +++ b/plugins/autocertkit @@ -1225,6 +1225,7 @@ def reset_arp(session, args): to send traffic too.""" vm_ref = validate_exists(args, 'vm_ref') + mode = validate_exists(args, 'mode', '0', False) log.debug("Reset ARP for VM %s" % vm_ref) @@ -1260,8 +1261,12 @@ def reset_arp(session, args): # Handle the Droid VM case vm_m_ip = validate_exists(args, 'mip') + arp_ignore_value = 1 if mode == '0' else 0 + rp_filter_value = 0 if mode == '0' else 1 + # Global ARP Ignore - set_kernel_parameter("net.ipv4.conf.all.arp_ignore", 1, vm_m_ip) + set_kernel_parameter("net.ipv4.conf.all.arp_ignore", arp_ignore_value , vm_m_ip) + set_kernel_parameter("net.ipv4.conf.default.arp_ignore", arp_ignore_value , vm_m_ip) ''' # Revert arp_ignore to default 0, otherwise DLVM (CentOS 7.2) no interface will reply arp query. @@ -1272,24 +1277,25 @@ def reset_arp(session, args): call = [SSH, vm_m_ip, cmd] make_local_call(call) ''' - + # In previous DLVM (CentOS 5), rp_filter is 0. If don't set in new DLVM, then Multicast test # will be failed using interfaces in same one subnet # Change global setting - set_kernel_parameter("net.ipv4.conf.all.rp_filter", 0, vm_m_ip) - set_kernel_parameter("net.ipv4.conf.default.rp_filter", 0, vm_m_ip) + set_kernel_parameter("net.ipv4.conf.all.rp_filter", rp_filter_value, vm_m_ip) + set_kernel_parameter("net.ipv4.conf.default.rp_filter", rp_filter_value, vm_m_ip) + # Change current existing interface cmd = """ip -o link | awk '{if($2 ~ "eth.+:") print $2}' | sed 's/:$//'""" call = [SSH, vm_m_ip, cmd] iface_list = make_local_call(call)["stdout"].split() for iface in iface_list: - config_key = "net.ipv4.conf.%s.rp_filter" % iface - set_kernel_parameter(config_key, 0, vm_m_ip) + set_kernel_parameter("net.ipv4.conf.%s.arp_ignore" % iface, arp_ignore_value, vm_m_ip) + set_kernel_parameter("net.ipv4.conf.%s.rp_filter" % iface, rp_filter_value, vm_m_ip) # reload sysctl.conf variables call = [SSH, vm_m_ip, SYSCTL, "--system"] make_local_call(call) - + # log arp call = [SSH, vm_m_ip, "cat", "/proc/net/arp"] make_local_call(call)