Skip to content

Commit efeef21

Browse files
committed
Add EVPN LAG Support
AI-assisted: Claude Code Signed-off-by: Freerk-Ole Zakfeld <fzakfeld@scaleuptech.com>
1 parent a84614c commit efeef21

4 files changed

Lines changed: 26 additions & 4 deletions

File tree

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"git.ignoreLimitWarning": true
3+
}

osism/tasks/conductor/sonic/config_generator.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ def generate_sonic_config(device, hwsku, device_as_mapping=None, config_version=
274274
config["BREAKOUT_PORTS"].update(breakout_info["breakout_ports"])
275275

276276
# Add port channel configuration
277-
_add_portchannel_configuration(config, portchannel_info)
277+
evpn_system_mac = device.config_context.get("_evpn_system_mac")
278+
_add_portchannel_configuration(config, portchannel_info, evpn_system_mac)
278279

279280
# Add VRF configuration
280281
_add_vrf_configuration(config, vrf_info, netbox_interfaces)
@@ -2067,17 +2068,20 @@ def _add_vrf_configuration(config, vrf_info, netbox_interfaces):
20672068
)
20682069

20692070

2070-
def _add_portchannel_configuration(config, portchannel_info):
2071+
def _add_portchannel_configuration(config, portchannel_info, evpn_system_mac=None):
20712072
"""Add port channel configuration from NetBox."""
20722073
if portchannel_info["portchannels"]:
20732074
for pc_name, pc_data in portchannel_info["portchannels"].items():
20742075
# Add PORTCHANNEL configuration
2075-
config["PORTCHANNEL"][pc_name] = {
2076+
pc_config = {
20762077
"admin_status": pc_data["admin_status"],
20772078
"fast_rate": pc_data["fast_rate"],
20782079
"min_links": pc_data["min_links"],
20792080
"mtu": pc_data["mtu"],
20802081
}
2082+
if pc_data.get("evpn_lag") and evpn_system_mac:
2083+
pc_config["system_mac"] = evpn_system_mac
2084+
config["PORTCHANNEL"][pc_name] = pc_config
20812085

20822086
# Add PORTCHANNEL_INTERFACE configuration to enable IPv6 link-local
20832087
config["PORTCHANNEL_INTERFACE"][pc_name] = {

osism/tasks/conductor/sonic/constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# Tag to add AF L2VPN EVPN to BGP neighbor
66
BGP_AF_L2VPN_EVPN_TAG = "bgp-af-l2vpn-evpn"
77

8+
# Tag to enable EVPN Multihoming (evpn-lag mode) on a port channel
9+
EVPN_LAG_TAG = "evpn-lag"
10+
811
# Default AS prefix for local ASN calculation
912
DEFAULT_LOCAL_AS_PREFIX = 4200
1013

osism/tasks/conductor/sonic/interface.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import re
88
from loguru import logger
99

10-
from .constants import PORT_TYPE_TO_SPEED_MAP, HIGH_SPEED_PORTS, PORT_CONFIG_PATH
10+
from .constants import PORT_TYPE_TO_SPEED_MAP, HIGH_SPEED_PORTS, PORT_CONFIG_PATH, EVPN_LAG_TAG
1111
from .cache import get_cached_device_interfaces
1212

1313
# Global cache for port configurations to avoid repeated file reads
@@ -1044,12 +1044,24 @@ def detect_port_channels(device):
10441044

10451045
# Initialize port channel if not exists
10461046
if portchannel_name not in portchannels:
1047+
# Find the full LAG interface object to check tags
1048+
lag_interface = next(
1049+
(iface for iface in lag_interfaces if iface.id == lag_parent.id),
1050+
None,
1051+
)
1052+
evpn_lag = False
1053+
if lag_interface and hasattr(lag_interface, "tags") and lag_interface.tags:
1054+
evpn_lag = any(
1055+
tag.slug == EVPN_LAG_TAG for tag in lag_interface.tags
1056+
)
1057+
10471058
portchannels[portchannel_name] = {
10481059
"members": [],
10491060
"admin_status": "up",
10501061
"fast_rate": "true",
10511062
"min_links": "1",
10521063
"mtu": "9100",
1064+
"evpn_lag": evpn_lag,
10531065
}
10541066

10551067
# Add member to port channel

0 commit comments

Comments
 (0)