Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion framework/python/src/net_orc/network_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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)

Expand All @@ -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 +
Expand Down
13 changes: 7 additions & 6 deletions modules/test/conn/python/src/connection_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
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'

TR_CONTAINER_MAC_PREFIX = '9a:02:57:1e:8f:'


class ConnectionModule(TestModule):
"""Connection Test module"""
Expand Down Expand Up @@ -191,18 +192,18 @@ 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
mac_addresses = set()
LOGGER.info('Inspecting: ' + str(len(packets)) + ' packets')
for packet in packets:
# 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 DHCP in packet and packet[DHCP].options[0][1] == 3:
mac_address = packet[Ether].src
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
Expand Down