diff options
author | Juraj Sloboda <jsloboda@cisco.com> | 2017-04-14 03:24:45 +0200 |
---|---|---|
committer | Ole Trøan <otroan@employees.org> | 2017-04-19 07:06:16 +0000 |
commit | d367768270a3d19447af1a7059068e1f20fd15a6 (patch) | |
tree | e37a9d4f2e400892008c1750e9ff854007bf2ffa /test/test_snat.py | |
parent | 977c1cbc1d37945391dc65848ab819467ad9efd4 (diff) |
Support ping from outside network in 1:1 NAT (VPP-695)
Change-Id: Iec8fd4c2bd26874bd8bda82172af797e9b92592c
Signed-off-by: Juraj Sloboda <jsloboda@cisco.com>
Diffstat (limited to 'test/test_snat.py')
-rw-r--r-- | test/test_snat.py | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/test/test_snat.py b/test/test_snat.py index b455e620c74..42b07193178 100644 --- a/test/test_snat.py +++ b/test/test_snat.py @@ -560,7 +560,7 @@ class TestSNAT(MethodHolder): self.verify_capture_out_with_icmp_errors(capture) def test_ping_out_interface_from_outside(self): - """ Ping SNAT out interface from outside """ + """ Ping SNAT out interface from outside network """ self.snat_add_address(self.snat_addr) self.vapi.snat_interface_add_del_feature(self.pg0.sw_if_index) @@ -587,6 +587,36 @@ class TestSNAT(MethodHolder): "(outside network):", packet)) raise + def test_ping_internal_host_from_outside(self): + """ Ping internal host from outside network """ + + self.snat_add_static_mapping(self.pg0.remote_ip4, self.snat_addr) + self.vapi.snat_interface_add_del_feature(self.pg0.sw_if_index) + self.vapi.snat_interface_add_del_feature(self.pg1.sw_if_index, + is_inside=0) + + # out2in + pkt = (Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac) / + IP(src=self.pg1.remote_ip4, dst=self.snat_addr, ttl=64) / + ICMP(id=self.icmp_id_out, type='echo-request')) + self.pg1.add_stream(pkt) + self.pg_enable_capture(self.pg_interfaces) + self.pg_start() + capture = self.pg0.get_capture(1) + self.verify_capture_in(capture, self.pg0, packet_num=1) + self.assert_equal(capture[0][IP].proto, IP_PROTOS.icmp) + + # in2out + pkt = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) / + IP(src=self.pg0.remote_ip4, dst=self.pg1.remote_ip4, ttl=64) / + ICMP(id=self.icmp_id_in, type='echo-reply')) + self.pg0.add_stream(pkt) + self.pg_enable_capture(self.pg_interfaces) + self.pg_start() + capture = self.pg1.get_capture(1) + self.verify_capture_out(capture, same_port=True, packet_num=1) + self.assert_equal(capture[0][IP].proto, IP_PROTOS.icmp) + def test_static_in(self): """ SNAT 1:1 NAT initialized from inside network """ |