summaryrefslogtreecommitdiffstats
path: root/test/test_ipsec_api.py
diff options
context:
space:
mode:
authorMaxime Peim <mpeim@cisco.com>2023-03-20 14:13:56 +0000
committerNeale Ranns <neale@graphiant.com>2023-06-23 17:38:55 +0000
commit1271e3a2a1b028e5b9cd7ca35a6bd06ddbe2c63b (patch)
tree6c8e806f3f730c2aebd839c34d6fc20cc5bbc2fd /test/test_ipsec_api.py
parent601972bb20c3f2846c0d3d3225a0a629126fe1ac (diff)
ipsec: manually binding an SA to a worker
An SA is normally bound to the first thread using it. However, one could want to manually bind an SA to a specific worker. Type: improvement Signed-off-by: Maxime Peim <mpeim@cisco.com> Change-Id: I05cbbf753e44a01d9964ee47812c964db9bbb488
Diffstat (limited to 'test/test_ipsec_api.py')
-rw-r--r--test/test_ipsec_api.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/test_ipsec_api.py b/test/test_ipsec_api.py
index 9c62c87e16d..521762b8181 100644
--- a/test/test_ipsec_api.py
+++ b/test/test_ipsec_api.py
@@ -4,10 +4,14 @@ from framework import VppTestCase, VppTestRunner
from template_ipsec import TemplateIpsec, IPsecIPv4Params
from vpp_papi import VppEnum
+from vpp_ipsec import VppIpsecSA
+
class IpsecApiTestCase(VppTestCase):
"""IPSec API tests"""
+ vpp_worker_count = 2
+
@classmethod
def setUpClass(cls):
super(IpsecApiTestCase, cls).setUpClass()
@@ -115,6 +119,40 @@ class IpsecApiTestCase(VppTestCase):
)
self.vapi.ipsec_select_backend(protocol=self.vpp_ah_protocol, index=0)
+ def __check_sa_binding(self, sa_id, thread_index):
+ found_sa = False
+ sa_dumps = self.vapi.ipsec_sa_v4_dump()
+ for dump in sa_dumps:
+ if dump.entry.sad_id == sa_id:
+ self.assertEqual(dump.thread_index, thread_index)
+ found_sa = True
+ break
+
+ if not found_sa:
+ self.fail("SA not found in VPP")
+
+ def test_sa_worker_bind(self):
+ """Bind an SA to a worker"""
+ sa = VppIpsecSA(
+ self,
+ self.ipv4_params.scapy_tun_sa_id,
+ self.ipv4_params.scapy_tun_spi,
+ self.ipv4_params.auth_algo_vpp_id,
+ self.ipv4_params.auth_key,
+ self.ipv4_params.crypt_algo_vpp_id,
+ self.ipv4_params.crypt_key,
+ VppEnum.vl_api_ipsec_proto_t.IPSEC_API_PROTO_ESP,
+ )
+ sa.add_vpp_config()
+
+ self.__check_sa_binding(sa.id, 0xFFFF)
+
+ self.vapi.ipsec_sad_bind(sa_id=sa.id, worker=1)
+
+ self.__check_sa_binding(sa.id, 2)
+
+ sa.remove_vpp_config()
+
if __name__ == "__main__":
unittest.main(testRunner=VppTestRunner)