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

addons: vlan: error out when vlan-raw-device config change on existing vlan

kernel doesn't support vlan raw-device change on existing vlan, user needs to
manually ifdown/ifup the device

[13:45:06] root:~ # ifquery vlan42
auto vlan42
iface vlan42
      address 42.42.42.42/24
      vlan-id 42
      vlan-raw-device swp1

[13:45:07] root:~ # ifup -a
[13:45:09] root:~ # echo $?
0
[13:45:10] root:~ # ip link show vlan42
34: vlan42@swp1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default
    link/ether 90:e2:ba:2c:b1:96 brd ff:ff:ff:ff:ff:ff
[13:45:13] root:~ # nano /etc/network/interfaces
[13:45:19] root:~ # ifquery vlan42
auto vlan42
iface vlan42
      address 42.42.42.42/24
      vlan-id 42
      vlan-raw-device swp2

[13:45:25] root:~ # ifreload -a
error: vlan42: cannot change vlan-raw-device from swp1 to swp2: operation not supported. Please delete the device with 'ifdown vlan42' and recreate it to apply the change.
[13:45:27] root:~ # echo $?
1
[13:45:30] root:~ #

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
This commit is contained in:
Julien Fortin
2018-08-09 15:46:16 +02:00
parent 8329d2b8af
commit 7114342b25

View File

@@ -129,9 +129,21 @@ class vlan(moduleBase):
% (ifaceobj.name, vlan_protocol, ifaceobj.name))
if not ifupdownflags.flags.PERFMODE:
vlan_exists = self.ipcmd.link_exists(ifaceobj.name)
if vlan_exists:
user_vlan_raw_device = ifaceobj.get_attr_value_first('vlan-raw-device')
cached_vlan_raw_device = self.ipcmd.cache_get('link', [ifaceobj.name, 'link'])
if cached_vlan_raw_device != user_vlan_raw_device:
raise Exception('%s: cannot change vlan-raw-device from %s to %s: operation not supported. '
'Please delete the device with \'ifdown %s\' and recreate it to apply the change.'
% (ifaceobj.name, cached_vlan_raw_device, user_vlan_raw_device, ifaceobj.name))
if not self.ipcmd.link_exists(vlanrawdevice):
raise Exception('rawdevice %s not present' %vlanrawdevice)
if self.ipcmd.link_exists(ifaceobj.name):
if vlan_exists:
self._bridge_vid_add_del(ifaceobj, vlanrawdevice, vlanid)
return