Skip to content

Commit 282b741

Browse files
authored
SR-OS: Set correct port mode for all VLAN combinations (#2326)
A combination of SVI VLAN and routed VLAN on the same interface requires "hybrid" port mode due to the way routed VLAN interfaces are configured on SR-OS (they are in "router Base", not in IES service). This commit moves the calculation of port mode into SR-OS device module, making it much easier to understand and debug than the attempts to reverse-engineer it in the Jinja2 template.
1 parent ac1ff90 commit 282b741

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

netsim/ansible/templates/initial/sros.j2

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,8 @@
152152
{% if l.mtu is defined and '_use_ip_mtu' not in l %}
153153
mtu: {{ l.mtu + eth_header }} # max 9800
154154
{% endif %}
155-
{% if l.vlan.trunk_id is defined or (l.parent_ifindex is defined and interfaces[l.parent_ifindex-1].vlan.trunk_id is defined) %}
156-
mode: hybrid # Support mixed trunks by using hybrid ports
157-
{% elif not in_base %}
158-
mode: access
159-
{% else %}
160-
mode: network
155+
{% if l._port_mode is defined %}
156+
mode: {{ l._port_mode }}
161157
{% endif %}
162158
{% if tagged %}
163159
{% set portname = portname + ':' + vlan|string %}

netsim/devices/sros.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,36 @@ def evpn_vrf_rp(node: Box) -> None:
3737
node=node,
3838
category=log.IncorrectValue)
3939

40+
def set_port_mode(intf: Box, mode: str) -> None:
41+
if '_port_mode' not in intf:
42+
intf._port_mode = mode
43+
elif intf._port_mode != mode:
44+
intf._port_mode = 'hybrid'
45+
46+
def set_port_modes(node: Box) -> None:
47+
for intf in node.interfaces:
48+
if intf.type in ['svi', 'loopback']:
49+
continue
50+
51+
t_intf = intf
52+
if intf.type == 'vlan_member':
53+
pif_list = [ p_if for p_if in node.interfaces if p_if.ifname == intf.parent_ifname ]
54+
if not pif_list:
55+
log.fatal(f'SROS: Cannot find parent interface {intf.parent_ifname} on node {node.name}')
56+
t_intf = pif_list[0]
57+
58+
if 'vrf' in intf:
59+
set_port_mode(t_intf,'access')
60+
elif 'ipv4' in intf or 'ipv6' in intf:
61+
set_port_mode(t_intf,'network')
62+
else:
63+
set_port_mode(t_intf,'access')
64+
4065
class SROS(_Quirks):
4166

4267
@classmethod
4368
def device_quirks(self, node: Box, topology: Box) -> None:
69+
set_port_modes(node)
4470
ipv4_unnumbered(node)
4571
vrf_route_leaking(node)
4672
evpn_vrf_rp(node)

0 commit comments

Comments
 (0)