Skip to content

Commit c4157a6

Browse files
authored
Merge pull request #2442 from anarkiwi/master
Verify hairpin routing.
2 parents 95471f7 + 1250480 commit c4157a6

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

tests/integration/mininet_tests.py

+29-1
Original file line numberDiff line numberDiff line change
@@ -4534,14 +4534,42 @@ def test_tagged(self):
45344534
self.wait_nonzero_packet_count_flow(
45354535
{'dl_type': 0x0800, 'nw_dst': str(ip)}, table_id=self._IPV4_FIB_TABLE)
45364536

4537-
# verify reachability between hosts within each subnet
4537+
# verify L3 reachability between hosts within each subnet
45384538
for vid in self.NEW_VIDS:
45394539
macvlan_int = 'macvlan%u' % vid
45404540
host_ip = '192.168.%u.%u' % (vid, 1)
45414541
other_ip = '192.168.%u.%u' % (vid, 2)
45424542
self.one_ipv4_ping(host, other_ip, intf=macvlan_int)
45434543
self.one_ipv4_ping(other_host, host_ip, intf=macvlan_int)
45444544

4545+
# verify L3 hairpin reachability
4546+
macvlan1_int = 'macvlan%u' % self.NEW_VIDS[0]
4547+
macvlan2_int = 'macvlan%u' % self.NEW_VIDS[1]
4548+
macvlan1_ip = '192.168.%u.1' % self.NEW_VIDS[0]
4549+
macvlan2_ip = '192.168.%u.1' % self.NEW_VIDS[1]
4550+
macvlan1_gw = '192.168.%u.254' % self.NEW_VIDS[0]
4551+
macvlan2_gw = '192.168.%u.254' % self.NEW_VIDS[1]
4552+
macvlan2_mac = self.get_mac_of_intf(host, macvlan2_int)
4553+
netns = host.name
4554+
setup_cmds = []
4555+
if self.get_netns_list(host):
4556+
setup_cmds.append('ip netns del %s' % netns)
4557+
setup_cmds.extend(
4558+
[('ip netns add %s' % netns),
4559+
('ip link set %s netns %s' % (macvlan2_int, netns))])
4560+
for exec_cmd in (
4561+
('ip address add %s/24 brd + dev %s' % (macvlan2_ip, macvlan2_int),
4562+
'ip link set %s up' % macvlan2_int,
4563+
'ip route add default via %s' % macvlan2_gw)):
4564+
setup_cmds.append('ip netns exec %s %s' % (netns, exec_cmd))
4565+
setup_cmds.append(
4566+
'ip route add %s/32 via %s' % (macvlan2_ip, macvlan1_gw))
4567+
self.quiet_commands(host, setup_cmds)
4568+
self.one_ipv4_ping(host, macvlan2_ip, intf=macvlan1_int)
4569+
self.quiet_commands(host, ['ip netns del %s' % netns])
4570+
self.wait_nonzero_packet_count_flow(
4571+
{'eth_dst': macvlan2_mac}, table_id=self._ETH_DST_HAIRPIN_TABLE)
4572+
45454573

45464574
class FaucetTaggedScaleTest(FaucetTaggedTest):
45474575

0 commit comments

Comments
 (0)