From 865002ee6d826d9d6bd17a594fdd9200644b9beb Mon Sep 17 00:00:00 2001 From: jhughesbiot Date: Wed, 28 Jun 2023 10:48:38 -0600 Subject: [PATCH 1/2] Fix single ip test from detecting faux-device during validation as a failure --- framework/python/src/net_orc/network_validator.py | 7 ++++++- modules/test/conn/python/src/connection_module.py | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/framework/python/src/net_orc/network_validator.py b/framework/python/src/net_orc/network_validator.py index a4c51eb2d..4260396e5 100644 --- a/framework/python/src/net_orc/network_validator.py +++ b/framework/python/src/net_orc/network_validator.py @@ -30,7 +30,7 @@ DEVICE_BRIDGE = 'tr-d' CONF_DIR = 'local' CONF_FILE = 'system.json' - +TR_CONTAINER_MAC_PREFIX = '9a:02:57:1e:8f:' class NetworkValidator: """Perform validation of network services.""" @@ -238,6 +238,10 @@ def _attach_device_to_network(self, device): util.run_command('ip link add ' + bridge_intf + ' type veth peer name ' + container_intf) + mac_addr = TR_CONTAINER_MAC_PREFIX + '10' + + util.run_command('ip link set dev ' + container_intf + ' address ' + mac_addr) + # Add bridge interface to device bridge util.run_command('ovs-vsctl add-port ' + DEVICE_BRIDGE + ' ' + bridge_intf) @@ -258,6 +262,7 @@ def _attach_device_to_network(self, device): util.run_command('ip netns exec ' + container_net_ns + ' ip link set dev ' + container_intf + ' name veth0') + # Set interfaces up util.run_command('ip link set dev ' + bridge_intf + ' up') util.run_command('ip netns exec ' + container_net_ns + diff --git a/modules/test/conn/python/src/connection_module.py b/modules/test/conn/python/src/connection_module.py index 196c335d8..fe8c9b79c 100644 --- a/modules/test/conn/python/src/connection_module.py +++ b/modules/test/conn/python/src/connection_module.py @@ -25,6 +25,8 @@ STARTUP_CAPTURE_FILE = '/runtime/device/startup.pcap' MONITOR_CAPTURE_FILE = '/runtime/device/monitor.pcap' +TR_CONTAINER_MAC_PREFIX = '9a:02:57:1e:8f:' + class ConnectionModule(TestModule): """Connection Test module""" @@ -73,7 +75,8 @@ def _connection_single_ip(self): # Option[1] = message-type, option 3 = DHCPREQUEST if DHCP in packet and packet[DHCP].options[0][1] == 3: mac_address = packet[Ether].src - mac_addresses.add(mac_address.upper()) + if not mac_address.startswith(TR_CONTAINER_MAC_PREFIX): + mac_addresses.add(mac_address.upper()) # Check if the device mac address is in the list of DHCPREQUESTs result = self._device_mac.upper() in mac_addresses From a4dd87a6cf48f6e00c897c2d0e967086363eed9a Mon Sep 17 00:00:00 2001 From: jhughesbiot Date: Fri, 14 Jul 2023 14:53:41 -0600 Subject: [PATCH 2/2] remove dhcp server capture file from scan --- modules/test/conn/python/src/connection_module.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/test/conn/python/src/connection_module.py b/modules/test/conn/python/src/connection_module.py index 82fda77d8..1b0e38023 100644 --- a/modules/test/conn/python/src/connection_module.py +++ b/modules/test/conn/python/src/connection_module.py @@ -22,7 +22,6 @@ LOG_NAME = 'test_connection' LOGGER = None OUI_FILE = '/usr/local/etc/oui.txt' -DHCP_SERVER_CAPTURE_FILE = '/runtime/network/dhcp-1.pcap' STARTUP_CAPTURE_FILE = '/runtime/device/startup.pcap' MONITOR_CAPTURE_FILE = '/runtime/device/monitor.pcap' SLAAC_PREFIX = "fd10:77be:4186" @@ -116,8 +115,7 @@ def _connection_single_ip(self): return result, 'No MAC address found.' # Read all the pcap files containing DHCP packet information - packets = rdpcap(DHCP_SERVER_CAPTURE_FILE) - packets.append(rdpcap(STARTUP_CAPTURE_FILE)) + packets = rdpcap(STARTUP_CAPTURE_FILE) packets.append(rdpcap(MONITOR_CAPTURE_FILE)) # Extract MAC addresses from DHCP packets