From 0493bac6cb9dba9500d297516138bba8a540cc00 Mon Sep 17 00:00:00 2001 From: Julien Fortin Date: Wed, 14 Sep 2016 17:15:36 -0700 Subject: [PATCH] addons: addressvirtual: adjusting macvlan mtu based on the lower device 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: mtu 1500 qdisc noqueue state UP mode DEFAULT group default bridge.20@bridge: mtu 1500 qdisc noqueue state UP mode DEFAULT group default bridge-20-v0@bridge.20: mtu 1500 qdisc noqueue state UP mode DEFAULT group default $ #change mtu to 9000 $ ifreload -a $ ip link show bridge: mtu 9000 qdisc noqueue state UP mode DEFAULT group default bridge.20@bridge: mtu 9000 qdisc noqueue state UP mode DEFAULT group default bridge-20-v0@bridge.20: mtu 9000 qdisc noqueue state UP mode DEFAULT group default $ Signed-off-by: Julien Fortin --- addons/addressvirtual.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/addressvirtual.py b/addons/addressvirtual.py index dd5f339..dccfbf7 100644 --- a/addons/addressvirtual.py +++ b/addons/addressvirtual.py @@ -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):