Browse Source

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
changes/06/747406/1
Slawek Kaplonski 12 months ago
parent
commit
a4e04a7f8b
  1. 3
      neutron/agent/linux/ip_lib.py
  2. 16
      neutron/tests/functional/agent/linux/test_interface.py

3
neutron/agent/linux/ip_lib.py

@ -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)

16
neutron/tests/functional/agent/linux/test_interface.py

@ -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):

Loading…
Cancel
Save