Fix get_ipv6_llas method in the interface driver

This method is using ip_lib.get_devices_with_ip function to get
IP addresses with scope "link".
Unfortunatelly this method wasn't translating scope names to the pyrout2
values and due to that wasn't returning correct IP addresses.

Now this is fixed and correctl link local IPv6 addresses are returned.

Change-Id: Ia41c1bc627ad2ce89d658ff1fdedee802f6dfa15
Closes-Bug: #1892489
This commit is contained in:
Slawek Kaplonski 2020-08-21 15:06:01 +02:00
parent 8459b80a33
commit a4e04a7f8b
2 changed files with 19 additions and 0 deletions

View File

@ -1361,6 +1361,9 @@ def get_devices_with_ip(namespace, name=None, **kwargs):
link_args = {}
if name:
link_args['ifname'] = name
scope = kwargs.pop('scope', None)
if scope:
kwargs['scope'] = IP_ADDRESS_SCOPE_NAME[scope]
devices = privileged.get_link_devices(namespace, **link_args)
retval = []
for parsed_ips in (_parse_link_device(namespace, device, **kwargs)

View File

@ -69,6 +69,22 @@ class InterfaceDriverTestCaseMixin(object):
self.interface.set_mtu,
device_name=device_name, namespace=namespace))
def test_ipv6_lla_create_and_get(self):
lla_address = "fe80::f816:3eff:fe66:73bf/64"
global_address = "2001::1/64"
device_name = utils.get_rand_name()
namespace = self.useFixture(net_helpers.NamespaceFixture())
namespace.ip_wrapper.add_dummy(device_name)
self.interface.add_ipv6_addr(
device_name, lla_address, namespace.name, 'link')
self.interface.add_ipv6_addr(
device_name, global_address, namespace.name, 'global')
existing_addresses = [
a['cidr'] for a in self.interface.get_ipv6_llas(
device_name, namespace.name)]
self.assertIn(lla_address, existing_addresses)
self.assertNotIn(global_address, existing_addresses)
class OVSInterfaceDriverTestCase(linux_base.BaseOVSLinuxTestCase,
InterfaceDriverTestCaseMixin):