1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

addons: addressvirtual: ifquery -r doesn't display link-local address

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>
This commit is contained in:
Julien Fortin
2018-10-08 15:18:32 +02:00
parent d665f4f10e
commit c3175b312b

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