Skip to content

Commit 1e900bd

Browse files
authored
IOS LAG implementation for layer-2 images (#2525)
1 parent 5aae878 commit 1e900bd

File tree

7 files changed

+46
-3
lines changed

7 files changed

+46
-3
lines changed

docs/module/lag.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ LAG is currently supported on these platforms:
1010
| --------------------- |:--:|:--:|:--:|:---:|
1111
| Arista EOS [](caveats-eos) |||||
1212
| Aruba AOS-CX [](caveats-aruba) |||||
13+
| Cisco IOL L2[^iol2] |||||
14+
| Cisco IOSV L2[^iol2] |||||
1315
| Cumulus Linux 4.x |||||
1416
| Cumulus 5.x (NVUE) |||||
1517
| Dell OS10 |||||
@@ -18,6 +20,7 @@ LAG is currently supported on these platforms:
1820
| JunOS[^Junos] |||||
1921

2022
[^Junos]: Includes vSRX, vPTX and vJunos-switch. vJunos-router (and vMX) do not support LAG.
23+
[^iol2]: Port-Channel interfaces will be treated like physical interfaces. Setting LACP rate is not avilable.
2124

2225
## Parameters
2326

netsim/ansible/templates/initial/ios.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ interface {{ mgmt.ifname|default('GigabitEthernet0/0') }}
5151
interface {{ l.ifname }}
5252
{% if l.type == 'vlan_member' and l.vlan.access_id is defined %}
5353
encapsulation dot1Q {{ l.vlan.access_id }}
54-
{% elif (l.type == 'lag' or l.virtual_interface is not defined) and netlab_device_type in ['iosvl2','ioll2'] %}
54+
{% elif l.virtual_interface is not defined and netlab_device_type in ['iosvl2','ioll2'] %}
5555
no switchport
5656
{% endif %}
5757
{% if l.vrf is defined %}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{% for intf in interfaces if intf.type == 'lag' %}
2+
{% set _switchport = intf.vlan is defined %}
3+
interface {{ intf.ifname }}
4+
description {{ intf.name }}
5+
{% if _switchport %}
6+
switchport
7+
{% endif %}
8+
{% for ch in interfaces if ch.lag._parentindex|default(None) == intf.lag.ifindex %}
9+
{% set lag_mode =
10+
'on' if intf.lag.lacp|default('') == 'off' else
11+
'active' if intf.lag.lacp_mode|default('') == 'active' else
12+
'passive' %}
13+
interface {{ ch.ifname }}
14+
description {{ ch.name }} in channel-group {{ intf.lag.ifindex }}
15+
{% if _switchport %}
16+
switchport
17+
{% endif %}
18+
channel-group {{ intf.lag.ifindex }} mode {{ lag_mode }}
19+
{% endfor %}
20+
{% endfor %}

netsim/devices/ioll2.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from . import _Quirks
77

8-
from .iosvl2 import check_reserved_vlans,vlan_1_tagged
8+
from .iosvl2 import check_reserved_vlans,vlan_1_tagged,lag_remove_virtual
99
from .iol import IOSXE as _IOSXE
1010

1111
class IOSL2(_IOSXE):
@@ -17,3 +17,5 @@ def device_quirks(self, node: Box, topology: Box) -> None:
1717
if 'vlan' in mods:
1818
vlan_1_tagged(node,topology)
1919
check_reserved_vlans(node,topology)
20+
if 'lag' in mods:
21+
lag_remove_virtual(node,topology)

netsim/devices/ioll2.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
description: IOSv L2 image
33
parent: iol
4+
lag_interface_name: "Port-channel{lag.ifindex}"
45

56
features:
67
vlan:
@@ -13,6 +14,9 @@ features:
1314
supported_protocols: [ stp, rstp, mstp, pvrst ]
1415
enable_per_port: True
1516
port_type: True
17+
lag:
18+
mlag: False
19+
passive: True
1620
clab:
1721
group_vars:
1822
netlab_device_type: ioll2

netsim/devices/iosvl2.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,21 @@ def vlan_1_tagged(node: Box, topology: Box) -> None:
3535
quirk='vlan.tagged_1',
3636
category=Warning)
3737

38+
'''
39+
IOSv (classic) layer-2 image treats Port-Channel interfaces as physical interfaces
40+
'''
41+
def lag_remove_virtual(node: Box, topology: Box) -> None:
42+
for intf in node.interfaces:
43+
if intf.get('type') == 'lag' and 'virtual_interface' in intf:
44+
del intf['virtual_interface']
45+
3846
class IOSvL2(_IOS):
3947
@classmethod
4048
def device_quirks(self, node: Box, topology: Box) -> None:
4149
mods = node.get('module',[])
4250
if 'vlan' in mods:
4351
vlan_1_tagged(node,topology)
4452
check_reserved_vlans(node,topology)
45-
53+
if 'lag' in mods:
54+
lag_remove_virtual(node,topology)
4655
common_ios_quirks(node,topology)

netsim/devices/iosvl2.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
description: IOSv L2 image
33
interface_name: GigabitEthernet{ifindex // 4}/{ifindex % 4}
4+
lag_interface_name: "Port-channel{lag.ifindex}"
5+
46
parent: iosv
57
group_vars:
68
netlab_device_type: iosvl2
@@ -17,6 +19,9 @@ features:
1719
supported_protocols: [ stp, rstp, mstp, pvrst ]
1820
enable_per_port: True
1921
port_type: True
22+
lag:
23+
mlag: False
24+
passive: True
2025
libvirt:
2126
image: cisco/iosvl2
2227
build: https://netlab.tools/labs/iosvl2/

0 commit comments

Comments
 (0)