FIX: use len parameter name in prefix structure in ip_route_add_del 32/20432/16
authorJan Gelety <jgelety@cisco.com>
Mon, 17 Jun 2019 14:22:39 +0000 (16:22 +0200)
committerVratko Polak <vrpolak@cisco.com>
Wed, 3 Jul 2019 15:21:36 +0000 (15:21 +0000)
 + new vpp stabel build with fixed ipv6 address incrementation

Change-Id: Id3f4104a48e45b6fd70ccbd47ad9e3c6925220fd
Signed-off-by: Jan Gelety <jgelety@cisco.com>
VPP_STABLE_VER_CENTOS
VPP_STABLE_VER_UBUNTU
VPP_STABLE_VER_UBUNTU_BIONIC
resources/libraries/python/IPUtil.py
tests/vpp/device/ip4/eth2p-ethip4-ip4base-dev.robot
tests/vpp/device/ip6/eth2p-ethip6-ip6base-dev.robot

index 76f92fa..27cd495 100644 (file)
@@ -1 +1 @@
-19.08-rc0~487_gb98dbb1~b7225
\ No newline at end of file
+19.08-rc0~575_gb34f99c~b7321
\ No newline at end of file
index af121eb..376026d 100644 (file)
@@ -1 +1 @@
-19.08-rc0~487-gb98dbb1~b7340
\ No newline at end of file
+19.08-rc0~575-gb34f99c~b7431
\ No newline at end of file
index e136c07..077ae11 100644 (file)
@@ -1 +1 @@
-19.08-rc0~487-gb98dbb1f2
\ No newline at end of file
+19.08-rc0~575-gb34f99ced
\ No newline at end of file
index 7f23353..0c4356b 100644 (file)
 
 import re
 
-from socket import AF_INET, AF_INET6, inet_pton
-
 from enum import IntEnum
-from ipaddress import ip_address
-from ipaddress import IPv4Network, IPv6Network
+from ipaddress import ip_address, IPv4Network, IPv6Network
 
 from resources.libraries.python.Constants import Constants
 from resources.libraries.python.InterfaceUtil import InterfaceUtil
@@ -144,6 +141,19 @@ class IPUtil(object):
 
         return data
 
+    @staticmethod
+    def vpp_get_ip_tables(node):
+        """Get dump of all IP FIB tables on a VPP node.
+
+        :param node: VPP node.
+        :type node: dict
+        """
+
+        PapiExecutor.run_cli_cmd(node, 'show ip fib')
+        PapiExecutor.run_cli_cmd(node, 'show ip fib summary')
+        PapiExecutor.run_cli_cmd(node, 'show ip6 fib')
+        PapiExecutor.run_cli_cmd(node, 'show ip6 fib summary')
+
     @staticmethod
     def get_interface_vrf_table(node, interface, ip_version='ipv4'):
         """Get vrf ID for the given interface.
@@ -387,8 +397,7 @@ class IPUtil(object):
             del_all=0,
             address_length=int(prefix_length) if prefix_length else 128
             if ip_addr.version == 6 else 32,
-            address=inet_pton(
-                AF_INET6 if ip_addr.version == 6 else AF_INET, str(ip_addr)))
+            address=ip_addr.packed)
         err_msg = 'Failed to add IP address on interface {ifc}'.format(
             ifc=interface)
         with PapiExecutor(node) as papi_exec:
@@ -426,8 +435,20 @@ class IPUtil(object):
                 verify_reply(err_msg=err_msg)
 
     @staticmethod
-    def vpp_route_add(node, network, prefix_len, **kwargs):
-        """Add route to the VPP node.
+    def union_addr(ip_addr):
+        """Creates union IP address.
+
+        :param ip_addr: IPv4 or IPv6 address.
+        :type ip_addr: IPv4Address or IPv6Address
+        :returns: Union IP address.
+        :rtype: dict
+        """
+        return dict(ip6=ip_addr.packed) if ip_addr.version == 6 \
+            else dict(ip4=ip_addr.packed)
+
+    @staticmethod
+    def compose_vpp_route_structure(node, network, prefix_len, **kwargs):
+        """Create route object for ip_route_add_del api call.
 
         :param node: VPP node.
         :param network: Route destination network address.
@@ -448,52 +469,27 @@ class IPUtil(object):
         :type network: str
         :type prefix_len: int
         :type kwargs: dict
+        :returns: route parameter basic structure
+        :rtype: dict
         """
-        count = kwargs.get("count", 1)
-
-        if count > 100:
-            gateway = kwargs.get("gateway", '')
-
-            vrf = kwargs.get("vrf", None)
-            multipath = kwargs.get("multipath", False)
-
-            with VatTerminal(node, json_param=False) as vat:
-                vat.vat_terminal_exec_cmd_from_template(
-                    'vpp_route_add.vat',
-                    network=network,
-                    prefix_length=prefix_len,
-                    via='via {}'.format(gateway) if gateway else '',
-                    vrf='vrf {}'.format(vrf) if vrf else '',
-                    count='count {}'.format(count) if count else '',
-                    multipath='multipath' if multipath else '')
-            return
-
         interface = kwargs.get('interface', '')
         gateway = kwargs.get('gateway', '')
 
         net_addr = ip_address(unicode(network))
 
-        def union_addr(ip_addr):
-            """Creates union IP address.
-
-            :param ip_addr: IPv4 or IPv6 address.
-            :type ip_addr: IPv4Address or IPv6Address
-            :returns: Union IP address.
-            :rtype: dict
-            """
-            return dict(ip6=inet_pton(AF_INET6, str(ip_addr))) \
-                if ip_addr.version == 6 \
-                else dict(ip4=inet_pton(AF_INET, str(ip_addr)))
-
         addr = dict(
             af=getattr(
                 AddressFamily, 'ADDRESS_IP6' if net_addr.version == 6
-                else 'ADDRESS_IP4').value)
-        prefix = dict(address_length=int(prefix_len))
+                else 'ADDRESS_IP4').value,
+            un=None)
+        prefix = dict(
+            len=int(prefix_len),
+            address=addr)
 
         paths = list()
         n_hop = dict(
-            address=union_addr(ip_address(unicode(gateway))) if gateway else 0,
+            address=IPUtil.union_addr(ip_address(unicode(gateway))) if gateway
+            else 0,
             via_label=MPLS_LABEL_INVALID,
             obj_id=Constants.BITWISE_NON_ZERO)
         path = dict(
@@ -519,22 +515,72 @@ class IPUtil(object):
 
         route = dict(
             table_id=int(kwargs.get('vrf', 0)),
+            prefix=prefix,
             n_paths=len(paths),
             paths=paths)
+
+        return route
+
+    @staticmethod
+    def vpp_route_add(node, network, prefix_len, **kwargs):
+        """Add route to the VPP node.
+
+        :param node: VPP node.
+        :param network: Route destination network address.
+        :param prefix_len: Route destination network prefix length.
+        :param kwargs: Optional key-value arguments:
+
+            gateway: Route gateway address. (str)
+            interface: Route interface. (str)
+            vrf: VRF table ID. (int)
+            count: number of IP addresses to add starting from network IP (int)
+            local: The route is local with same prefix (increment is 1).
+                If None, then is not used. (bool)
+            lookup_vrf: VRF table ID for lookup. (int)
+            multipath: Enable multipath routing. (bool)
+            weight: Weight value for unequal cost multipath routing. (int)
+
+        :type node: dict
+        :type network: str
+        :type prefix_len: int
+        :type kwargs: dict
+        """
+        count = kwargs.get("count", 1)
+
+        if count > 100:
+            gateway = kwargs.get("gateway", '')
+
+            vrf = kwargs.get("vrf", None)
+            multipath = kwargs.get("multipath", False)
+
+            with VatTerminal(node, json_param=False) as vat:
+                vat.vat_terminal_exec_cmd_from_template(
+                    'vpp_route_add.vat',
+                    network=network,
+                    prefix_length=prefix_len,
+                    via='via {}'.format(gateway) if gateway else '',
+                    vrf='vrf {}'.format(vrf) if vrf else '',
+                    count='count {}'.format(count) if count else '',
+                    multipath='multipath' if multipath else '')
+            return
+
+        net_addr = ip_address(unicode(network))
         cmd = 'ip_route_add_del'
+        route = IPUtil.compose_vpp_route_structure(
+            node, network, prefix_len, **kwargs)
         args = dict(
             is_add=1,
-            is_multipath=int(kwargs.get('multipath', False)))
+            is_multipath=int(kwargs.get('multipath', False)),
+            route=route)
 
         err_msg = 'Failed to add route(s) on host {host}'.format(
             host=node['host'])
         with PapiExecutor(node) as papi_exec:
             for i in xrange(kwargs.get('count', 1)):
-                addr['un'] = union_addr(net_addr + i)
-                prefix['address'] = addr
-                route['prefix'] = prefix
+                args['route']['prefix']['address']['un'] = \
+                    IPUtil.union_addr(net_addr + i)
                 history = False if 1 < i < kwargs.get('count', 1) else True
-                papi_exec.add(cmd, history=history, route=route, **args)
+                papi_exec.add(cmd, history=history, **args)
                 if i > 0 and i % Constants.PAPI_MAX_API_BULK == 0:
                     papi_exec.get_replies(err_msg).verify_replies(
                         err_msg=err_msg)
index 67e0704..23a5b76 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2018 Cisco and/or its affiliates.
+# Copyright (c) 2019 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:
 | | ... | remote_host1_ip4=${remote_host1_ip4}
 | | ... | remote_host2_ip4=${remote_host2_ip4}
 | | ... | remote_host_ip4_prefix=${remote_host_ip4_prefix}
+| | And VPP Get IP tables | ${dut_node}
 | | When All Vpp Interfaces Ready Wait | ${nodes}
 | | Then Send IPv4 ping packet and verify headers | ${tg_node}
 | | ... | ${tg_to_dut_if1} | ${tg_node} | ${tg_to_dut_if2}
index 424ff3e..4851c92 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2018 Cisco and/or its affiliates.
+# Copyright (c) 2019 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:
 | | ... | remote_host2_ip6=${remote_host2_ip6}
 | | ... | remote_host_ip6_prefix=${remote_host_ip6_prefix}
 | | And Suppress ICMPv6 router advertisement message | ${nodes}
+| | And VPP Get IP tables | ${dut_node}
 | | And All Vpp Interfaces Ready Wait | ${nodes}
 | | Then Send IPv6 echo request packet and verify headers | ${tg_node}
 | | ... | ${tg_to_dut_if1} | ${tg_node} | ${tg_to_dut_if2}