Skip to content

Commit

Permalink
Merge pull request #40 from wobcom/fix/enforce-mtu-on-core
Browse files Browse the repository at this point in the history
Added a warning for configuring a core interface without an MTU
  • Loading branch information
johannwagner authored Jan 13, 2025
2 parents 247805d + e3ffd33 commit 0a09029
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions cosmo/clients/netbox_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ def _fetch_data(self, kwargs):
}
parent {
id
mtu
}
custom_fields
}
Expand Down
15 changes: 15 additions & 0 deletions cosmo/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ def allow_private_ips(self):


class RouterSerializer:

MINIMAL_CORE_MTU = 9000

def __init__(self, cfg, device, l2vpn_list, vrfs, loopbacks):
try:
match device["platform"]["manufacturer"]["slug"]:
Expand Down Expand Up @@ -244,6 +247,18 @@ def _get_unit(self, iface, is_loopback=False):
families["inet6"]["ipv6_ra"] = True

if tags.has("core"):

parent_mtu = iface['parent']['mtu'] if iface.get('parent') else None
mtu = iface['mtu'] or parent_mtu
# Note: There is a legacy use-case with a 1500 MTU in the network, which is normally not used.
# We allow this configuration specifically.
is_sonderlocke_mtu = tags.has( "mtu", "sonderlocke")

if not mtu:
warnings.warn(f"Interface {iface['name']} on device {self.device['name']} has a core tag, but no MTU set.")
elif not is_sonderlocke_mtu and mtu < self.MINIMAL_CORE_MTU:
warnings.warn(f"Interface {iface['name']} on device {self.device['name']} has a low MTU for a core link.")

families["iso"] = {}
families["mpls"] = {}

Expand Down
2 changes: 1 addition & 1 deletion cosmo/tests/test_case_vrf_staticroute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ device_list:
lag: null
mac_address: null
mode: null
mtu: null
mtu: 9500
name: et-0/0/2.0
tagged_vlans: []
tags:
Expand Down

0 comments on commit 0a09029

Please sign in to comment.