From e4238aa34f89ff8b60243978ade55828662d268a Mon Sep 17 00:00:00 2001 From: Steven Luong Date: Fri, 19 Apr 2024 09:49:20 -0700 Subject: ethernet: check destination mac for L3 in ethernet-input node When the NIC does not support mac filter, we rely on ethernet-input node to do the destination mac check, ie, when the interface is in L3, the mac address for the packet must be the mac address of the interface where the packet arrives. This works fine in ethernet-input node when all packets in the frame might have different interfaces, ie, ETH_INPUT_FRAME_F_SINGLE_SW_IF_ID is not set in the frame. However, when all packets are having the same interface, ETH_INPUT_FRAME_F_SINGLE_SW_IF_ID is set, ethernet-input node goes through the optimized routine eth_input_single_int -> eth_input_process_frame. That is where dmac check has a bug when all packets in the frame are either, ip4, ip6, or mpls without vlan tags. Because without vlan tags, the code handles all packets in fast path and ignores dmac check. With vlan tags, the code goes to slow path where dmac check is handled properly. The fix is to check if we have a bad dmac in the fast path and force the code to go to slow path which will handle dmac check properly. Also do a wholesale correction on all the testcases which do not use the proper dmac when sending L3 packets. Type: fix Change-Id: I73153a805cecdc24c4eefcc781676de04737ae2c Signed-off-by: Steven Luong --- test/test_gso.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'test/test_gso.py') diff --git a/test/test_gso.py b/test/test_gso.py index 1db83be50a8..3d9ce5fb4ee 100644 --- a/test/test_gso.py +++ b/test/test_gso.py @@ -405,7 +405,7 @@ class TestGSO(VppTestCase): # IPv4/IPv4 - VXLAN # p45 = ( - Ether(src=self.pg2.remote_mac, dst="02:fe:60:1e:a2:79") + Ether(src=self.pg2.remote_mac, dst=self.pg2.local_mac) / IP(src=self.pg2.remote_ip4, dst="172.16.3.3", flags="DF") / TCP(sport=1234, dport=1234) / Raw(b"\xa5" * 65200) @@ -424,7 +424,7 @@ class TestGSO(VppTestCase): inner = rx[VXLAN].payload self.assertEqual(rx[IP].len - 20 - 8 - 8, len(inner)) self.assertEqual(inner[Ether].src, self.pg2.remote_mac) - self.assertEqual(inner[Ether].dst, "02:fe:60:1e:a2:79") + self.assertEqual(inner[Ether].dst, self.pg2.local_mac) self.assertEqual(inner[IP].src, self.pg2.remote_ip4) self.assertEqual(inner[IP].dst, "172.16.3.3") self.assert_ip_checksum_valid(inner) @@ -438,7 +438,7 @@ class TestGSO(VppTestCase): # IPv4/IPv6 - VXLAN # p65 = ( - Ether(src=self.pg2.remote_mac, dst="02:fe:60:1e:a2:79") + Ether(src=self.pg2.remote_mac, dst=self.pg2.local_mac) / IPv6(src=self.pg2.remote_ip6, dst="fd01:3::3") / TCP(sport=1234, dport=1234) / Raw(b"\xa5" * 65200) @@ -457,7 +457,7 @@ class TestGSO(VppTestCase): inner = rx[VXLAN].payload self.assertEqual(rx[IP].len - 20 - 8 - 8, len(inner)) self.assertEqual(inner[Ether].src, self.pg2.remote_mac) - self.assertEqual(inner[Ether].dst, "02:fe:60:1e:a2:79") + self.assertEqual(inner[Ether].dst, self.pg2.local_mac) self.assertEqual(inner[IPv6].src, self.pg2.remote_ip6) self.assertEqual(inner[IPv6].dst, "fd01:3::3") self.assert_tcp_checksum_valid(inner) @@ -483,7 +483,7 @@ class TestGSO(VppTestCase): # IPv6/IPv4 - VXLAN # p46 = ( - Ether(src=self.pg2.remote_mac, dst="02:fe:60:1e:a2:79") + Ether(src=self.pg2.remote_mac, dst=self.pg2.local_mac) / IP(src=self.pg2.remote_ip4, dst="172.16.3.3", flags="DF") / TCP(sport=1234, dport=1234) / Raw(b"\xa5" * 65200) @@ -501,7 +501,7 @@ class TestGSO(VppTestCase): inner = rx[VXLAN].payload self.assertEqual(rx[IPv6].plen - 8 - 8, len(inner)) self.assertEqual(inner[Ether].src, self.pg2.remote_mac) - self.assertEqual(inner[Ether].dst, "02:fe:60:1e:a2:79") + self.assertEqual(inner[Ether].dst, self.pg2.local_mac) self.assertEqual(inner[IP].src, self.pg2.remote_ip4) self.assertEqual(inner[IP].dst, "172.16.3.3") self.assert_ip_checksum_valid(inner) @@ -515,7 +515,7 @@ class TestGSO(VppTestCase): # IPv6/IPv6 - VXLAN # p66 = ( - Ether(src=self.pg2.remote_mac, dst="02:fe:60:1e:a2:79") + Ether(src=self.pg2.remote_mac, dst=self.pg2.local_mac) / IPv6(src=self.pg2.remote_ip6, dst="fd01:3::3") / TCP(sport=1234, dport=1234) / Raw(b"\xa5" * 65200) @@ -533,7 +533,7 @@ class TestGSO(VppTestCase): inner = rx[VXLAN].payload self.assertEqual(rx[IPv6].plen - 8 - 8, len(inner)) self.assertEqual(inner[Ether].src, self.pg2.remote_mac) - self.assertEqual(inner[Ether].dst, "02:fe:60:1e:a2:79") + self.assertEqual(inner[Ether].dst, self.pg2.local_mac) self.assertEqual(inner[IPv6].src, self.pg2.remote_ip6) self.assertEqual(inner[IPv6].dst, "fd01:3::3") self.assert_tcp_checksum_valid(inner) @@ -590,7 +590,7 @@ class TestGSO(VppTestCase): # IPv4/IPv4 - IPIP # p47 = ( - Ether(src=self.pg2.remote_mac, dst="02:fe:60:1e:a2:79") + Ether(src=self.pg2.remote_mac, dst=self.pg2.local_mac) / IP(src=self.pg2.remote_ip4, dst="172.16.10.3", flags="DF") / TCP(sport=1234, dport=1234) / Raw(b"\xa5" * 65200) @@ -633,7 +633,7 @@ class TestGSO(VppTestCase): # IPv4/IPv6 - IPIP # p67 = ( - Ether(src=self.pg2.remote_mac, dst="02:fe:60:1e:a2:79") + Ether(src=self.pg2.remote_mac, dst=self.pg2.local_mac) / IPv6(src=self.pg2.remote_ip6, dst="fd01:10::3") / TCP(sport=1234, dport=1234) / Raw(b"\xa5" * 65200) @@ -731,7 +731,7 @@ class TestGSO(VppTestCase): # IPv6/IPv4 - IPIP # p48 = ( - Ether(src=self.pg2.remote_mac, dst="02:fe:60:1e:a2:79") + Ether(src=self.pg2.remote_mac, dst=self.pg2.local_mac) / IP(src=self.pg2.remote_ip4, dst="172.16.10.3", flags="DF") / TCP(sport=1234, dport=1234) / Raw(b"\xa5" * 65200) @@ -774,7 +774,7 @@ class TestGSO(VppTestCase): # IPv6/IPv6 - IPIP # p68 = ( - Ether(src=self.pg2.remote_mac, dst="02:fe:60:1e:a2:79") + Ether(src=self.pg2.remote_mac, dst=self.pg2.local_mac) / IPv6(src=self.pg2.remote_ip6, dst="fd01:10::3") / TCP(sport=1234, dport=1234) / Raw(b"\xa5" * 65200) @@ -842,7 +842,7 @@ class TestGSO(VppTestCase): self.ip4_via_gre4_tunnel.add_vpp_config() pgre4 = ( - Ether(src=self.pg2.remote_mac, dst="02:fe:60:1e:a2:79") + Ether(src=self.pg2.remote_mac, dst=self.pg2.local_mac) / IP(src=self.pg2.remote_ip4, dst="172.16.10.3", flags="DF") / TCP(sport=1234, dport=1234) / Raw(b"\xa5" * 65200) @@ -952,7 +952,7 @@ class TestGSO(VppTestCase): # Create IPv6 packet # pgre6 = ( - Ether(src=self.pg2.remote_mac, dst="02:fe:60:1e:a2:79") + Ether(src=self.pg2.remote_mac, dst=self.pg2.local_mac) / IPv6(src=self.pg2.remote_ip6, dst="fd01:10::3") / TCP(sport=1234, dport=1234) / Raw(b"\xa5" * 65200) @@ -1078,7 +1078,7 @@ class TestGSO(VppTestCase): # IPv4/IPv4 - IPSEC # ipsec44 = ( - Ether(src=self.pg2.remote_mac, dst="02:fe:60:1e:a2:79") + Ether(src=self.pg2.remote_mac, dst=self.pg2.local_mac) / IP(src=self.pg2.remote_ip4, dst="172.16.10.3", flags="DF") / TCP(sport=1234, dport=1234) / Raw(b"\xa5" * 65200) @@ -1116,7 +1116,7 @@ class TestGSO(VppTestCase): # IPv4/IPv6 - IPSEC # ipsec46 = ( - Ether(src=self.pg2.remote_mac, dst="02:fe:60:1e:a2:79") + Ether(src=self.pg2.remote_mac, dst=self.pg2.local_mac) / IPv6(src=self.pg2.remote_ip6, dst="fd01:10::3") / TCP(sport=1234, dport=1234) / Raw(b"\xa5" * 65200) @@ -1213,7 +1213,7 @@ class TestGSO(VppTestCase): # IPv6/IPv4 - IPSEC # ipsec64 = ( - Ether(src=self.pg2.remote_mac, dst="02:fe:60:1e:a2:79") + Ether(src=self.pg2.remote_mac, dst=self.pg2.local_mac) / IP(src=self.pg2.remote_ip4, dst="172.16.10.3", flags="DF") / TCP(sport=1234, dport=1234) / Raw(b"\xa5" * 65200) @@ -1252,7 +1252,7 @@ class TestGSO(VppTestCase): # IPv6/IPv6 - IPSEC # ipsec66 = ( - Ether(src=self.pg2.remote_mac, dst="02:fe:60:1e:a2:79") + Ether(src=self.pg2.remote_mac, dst=self.pg2.local_mac) / IPv6(src=self.pg2.remote_ip6, dst="fd01:10::3") / TCP(sport=1234, dport=1234) / Raw(b"\xa5" * 65200) -- cgit 1.2.3-korg