From d92086e8ee964d2d5700046ef85c6b681844288a Mon Sep 17 00:00:00 2001 From: Vratko Polak Date: Thu, 18 Aug 2022 15:10:54 +0200 Subject: feat(papi): use newer API messages Updated for what is available in (last common ancestor of) 2206. (So newer messages such as ipsec_spd_entry_add_del_v2 are not used yet.) + Removed messgages documented as unused. - Did not check if more become unused. + Restored alphabetical order. Change-Id: I4191c3f8629106f52ce387d03f30f9f973ffbefe Signed-off-by: Vratko Polak --- resources/libraries/python/FlowUtil.py | 2 +- resources/libraries/python/IPsecUtil.py | 30 +++++++++-------------------- resources/libraries/python/InterfaceUtil.py | 2 +- resources/libraries/python/Tap.py | 4 ++-- 4 files changed, 13 insertions(+), 25 deletions(-) (limited to 'resources/libraries/python') diff --git a/resources/libraries/python/FlowUtil.py b/resources/libraries/python/FlowUtil.py index 23293b6dc6..f92f5148db 100644 --- a/resources/libraries/python/FlowUtil.py +++ b/resources/libraries/python/FlowUtil.py @@ -400,7 +400,7 @@ class FlowUtil: :rtype: int :raises ValueError: If action type is not supported. """ - cmd = u"flow_add" + cmd = u"flow_add_v2" if action == u"redirect-to-queue": flow_rule = { diff --git a/resources/libraries/python/IPsecUtil.py b/resources/libraries/python/IPsecUtil.py index 6ed2db1eae..86bed716d1 100644 --- a/resources/libraries/python/IPsecUtil.py +++ b/resources/libraries/python/IPsecUtil.py @@ -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,12 +582,9 @@ 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 - ) - args = dict( - is_add=True, - entry=sad_entry + udp_dst_port=4500, # default value in api ) + args = dict(entry=sad_entry) with PapiSocketExecutor(node) as papi_exec: for i in range(n_entries): args[u"entry"][u"sad_id"] = int(sad_id) + i @@ -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)) @@ -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)) diff --git a/resources/libraries/python/InterfaceUtil.py b/resources/libraries/python/InterfaceUtil.py index 4a53f71a01..7578716023 100644 --- a/resources/libraries/python/InterfaceUtil.py +++ b/resources/libraries/python/InterfaceUtil.py @@ -1311,7 +1311,7 @@ class InterfaceUtil: node, u"set logging class af_xdp level debug" ) - cmd = u"af_xdp_create" + cmd = u"af_xdp_create_v2" pci_addr = Topology.get_interface_pci_addr(node, if_key) args = dict( name=InterfaceUtil.pci_to_eth(node, pci_addr), diff --git a/resources/libraries/python/Tap.py b/resources/libraries/python/Tap.py index 7a987fc34b..7380344b72 100644 --- a/resources/libraries/python/Tap.py +++ b/resources/libraries/python/Tap.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2022 Cisco and/or its affiliates. # 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: @@ -64,7 +64,7 @@ class Tap: :returns: Returns a interface index. :rtype: int """ - cmd = u"tap_create_v2" + cmd = u"tap_create_v3" args = dict( id=Constants.BITWISE_NON_ZERO, use_random_mac=bool(mac is None), -- cgit 1.2.3-korg