]> git.proxmox.com Git - mirror_ifupdown2.git/commitdiff
addons: addressvirtual: ifquery -r doesn't display link-local address
authorJulien Fortin <julien@cumulusnetworks.com>
Mon, 8 Oct 2018 13:18:32 +0000 (15:18 +0200)
committerJulien Fortin <julien@cumulusnetworks.com>
Thu, 13 Dec 2018 22:43:57 +0000 (14:43 -0800)
The issue here lies with how we query the cache to get the ips addresses
configured on the macvlan. A few months ago we added support for link scope
addresses in the cache, since the kernel may add it's own link addresse to
some interfaces we need to filter them out when querying the cache (because
we just want to get the list of IPs managed by ifupdown2). To perform this
filtering we need to look at the current user configuration (/e/n/i) but we
also need to look at past configuration. To perform this filtering we need
to provide the API LinkUtils:get_running_addrs a special parameter for
address-virtual (we need an ifaceobj).

$ ifquery -a
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto vlan1000
iface vlan1000
address 192.168.10.2/24
address fc00:10::2/64
address-virtual 00:00:5e:00:01:01 192.168.10.1/24 fc00:10::1/64 fe80::1/64
address-virtual-ipv6-addrgen off
vlan-id 1000
vlan-raw-device bridge
vrf blue

auto bridge
iface bridge
bridge-ports swp1

auto blue
iface blue
vrf-table auto

$ ifreload -a
$ echo $?
0
$ ifquery -a -c
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp                                                [pass]

auto vlan1000
iface vlan1000                                                      [pass]
vlan-raw-device bridge                                      [pass]
vlan-id 1000                                                [pass]
vrf blue                                                    [pass]
address 192.168.10.2/24                                     [pass]
address fc00:10::2/64                                       [pass]
address-virtual 00:00:5e:00:01:01 192.168.10.1/24 fc00:10::1/64 fe80::1/64     [pass]
address-virtual-ipv6-addrgen off                            [pass]

auto bridge
iface bridge                                                        [pass]
bridge-ports swp1                                           [pass]

auto blue
iface blue                                                          [pass]
vrf-table 1001                                              [pass]

$ ifquery -r vlan1000
auto vlan1000
iface vlan1000
vlan-id 1000
vlan-protocol 802.1Q
vlan-raw-device bridge
address 192.168.10.2/24
address fc00:10::2/64
address-virtual 00:00:5e:00:01:01 192.168.10.1/24 fe80::1/64 fc00:10::1/64
address-virtual-ipv6-addrgen off

$

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
ifupdown2/addons/addressvirtual.py

index 99c40085df67897f294976999e3833e3f4b132c1..0748023373dc7ece225f47b967d0f04ce533f96f 100644 (file)
@@ -577,13 +577,19 @@ class addressvirtual(moduleBase):
         for av in address_virtuals:
             macvlan_ifacename = os.path.basename(av)
             rhwaddress = self.ipcmd.link_get_hwaddress(macvlan_ifacename)
-            raddress = self.ipcmd.get_running_addrs(None, macvlan_ifacename)
+
+            raddress = []
+            for obj in ifaceobj_getfunc(ifaceobjrunning.name) or []:
+                raddress.extend(self.ipcmd.get_running_addrs(None, macvlan_ifacename, addr_virtual_ifaceobj=obj) or [])
+
+            raddress = list(set(raddress))
+
             if not raddress:
                 self.logger.warn('%s: no running addresses'
                                  %ifaceobjrunning.name)
                 raddress = []
             ifaceobjrunning.update_config('address-virtual',
-                            '%s %s' %(rhwaddress, ''.join(raddress)))
+                            '%s %s' %(rhwaddress, ' '.join(raddress)))
 
             macvlans_ipv6_addrgen_list.append((macvlan_ifacename, self.ipcmd.get_ipv6_addrgen_mode(macvlan_ifacename)))