@@ -288,7 +288,7 @@ def generate_sonic_config(device, hwsku, device_as_mapping=None, config_version=
288288 _add_portchannel_configuration (config , portchannel_info , evpn_system_mac )
289289
290290 # Add VRF configuration
291- _add_vrf_configuration (config , vrf_info , netbox_interfaces )
291+ _add_vrf_configuration (config , vrf_info , vlan_info , netbox_interfaces )
292292
293293 # Set DATABASE VERSION from config_version parameter or default
294294 if "VERSIONS" not in config :
@@ -1978,12 +1978,13 @@ def _get_vrf_info(device):
19781978 return vrf_info
19791979
19801980
1981- def _add_vrf_configuration (config , vrf_info , netbox_interfaces ):
1981+ def _add_vrf_configuration (config , vrf_info , vlan_info , netbox_interfaces ):
19821982 """Add VRF configuration to config.
19831983
19841984 Args:
19851985 config: Configuration dictionary to update
19861986 vrf_info: VRF information dictionary from _get_vrf_info()
1987+ vlan_info: VLAN information dictionary from get_device_vlans()
19871988 netbox_interfaces: Dict mapping SONiC names to NetBox interface info
19881989 """
19891990 # Track VRFs with VNI for VXLAN configuration
@@ -2070,8 +2071,11 @@ def _add_vrf_configuration(config, vrf_info, netbox_interfaces):
20702071 config ["BGP_GLOBALS" ][vrf_name ] = copy .deepcopy (default_bgp )
20712072 logger .info (f"Added BGP_GLOBALS for VRF { vrf_name } " )
20722073
2073- # Add VXLAN configuration if there are VRFs with VNI
2074- if vrfs_with_vni :
2074+ # Collect L2 VNI VLANs (tagged evpn-l2vni in NetBox, VNI == VID)
2075+ l2vni_vlans = vlan_info .get ("l2vni_vlans" , {})
2076+
2077+ # Add VXLAN configuration if there are VRFs with VNI or L2 VNI VLANs
2078+ if vrfs_with_vni or l2vni_vlans :
20752079 # Get source IP from BGP_GLOBALS default router_id
20762080 src_ip = config .get ("BGP_GLOBALS" , {}).get ("default" , {}).get ("router_id" , "" )
20772081
@@ -2090,7 +2094,7 @@ def _add_vrf_configuration(config, vrf_info, netbox_interfaces):
20902094 }
20912095 logger .info (f"Added VXLAN_EVPN_NVO nvo1 with source_vtep { VXLAN_VTEP_NAME } " )
20922096
2093- # Add VXLAN_TUNNEL_MAP for each VRF with VNI
2097+ # Add VXLAN_TUNNEL_MAP for each VRF with VNI (L3 / IRB)
20942098 for vrf_entry in vrfs_with_vni :
20952099 vni = vrf_entry ["vni" ]
20962100 vlan_name = f"Vlan{ vni } "
@@ -2101,6 +2105,22 @@ def _add_vrf_configuration(config, vrf_info, netbox_interfaces):
21012105 }
21022106 logger .info (f"Added VXLAN_TUNNEL_MAP { map_key } " )
21032107
2108+ # Add VXLAN_TUNNEL_MAP for each L2 VNI VLAN (pure L2, no VRF assignment)
2109+ vrf_vnis = {entry ["vni" ] for entry in vrfs_with_vni }
2110+ for vid , vni in l2vni_vlans .items ():
2111+ if vni in vrf_vnis :
2112+ logger .debug (
2113+ f"Skipping L2 VNI { vni } for Vlan{ vid } : already covered by VRF tunnel map"
2114+ )
2115+ continue
2116+ vlan_name = f"Vlan{ vid } "
2117+ map_key = f"{ VXLAN_VTEP_NAME } |map_{ vni } _{ vlan_name } "
2118+ config ["VXLAN_TUNNEL_MAP" ][map_key ] = {
2119+ "vlan" : vlan_name ,
2120+ "vni" : str (vni ),
2121+ }
2122+ logger .info (f"Added L2 VXLAN_TUNNEL_MAP { map_key } " )
2123+
21042124 # Add VRF assignments to interfaces
21052125 for sonic_interface , vrf_name in vrf_info ["interface_vrf_mapping" ].items ():
21062126 # Check if this is a regular interface
0 commit comments