mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
addons: address: add support for a separate default mtu policy for eth interfaces
New module global policy mgmt_intf_mtu for mgmt interace mtu: $ cat /var/lib/ifupdown2/policy.d/address.json { "address": { "module_globals": { "enable_l3_iface_forwarding_checks": "yes", "vlan_aware_bridge_address_support": "no", "l3_intf_arp_accept": "1", "mgmt_intf_mtu": "1500" }, "defaults": { "mtu": "9216", "ip-forward": "on", "ip6-forward": "on" } } } If not specified mgmt_intf_mtu becomes equal to the mtu from defaults section. Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
This commit is contained in:
@@ -189,7 +189,11 @@ class address(Addon, moduleBase):
|
||||
)
|
||||
|
||||
self.default_mtu = self.__policy_get_default_mtu()
|
||||
self.max_mtu = self.__policy_get_max_mtu()
|
||||
self.default_mgmt_intf_mtu = self.__policy_get_mgmt_intf_mtu()
|
||||
if not self.default_mgmt_intf_mtu:
|
||||
self.default_mgmt_intf_mtu = self.default_mtu
|
||||
self.default_mgmt_intf_mtu_int = self.default_mtu_int
|
||||
self.max_mtu = self.__policy_get_max_mtu()
|
||||
|
||||
self.default_loopback_addresses = (ipnetwork.IPNetwork('127.0.0.1/8'), ipnetwork.IPNetwork('::1/128'))
|
||||
|
||||
@@ -242,6 +246,26 @@ class address(Addon, moduleBase):
|
||||
self.logger.info("address: max_mtu undefined")
|
||||
return 0
|
||||
|
||||
def __policy_get_mgmt_intf_mtu(self):
|
||||
default_mgmt_mtu = policymanager.policymanager_api.get_module_globals(
|
||||
module_name=self.__class__.__name__,
|
||||
attr="mgmt_intf_mtu")
|
||||
self.default_mgmt_mtu_int = None
|
||||
|
||||
if not default_mgmt_mtu:
|
||||
return None
|
||||
|
||||
try:
|
||||
self.default_mgmt_mtu_int = int(default_mgmt_mtu)
|
||||
except ValueError as e:
|
||||
self.logger.error("address: invalid default mgmt mtu \"%s\" set via policy: %s" % (default_mgmt_mtu, str(e)))
|
||||
default_mgmt_mtu = self.DEFAULT_MTU_STRING
|
||||
self.default_mgmt_mtu_int = int(self.DEFAULT_MTU_STRING)
|
||||
|
||||
self.logger.info("address: using default mgmt interface mtu %s" % default_mgmt_mtu)
|
||||
|
||||
return default_mgmt_mtu
|
||||
|
||||
def syntax_check(self, ifaceobj, ifaceobj_getfunc=None):
|
||||
return (self.syntax_check_multiple_gateway(ifaceobj)
|
||||
and self.syntax_check_addr_allowed_on(ifaceobj, True)
|
||||
@@ -702,6 +726,10 @@ class address(Addon, moduleBase):
|
||||
return
|
||||
|
||||
def _process_mtu_config_mtu_none(self, ifaceobj):
|
||||
|
||||
if (ifaceobj.link_privflags & ifaceLinkPrivFlags.MGMT_INTF):
|
||||
return
|
||||
|
||||
cached_link_mtu = self.cache.get_link_mtu(ifaceobj.name)
|
||||
|
||||
if ifaceobj.link_kind:
|
||||
@@ -853,7 +881,11 @@ class address(Addon, moduleBase):
|
||||
mtu_from_policy = False
|
||||
|
||||
if not mtu_str:
|
||||
mtu_str = self.ifaces_defaults.get(ifaceobj.name, {}).get('mtu')
|
||||
if (ifaceobj.link_privflags & ifaceLinkPrivFlags.MGMT_INTF):
|
||||
mtu_str = self.default_mgmt_intf_mtu
|
||||
if not mtu_str:
|
||||
mtu_str = self.ifaces_defaults.get(ifaceobj.name, {}).get('mtu')
|
||||
|
||||
mtu_from_policy = True
|
||||
|
||||
if mtu_str:
|
||||
|
Reference in New Issue
Block a user