|
@@ -309,32 +309,52 @@ def _update_veth_config (interface, config):
|
|
|
# @param ifaces: All interface configuration (as dict)
|
|
|
# @param iface_name: Name of the interface to set MTU for
|
|
|
# @param mtu: The MTU value to set (integer)
|
|
|
+# When <mtu> is <= 0, the <mtu> configured for <iface_name>
|
|
|
+# will be used to set the MTU of the upper interface, and the
|
|
|
+# default MTU if none is configured explicitly.
|
|
|
def _set_mtu_to_iface_and_upper (ifaces, iface_name, mtu):
|
|
|
iface_config = ifaces.get (iface_name)
|
|
|
|
|
|
+ # By default we assume that we should set the given MTU value as the 'automtu'
|
|
|
+ # attribute to allow distinction between manually set and autogenerated MTU
|
|
|
+ # values.
|
|
|
+ set_automtu = True
|
|
|
+
|
|
|
+ # If a mtu values <= 0 is given, use the MTU configured for this interface
|
|
|
+ # or, if none is set, the default value when configuring the vlan-raw-device.
|
|
|
+ if mtu <= 0:
|
|
|
+ set_automtu = False
|
|
|
+ mtu = iface_config.get ('mtu', MTU['default'])
|
|
|
+
|
|
|
# If this interface already has a MTU set - probably because someone manually
|
|
|
- # specified one in the node pillar - we do not do anything here.
|
|
|
+ # specified one in the node pillar - we do not touch the MTU of this interface.
|
|
|
+ # Nevertheless it's worth looking at any underlying interface.
|
|
|
if 'mtu' in iface_config:
|
|
|
- return
|
|
|
+ set_automtu = False
|
|
|
|
|
|
- # Set generated MTU as 'automtu' value to allow distinction between manually
|
|
|
- # set and autogenerated MTU values.
|
|
|
# There might be - read: "we have" - a situation where on top of e.g. bond0
|
|
|
# there are vlans holding VXLAN communicaton as well a vlans directly carrying
|
|
|
- # BATMAN traffic. Now depending on which interface is evaluation first, the upper
|
|
|
+ # BATMAN traffic. Now depending on which interface is evaluated first, the upper
|
|
|
# MTU is either correct, or maybe to small.
|
|
|
#
|
|
|
- # If any former autogenerated MTU is greater-of-equal that the one we want to
|
|
|
+ # If any former autogenerated MTU is greater-or-equal than the one we want to
|
|
|
# set now, we'll ignore it, and go for the greater one.
|
|
|
- if 'automtu' in iface_config and iface_config['automtu'] >= mtu:
|
|
|
- return
|
|
|
+ elif 'automtu' in iface_config and iface_config['automtu'] >= mtu:
|
|
|
+ set_automtu = False
|
|
|
|
|
|
- # Set given MTU to this device.
|
|
|
- iface_config['automtu'] = mtu
|
|
|
+ # If we still consider this a good move, set given MTU to this device.
|
|
|
+ if set_automtu:
|
|
|
+ iface_config['automtu'] = mtu
|
|
|
|
|
|
# If this is a VLAN - which it probably is - fix the MTU of the underlying interface, too.
|
|
|
+ # Check for 'vlan-raw-device' in iface_config and in vlan subconfig (yeah, that's not ideal).
|
|
|
+ vlan_raw_device = None
|
|
|
if 'vlan-raw-device' in iface_config:
|
|
|
vlan_raw_device = iface_config['vlan-raw-device']
|
|
|
+ elif 'vlan' in iface_config and 'vlan-raw-device' in iface_config['vlan']:
|
|
|
+ vlan_raw_device = iface_config['vlan']['vlan-raw-device']
|
|
|
+
|
|
|
+ if vlan_raw_device:
|
|
|
vlan_raw_device_config = ifaces.get (vlan_raw_device, None)
|
|
|
|
|
|
# vlan-raw-device might point to ethX which usually isn't configured explicitly
|
|
@@ -775,6 +795,7 @@ def get_interface_config (node_config, sites_config, node_id = ""):
|
|
|
|
|
|
if 'vlan-raw-device' in config or 'vlan-id' in config:
|
|
|
_update_vlan_config (config)
|
|
|
+ _set_mtu_to_iface_and_upper (ifaces, interface, 0)
|
|
|
|
|
|
# Pimp configuration for VEth link pairs
|
|
|
if interface.startswith ('veth_'):
|