summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSteven Luong <sluong@cisco.com>2024-10-22 10:44:07 -0700
committerFlorin Coras <florin.coras@gmail.com>2024-11-06 18:13:01 +0000
commite0c4e6e32d9cd4b1b2c9647cd12a2e6214986e07 (patch)
tree3b521af4895eddf2ed7ca0dcae165c2abf60cd7d /test
parentafd05739d68fe7708153687e1aa177fee4411c5f (diff)
session: session table holding free appns index
session table may be shared among multiple appns's. app ns add id blue secret 1 if tap0 app ns add id red secret 1 if tap0 session table holds the last added app_ns's appns_index. If the last app_ns is deleted, session table is not free since there is still an appns which uses the same session table. In that case, session table is holding the free app_ns's appns_index and it can cause problem. The fix is to modify appns_index in session table to hold a vector of appns_index's instead of just the appns_index that was last added. When the app ns is deleted, remove the deleted appns_index from the session table's vector of appns_index's. Type: fix Change-Id: Ied8bc97f185071dc89b9b56656e18efbd2995131 Signed-off-by: Steven Luong <sluong@cisco.com>
Diffstat (limited to 'test')
-rw-r--r--test/asf/test_session.py85
-rw-r--r--test/asf/test_session_sdl.py15
2 files changed, 96 insertions, 4 deletions
diff --git a/test/asf/test_session.py b/test/asf/test_session.py
index 957f3234271..7850f2270da 100644
--- a/test/asf/test_session.py
+++ b/test/asf/test_session.py
@@ -71,7 +71,7 @@ class TestSession(VppAsfTestCase):
)
super(TestSession, self).tearDown()
- self.vapi.session_enable_disable(is_enable=1)
+ self.vapi.session_enable_disable(is_enable=0)
def test_segment_manager_alloc(self):
"""Session Segment Manager Multiple Segment Allocation"""
@@ -123,6 +123,89 @@ class TestSession(VppAsfTestCase):
@tag_fixme_vpp_workers
+class TestApplicationNamespace(VppAsfTestCase):
+ """Application Namespacee"""
+
+ @classmethod
+ def setUpClass(cls):
+ super(TestApplicationNamespace, cls).setUpClass()
+
+ @classmethod
+ def tearDownClass(cls):
+ super(TestApplicationNamespace, cls).tearDownClass()
+
+ def setUp(self):
+ super(TestApplicationNamespace, self).setUp()
+ self.create_loopback_interfaces(1)
+
+ def tearDown(self):
+ super(TestApplicationNamespace, self).tearDown()
+ self.vapi.session_enable_disable_v2(
+ rt_engine_type=VppEnum.vl_api_rt_backend_engine_t.RT_BACKEND_ENGINE_API_DISABLE
+ )
+
+ def test_application_namespace(self):
+ """Application Namespace Create"""
+
+ self.vapi.session_enable_disable_v2(
+ rt_engine_type=VppEnum.vl_api_rt_backend_engine_t.RT_BACKEND_ENGINE_API_RULE_TABLE
+ )
+
+ # Configure 2 namespaces, sharing the same interface
+ app0 = self.vapi.app_namespace_add_del_v4(
+ namespace_id="0", sw_if_index=self.loop0.sw_if_index
+ )
+ app1 = self.vapi.app_namespace_add_del_v4(
+ namespace_id="1", sw_if_index=self.loop0.sw_if_index
+ )
+
+ self.vapi.session_rule_add_del(
+ transport_proto=VppEnum.vl_api_transport_proto_t.TRANSPORT_PROTO_API_TCP,
+ lcl="172.100.1.1/32",
+ rmt="172.100.1.2/32",
+ lcl_port=5000,
+ rmt_port=5000,
+ action_index=1,
+ appns_index=app0.appns_index,
+ scope=VppEnum.vl_api_session_rule_scope_t.SESSION_RULE_SCOPE_API_GLOBAL,
+ is_add=1,
+ )
+ dump = self.vapi.session_rules_v2_dump()
+ # session table should contain 3 appns's indices (default, app0, and app1)
+ self.assertEqual(len(dump[1].appns_index), 3)
+ self.assertEqual(dump[1].count, 3)
+ self.assertEqual(dump[1].appns_index[0], 0)
+ self.assertEqual(dump[1].appns_index[1], app0.appns_index)
+ self.assertEqual(dump[1].appns_index[2], app1.appns_index)
+
+ # remove the last namespace
+ self.vapi.app_namespace_add_del_v4(
+ namespace_id="1", sw_if_index=self.loop0.sw_if_index, is_add=0
+ )
+ dump = self.vapi.session_rules_v2_dump()
+ # session table should contain the remainging appns's index
+ self.assertEqual(len(dump[1].appns_index), 2)
+ self.assertEqual(dump[1].count, 2)
+ self.assertEqual(dump[1].appns_index[0], 0)
+ self.assertEqual(dump[1].appns_index[1], app0.appns_index)
+
+ self.vapi.app_namespace_add_del_v4(
+ namespace_id="0", sw_if_index=self.loop0.sw_if_index, is_add=0
+ )
+ self.vapi.session_rule_add_del(
+ transport_proto=VppEnum.vl_api_transport_proto_t.TRANSPORT_PROTO_API_TCP,
+ lcl="172.100.1.1/32",
+ rmt="172.100.1.2/32",
+ lcl_port=5000,
+ rmt_port=5000,
+ action_index=1,
+ appns_index=app0.appns_index,
+ scope=VppEnum.vl_api_session_rule_scope_t.SESSION_RULE_SCOPE_API_GLOBAL,
+ is_add=0,
+ )
+
+
+@tag_fixme_vpp_workers
class TestSessionUnitTests(VppAsfTestCase):
"""Session Unit Tests Case"""
diff --git a/test/asf/test_session_sdl.py b/test/asf/test_session_sdl.py
index c03dc83ba1e..952ad10bb79 100644
--- a/test/asf/test_session_sdl.py
+++ b/test/asf/test_session_sdl.py
@@ -78,10 +78,10 @@ class TestSessionSDL(VppTestCase):
)
# Configure namespaces
- self.vapi.app_namespace_add_del_v4(
+ app0 = self.vapi.app_namespace_add_del_v4(
namespace_id="0", sw_if_index=self.loop0.sw_if_index
)
- self.vapi.app_namespace_add_del_v4(
+ app1 = self.vapi.app_namespace_add_del_v4(
namespace_id="1", sw_if_index=self.loop1.sw_if_index
)
@@ -120,8 +120,12 @@ class TestSessionSDL(VppTestCase):
)
self.apply_rules(rules, is_add=1, appns_index=0)
- filter = self.vapi.session_sdl_v2_dump()
+ filter = self.vapi.session_sdl_v3_dump()
self.assertEqual(filter[0].rmt, IPv4Network(self.loop1.local_ip4 + "/32"))
+ self.assertEqual(len(filter[0].appns_index), 2)
+ self.assertEqual(filter[0].count, 2)
+ self.assertEqual(filter[0].appns_index[0], 0)
+ self.assertEqual(filter[0].appns_index[1], app0.appns_index)
# irrelevant rules - add 64k entries in one API call
rules = []
@@ -158,6 +162,11 @@ class TestSessionSDL(VppTestCase):
self.vapi.app_namespace_add_del_v4(
is_add=0, namespace_id="0", sw_if_index=self.loop0.sw_if_index
)
+ filter = self.vapi.session_sdl_v3_dump()
+ self.assertEqual(len(filter[0].appns_index), 1)
+ self.assertEqual(filter[0].count, 1)
+ self.assertEqual(filter[0].appns_index[0], 0)
+
self.vapi.app_namespace_add_del_v4(
is_add=0, namespace_id="1", sw_if_index=self.loop1.sw_if_index
)