X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FIPsecUtil.py;h=d7f21361384c083ff964c9a7e19a1bf066fedca5;hb=5302eeabb757ccf710568a66b8f6435c1894cd4d;hp=6ed2db1eae440e39a6076751007e76c7c5aa7783;hpb=f7ee014dee09b4089924342b0fe5654b2fe91e90;p=csit.git diff --git a/resources/libraries/python/IPsecUtil.py b/resources/libraries/python/IPsecUtil.py index 6ed2db1eae..d7f2136138 100644 --- a/resources/libraries/python/IPsecUtil.py +++ b/resources/libraries/python/IPsecUtil.py @@ -1,5 +1,5 @@ -# Copyright (c) 2022 Cisco and/or its affiliates. -# Copyright (c) 2022 PANTHEON.tech s.r.o. +# Copyright (c) 2023 Cisco and/or its affiliates. +# Copyright (c) 2023 PANTHEON.tech s.r.o. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: @@ -438,7 +438,7 @@ class IPsecUtil: src_addr = u"" dst_addr = u"" - cmd = u"ipsec_sad_entry_add_del_v3" + cmd = u"ipsec_sad_entry_add" err_msg = f"Failed to add Security Association Database entry " \ f"on host {node[u'host']}" sad_entry = dict( @@ -462,10 +462,7 @@ class IPsecUtil: udp_src_port=4500, # default value in api udp_dst_port=4500 # default value in api ) - args = dict( - is_add=True, - entry=sad_entry - ) + args = dict(entry=sad_entry) with PapiSocketExecutor(node) as papi_exec: papi_exec.add(cmd, **args).get_reply(err_msg) @@ -562,7 +559,7 @@ class IPsecUtil: IPsecSadFlags.IPSEC_API_SAD_FLAG_IS_TUNNEL_V6 ) - cmd = u"ipsec_sad_entry_add_del_v3" + cmd = u"ipsec_sad_entry_add" err_msg = f"Failed to add Security Association Database entry " \ f"on host {node[u'host']}" @@ -585,13 +582,10 @@ class IPsecUtil: ), protocol=int(IPsecProto.IPSEC_API_PROTO_ESP), udp_src_port=4500, # default value in api - udp_dst_port=4500 # default value in api + udp_dst_port=4500, # default value in api ) - args = dict( - is_add=True, - entry=sad_entry - ) - with PapiSocketExecutor(node) as papi_exec: + args = dict(entry=sad_entry) + with PapiSocketExecutor(node, is_async=True) as papi_exec: for i in range(n_entries): args[u"entry"][u"sad_id"] = int(sad_id) + i args[u"entry"][u"spi"] = int(spi) + i @@ -695,7 +689,7 @@ class IPsecUtil: else f"Failed to configure IP addresses and IP routes " \ f"on interface {interface} on host {node[u'host']}" - with PapiSocketExecutor(node) as papi_exec: + with PapiSocketExecutor(node, is_async=True) as papi_exec: for i in range(n_tunnels): tunnel_dst_addr = tunnel_dst + i * addr_incr args1[u"prefix"] = IPUtil.create_prefix_object( @@ -1415,7 +1409,7 @@ class IPsecUtil: loop_sw_if_idx = InterfaceUtil.vpp_get_interface_sw_index( nodes[u"DUT1"], u"loop0" ) - with PapiSocketExecutor(nodes[u"DUT1"]) as papi_exec: + with PapiSocketExecutor(nodes[u"DUT1"], is_async=True) as papi_exec: # Configure IP addresses on loop0 interface cmd = u"sw_interface_add_del_address" args = dict( @@ -1471,7 +1465,7 @@ class IPsecUtil: # Configure IPSec SAD entries ckeys = [bytes()] * existing_tunnels ikeys = [bytes()] * existing_tunnels - cmd = u"ipsec_sad_entry_add_del_v3" + cmd = u"ipsec_sad_entry_add" c_key = dict( length=0, data=None @@ -1502,10 +1496,7 @@ class IPsecUtil: udp_src_port=IPSEC_UDP_PORT_NONE, udp_dst_port=IPSEC_UDP_PORT_NONE, ) - args = dict( - is_add=True, - entry=sad_entry - ) + args = dict(entry=sad_entry) for i in range(existing_tunnels, n_tunnels): ckeys.append( gen_key(IPsecUtil.get_crypto_alg_key_len(crypto_alg)) @@ -1658,7 +1649,7 @@ class IPsecUtil: :type spi_d: dict :type existing_tunnels: int """ - with PapiSocketExecutor(nodes[u"DUT2"]) as papi_exec: + with PapiSocketExecutor(nodes[u"DUT2"], is_async=True) as papi_exec: if not existing_tunnels: # Set IP address on VPP node 2 interface cmd = u"sw_interface_add_del_address" @@ -1675,7 +1666,7 @@ class IPsecUtil: ) err_msg = f"Failed to set IP address on interface {if2_key} " \ f"on host {nodes[u'DUT2'][u'host']}" - papi_exec.add(cmd, **args).get_reply(err_msg) + papi_exec.add(cmd, **args).get_replies(err_msg) # Configure IPIP tunnel interfaces cmd = u"ipip_add_tunnel" ipip_tunnel = dict( @@ -1713,7 +1704,7 @@ class IPsecUtil: ] ) # Configure IPSec SAD entries - cmd = u"ipsec_sad_entry_add_del_v3" + cmd = u"ipsec_sad_entry_add" c_key = dict( length=0, data=None @@ -1744,10 +1735,7 @@ class IPsecUtil: udp_src_port=IPSEC_UDP_PORT_NONE, udp_dst_port=IPSEC_UDP_PORT_NONE, ) - args = dict( - is_add=True, - entry=sad_entry - ) + args = dict(entry=sad_entry) for i in range(existing_tunnels, n_tunnels): ckeys.append( gen_key(IPsecUtil.get_crypto_alg_key_len(crypto_alg))