X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Fvpp_interface.py;h=e8100d362ec772c34902d8367dc94f650aa0ce50;hb=refs%2Fchanges%2F11%2F20711%2F4;hp=7be0d45e39b124f328da677ea6ad98fd6ebbcf7c;hpb=2ac885c665309fc670cec96675ec1f510116fc13;p=vpp.git diff --git a/test/vpp_interface.py b/test/vpp_interface.py index 7be0d45e39b..e8100d362ec 100644 --- a/test/vpp_interface.py +++ b/test/vpp_interface.py @@ -7,6 +7,12 @@ from six import moves from util import Host, mk_ll_addr from vpp_papi import mac_ntop +from ipaddress import IPv4Network + +try: + text_type = unicode +except NameError: + text_type = str @six.add_metaclass(abc.ABCMeta) @@ -229,7 +235,7 @@ class VppInterface(object): self._remote_addr_n = {socket.AF_INET: self.remote_ip4n, socket.AF_INET6: self.remote_ip6n} - r = self.test.vapi.sw_interface_dump() + 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', @@ -343,14 +349,16 @@ class VppInterface(object): suppress=suppress, send_unicast=send_unicast) - # TODO: This should accept ipaddress object. - def ip6_ra_prefix(self, address, address_length, is_no=0, + def ip6_ra_prefix(self, prefix, is_no=0, off_link=0, no_autoconfig=0, use_default=0): - """Configure IPv6 RA suppress on the VPP interface.""" + """Configure IPv6 RA suppress on the VPP interface. + + prefix can be a string in the format of '
/' + or ipaddress.ipnetwork object (if strict.)""" + self.test.vapi.sw_interface_ip6nd_ra_prefix( sw_if_index=self.sw_if_index, - prefix={'address': address, - 'address_length': address_length}, + prefix=prefix, use_default=use_default, off_link=off_link, no_autoconfig=no_autoconfig, is_no=is_no) @@ -406,9 +414,10 @@ class VppInterface(object): def is_ip4_entry_in_fib_dump(self, dump): for i in dump: - if i.address == self.local_ip4n and \ - i.address_length == self.local_ip4_prefix_len and \ - i.table_id == self.ip4_table_id: + n = IPv4Network(text_type("%s/%d" % (self.local_ip4, + self.local_ip4_prefix_len))) + if i.route.prefix == n and \ + i.route.table_id == self.ip4_table_id: return True return False @@ -429,7 +438,7 @@ class VppInterface(object): enable) def query_vpp_config(self): - dump = self.test.vapi.sw_interface_dump() + dump = self.test.vapi.sw_interface_dump(sw_if_index=self.sw_if_index) return self.is_interface_config_in_dump(dump) def get_interface_config_from_dump(self, dump):