aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2017-10-26 03:37:38 -0700
committerOle Trøan <otroan@employees.org>2017-10-26 17:35:28 +0000
commit5ba86f72439a627f2084bcafb221ad77f4990168 (patch)
treeba76c4e83d3dbaa6c0b39854da385ff511cc4b18 /test
parent0404c682613c163c54d787a86e4b281bd3bba340 (diff)
NAT: delete session API/CLI (VPP-1041)
Administratively delete NAT44 session for specific inside/outside addresses and port pair. Change-Id: If5ab500ac3592c7153d6d8f2cc0297df7309fbc3 Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'test')
-rw-r--r--test/test_nat.py27
-rw-r--r--test/vpp_papi_provider.py23
2 files changed, 50 insertions, 0 deletions
diff --git a/test/test_nat.py b/test/test_nat.py
index 792b21b418f..37e1b1e7b75 100644
--- a/test/test_nat.py
+++ b/test/test_nat.py
@@ -2452,6 +2452,33 @@ class TestNAT44(MethodHolder):
self.logger.error(ppp("Unexpected or invalid packet:", p))
raise
+ def test_del_session(self):
+ """ Delete NAT44 session """
+ self.nat44_add_address(self.nat_addr)
+ self.vapi.nat44_interface_add_del_feature(self.pg0.sw_if_index)
+ self.vapi.nat44_interface_add_del_feature(self.pg1.sw_if_index,
+ is_inside=0)
+
+ pkts = self.create_stream_in(self.pg0, self.pg1)
+ self.pg0.add_stream(pkts)
+ self.pg_enable_capture(self.pg_interfaces)
+ self.pg_start()
+ capture = self.pg1.get_capture(len(pkts))
+
+ sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4n, 0)
+ nsessions = len(sessions)
+
+ self.vapi.nat44_del_session(sessions[0].inside_ip_address,
+ sessions[0].inside_port,
+ sessions[0].protocol)
+ self.vapi.nat44_del_session(sessions[1].outside_ip_address,
+ sessions[1].outside_port,
+ sessions[1].protocol,
+ is_in=0)
+
+ sessions = self.vapi.nat44_user_session_dump(self.pg0.remote_ip4n, 0)
+ self.assertEqual(nsessions - len(sessions), 2)
+
def tearDown(self):
super(TestNAT44, self).tearDown()
if not self.vpp_dead:
diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py
index 68b2bd0b514..8e7235659be 100644
--- a/test/vpp_papi_provider.py
+++ b/test/vpp_papi_provider.py
@@ -1346,6 +1346,29 @@ class VppPapiProvider(object):
"""
return self.api(self.papi.nat44_lb_static_mapping_dump, {})
+ def nat44_del_session(
+ self,
+ addr,
+ port,
+ protocol,
+ vrf_id=0,
+ is_in=1):
+ """Delete NAT44 session
+
+ :param addr: IPv4 address
+ :param por: port number
+ :param protocol: IP protocol number
+ :param vrf_id: VRF ID
+ :param is_in: 1 if inside network addres and port pari, 0 if outside
+ """
+ return self.api(
+ self.papi.nat44_del_session,
+ {'address': addr,
+ 'port': port,
+ 'protocol': protocol,
+ 'vrf_id': vrf_id,
+ 'is_in': is_in})
+
def nat_det_add_del_map(
self,
in_addr,