diff options
Diffstat (limited to 'resources')
-rw-r--r-- | resources/api/vpp/supported_crcs.yaml | 6 | ||||
-rw-r--r-- | resources/libraries/python/Tap.py | 56 |
2 files changed, 37 insertions, 25 deletions
diff --git a/resources/api/vpp/supported_crcs.yaml b/resources/api/vpp/supported_crcs.yaml index 720ce26dba..2fd80020b8 100644 --- a/resources/api/vpp/supported_crcs.yaml +++ b/resources/api/vpp/supported_crcs.yaml @@ -223,11 +223,11 @@ sw_interface_slave_dump: '0xd85aab0d' # perf # ^^ see bond_* sw_interface_tap_v2_dump: '0x51077d14' # dev - sw_interface_tap_v2_details: '0x5ee87a5f' # dev + sw_interface_tap_v2_details: '0x547b146a' # dev sw_interface_vhost_user_details: '0x91ff3307' # dev sw_interface_vhost_user_dump: '0x51077d14' # dev - tap_create_v2: '0x8fa99320' # dev - tap_create_v2_reply: '0xfda5941f' # dev + tap_create_v2: '0x958bfdfc' # dev + tap_create_v2_reply: '0x903324db' # dev vxlan_add_del_tunnel: '0x00f4bdd0' # virl vxlan_add_del_tunnel_reply: '0xfda5941f' # virl vxlan_tunnel_details: '0xce38e127' # virl diff --git a/resources/libraries/python/Tap.py b/resources/libraries/python/Tap.py index 103eeffd9e..50e065f9b5 100644 --- a/resources/libraries/python/Tap.py +++ b/resources/libraries/python/Tap.py @@ -13,16 +13,22 @@ """Tap utilities library.""" -from ipaddress import ip_address +from enum import IntEnum + from robot.api import logger from resources.libraries.python.Constants import Constants -from resources.libraries.python.L2Util import L2Util from resources.libraries.python.InterfaceUtil import InterfaceUtil +from resources.libraries.python.L2Util import L2Util from resources.libraries.python.PapiExecutor import PapiSocketExecutor from resources.libraries.python.topology import Topology +class TapFlags(IntEnum): + """TAP interface flags.""" + TAP_FLAG_GSO = 1 + + class Tap(object): """Tap utilities.""" @@ -44,17 +50,18 @@ class Tap(object): cmd = 'tap_create_v2' args = dict( id=Constants.BITWISE_NON_ZERO, - use_random_mac=0 if mac else 1, - mac_address=L2Util.mac_to_bin(mac) if mac else 6 * b'\x00', - host_namespace=64 * b'\x00', - host_mac_addr=6 * b'\x00', - host_if_name_set=1, - host_if_name=tap_name + (64 - len(tap_name)) * b'\x00', - host_bridge=64 * b'\x00', - host_ip4_addr=4 * b'\x00', - host_ip6_addr=16 * b'\x00', - host_ip4_gw=4 * b'\x00', - host_ip6_gw=16 * b'\x00' + use_random_mac=False if mac else True, + mac_address=L2Util.mac_to_bin(mac) if mac else None, + host_mtu_set=False, + host_mac_addr_set=False, + host_ip4_prefix_set=False, + host_ip6_prefix_set=False, + host_ip4_gw_set=False, + host_ip6_gw_set=False, + host_namespace_set=False, + host_if_name_set=True, + host_bridge_set=False, + host_if_name=tap_name, ) err_msg = 'Failed to create tap interface {tap} on host {host}'.format( tap=tap_name, host=node['host']) @@ -120,14 +127,19 @@ class Tap(object): :returns: Processed tap interface dump. :rtype: dict """ - tap_dump['dev_name'] = tap_dump['dev_name'].rstrip('\x00') - tap_dump['host_if_name'] = tap_dump['host_if_name'].rstrip('\x00') - tap_dump['host_namespace'] = \ - tap_dump['host_namespace'].rstrip('\x00') - tap_dump['host_mac_addr'] = \ - L2Util.bin_to_mac(tap_dump['host_mac_addr']) - tap_dump['host_ip4_addr'] = ip_address(tap_dump['host_ip4_addr']) - tap_dump['host_ip6_addr'] = ip_address(tap_dump['host_ip6_addr']) + tap_dump['host_mac_addr'] = str(tap_dump['host_mac_addr']) + tap_dump['host_ip4_prefix'] = str(tap_dump['host_ip4_prefix']) + tap_dump['host_ip6_prefix'] = str(tap_dump['host_ip6_prefix']) + tap_dump['tap_flags'] = tap_dump['tap_flags'].value \ + if hasattr(tap_dump['tap_flags'], 'value') \ + else int(tap_dump['tap_flags']) + tap_dump['host_namespace'] = None \ + if tap_dump['host_namespace'] == '(nil)' \ + else tap_dump['host_namespace'] + tap_dump['host_bridge'] = None \ + if tap_dump['host_bridge'] == '(nil)' \ + else tap_dump['host_bridge'] + return tap_dump cmd = 'sw_interface_tap_v2_dump' @@ -140,7 +152,7 @@ class Tap(object): for dump in details: if name is None: data.append(process_tap_dump(dump)) - elif dump.get('host_if_name').rstrip('\x00') == name: + elif dump.get('host_if_name') == name: data = process_tap_dump(dump) break |