aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJakub Grajciar <jgrajcia@cisco.com>2019-03-18 13:17:53 +0100
committerOle Trøan <otroan@employees.org>2019-08-20 09:57:10 +0000
commit053204ab039d34a990ff0e14c32ce3b294fcce0e (patch)
tree7261eaf0b905ea456ac536d8f728e89319b16a69 /test
parentdf36f4963f1a590ce9a02f048507c3d4590580ae (diff)
api: Cleanup APIs interface.api
Use of consistent API types for interface.api Type: fix Change-Id: I88206d7d0907cffd564031f73c9a996df2e5e21a Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
Diffstat (limited to 'test')
-rw-r--r--test/ext/vapi_c_test.c18
-rw-r--r--test/ext/vapi_cpp_test.cpp8
-rw-r--r--test/remote_test.py9
-rw-r--r--test/test_bond.py8
-rw-r--r--test/test_container.py8
-rw-r--r--test/test_interface_crud.py4
-rw-r--r--test/test_ip4.py19
-rw-r--r--test/test_memif.py6
-rw-r--r--test/test_nat.py35
-rw-r--r--test/test_span.py2
-rw-r--r--test/vpp_interface.py128
-rw-r--r--test/vpp_ip_route.py6
-rw-r--r--test/vpp_memif.py16
-rw-r--r--test/vpp_sub_interface.py8
14 files changed, 148 insertions, 127 deletions
diff --git a/test/ext/vapi_c_test.c b/test/ext/vapi_c_test.c
index 0b22fff1706..725f5c30407 100644
--- a/test/ext/vapi_c_test.c
+++ b/test/ext/vapi_c_test.c
@@ -514,7 +514,7 @@ sw_interface_dump_cb (struct vapi_ctx_s *ctx, void *callback_ctx,
{
ck_assert (NULL != reply);
printf ("Interface dump entry: [%u]: %s\n", reply->sw_if_index,
- reply->interface_name);
+ reply->interface_name.buf);
size_t i = 0;
for (i = 0; i < dctx->num_ifs; ++i)
{
@@ -577,8 +577,8 @@ START_TEST (test_loopbacks_1)
clib_memset (&seen, 0, sizeof (seen));
dump = vapi_alloc_sw_interface_dump (ctx);
dump->payload.name_filter_valid = 0;
- clib_memset (dump->payload.name_filter, 0,
- sizeof (dump->payload.name_filter));
+ clib_memset (dump->payload.name_filter.buf, 0,
+ dump->payload.name_filter.length);
while (VAPI_EAGAIN ==
(rv =
vapi_sw_interface_dump (ctx, dump, sw_interface_dump_cb,
@@ -609,8 +609,8 @@ START_TEST (test_loopbacks_1)
clib_memset (&seen, 0, sizeof (seen));
dump = vapi_alloc_sw_interface_dump (ctx);
dump->payload.name_filter_valid = 0;
- clib_memset (dump->payload.name_filter, 0,
- sizeof (dump->payload.name_filter));
+ clib_memset (dump->payload.name_filter.buf, 0,
+ dump->payload.name_filter.length);
while (VAPI_EAGAIN ==
(rv =
vapi_sw_interface_dump (ctx, dump, sw_interface_dump_cb, &dctx)))
@@ -734,8 +734,8 @@ START_TEST (test_loopbacks_2)
sw_interface_dump_ctx dctx = { false, num_ifs, sw_if_indexes, seen, 0 };
vapi_msg_sw_interface_dump *dump = vapi_alloc_sw_interface_dump (ctx);
dump->payload.name_filter_valid = 0;
- clib_memset (dump->payload.name_filter, 0,
- sizeof (dump->payload.name_filter));
+ clib_memset (dump->payload.name_filter.buf, 0,
+ dump->payload.name_filter.length);
while (VAPI_EAGAIN ==
(rv =
vapi_sw_interface_dump (ctx, dump, sw_interface_dump_cb, &dctx)))
@@ -775,8 +775,8 @@ START_TEST (test_loopbacks_2)
dctx.last_called = false;
dump = vapi_alloc_sw_interface_dump (ctx);
dump->payload.name_filter_valid = 0;
- clib_memset (dump->payload.name_filter, 0,
- sizeof (dump->payload.name_filter));
+ clib_memset (dump->payload.name_filter.buf, 0,
+ dump->payload.name_filter.length);
while (VAPI_EAGAIN ==
(rv =
vapi_sw_interface_dump (ctx, dump, sw_interface_dump_cb, &dctx)))
diff --git a/test/ext/vapi_cpp_test.cpp b/test/ext/vapi_cpp_test.cpp
index 68366af2ac8..46a2c0ec2f1 100644
--- a/test/ext/vapi_cpp_test.cpp
+++ b/test/ext/vapi_cpp_test.cpp
@@ -151,7 +151,7 @@ START_TEST (test_loopbacks_1)
Sw_interface_dump d (con);
auto &p = d.get_request ().get_payload ();
p.name_filter_valid = 0;
- memset (p.name_filter, 0, sizeof (p.name_filter));
+ memset (p.name_filter.buf, 0, p.name_filter.length);
auto rv = d.execute ();
ck_assert_int_eq (VAPI_OK, rv);
WAIT_FOR_RESPONSE (d, rv);
@@ -193,7 +193,7 @@ START_TEST (test_loopbacks_1)
Sw_interface_dump d (con);
auto &p = d.get_request ().get_payload ();
p.name_filter_valid = 0;
- memset (p.name_filter, 0, sizeof (p.name_filter));
+ memset (p.name_filter.buf, 0, p.name_filter.length);
auto rv = d.execute ();
ck_assert_int_eq (VAPI_OK, rv);
WAIT_FOR_RESPONSE (d, rv);
@@ -311,7 +311,7 @@ START_TEST (test_loopbacks_2)
Sw_interface_dump d (con, std::ref (swdcb));
auto &p = d.get_request ().get_payload ();
p.name_filter_valid = 0;
- memset (p.name_filter, 0, sizeof (p.name_filter));
+ memset (p.name_filter.buf, 0, p.name_filter.length);
auto rv = d.execute ();
ck_assert_int_eq (VAPI_OK, rv);
WAIT_FOR_RESPONSE (d, rv);
@@ -340,7 +340,7 @@ START_TEST (test_loopbacks_2)
Sw_interface_dump d (con);
auto &p = d.get_request ().get_payload ();
p.name_filter_valid = 0;
- memset (p.name_filter, 0, sizeof (p.name_filter));
+ memset (p.name_filter.buf, 0, p.name_filter.length);
auto rv = d.execute ();
ck_assert_int_eq (VAPI_OK, rv);
WAIT_FOR_RESPONSE (d, rv);
diff --git a/test/remote_test.py b/test/remote_test.py
index cd2e46fe219..9c825ccf755 100644
--- a/test/remote_test.py
+++ b/test/remote_test.py
@@ -3,14 +3,13 @@
import inspect
import os
import unittest
+from framework import VppTestCase
from multiprocessing import Process, Pipe
from pickle import dumps
-
import six
from six import moves
-
-from framework import VppTestCase
-from aenum import Enum
+import sys
+from aenum import IntEnum, IntFlag
class SerializableClassCopy(object):
@@ -270,7 +269,7 @@ class RemoteClass(Process):
if type(obj) is tuple:
rv = tuple(rv)
return rv
- elif (isinstance(obj, Enum)):
+ elif (isinstance(obj, IntEnum) or isinstance(obj, IntFlag)):
return obj.value
else:
return self._make_obj_serializable(obj)
diff --git a/test/test_bond.py b/test/test_bond.py
index d1ae77ad3f5..60ee33c0356 100644
--- a/test/test_bond.py
+++ b/test/test_bond.py
@@ -9,6 +9,7 @@ from scapy.layers.l2 import Ether
from scapy.layers.inet import IP, UDP
from vpp_bond_interface import VppBondInterface
from vpp_papi import MACAddress
+from vpp_ip import VppIpPrefix
class TestBondInterface(VppTestCase):
@@ -70,10 +71,9 @@ class TestBondInterface(VppTestCase):
mac_address=mac)
bond0.add_vpp_config()
bond0.admin_up()
- bond0_addr = socket.inet_pton(socket.AF_INET, "10.10.10.1")
- self.vapi.sw_interface_add_del_address(sw_if_index=bond0.sw_if_index,
- address=bond0_addr,
- address_length=24)
+ self.vapi.sw_interface_add_del_address(
+ sw_if_index=bond0.sw_if_index,
+ prefix=VppIpPrefix("10.10.10.1", 24).encode())
self.pg2.config_ip4()
self.pg2.resolve_arp()
diff --git a/test/test_container.py b/test/test_container.py
index 139dfcfbcaf..1e3ec40a2f7 100644
--- a/test/test_container.py
+++ b/test/test_container.py
@@ -82,11 +82,11 @@ class ContainerIntegrationTestCase(VppTestCase):
for i in range(2):
intf = self.lo_interfaces[i]
intf.admin_up()
- intf._local_ip4 = self.pg_interfaces[i].remote_ip4
- intf._local_ip4_prefix_len = 32
+ intf.local_ip4 = self.pg_interfaces[i].remote_ip4
+ intf.local_ip4_prefix_len = 32
intf.config_ip4()
- intf._local_ip6 = self.pg_interfaces[i].remote_ip6
- intf._local_ip6_prefix_len = 128
+ intf.local_ip6 = self.pg_interfaces[i].remote_ip6
+ intf.local_ip6_prefix_len = 128
intf.config_ip6()
def test_0110_basic_conn_test(self):
diff --git a/test/test_interface_crud.py b/test/test_interface_crud.py
index ae30a6d47ea..4711c2f7931 100644
--- a/test/test_interface_crud.py
+++ b/test/test_interface_crud.py
@@ -85,7 +85,7 @@ class TestLoopbackInterfaceCRUD(VppTestCase):
# create
loopbacks = self.create_loopback_interfaces(20)
for i in loopbacks:
- i.local_ip4_prefix_len = 32
+ i.local_ip4_prefix.len = 32
i.config_ip4()
i.admin_up()
@@ -127,7 +127,7 @@ class TestLoopbackInterfaceCRUD(VppTestCase):
# create
loopbacks = self.create_loopback_interfaces(20)
for i in loopbacks:
- i.local_ip4_prefix_len = 32
+ i.local_ip4_prefix.len = 32
i.config_ip4()
i.admin_up()
diff --git a/test/test_ip4.py b/test/test_ip4.py
index 0923771200e..60bc023a280 100644
--- a/test/test_ip4.py
+++ b/test/test_ip4.py
@@ -13,6 +13,7 @@ from six import moves
from framework import VppTestCase, VppTestRunner
from util import ppp
+from vpp_ip import VppIpPrefix
from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpMRoute, \
VppMRoutePath, MRouteItfFlags, MRouteEntryFlags, VppMplsIpBind, \
VppMplsTable, VppIpTable, FibPathType, find_route, \
@@ -920,8 +921,8 @@ class TestIPSubNets(VppTestCase):
ip_addr_n = socket.inet_pton(socket.AF_INET, "10.10.10.10")
self.vapi.sw_interface_add_del_address(
- sw_if_index=self.pg0.sw_if_index, address=ip_addr_n,
- address_length=16)
+ sw_if_index=self.pg0.sw_if_index,
+ prefix=VppIpPrefix("10.10.10.10", 16).encode())
pn = (Ether(src=self.pg1.remote_mac,
dst=self.pg1.local_mac) /
@@ -939,8 +940,9 @@ class TestIPSubNets(VppTestCase):
# remove the sub-net and we are forwarding via the cover again
self.vapi.sw_interface_add_del_address(
- sw_if_index=self.pg0.sw_if_index, address=ip_addr_n,
- address_length=16, is_add=0)
+ sw_if_index=self.pg0.sw_if_index,
+ prefix=VppIpPrefix("10.10.10.10", 16).encode(), is_add=0)
+
self.pg1.add_stream(pn)
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
@@ -957,8 +959,8 @@ class TestIPSubNets(VppTestCase):
ip_addr_n = socket.inet_pton(socket.AF_INET, "10.10.10.10")
self.vapi.sw_interface_add_del_address(
- sw_if_index=self.pg0.sw_if_index, address=ip_addr_n,
- address_length=31)
+ sw_if_index=self.pg0.sw_if_index,
+ prefix=VppIpPrefix("10.10.10.10", 31).encode())
pn = (Ether(src=self.pg1.remote_mac,
dst=self.pg1.local_mac) /
@@ -974,8 +976,9 @@ class TestIPSubNets(VppTestCase):
# remove the sub-net and we are forwarding via the cover again
self.vapi.sw_interface_add_del_address(
- sw_if_index=self.pg0.sw_if_index, address=ip_addr_n,
- address_length=31, is_add=0)
+ sw_if_index=self.pg0.sw_if_index,
+ prefix=VppIpPrefix("10.10.10.10", 31).encode(), is_add=0)
+
self.pg1.add_stream(pn)
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
diff --git a/test/test_memif.py b/test/test_memif.py
index aae5b3c1efb..6413cfdbf20 100644
--- a/test/test_memif.py
+++ b/test/test_memif.py
@@ -209,14 +209,14 @@ class TestMemif(VppTestCase):
pkts = []
for i in range(num):
pkt = (Ether(dst=pg.local_mac, src=pg.remote_mac) /
- IP(src=pg.remote_ip4, dst=memif.ip4_addr) /
+ IP(src=pg.remote_ip4, dst=memif.ip_prefix.address) /
ICMP(id=memif.if_id, type='echo-request', seq=i))
pkts.append(pkt)
return pkts
def _verify_icmp(self, pg, memif, rx, seq):
ip = rx[IP]
- self.assertEqual(ip.src, memif.ip4_addr)
+ self.assertEqual(ip.src, memif.ip_prefix.address)
self.assertEqual(ip.dst, pg.remote_ip4)
self.assertEqual(ip.proto, 1)
icmp = rx[ICMP]
@@ -250,7 +250,7 @@ class TestMemif(VppTestCase):
# add routing to remote vpp
route = VppIpRoute(self.remote_test, self.pg0._local_ip4_subnet, 24,
- [VppRoutePath(memif.ip4_addr, 0xffffffff)],
+ [VppRoutePath(memif.ip_prefix.address, 0xffffffff)],
register=False)
route.add_vpp_config()
diff --git a/test/test_nat.py b/test/test_nat.py
index 773eb51d4ee..a64b5709c72 100644
--- a/test/test_nat.py
+++ b/test/test_nat.py
@@ -27,6 +27,7 @@ from io import BytesIO
from vpp_papi import VppEnum
from vpp_ip_route import VppIpRoute, VppRoutePath, FibPathType
from vpp_neighbor import VppNeighbor
+from vpp_ip import VppIpAddress, VppIpPrefix
from scapy.all import bind_layers, Packet, ByteEnumField, ShortField, \
IPField, IntField, LongField, XByteField, FlagsField, FieldLenField, \
PacketListField
@@ -1504,16 +1505,16 @@ class TestNAT44(MethodHolder):
cls.vapi.ip_table_add_del(is_add=1, table_id=10)
cls.vapi.ip_table_add_del(is_add=1, table_id=20)
- cls.pg4._local_ip4 = "172.16.255.1"
- cls.pg4._local_ip4n = socket.inet_pton(socket.AF_INET, i.local_ip4)
+ cls.pg4._local_ip4 = VppIpPrefix("172.16.255.1",
+ cls.pg4.local_ip4_prefix.len)
cls.pg4._remote_hosts[0]._ip4 = "172.16.255.2"
cls.pg4.set_table_ip4(10)
- cls.pg5._local_ip4 = "172.17.255.3"
- cls.pg5._local_ip4n = socket.inet_pton(socket.AF_INET, i.local_ip4)
+ cls.pg5._local_ip4 = VppIpPrefix("172.17.255.3",
+ cls.pg5.local_ip4_prefix.len)
cls.pg5._remote_hosts[0]._ip4 = "172.17.255.4"
cls.pg5.set_table_ip4(10)
- cls.pg6._local_ip4 = "172.16.255.1"
- cls.pg6._local_ip4n = socket.inet_pton(socket.AF_INET, i.local_ip4)
+ cls.pg6._local_ip4 = VppIpPrefix("172.16.255.1",
+ cls.pg6.local_ip4_prefix.len)
cls.pg6._remote_hosts[0]._ip4 = "172.16.255.2"
cls.pg6.set_table_ip4(20)
for i in cls.overlapping_interfaces:
@@ -1526,10 +1527,10 @@ class TestNAT44(MethodHolder):
cls.pg9.generate_remote_hosts(2)
cls.pg9.config_ip4()
- ip_addr_n = socket.inet_pton(socket.AF_INET, "10.0.0.1")
cls.vapi.sw_interface_add_del_address(
- sw_if_index=cls.pg9.sw_if_index, address=ip_addr_n,
- address_length=24)
+ sw_if_index=cls.pg9.sw_if_index,
+ prefix=VppIpPrefix("10.0.0.1", 24).encode())
+
cls.pg9.admin_up()
cls.pg9.resolve_arp()
cls.pg9._remote_hosts[1]._ip4 = cls.pg9._remote_hosts[0]._ip4
@@ -4428,10 +4429,10 @@ class TestNAT44EndpointDependent(MethodHolder):
cls.pg4.generate_remote_hosts(2)
cls.pg4.config_ip4()
- ip_addr_n = socket.inet_pton(socket.AF_INET, "10.0.0.1")
cls.vapi.sw_interface_add_del_address(
- sw_if_index=cls.pg4.sw_if_index, address=ip_addr_n,
- address_length=24)
+ sw_if_index=cls.pg4.sw_if_index,
+ prefix=VppIpPrefix("10.0.0.1", 24).encode())
+
cls.pg4.admin_up()
cls.pg4.resolve_arp()
cls.pg4._remote_hosts[1]._ip4 = cls.pg4._remote_hosts[0]._ip4
@@ -4440,9 +4441,8 @@ class TestNAT44EndpointDependent(MethodHolder):
zero_ip4n = socket.inet_pton(socket.AF_INET, "0.0.0.0")
cls.vapi.ip_table_add_del(is_add=1, table_id=1)
- cls.pg5._local_ip4 = "10.1.1.1"
- cls.pg5._local_ip4n = socket.inet_pton(socket.AF_INET,
- cls.pg5.local_ip4)
+ cls.pg5._local_ip4 = VppIpPrefix("10.1.1.1",
+ cls.pg5.local_ip4_prefix.len)
cls.pg5._remote_hosts[0]._ip4 = "10.1.1.2"
cls.pg5._remote_hosts[0]._ip4n = socket.inet_pton(
socket.AF_INET, cls.pg5.remote_ip4)
@@ -4456,9 +4456,8 @@ class TestNAT44EndpointDependent(MethodHolder):
register=False)
r1.add_vpp_config()
- cls.pg6._local_ip4 = "10.1.2.1"
- cls.pg6._local_ip4n = socket.inet_pton(socket.AF_INET,
- cls.pg6.local_ip4)
+ cls.pg6._local_ip4 = VppIpPrefix("10.1.2.1",
+ cls.pg6.local_ip4_prefix.len)
cls.pg6._remote_hosts[0]._ip4 = "10.1.2.2"
cls.pg6._remote_hosts[0]._ip4n = socket.inet_pton(
socket.AF_INET, cls.pg6.remote_ip4)
diff --git a/test/test_span.py b/test/test_span.py
index e4b0d0ad2b4..c67bc7b8587 100644
--- a/test/test_span.py
+++ b/test/test_span.py
@@ -235,7 +235,7 @@ class TestSpan(VppTestCase):
self.sub_if.admin_up()
self.vapi.sw_interface_set_flags(self.vxlan.sw_if_index,
- admin_up_down=1)
+ flags=1)
self.bridge(self.vxlan.sw_if_index, is_add=1)
# Create bi-directional cross-connects between pg0 subif and pg1
diff --git a/test/vpp_interface.py b/test/vpp_interface.py
index e8100d362ec..1e047f5f700 100644
--- a/test/vpp_interface.py
+++ b/test/vpp_interface.py
@@ -6,7 +6,8 @@ import six
from six import moves
from util import Host, mk_ll_addr
-from vpp_papi import mac_ntop
+from vpp_papi import mac_ntop, VppEnum
+from vpp_ip import VppIpAddress, VppIpPrefix
from ipaddress import IPv4Network
try:
@@ -43,22 +44,33 @@ class VppInterface(object):
return self._remote_addr
@property
- def local_addr_n(self):
- return self._local_addr_n
+ def local_ip4(self):
+ """Local IPv4 address on VPP interface (string)."""
+ return self._local_ip4.address
+
+ @local_ip4.setter
+ def local_ip4(self, value):
+ self._local_ip4.address = value
@property
- def remote_addr_n(self):
- return self._remote_addr_n
+ def local_ip4_prefix_len(self):
+ """Local IPv4 prefix length """
+ return self._local_ip4.len
+
+ @local_ip4_prefix_len.setter
+ def local_ip4_prefix_len(self, value):
+ self._local_ip4.len = value
@property
- def local_ip4(self):
- """Local IPv4 address on VPP interface (string)."""
+ def local_ip4_prefix(self):
+ """Local IPv4 prefix """
return self._local_ip4
@property
def local_ip4n(self):
+ """DEPRECATED """
"""Local IPv4 address - raw, suitable as API parameter."""
- return socket.inet_pton(socket.AF_INET, self._local_ip4)
+ return socket.inet_pton(socket.AF_INET, self._local_ip4.address)
@property
def remote_ip4(self):
@@ -67,18 +79,38 @@ class VppInterface(object):
@property
def remote_ip4n(self):
- """IPv4 address of remote peer - raw, suitable as API parameter."""
- return socket.inet_pton(socket.AF_INET, self.remote_ip4)
+ """DEPRECATED """
+ """Local IPv6 address - raw, suitable as API parameter."""
+ return socket.inet_pton(socket.AF_INET, self._remote_hosts[0].ip4)
@property
def local_ip6(self):
"""Local IPv6 address on VPP interface (string)."""
+ return self._local_ip6.address
+
+ @local_ip6.setter
+ def local_ip6(self, value):
+ self._local_ip6.address = value
+
+ @property
+ def local_ip6_prefix_len(self):
+ """Local IPv6 prefix length """
+ return self._local_ip6.len
+
+ @local_ip6_prefix_len.setter
+ def local_ip6_prefix_len(self, value):
+ self._local_ip6.len = value
+
+ @property
+ def local_ip6_prefix(self):
+ """Local IPv6 prefix """
return self._local_ip6
@property
def local_ip6n(self):
+ """DEPRECATED """
"""Local IPv6 address - raw, suitable as API parameter."""
- return socket.inet_pton(socket.AF_INET6, self.local_ip6)
+ return socket.inet_pton(socket.AF_INET6, self._local_ip6.address)
@property
def remote_ip6(self):
@@ -87,18 +119,20 @@ class VppInterface(object):
@property
def remote_ip6n(self):
- """IPv6 address of remote peer - raw, suitable as API parameter"""
- return socket.inet_pton(socket.AF_INET6, self.remote_ip6)
+ """DEPRECATED """
+ """Local IPv6 address - raw, suitable as API parameter."""
+ return socket.inet_pton(socket.AF_INET6, self._remote_hosts[0].ip6)
@property
def local_ip6_ll(self):
"""Local IPv6 link-local address on VPP interface (string)."""
- return self._local_ip6_ll
+ return self._local_ip6_ll.address
@property
def local_ip6n_ll(self):
- """Local IPv6 link-local address - raw, suitable as API parameter."""
- return self._local_ip6n_ll
+ """DEPRECATED """
+ """Local IPv6 link-local address on VPP interface (string)."""
+ return socket.inet_pton(socket.AF_INET6, self._local_ip6_ll.address)
@property
def remote_ip6_ll(self):
@@ -108,9 +142,9 @@ class VppInterface(object):
@property
def remote_ip6n_ll(self):
- """Link-local IPv6 address of remote peer
- - raw, suitable as API parameter"""
- return self._remote_ip6n_ll
+ """DEPRECATED """
+ """Local IPv6 link-local address on VPP interface (string)."""
+ return socket.inet_pton(socket.AF_INET6, self._remote_ip6_ll)
@property
def name(self):
@@ -199,7 +233,7 @@ class VppInterface(object):
def set_mac(self, mac):
self._local_mac = str(mac)
- self._local_ip6_ll = mk_ll_addr(self._local_mac)
+ self._local_ip6_ll = VppIpAddress(mk_ll_addr(self._local_mac))
self.test.vapi.sw_interface_set_mac_address(
self.sw_if_index, mac.packed)
@@ -208,39 +242,27 @@ class VppInterface(object):
self.generate_remote_hosts()
- self._local_ip4 = "172.16.%u.1" % self.sw_if_index
- self._local_ip4n = socket.inet_pton(socket.AF_INET, self.local_ip4)
+ self._local_ip4 = VppIpPrefix("172.16.%u.1" % self.sw_if_index, 24)
self._local_ip4_subnet = "172.16.%u.0" % self.sw_if_index
- self._local_ip4n_subnet = socket.inet_pton(socket.AF_INET,
- self._local_ip4_subnet)
self._local_ip4_bcast = "172.16.%u.255" % self.sw_if_index
- self._local_ip4n_bcast = socket.inet_pton(socket.AF_INET,
- self._local_ip4_bcast)
- self.local_ip4_prefix_len = 24
self.has_ip4_config = False
self.ip4_table_id = 0
- self._local_ip6 = "fd01:%x::1" % self.sw_if_index
- self._local_ip6n = socket.inet_pton(socket.AF_INET6, self.local_ip6)
- self.local_ip6_prefix_len = 64
+ self._local_ip6 = VppIpPrefix("fd01:%x::1" % self.sw_if_index, 64)
self.has_ip6_config = False
self.ip6_table_id = 0
self._local_addr = {socket.AF_INET: self.local_ip4,
socket.AF_INET6: self.local_ip6}
- self._local_addr_n = {socket.AF_INET: self.local_ip4n,
- socket.AF_INET6: self.local_ip6n}
self._remote_addr = {socket.AF_INET: self.remote_ip4,
socket.AF_INET6: self.remote_ip6}
- self._remote_addr_n = {socket.AF_INET: self.remote_ip4n,
- socket.AF_INET6: self.remote_ip6n}
r = self.test.vapi.sw_interface_dump(sw_if_index=self.sw_if_index)
for intf in r:
if intf.sw_if_index == self.sw_if_index:
self._name = intf.interface_name.split(b'\0',
1)[0].decode('utf8')
- self._local_mac = mac_ntop(intf.l2_address)
+ self._local_mac = bytes(intf.l2_address)
self._dump = intf
break
else:
@@ -248,18 +270,13 @@ class VppInterface(object):
"Could not find interface with sw_if_index %d "
"in interface dump %s" %
(self.sw_if_index, moves.reprlib.repr(r)))
- self._local_ip6_ll = mk_ll_addr(self.local_mac)
- self._local_ip6n_ll = socket.inet_pton(socket.AF_INET6,
- self.local_ip6_ll)
+ self._local_ip6_ll = VppIpAddress(mk_ll_addr(self.local_mac))
self._remote_ip6_ll = mk_ll_addr(self.remote_mac)
- self._remote_ip6n_ll = socket.inet_pton(socket.AF_INET6,
- self.remote_ip6_ll)
def config_ip4(self):
"""Configure IPv4 address on the VPP interface."""
self.test.vapi.sw_interface_add_del_address(
- sw_if_index=self.sw_if_index, address=self.local_ip4n,
- address_length=self.local_ip4_prefix_len)
+ sw_if_index=self.sw_if_index, prefix=self._local_ip4.encode())
self.has_ip4_config = True
def unconfig_ip4(self):
@@ -267,8 +284,8 @@ class VppInterface(object):
try:
if self.has_ip4_config:
self.test.vapi.sw_interface_add_del_address(
- sw_if_index=self.sw_if_index, address=self.local_ip4n,
- address_length=self.local_ip4_prefix_len, is_add=0)
+ sw_if_index=self.sw_if_index,
+ prefix=self._local_ip4.encode(), is_add=0)
except AttributeError:
self.has_ip4_config = False
self.has_ip4_config = False
@@ -286,8 +303,7 @@ class VppInterface(object):
def config_ip6(self):
"""Configure IPv6 address on the VPP interface."""
self.test.vapi.sw_interface_add_del_address(
- sw_if_index=self.sw_if_index, address=self._local_ip6n,
- address_length=self.local_ip6_prefix_len, is_ipv6=1)
+ sw_if_index=self.sw_if_index, prefix=self._local_ip6.encode())
self.has_ip6_config = True
def unconfig_ip6(self):
@@ -295,9 +311,8 @@ class VppInterface(object):
try:
if self.has_ip6_config:
self.test.vapi.sw_interface_add_del_address(
- sw_if_index=self.sw_if_index, address=self.local_ip6n,
- address_length=self.local_ip6_prefix_len, is_ipv6=1,
- is_add=0)
+ sw_if_index=self.sw_if_index,
+ prefix=self._local_ip6.encode(), is_add=0)
except AttributeError:
self.has_ip6_config = False
self.has_ip6_config = False
@@ -365,13 +380,14 @@ class VppInterface(object):
def admin_up(self):
"""Put interface ADMIN-UP."""
- self.test.vapi.sw_interface_set_flags(self.sw_if_index,
- admin_up_down=1)
+ self.test.vapi.sw_interface_set_flags(
+ self.sw_if_index,
+ flags=VppEnum.vl_api_if_status_flags_t.IF_STATUS_API_FLAG_ADMIN_UP)
def admin_down(self):
"""Put interface ADMIN-down."""
self.test.vapi.sw_interface_set_flags(self.sw_if_index,
- admin_up_down=0)
+ flags=0)
def link_up(self):
"""Put interface link-state-UP."""
@@ -459,15 +475,15 @@ class VppInterface(object):
name='sw_interface_event')
self.test.assert_equal(event.sw_if_index, self.sw_if_index,
"sw_if_index")
- self.test.assert_equal(event.admin_up_down, admin_up_down,
+ self.test.assert_equal((event.flags & 1), admin_up_down,
"admin state")
- self.test.assert_equal(event.link_up_down, link_up_down,
+ self.test.assert_equal((event.flags & 2), link_up_down,
"link state")
dump = self.test.vapi.sw_interface_dump()
if_state = self.get_interface_config_from_dump(dump)
- self.test.assert_equal(if_state.admin_up_down, admin_up_down,
+ self.test.assert_equal((if_state.flags & 1), admin_up_down,
"admin state")
- self.test.assert_equal(if_state.link_up_down, link_up_down,
+ self.test.assert_equal((if_state.flags & 2), link_up_down,
"link state")
def __str__(self):
diff --git a/test/vpp_ip_route.py b/test/vpp_ip_route.py
index a70180b3de5..7742936a8a0 100644
--- a/test/vpp_ip_route.py
+++ b/test/vpp_ip_route.py
@@ -202,15 +202,13 @@ class VppIpInterfaceAddress(VppObject):
def add_vpp_config(self):
self._test.vapi.sw_interface_add_del_address(
- sw_if_index=self.intf.sw_if_index, address=self.prefix.bytes,
- address_length=self.prefix.length, is_ipv6=self.prefix.is_ip6,
+ sw_if_index=self.intf.sw_if_index, prefix=self.prefix.encode(),
is_add=1)
self._test.registry.register(self, self._test.logger)
def remove_vpp_config(self):
self._test.vapi.sw_interface_add_del_address(
- sw_if_index=self.intf.sw_if_index, address=self.prefix.bytes,
- address_length=self.prefix.length, is_ipv6=self.prefix.is_ip6,
+ sw_if_index=self.intf.sw_if_index, prefix=self.prefix.encode(),
is_add=0)
def query_vpp_config(self):
diff --git a/test/vpp_memif.py b/test/vpp_memif.py
index 7fa45092740..befcc2840c5 100644
--- a/test/vpp_memif.py
+++ b/test/vpp_memif.py
@@ -3,6 +3,8 @@ import socket
import six
from vpp_object import VppObject
+from vpp_ip import VppIpPrefix
+from vpp_papi import VppEnum
class MEMIF_ROLE:
@@ -84,8 +86,8 @@ class VppMemif(VppObject):
self.buffer_size = buffer_size
self.hw_addr = hw_addr
self.sw_if_index = None
- self.ip4_addr = "192.168.%d.%d" % (self.if_id + 1, self.role + 1)
- self.ip4_addr_len = 24
+ self.ip_prefix = VppIpPrefix("192.168.%d.%d" %
+ (self.if_id + 1, self.role + 1), 24)
def add_vpp_config(self):
rv = self._test.vapi.memif_create(
@@ -112,11 +114,13 @@ class VppMemif(VppObject):
def admin_up(self):
if self.sw_if_index:
- return self._test.vapi.sw_interface_set_flags(self.sw_if_index, 1)
+ return self._test.vapi.sw_interface_set_flags(
+ sw_if_index=self.sw_if_index, flags=1)
def admin_down(self):
if self.sw_if_index:
- return self._test.vapi.sw_interface_set_flags(self.sw_if_index, 0)
+ return self._test.vapi.sw_interface_set_flags(
+ sw_if_index=self.sw_if_index, flags=0)
def wait_for_link_up(self, timeout, step=1):
if not self.sw_if_index:
@@ -132,9 +136,7 @@ class VppMemif(VppObject):
def config_ip4(self):
return self._test.vapi.sw_interface_add_del_address(
- sw_if_index=self.sw_if_index, address=socket.inet_pton(
- socket.AF_INET, self.ip4_addr),
- address_length=self.ip4_addr_len)
+ sw_if_index=self.sw_if_index, prefix=self.ip_prefix.encode())
def remove_vpp_config(self):
self._test.vapi.memif_delete(self.sw_if_index)
diff --git a/test/vpp_sub_interface.py b/test/vpp_sub_interface.py
index 4961ba5ff69..8f422d8a050 100644
--- a/test/vpp_sub_interface.py
+++ b/test/vpp_sub_interface.py
@@ -3,6 +3,7 @@ import abc
import six
from vpp_pg_interface import VppPGInterface
from vpp_interface import VppInterface
+from vpp_papi import VppEnum
class L2_VTR_OP:
@@ -182,10 +183,13 @@ class VppDot1ADSubint(VppSubInterface):
def __init__(self, test, parent, sub_id, outer_vlan, inner_vlan):
super(VppDot1ADSubint, self).__init__(test, parent, sub_id)
+ flags = (VppEnum.vl_api_sub_if_flags_t.SUB_IF_API_FLAG_DOT1AD |
+ VppEnum.vl_api_sub_if_flags_t.SUB_IF_API_FLAG_TWO_TAGS |
+ VppEnum.vl_api_sub_if_flags_t.SUB_IF_API_FLAG_EXACT_MATCH)
r = test.vapi.create_subif(sw_if_index=parent.sw_if_index,
sub_id=sub_id, outer_vlan_id=outer_vlan,
- inner_vlan_id=inner_vlan, two_tags=1,
- dot1ad=1, exact_match=1)
+ inner_vlan_id=inner_vlan,
+ sub_if_flags=flags)
self.set_sw_if_index(r.sw_if_index)
self._outer_vlan = outer_vlan
self._inner_vlan = inner_vlan