]> git.proxmox.com Git - mirror_ifupdown2.git/commitdiff
addons: addressvirtual: adjusting macvlan mtu based on the lower device
authorJulien Fortin <julien@cumulusnetworks.com>
Thu, 15 Sep 2016 00:15:36 +0000 (17:15 -0700)
committerJulien Fortin <julien@cumulusnetworks.com>
Thu, 15 Sep 2016 00:15:36 +0000 (17:15 -0700)
Ticket: CM-11214
Reviewed By: Roopa
Testing Done:

Previously we were adjusting the macvlan mtu based on the wrong device.
We used to do, using the config example bellow:

get_mtu(ifaceobj.lowerifaces[0])
get_mtu("bridge")

instead of doing get_mtu(bridge.20)

$ cat /etc/network/interfaces
auto tap0
iface tap0
      #mtu 9000
      mtu 1500

auto bridge
iface bridge
      bridge-ports tap0

auto bridge.20
iface bridge.20
      address 10.7.192.194/27
      address-virtual 44:38:39:ff:00:20 10.7.192.193
$ ifreload -a
$ ip link show
bridge: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default
bridge.20@bridge: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default
bridge-20-v0@bridge.20: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default
$ #change mtu to 9000
$ ifreload -a
$ ip link show
bridge: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc noqueue state UP mode DEFAULT group default
bridge.20@bridge: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc noqueue state UP mode DEFAULT group default
bridge-20-v0@bridge.20: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc noqueue state UP mode DEFAULT group default
$

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

index dd5f33958e69ad41e0fe84dfeac0368b975ab4fb..dccfbf7fcc7e4c20a29561c200f198175f42d12a 100644 (file)
@@ -195,11 +195,16 @@ class addressvirtual(moduleBase):
                 self._fix_connected_route(ifaceobj, macvlan_ifacename,
                                           ips[0])
                 if update_mtu:
-                    lower_iface_mtu = self.ipcmd.link_get_mtu(ifaceobj.lowerifaces[0], refresh=True)
+                    lower_iface_mtu = self.ipcmd.link_get_mtu(ifaceobj.name, refresh=True)
                     update_mtu = False
 
                 if lower_iface_mtu and lower_iface_mtu != self.ipcmd.link_get_mtu(macvlan_ifacename):
-                    self.ipcmd.link_set_mtu(macvlan_ifacename, lower_iface_mtu)
+                    try:
+                        self.ipcmd.link_set_mtu(macvlan_ifacename,
+                                                lower_iface_mtu)
+                    except Exception as e:
+                        self.logger.info('%s: failed to set mtu %s: %s' %
+                                         (macvlan_ifacename, lower_iface_mtu, e))
 
             # handle vrf slaves
             if (ifaceobj.link_privflags & ifaceLinkPrivFlags.VRF_SLAVE):