aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJakub Grajciar <jgrajcia@cisco.com>2019-03-01 08:55:49 +0100
committerOle Trøan <otroan@employees.org>2019-03-15 10:24:22 +0000
commite63325e3ca03c847963863446345e6c80a2c0cfd (patch)
treecae33764e6186727697e91862c32f2b08334866b /test
parent4ba4edd15085ce31145ef5da6342e435c57c1150 (diff)
API: Cleanup APIs interface.api
Use of consistent API types for interface.api Change-Id: Ieb54cebb4ac96b432a3f0b41596718aa2f34885b 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.py15
-rw-r--r--test/test_bond.py8
-rw-r--r--test/test_interface_crud.py4
-rw-r--r--test/test_ip4.py19
-rw-r--r--test/test_memif.py13
-rw-r--r--test/test_nat.py35
-rw-r--r--test/test_span.py2
-rw-r--r--test/vpp_interface.py112
-rw-r--r--test/vpp_ip_route.py6
-rw-r--r--test/vpp_memif.py16
-rw-r--r--test/vpp_sub_interface.py8
13 files changed, 139 insertions, 125 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 bc6d70764ec..f5b3c620cc4 100644
--- a/test/remote_test.py
+++ b/test/remote_test.py
@@ -3,14 +3,21 @@
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
+import sys
+if sys.version_info <= (3, 4):
+ from aenum import IntEnum
+else:
+ from enum import IntEnum
-from framework import VppTestCase
-from enum import Enum
+if sys.version_info <= (3, 6):
+ from aenum import IntFlag
+else:
+ from enum import IntFlag
class SerializableClassCopy(object):
@@ -266,7 +273,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 533038e658a..eb43281719e 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):
@@ -64,10 +65,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_interface_crud.py b/test/test_interface_crud.py
index d78cb58be0b..b845c6b877e 100644
--- a/test/test_interface_crud.py
+++ b/test/test_interface_crud.py
@@ -81,7 +81,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()
@@ -123,7 +123,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 c8c0a71d171..8282d134836 100644
--- a/test/test_ip4.py
+++ b/test/test_ip4.py
@@ -17,6 +17,7 @@ from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpMRoute, \
VppMRoutePath, MRouteItfFlags, MRouteEntryFlags, VppMplsIpBind, \
VppMplsTable, VppIpTable
from vpp_sub_interface import VppSubInterface, VppDot1QSubint, VppDot1ADSubint
+from vpp_ip import VppIpPrefix
class TestIPv4(VppTestCase):
@@ -810,8 +811,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) /
@@ -829,8 +830,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()
@@ -847,8 +849,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) /
@@ -864,8 +866,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 d89e06bfb4b..e5ff18186c1 100644
--- a/test/test_memif.py
+++ b/test/test_memif.py
@@ -208,14 +208,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]
@@ -249,10 +249,11 @@ class TestMemif(VppTestCase):
# add routing to remote vpp
dst_addr = socket.inet_pton(socket.AF_INET, self.pg0._local_ip4_subnet)
dst_addr_len = 24
- next_hop_addr = socket.inet_pton(socket.AF_INET, memif.ip4_addr)
- self.remote_test.vapi.ip_add_del_route(dst_address=dst_addr,
- dst_address_length=dst_addr_len,
- next_hop_address=next_hop_addr)
+ next_hop_addr = socket.inet_pton(socket.AF_INET,
+ memif.ip_prefix.address)
+ self.remote_test.vapi.ip_add_del_route(
+ dst_address=dst_addr, dst_address_length=dst_addr_len,
+ next_hop_address=next_hop_addr)
# create ICMP echo-request from local pg to remote memif
packet_num = 10
diff --git a/test/test_nat.py b/test/test_nat.py
index b2c442f81e6..69a18f8a097 100644
--- a/test/test_nat.py
+++ b/test/test_nat.py
@@ -26,6 +26,7 @@ from syslog_rfc5424_parser.constants import SyslogFacility, SyslogSeverity
from vpp_papi_provider import SYSLOG_SEVERITY
from io import BytesIO
from vpp_papi import VppEnum
+from vpp_ip import VppIpAddress, VppIpPrefix
from scapy.all import bind_layers, Packet, ByteEnumField, ShortField, \
IPField, IntField, LongField, XByteField, FlagsField, FieldLenField, \
PacketListField
@@ -1526,16 +1527,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:
@@ -1548,10 +1549,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
@@ -4213,10 +4214,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
@@ -4225,9 +4226,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)
@@ -4240,9 +4240,8 @@ class TestNAT44EndpointDependent(MethodHolder):
next_hop_sw_if_index=cls.pg5.sw_if_index,
table_id=1)
- 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 b6f816e9cf2..dddd57f9b8f 100644
--- a/test/test_span.py
+++ b/test/test_span.py
@@ -233,7 +233,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 d586c849b02..4c4e4138479 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
@six.add_metaclass(abc.ABCMeta)
@@ -37,22 +38,25 @@ 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
@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
@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):
@@ -61,18 +65,30 @@ 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
+
+ @property
+ def local_ip6_prefix_len(self):
+ """Local IPv6 prefix length """
+ return self._local_ip6.len
+
+ @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):
@@ -81,18 +97,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):
@@ -102,9 +120,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):
@@ -193,7 +211,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)
@@ -202,39 +220,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()
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:
@@ -242,18 +248,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):
@@ -261,8 +262,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
@@ -280,8 +281,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):
@@ -289,9 +289,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
@@ -357,13 +356,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."""
@@ -450,15 +450,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 b7ceb3474d4..fbc00d394f5 100644
--- a/test/vpp_ip_route.py
+++ b/test/vpp_ip_route.py
@@ -161,15 +161,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 4ad9ffde4d7..88b9189032d 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:
@@ -87,8 +89,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(self.role, self.mode, self.rx_queues,
@@ -101,11 +103,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:
@@ -121,9 +125,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 15cd6edb8e0..90989291c1f 100644
--- a/test/vpp_sub_interface.py
+++ b/test/vpp_sub_interface.py
@@ -4,6 +4,7 @@ import six
from vpp_pg_interface import VppPGInterface
from vpp_papi_provider import L2_VTR_OP
from vpp_interface import VppInterface
+from vpp_papi import VppEnum
@six.add_metaclass(abc.ABCMeta)
@@ -171,10 +172,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