Преглед изворни кода

Distinguish between generated and manually set MTU within #SDN.

  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
  MTU is either correct, or maybe to small.

  If any former autogenerated MTU is greater-of-equal that the one we want to
  set now, we'll ignore it, and go for the greater one.

Signed-off-by: Maximilian Wilhelm <max@rfc2324.org>
Maximilian Wilhelm пре 7 година
родитељ
комит
b8b4843ba0
1 измењених фајлова са 27 додато и 7 уклоњено
  1. 27 7
      _modules/ffho_net.py

+ 27 - 7
_modules/ffho_net.py

@@ -311,8 +311,20 @@ def _set_mtu_to_iface_and_upper (ifaces, iface_name, mtu):
 	if 'mtu' in iface_config:
 		return
 
+	# 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
+	# MTU is either correct, or maybe to small.
+	#
+	# If any former autogenerated MTU is greater-of-equal that 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
+
 	# Set given MTU to this device.
-	iface_config['mtu'] = mtu
+	iface_config['automtu'] = mtu
 
 	# If this is a VLAN - which it probably is - fix the MTU of the underlying interface, too.
 	if 'vlan-raw-device' in iface_config:
@@ -326,8 +338,14 @@ def _set_mtu_to_iface_and_upper (ifaces, iface_name, mtu):
 			vlan_raw_device_config = {}
 			ifaces[vlan_raw_device] = vlan_raw_device_config
 
-		if not 'mtu' in vlan_raw_device_config:
-			vlan_raw_device_config['mtu'] = mtu
+		# If there is a manually set MTU for this device, we don't do nothin'
+		if 'mtu' in vlan_raw_device_config:
+			return
+
+		if 'automtu' in vlan_raw_device_config and vlan_raw_device_config['automtu'] >= mtu:
+			return
+
+		vlan_raw_device_config['automtu'] = mtu
 
 
 # Generate configuration entries for any batman related interfaces not
@@ -728,8 +746,8 @@ def get_interface_config (node_config, sites_config, node_id = ""):
 	# Enhance ifaces configuration with some meaningful defaults for
 	# bonding, bridge and vlan interfaces, MAC address for batman ifaces, etc.
 	for interface, config in ifaces.items ():
-		if type (config) not in [ dict, collections.OrderedDict ]:
-			raise Exception ("Configuration for interface %s on node %s seems broken!" % (interface, node_id))
+#		if type (config) not in [ dict, collections.OrderedDict ]:
+#			raise Exception ("Configuration for interface %s on node %s seems broken: Type %s" % (interface, node_id, type (config)))
 
 		iface_type = config.get ('type', 'inet')
 
@@ -764,9 +782,11 @@ def get_interface_config (node_config, sites_config, node_id = ""):
 	for interface, config in ifaces.items ():
 		# Set default MTU if not already set manually or by any earlier function
 		if interface != 'lo' and ('mtu' not in config):
-			config['mtu'] = MTU['default']
+			# Set the MTU value of this interface to the autogenerated value (if any)
+			# or set the default, when no automtu is present.
+			config['mtu'] = config.get ('automtu', MTU['default'])
 
-		for key in [ 'batman_connect_sites', 'ospf', 'site', 'type' ]:
+		for key in [ 'automtu', 'batman_connect_sites', 'ospf', 'site', 'type' ]:
 			if key in config:
 				config.pop (key)
 	# This leaves 'auto', 'prefixes' and 'desc' as keys which should not be directly