diff options
author | Ole Troan <otroan@employees.org> | 2023-09-01 14:15:39 +0200 |
---|---|---|
committer | Andrew Yourtchenko <ayourtch@gmail.com> | 2023-09-04 15:14:46 +0000 |
commit | 34850e01876005422ba9523df5ae0400964e1c91 (patch) | |
tree | b0d538e9dd54d6fa183e9e8fedb587edd41bae79 /test | |
parent | 77812045e720d1434dd36a1db90c35daad0c8e00 (diff) |
npt66: checksum applied to src address instead of dst address on rx
Applied the checksum delta to the source address instead of the destination address
in the RX direction.
Cleaned up tests a little.
Type: fix
Change-Id: I871f3448365587e5319dfbca6ea356935321ff9b
Signed-off-by: Ole Troan <otroan@employees.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/test_npt66.py | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/test/test_npt66.py b/test/test_npt66.py index 5173c62d44f..6565c38aae0 100644 --- a/test/test_npt66.py +++ b/test/test_npt66.py @@ -29,35 +29,43 @@ class TestNPT66(VppTestCase): i.admin_down() super(TestNPT66, self).tearDown() - def send_and_verify(self, in2out, internal, external): - if in2out: - sendif = self.pg0 - recvif = self.pg1 - local_mac = self.pg0.local_mac - remote_mac = self.pg0.remote_mac - src = ipaddress.ip_interface(internal).ip + 1 - dst = self.pg1.remote_ip6 - else: - sendif = self.pg1 - recvif = self.pg0 - local_mac = self.pg1.local_mac - remote_mac = self.pg1.remote_mac - src = self.pg1.remote_ip6 - dst = ipaddress.ip_interface(external).ip + 1 + def send_and_verify(self, internal): + sendif = self.pg0 + recvif = self.pg1 + local_mac = self.pg0.local_mac + remote_mac = self.pg0.remote_mac + src = ipaddress.ip_interface(internal).ip + 1 + dst = self.pg1.remote_ip6 p = ( Ether(dst=local_mac, src=remote_mac) / IPv6(src=src, dst=dst) / ICMPv6EchoRequest() + / Raw(b"Request") ) rxs = self.send_and_expect(sendif, p, recvif) for rx in rxs: - rx.show2() original_cksum = rx[ICMPv6EchoRequest].cksum del rx[ICMPv6EchoRequest].cksum rx = rx.__class__(bytes(rx)) self.assertEqual(original_cksum, rx[ICMPv6EchoRequest].cksum) + # Generate a replies + reply = ( + Ether(dst=rx[Ether].src, src=local_mac) + / IPv6(src=rx[IPv6].dst, dst=rx[IPv6].src) + / ICMPv6EchoRequest() + / Raw(b"Reply") + ) + + replies = self.send_and_expect(recvif, reply, sendif) + for r in replies: + self.assertEqual(str(p[IPv6].src), r[IPv6].dst) + original_cksum = r[ICMPv6EchoRequest].cksum + del r[ICMPv6EchoRequest].cksum + r = r.__class__(bytes(r)) + self.assertEqual(original_cksum, r[ICMPv6EchoRequest].cksum) + def do_test(self, internal, external): self.vapi.npt66_binding_add_del( sw_if_index=self.pg1.sw_if_index, @@ -65,10 +73,10 @@ class TestNPT66(VppTestCase): external=external, is_add=True, ) + ## TODO use route api self.vapi.cli(f"ip route add {internal} via {self.pg0.remote_ip6}") - self.send_and_verify(True, internal, external) - self.send_and_verify(False, internal, external) + self.send_and_verify(internal) self.vapi.npt66_binding_add_del( sw_if_index=self.pg1.sw_if_index, @@ -80,6 +88,7 @@ class TestNPT66(VppTestCase): def test_npt66_simple(self): """Send and receive a packet through NPT66""" + self.do_test("fd00:0000:0000::/48", "2001:4650:c3ed::/48") self.do_test("fc00:1::/48", "2001:db8:1::/48") self.do_test("fc00:1234::/32", "2001:db8:1::/32") self.do_test("fc00:1234::/63", "2001:db8:1::/56") |