diff options
author | Matus Fabian <matfabia@cisco.com> | 2016-12-21 23:58:46 -0800 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2016-12-22 12:28:01 +0000 |
commit | 9902fcd3e06dae893264f7681e82a2b73141546c (patch) | |
tree | ab6435fafe9c6fc1fcf535e29a4b7e353c681cb7 /test | |
parent | 20d1232532e6f6c94c77a125b6c17680e14785b5 (diff) |
SNAT: Remove the oldest translation fix (VPP-568)
Fixed bug and add test.
Change-Id: Ibe70dfc81e6c264223050d316cf6a2a3a0e1524e
Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/test_snat.py | 27 | ||||
-rw-r--r-- | test/vpp_papi_provider.py | 6 |
2 files changed, 33 insertions, 0 deletions
diff --git a/test/test_snat.py b/test/test_snat.py index fdd81f02..8985c3e4 100644 --- a/test/test_snat.py +++ b/test/test_snat.py @@ -589,6 +589,33 @@ class TestSNAT(VppTestCase): self.logger.error(ppp("Unexpected or invalid packet:"), p) raise + def test_max_translations_per_user(self): + """ MAX translations per user - recycle the least recently used """ + + self.snat_add_address(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) + + # get maximum number of translations per user + snat_config = self.vapi.snat_show_config() + + # send more than maximum number of translations per user packets + pkts_num = snat_config.max_translations_per_user + 5 + pkts = [] + for port in range(0, pkts_num): + p = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) / + IP(src=self.pg0.remote_ip4, dst=self.pg1.remote_ip4) / + TCP(sport=1025 + port)) + pkts.append(p) + self.pg0.add_stream(pkts) + self.pg_enable_capture(self.pg_interfaces) + self.pg_start() + + # verify number of translated packet + capture = self.pg1.get_capture() + self.assertEqual(pkts_num, len(capture)) + def tearDown(self): super(TestSNAT, self).tearDown() if not self.vpp_dead: diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py index 7c905929..3279a274 100644 --- a/test/vpp_papi_provider.py +++ b/test/vpp_papi_provider.py @@ -842,6 +842,12 @@ class VppPapiProvider(object): """ return self.api(self.papi.snat_static_mapping_dump, {}) + def snat_show_config(self): + """Show S-NAT config + :return: S-NAT config parameters + """ + return self.api(self.papi.snat_show_config, {}) + def control_ping(self): self.api(self.papi.control_ping) |