aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2018-08-10 05:30:06 -0700
committerDamjan Marion <dmarion@me.com>2019-01-30 19:47:53 +0000
commit37029305c671f4e2d091d6f6c22142634e409043 (patch)
treef47257c77b860213fcd1901686874dee43ad1f73 /test
parent13b2ba2ad5527c8185dce368993a3877e7daf7a2 (diff)
Use IP and MAC API types for neighbors
use address_t and mac_address_t for IPv6 and ARP entries and all other API calls in ip.api aprat from the route ones, that will follow in a separate commit Change-Id: I67161737c2184d3f8fc1e79ebd2b55121c5b0191 Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'test')
-rw-r--r--test/test_dhcp.py10
-rw-r--r--test/test_ip6.py59
-rw-r--r--test/test_l2bd_arp_term.py11
-rw-r--r--test/test_nat.py74
-rw-r--r--test/test_neighbor.py33
-rw-r--r--test/vpp_interface.py16
-rw-r--r--test/vpp_neighbor.py54
-rw-r--r--test/vpp_papi_provider.py58
8 files changed, 152 insertions, 163 deletions
diff --git a/test/test_dhcp.py b/test/test_dhcp.py
index 3d00f1b8468..833ee00a529 100644
--- a/test/test_dhcp.py
+++ b/test/test_dhcp.py
@@ -1052,8 +1052,7 @@ class TestDHCP(VppTestCase):
nd_entry = VppNeighbor(self,
self.pg1.sw_if_index,
self.pg1.remote_hosts[1].mac,
- self.pg1.remote_hosts[1].ip6,
- af=AF_INET6)
+ self.pg1.remote_hosts[1].ip6)
nd_entry.add_vpp_config()
#
@@ -1267,9 +1266,10 @@ class TestDHCP(VppTestCase):
# remove the left over ARP entry
self.vapi.ip_neighbor_add_del(self.pg3.sw_if_index,
- mac_pton(self.pg3.remote_mac),
+ self.pg3.remote_mac,
self.pg3.remote_ip4,
is_add=0)
+
#
# remove the DHCP config
#
@@ -1423,7 +1423,7 @@ class TestDHCP(VppTestCase):
# remove the left over ARP entry
self.vapi.ip_neighbor_add_del(self.pg3.sw_if_index,
- mac_pton(self.pg3.remote_mac),
+ self.pg3.remote_mac,
self.pg3.remote_ip4,
is_add=0)
@@ -1530,7 +1530,7 @@ class TestDHCP(VppTestCase):
# remove the left over ARP entry
self.vapi.ip_neighbor_add_del(self.pg3.sw_if_index,
- mac_pton(self.pg3.remote_mac),
+ self.pg3.remote_mac,
self.pg3.remote_ip4,
is_add=0)
diff --git a/test/test_ip6.py b/test/test_ip6.py
index 930d556a876..bfb5506e3fe 100644
--- a/test/test_ip6.py
+++ b/test/test_ip6.py
@@ -26,6 +26,7 @@ from vpp_ip_route import VppIpRoute, VppRoutePath, find_route, VppIpMRoute, \
from vpp_neighbor import find_nbr, VppNeighbor
from vpp_pg_interface import is_ipv6_misc
from vpp_sub_interface import VppSubInterface, VppDot1QSubint
+from ipaddress import IPv6Network, IPv4Network
AF_INET6 = socket.AF_INET6
@@ -445,7 +446,6 @@ class TestIPv6(TestIPv6ND):
self.pg0.sw_if_index,
self.pg0.remote_hosts[2].mac,
self.pg0.remote_hosts[2].ip6,
- af=AF_INET6,
is_no_fib_entry=1)
nd_entry.add_vpp_config()
@@ -454,8 +454,7 @@ class TestIPv6(TestIPv6ND):
#
self.assertTrue(find_nbr(self,
self.pg0.sw_if_index,
- self.pg0._remote_hosts[2].ip6,
- inet=AF_INET6))
+ self.pg0._remote_hosts[2].ip6))
self.assertFalse(find_route(self,
self.pg0._remote_hosts[2].ip6,
128,
@@ -483,8 +482,7 @@ class TestIPv6(TestIPv6ND):
#
self.assertTrue(find_nbr(self,
self.pg0.sw_if_index,
- self.pg0._remote_hosts[2].ip6_ll,
- inet=AF_INET6))
+ self.pg0._remote_hosts[2].ip6_ll))
self.assertFalse(find_route(self,
self.pg0._remote_hosts[2].ip6_ll,
128,
@@ -511,8 +509,7 @@ class TestIPv6(TestIPv6ND):
#
self.assertTrue(find_nbr(self,
self.pg0.sw_if_index,
- self.pg0._remote_hosts[3].ip6_ll,
- inet=AF_INET6))
+ self.pg0._remote_hosts[3].ip6_ll))
self.assertFalse(find_route(self,
self.pg0._remote_hosts[3].ip6_ll,
128,
@@ -532,14 +529,12 @@ class TestIPv6(TestIPv6ND):
ns_pg1 = VppNeighbor(self,
self.pg1.sw_if_index,
self.pg1.remote_hosts[1].mac,
- self.pg1.remote_hosts[1].ip6,
- af=AF_INET6)
+ self.pg1.remote_hosts[1].ip6)
ns_pg1.add_vpp_config()
ns_pg2 = VppNeighbor(self,
self.pg2.sw_if_index,
self.pg2.remote_mac,
- self.pg1.remote_hosts[1].ip6,
- af=AF_INET6)
+ self.pg1.remote_hosts[1].ip6)
ns_pg2.add_vpp_config()
#
@@ -755,7 +750,7 @@ class TestIPv6(TestIPv6ND):
#
# Configure The RA to announce the links prefix
#
- self.pg0.ip6_ra_prefix(self.pg0.local_ip6n,
+ self.pg0.ip6_ra_prefix(self.pg0.local_ip6,
self.pg0.local_ip6_prefix_len)
#
@@ -781,7 +776,7 @@ class TestIPv6(TestIPv6ND):
# Change the prefix info to not off-link
# L-flag is clear
#
- self.pg0.ip6_ra_prefix(self.pg0.local_ip6n,
+ self.pg0.ip6_ra_prefix(self.pg0.local_ip6,
self.pg0.local_ip6_prefix_len,
off_link=1)
@@ -801,7 +796,7 @@ class TestIPv6(TestIPv6ND):
# Change the prefix info to not off-link, no-autoconfig
# L and A flag are clear in the advert
#
- self.pg0.ip6_ra_prefix(self.pg0.local_ip6n,
+ self.pg0.ip6_ra_prefix(self.pg0.local_ip6,
self.pg0.local_ip6_prefix_len,
off_link=1,
no_autoconfig=1)
@@ -822,7 +817,7 @@ class TestIPv6(TestIPv6ND):
# Change the flag settings back to the defaults
# L and A flag are set in the advert
#
- self.pg0.ip6_ra_prefix(self.pg0.local_ip6n,
+ self.pg0.ip6_ra_prefix(self.pg0.local_ip6,
self.pg0.local_ip6_prefix_len)
opt = ICMPv6NDOptPrefixInfo(
@@ -841,7 +836,7 @@ class TestIPv6(TestIPv6ND):
# Change the prefix info to not off-link, no-autoconfig
# L and A flag are clear in the advert
#
- self.pg0.ip6_ra_prefix(self.pg0.local_ip6n,
+ self.pg0.ip6_ra_prefix(self.pg0.local_ip6,
self.pg0.local_ip6_prefix_len,
off_link=1,
no_autoconfig=1)
@@ -862,7 +857,7 @@ class TestIPv6(TestIPv6ND):
# Use the reset to defults option to revert to defaults
# L and A flag are clear in the advert
#
- self.pg0.ip6_ra_prefix(self.pg0.local_ip6n,
+ self.pg0.ip6_ra_prefix(self.pg0.local_ip6,
self.pg0.local_ip6_prefix_len,
use_default=1)
@@ -881,7 +876,7 @@ class TestIPv6(TestIPv6ND):
#
# Advertise Another prefix. With no L-flag/A-flag
#
- self.pg0.ip6_ra_prefix(self.pg1.local_ip6n,
+ self.pg0.ip6_ra_prefix(self.pg1.local_ip6,
self.pg1.local_ip6_prefix_len,
off_link=1,
no_autoconfig=1)
@@ -911,7 +906,7 @@ class TestIPv6(TestIPv6ND):
# Remove the first refix-info - expect the second is still in the
# advert
#
- self.pg0.ip6_ra_prefix(self.pg0.local_ip6n,
+ self.pg0.ip6_ra_prefix(self.pg0.local_ip6,
self.pg0.local_ip6_prefix_len,
is_no=1)
@@ -930,7 +925,7 @@ class TestIPv6(TestIPv6ND):
#
# Remove the second prefix-info - expect no prefix-info i nthe adverts
#
- self.pg0.ip6_ra_prefix(self.pg1.local_ip6n,
+ self.pg0.ip6_ra_prefix(self.pg1.local_ip6,
self.pg1.local_ip6_prefix_len,
is_no=1)
@@ -1064,11 +1059,13 @@ class TestIPv6RD(TestIPv6ND):
self.pg1.local_mac)
def verify_prefix_info(self, reported_prefix, prefix_option):
- prefix = socket.inet_pton(socket.AF_INET6,
- prefix_option.getfieldval("prefix"))
- self.assert_equal(reported_prefix.dst_address, prefix)
- self.assert_equal(reported_prefix.dst_address_length,
- prefix_option.getfieldval("prefixlen"))
+ prefix = IPv6Network(
+ unicode(prefix_option.getfieldval("prefix") +
+ "/" +
+ str(prefix_option.getfieldval("prefixlen"))),
+ strict=False)
+ self.assert_equal(reported_prefix.prefix.network_address,
+ prefix.network_address)
L = prefix_option.getfieldval("L")
A = prefix_option.getfieldval("A")
option_flags = (L << 7) | (A << 6)
@@ -1366,8 +1363,7 @@ class IPv6NDProxyTest(TestIPv6ND):
#
self.assertTrue(find_nbr(self,
self.pg1.sw_if_index,
- self.pg0._remote_hosts[2].ip6,
- inet=AF_INET6))
+ self.pg0._remote_hosts[2].ip6))
#
# ... and we can route traffic to it
@@ -1428,8 +1424,7 @@ class IPv6NDProxyTest(TestIPv6ND):
self.assertTrue(find_nbr(self,
self.pg2.sw_if_index,
- self.pg0._remote_hosts[3].ip6,
- inet=AF_INET6))
+ self.pg0._remote_hosts[3].ip6))
#
# hosts can communicate. pg2->pg1
@@ -1469,12 +1464,10 @@ class IPv6NDProxyTest(TestIPv6ND):
self.assertFalse(find_nbr(self,
self.pg2.sw_if_index,
- self.pg0._remote_hosts[3].ip6,
- inet=AF_INET6))
+ self.pg0._remote_hosts[3].ip6))
self.assertFalse(find_nbr(self,
self.pg1.sw_if_index,
- self.pg0._remote_hosts[2].ip6,
- inet=AF_INET6))
+ self.pg0._remote_hosts[2].ip6))
#
# no longer proxy-ing...
diff --git a/test/test_l2bd_arp_term.py b/test/test_l2bd_arp_term.py
index 2321aa7c094..6d01daacc2f 100644
--- a/test/test_l2bd_arp_term.py
+++ b/test/test_l2bd_arp_term.py
@@ -163,15 +163,13 @@ class TestL2bdArpTerm(VppTestCase):
return '%s.%s.%s.%s' % (o1, o2, o3, o4)
def arp_event_host(self, e):
- return Host(mac=':'.join(['%02x' % ord(char) for char in e.new_mac]),
- ip4=self.inttoip4(e.address))
+ return Host(str(e.mac), ip4=str(e.ip))
def arp_event_hosts(self, evs):
return {self.arp_event_host(e) for e in evs}
def nd_event_host(self, e):
- return Host(mac=':'.join(['%02x' % ord(char) for char in e.new_mac]),
- ip6=inet_ntop(AF_INET6, e.address))
+ return Host(str(e.mac), ip6=str(e.ip))
def nd_event_hosts(self, evs):
return {self.nd_event_host(e) for e in evs}
@@ -439,7 +437,7 @@ class TestL2bdArpTerm(VppTestCase):
def test_l2bd_arp_term_12(self):
""" L2BD ND term - send NS packets verify reports
"""
- self.vapi.want_ip6_nd_events(address=inet_pton(AF_INET6, "::0"))
+ self.vapi.want_ip6_nd_events(ip="::")
dst_host = self.ip6_host(50, 50, "00:00:11:22:33:44")
self.bd_add_del(1, is_add=1)
self.set_bd_flags(1, arp_term=True, flood=False,
@@ -475,8 +473,7 @@ class TestL2bdArpTerm(VppTestCase):
def test_l2bd_arp_term_14(self):
""" L2BD ND term - disable ip4 arp events,send ns, verify no events
"""
- self.vapi.want_ip6_nd_events(enable_disable=0,
- address=inet_pton(AF_INET6, "::0"))
+ self.vapi.want_ip6_nd_events(enable_disable=0, ip="::")
dst_host = self.ip6_host(50, 50, "00:00:11:22:33:44")
macs = self.mac_list(range(10, 15))
hosts = self.ip6_hosts(5, 1, macs)
diff --git a/test/test_nat.py b/test/test_nat.py
index f51a950678c..0d74cb60f87 100644
--- a/test/test_nat.py
+++ b/test/test_nat.py
@@ -23,6 +23,7 @@ from syslog_rfc5424_parser import SyslogMessage, ParseError
from syslog_rfc5424_parser.constants import SyslogFacility, SyslogSeverity
from vpp_papi_provider import SYSLOG_SEVERITY
from io import BytesIO
+from vpp_papi import VppEnum
class MethodHolder(VppTestCase):
@@ -48,12 +49,13 @@ class MethodHolder(VppTestCase):
is_add=0)
for intf in [self.pg7, self.pg8]:
- neighbors = self.vapi.ip_neighbor_dump(intf.sw_if_index)
- for n in neighbors:
- self.vapi.ip_neighbor_add_del(intf.sw_if_index,
- n.mac_address,
- n.ip_address,
- is_add=0)
+ self.vapi.ip_neighbor_add_del(
+ intf.sw_if_index,
+ intf.remote_mac,
+ intf.remote_ip4,
+ flags=(VppEnum.vl_api_ip_neighbor_flags_t.
+ IP_API_NEIGHBOR_FLAG_STATIC),
+ is_add=0)
if self.pg7.has_ip4_config:
self.pg7.unconfig_ip4()
@@ -2964,14 +2966,18 @@ class TestNAT44(MethodHolder):
def test_dynamic_ipless_interfaces(self):
""" NAT44 interfaces without configured IP address """
- self.vapi.ip_neighbor_add_del(self.pg7.sw_if_index,
- mac_pton(self.pg7.remote_mac),
- self.pg7.remote_ip4n,
- is_static=1)
- self.vapi.ip_neighbor_add_del(self.pg8.sw_if_index,
- mac_pton(self.pg8.remote_mac),
- self.pg8.remote_ip4n,
- is_static=1)
+ self.vapi.ip_neighbor_add_del(
+ self.pg7.sw_if_index,
+ self.pg7.remote_mac,
+ self.pg7.remote_ip4,
+ flags=(VppEnum.vl_api_ip_neighbor_flags_t.
+ IP_API_NEIGHBOR_FLAG_STATIC))
+ self.vapi.ip_neighbor_add_del(
+ self.pg8.sw_if_index,
+ self.pg8.remote_mac,
+ self.pg8.remote_ip4,
+ flags=(VppEnum.vl_api_ip_neighbor_flags_t.
+ IP_API_NEIGHBOR_FLAG_STATIC))
self.vapi.ip_add_del_route(dst_address=self.pg7.remote_ip4n,
dst_address_length=32,
@@ -3006,14 +3012,18 @@ class TestNAT44(MethodHolder):
def test_static_ipless_interfaces(self):
""" NAT44 interfaces without configured IP address - 1:1 NAT """
- self.vapi.ip_neighbor_add_del(self.pg7.sw_if_index,
- mac_pton(self.pg7.remote_mac),
- self.pg7.remote_ip4n,
- is_static=1)
- self.vapi.ip_neighbor_add_del(self.pg8.sw_if_index,
- mac_pton(self.pg8.remote_mac),
- self.pg8.remote_ip4n,
- is_static=1)
+ self.vapi.ip_neighbor_add_del(
+ self.pg7.sw_if_index,
+ self.pg7.remote_mac,
+ self.pg7.remote_ip4,
+ flags=(VppEnum.vl_api_ip_neighbor_flags_t.
+ IP_API_NEIGHBOR_FLAG_STATIC))
+ self.vapi.ip_neighbor_add_del(
+ self.pg8.sw_if_index,
+ self.pg8.remote_mac,
+ self.pg8.remote_ip4,
+ flags=(VppEnum.vl_api_ip_neighbor_flags_t.
+ IP_API_NEIGHBOR_FLAG_STATIC))
self.vapi.ip_add_del_route(dst_address=self.pg7.remote_ip4n,
dst_address_length=32,
@@ -3052,14 +3062,18 @@ class TestNAT44(MethodHolder):
self.udp_port_out = 30607
self.icmp_id_out = 30608
- self.vapi.ip_neighbor_add_del(self.pg7.sw_if_index,
- mac_pton(self.pg7.remote_mac),
- self.pg7.remote_ip4n,
- is_static=1)
- self.vapi.ip_neighbor_add_del(self.pg8.sw_if_index,
- mac_pton(self.pg8.remote_mac),
- self.pg8.remote_ip4n,
- is_static=1)
+ self.vapi.ip_neighbor_add_del(
+ self.pg7.sw_if_index,
+ self.pg7.remote_mac,
+ self.pg7.remote_ip4,
+ flags=(VppEnum.vl_api_ip_neighbor_flags_t.
+ IP_API_NEIGHBOR_FLAG_STATIC))
+ self.vapi.ip_neighbor_add_del(
+ self.pg8.sw_if_index,
+ self.pg8.remote_mac,
+ self.pg8.remote_ip4,
+ flags=(VppEnum.vl_api_ip_neighbor_flags_t.
+ IP_API_NEIGHBOR_FLAG_STATIC))
self.vapi.ip_add_del_route(dst_address=self.pg7.remote_ip4n,
dst_address_length=32,
diff --git a/test/test_neighbor.py b/test/test_neighbor.py
index 47f002cd91a..c378cff4e13 100644
--- a/test/test_neighbor.py
+++ b/test/test_neighbor.py
@@ -7,6 +7,7 @@ from framework import VppTestCase, VppTestRunner
from vpp_neighbor import VppNeighbor, find_nbr
from vpp_ip_route import VppIpRoute, VppRoutePath, find_route, \
VppIpTable, DpoProto
+from vpp_papi import VppEnum
from scapy.packet import Raw
from scapy.layers.l2 import Ether, ARP, Dot1Q
@@ -693,8 +694,8 @@ class ARPTestCase(VppTestCase):
#
# Configure Proxy ARP for the subnet on PG0addresses on pg0
#
- self.vapi.proxy_arp_add_del(self.pg0._local_ip4n_subnet,
- self.pg0._local_ip4n_bcast)
+ self.vapi.proxy_arp_add_del(self.pg0._local_ip4_subnet,
+ self.pg0._local_ip4_bcast)
# Make pg2 un-numbered to pg0
#
@@ -731,8 +732,8 @@ class ARPTestCase(VppTestCase):
# cleanup
#
self.pg2.set_proxy_arp(0)
- self.vapi.proxy_arp_add_del(self.pg0._local_ip4n_subnet,
- self.pg0._local_ip4n_bcast,
+ self.vapi.proxy_arp_add_del(self.pg0._local_ip4_subnet,
+ self.pg0._local_ip4_bcast,
is_add=0)
def test_proxy_arp(self):
@@ -971,11 +972,7 @@ class ARPTestCase(VppTestCase):
UDP(sport=1234, dport=1234) /
Raw())
- self.pg0.add_stream(p0)
- self.pg_enable_capture(self.pg_interfaces)
- self.pg_start()
-
- rx1 = self.pg1.get_capture(1)
+ rx1 = self.send_and_expect(self.pg0, [p0], self.pg1)
self.verify_arp_req(rx1[0],
self.pg1.local_mac,
@@ -992,20 +989,14 @@ class ARPTestCase(VppTestCase):
hwsrc="00:00:5e:00:01:09", pdst=self.pg1.local_ip4,
psrc=self.pg1.remote_ip4))
- self.pg1.add_stream(p1)
- self.pg_enable_capture(self.pg_interfaces)
- self.pg_start()
+ self.send_and_assert_no_replies(self.pg1, p1, "ARP reply")
#
# IP packet destined for pg1 remote host arrives on pg0 again.
# VPP should have an ARP entry for that address now and the packet
# should be sent out pg1.
#
- self.pg0.add_stream(p0)
- self.pg_enable_capture(self.pg_interfaces)
- self.pg_start()
-
- rx1 = self.pg1.get_capture(1)
+ rx1 = self.send_and_expect(self.pg0, [p0], self.pg1)
self.verify_ip(rx1[0],
self.pg1.local_mac,
@@ -1416,7 +1407,7 @@ class ARPTestCase(VppTestCase):
class NeighborStatsTestCase(VppTestCase):
- """ ARP Test Case """
+ """ ARP/ND Counters """
def setUp(self):
super(NeighborStatsTestCase, self).setUp()
@@ -1489,14 +1480,12 @@ class NeighborStatsTestCase(VppTestCase):
nd1 = VppNeighbor(self,
self.pg0.sw_if_index,
self.pg0.remote_hosts[1].mac,
- self.pg0.remote_hosts[1].ip6,
- af=AF_INET6)
+ self.pg0.remote_hosts[1].ip6)
nd1.add_vpp_config()
nd2 = VppNeighbor(self,
self.pg0.sw_if_index,
self.pg0.remote_hosts[2].mac,
- self.pg0.remote_hosts[2].ip6,
- af=AF_INET6)
+ self.pg0.remote_hosts[2].ip6)
nd2.add_vpp_config()
p1 = (Ether(dst=self.pg1.local_mac,
diff --git a/test/vpp_interface.py b/test/vpp_interface.py
index 719f77b36c7..58384d2eeb9 100644
--- a/test/vpp_interface.py
+++ b/test/vpp_interface.py
@@ -5,7 +5,7 @@ from abc import abstractmethod, ABCMeta
from six import moves
from util import Host, mk_ll_addr
-from vpp_papi import mac_pton, mac_ntop
+from vpp_papi import mac_ntop
class VppInterface(object):
@@ -273,10 +273,9 @@ class VppInterface(object):
:param vrf_id: The FIB table / VRF ID. (Default value = 0)
"""
for host in self._remote_hosts:
- macn = mac_pton(host.mac)
- ipn = host.ip4n
- self.test.vapi.ip_neighbor_add_del(
- self.sw_if_index, macn, ipn)
+ self.test.vapi.ip_neighbor_add_del(self.sw_if_index,
+ host.mac,
+ host.ip4)
def config_ip6(self):
"""Configure IPv6 address on the VPP interface."""
@@ -304,10 +303,9 @@ class VppInterface(object):
:param vrf_id: The FIB table / VRF ID. (Default value = 0)
"""
for host in self._remote_hosts:
- macn = mac_pton(host.mac)
- ipn = host.ip6n
- self.test.vapi.ip_neighbor_add_del(
- self.sw_if_index, macn, ipn, is_ipv6=1)
+ self.test.vapi.ip_neighbor_add_del(self.sw_if_index,
+ host.mac,
+ host.ip6)
def unconfig(self):
"""Unconfigure IPv6 and IPv4 address on the VPP interface."""
diff --git a/test/vpp_neighbor.py b/test/vpp_neighbor.py
index 7815a286fef..7391447ff9b 100644
--- a/test/vpp_neighbor.py
+++ b/test/vpp_neighbor.py
@@ -4,25 +4,22 @@
object abstractions for ARP and ND
"""
-from socket import inet_pton, inet_ntop, AF_INET, AF_INET6
+from ipaddress import ip_address
from vpp_object import *
-from vpp_papi import mac_pton
+from vpp_papi import mac_pton, VppEnum
-def find_nbr(test, sw_if_index, ip_addr, is_static=0, inet=AF_INET, mac=None):
+def find_nbr(test, sw_if_index, nbr_addr, is_static=0, mac=None):
+ ip_addr = ip_address(unicode(nbr_addr))
+ e = VppEnum.vl_api_ip_neighbor_flags_t
nbrs = test.vapi.ip_neighbor_dump(sw_if_index,
- is_ipv6=1 if AF_INET6 == inet else 0)
- if inet == AF_INET:
- s = 4
- else:
- s = 16
- nbr_addr = inet_pton(inet, ip_addr)
+ is_ipv6=(6 is ip_addr.version))
for n in nbrs:
- if nbr_addr == n.ip_address[:s] \
- and is_static == n.is_static:
+ if ip_addr == n.neighbor.ip_address and \
+ is_static == (n.neighbor.flags & e.IP_API_NEIGHBOR_FLAG_STATIC):
if mac:
- if n.mac_address == mac_pton(mac):
+ if mac == str(n.neighbor.mac_address):
return True
else:
return True
@@ -35,25 +32,26 @@ class VppNeighbor(VppObject):
"""
def __init__(self, test, sw_if_index, mac_addr, nbr_addr,
- af=AF_INET, is_static=False, is_no_fib_entry=0):
+ is_static=False, is_no_fib_entry=False):
self._test = test
self.sw_if_index = sw_if_index
- self.mac_addr = mac_pton(mac_addr)
- self.af = af
- self.is_static = is_static
- self.is_no_fib_entry = is_no_fib_entry
+ self.mac_addr = mac_addr
self.nbr_addr = nbr_addr
- self.nbr_addr_n = inet_pton(af, nbr_addr)
+
+ e = VppEnum.vl_api_ip_neighbor_flags_t
+ self.flags = e.IP_API_NEIGHBOR_FLAG_NONE
+ if is_static:
+ self.flags |= e.IP_API_NEIGHBOR_FLAG_STATIC
+ if is_no_fib_entry:
+ self.flags |= e.IP_API_NEIGHBOR_FLAG_NO_FIB_ENTRY
def add_vpp_config(self):
r = self._test.vapi.ip_neighbor_add_del(
self.sw_if_index,
self.mac_addr,
- self.nbr_addr_n,
+ self.nbr_addr,
is_add=1,
- is_ipv6=1 if AF_INET6 == self.af else 0,
- is_static=self.is_static,
- is_no_adj_fib=self.is_no_fib_entry)
+ flags=self.flags)
self.stats_index = r.stats_index
self._test.registry.register(self, self._test.logger)
@@ -61,17 +59,19 @@ class VppNeighbor(VppObject):
self._test.vapi.ip_neighbor_add_del(
self.sw_if_index,
self.mac_addr,
- self.nbr_addr_n,
- is_ipv6=1 if AF_INET6 == self.af else 0,
+ self.nbr_addr,
is_add=0,
- is_static=self.is_static)
+ flags=self.flags)
+
+ def is_static(self):
+ e = VppEnum.vl_api_ip_neighbor_flags_t
+ return (self.flags & e.IP_API_NEIGHBOR_FLAG_STATIC)
def query_vpp_config(self):
return find_nbr(self._test,
self.sw_if_index,
self.nbr_addr,
- self.is_static,
- self.af)
+ self.is_static())
def __str__(self):
return self.object_id()
diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py
index d35fae9f2df..efe1454c934 100644
--- a/test/vpp_papi_provider.py
+++ b/test/vpp_papi_provider.py
@@ -338,9 +338,9 @@ class VppPapiProvider(object):
'reverse': reverse,
'is_ipv6': is_ip6})
- def ip6_nd_proxy(self, address, sw_if_index, is_del=0):
+ def ip6_nd_proxy(self, ip, sw_if_index, is_del=0):
return self.api(self.papi.ip6nd_proxy_add_del,
- {'address': address,
+ {'ip': ip,
'sw_if_index': sw_if_index,
'is_del': is_del})
@@ -368,8 +368,10 @@ class VppPapiProvider(object):
pref_lifetime=0xffffffff):
return self.api(self.papi.sw_interface_ip6nd_ra_prefix,
{'sw_if_index': sw_if_index,
- 'address': address,
- 'address_length': address_length,
+ 'prefix': {
+ 'address': address,
+ 'address_length': address_length,
+ },
'use_default': use_default,
'no_advertise': no_advertise,
'off_link': off_link,
@@ -491,16 +493,16 @@ class VppPapiProvider(object):
return self.api(self.papi.bd_ip_mac_dump,
{'bd_id': bd_id})
- def want_ip4_arp_events(self, enable_disable=1, address=0):
+ def want_ip4_arp_events(self, enable_disable=1, ip="0.0.0.0"):
return self.api(self.papi.want_ip4_arp_events,
{'enable_disable': enable_disable,
- 'address': address,
+ 'ip': ip,
'pid': os.getpid(), })
- def want_ip6_nd_events(self, enable_disable=1, address=0):
+ def want_ip6_nd_events(self, enable_disable=1, ip="::"):
return self.api(self.papi.want_ip6_nd_events,
{'enable_disable': enable_disable,
- 'address': address,
+ 'ip': ip,
'pid': os.getpid(), })
def want_ip6_ra_events(self, enable_disable=1):
@@ -1006,32 +1008,28 @@ class VppPapiProvider(object):
def ip_neighbor_add_del(self,
sw_if_index,
mac_address,
- dst_address,
+ ip_address,
is_add=1,
- is_ipv6=0,
- is_static=0,
- is_no_adj_fib=0,
- ):
+ flags=0):
""" Add neighbor MAC to IPv4 or IPv6 address.
:param sw_if_index:
:param mac_address:
:param dst_address:
:param is_add: (Default value = 1)
- :param is_ipv6: (Default value = 0)
- :param is_static: (Default value = 0)
- :param is_no_adj_fib: (Default value = 0)
+ :param flags: (Default value = 0/NONE)
"""
return self.api(
self.papi.ip_neighbor_add_del,
- {'sw_if_index': sw_if_index,
- 'is_add': is_add,
- 'is_ipv6': is_ipv6,
- 'is_static': is_static,
- 'is_no_adj_fib': is_no_adj_fib,
- 'mac_address': mac_address,
- 'dst_address': dst_address
- }
+ {
+ 'is_add': is_add,
+ 'neighbor': {
+ 'sw_if_index': sw_if_index,
+ 'flags': flags,
+ 'mac_address': mac_address,
+ 'ip_address': ip_address
+ }
+ }
)
def ip_neighbor_dump(self,
@@ -1051,9 +1049,9 @@ class VppPapiProvider(object):
)
def proxy_arp_add_del(self,
- low_address,
- hi_address,
- vrf_id=0,
+ low,
+ hi,
+ table_id=0,
is_add=1):
""" Config Proxy Arp Range.
@@ -1066,9 +1064,9 @@ class VppPapiProvider(object):
self.papi.proxy_arp_add_del,
{'proxy':
{
- 'vrf_id': vrf_id,
- 'low_address': low_address,
- 'hi_address': hi_address,
+ 'table_id': table_id,
+ 'low': low,
+ 'hi': hi,
},
'is_add': is_add})