diff options
author | Klement Sekera <ksekera@cisco.com> | 2021-03-09 17:53:47 +0100 |
---|---|---|
committer | Klement Sekera <ksekera@cisco.com> | 2021-03-09 17:54:22 +0100 |
commit | d2b69975731b786a05982677a7c39478905b25c6 (patch) | |
tree | 71dbf190c4fc544e14e37b3ec235ac3690026add /src/plugins/nat/test | |
parent | 31f0526852de07422206c5caed77fefa8bbed139 (diff) |
nat: fix dst nat thread issues
Make sure packet lands on the right thread for dst nat case.
Type: fix
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: I0ec4e4c2bb3fa80ff73fac588c36d36420ba68fa
Diffstat (limited to 'src/plugins/nat/test')
-rw-r--r-- | src/plugins/nat/test/test_nat44_ed.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/plugins/nat/test/test_nat44_ed.py b/src/plugins/nat/test/test_nat44_ed.py index 7040cb7266e..5e382aae855 100644 --- a/src/plugins/nat/test/test_nat44_ed.py +++ b/src/plugins/nat/test/test_nat44_ed.py @@ -1926,22 +1926,35 @@ class TestNAT44ED(NAT44EDTestCase): pkts = [] for i in range(x): + info = self.create_packet_info(self.pg0, self.pg1) + payload = self.info_to_payload(info) p = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) / IP(src=self.pg0.remote_hosts[i].ip4, dst=self.pg1.remote_ip4) / - UDP(sport=7000+i, dport=80+i)) + UDP(sport=7000+i, dport=8000+i) / + Raw(payload)) + info.data = p pkts.append(p) self.pg0.add_stream(pkts) self.pg_enable_capture(self.pg_interfaces) self.pg_start() recvd = self.pg1.get_capture(len(pkts)) - for (p_sent, p_recvd) in zip(pkts, recvd): + for p_recvd in recvd: + payload_info = self.payload_to_info(p_recvd[Raw]) + packet_index = payload_info.index + info = self._packet_infos[packet_index] + self.assertTrue(info is not None) + self.assertEqual(packet_index, info.index) + p_sent = info.data packed = socket.inet_aton(p_sent[IP].src) numeric = struct.unpack("!L", packed)[0] numeric = socket.htonl(numeric) a = nat_addresses[(numeric-1) % len(nat_addresses)] - self.assertEqual(a, p_recvd[IP].src, "Packet not translated") + self.assertEqual( + a, p_recvd[IP].src, + "Invalid packet (src IP %s translated to %s, but expected %s)" + % (p_sent[IP].src, p_recvd[IP].src, a)) class TestNAT44EDMW(TestNAT44ED): |