Skip to content

Commit 4d173dd

Browse files
authored
Print a warning if a LAG link uses a Linux bridge (#2038)
Closes #2036
1 parent d1feda2 commit 4d173dd

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

docs/module/lag.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ links:
6666
ifindex: 50
6767
```
6868

69+
(lag-multi-provider)=
6970
### Caveat: Multi-provider Labs
7071

7172
_netlab_ implements links between containers and virtual machines with Linux bridges that block LACP packets. Package virtual machines into [vrnetlab](clab-vrnetlab) containers to connect them to pure containers.

netsim/modules/lag.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,37 @@ def populate_mlag_peer(node: Box, intf: Box, topology: Box) -> None:
355355

356356
intf.pop('vlan',None) # Remove any VLANs provisioned on peerlinks
357357

358+
"""
359+
Sanity check: virtual LAG links that would have to use a Linux bridge would not work
360+
361+
This function depends on the exact sequence of events during the transformation process:
362+
363+
* LAG module creates extra "virtual lag" links to generate the bond interfaces
364+
* Multi-provider code marks those links as multi-provider links and adds a "bridge" attribute
365+
* The sanity check is run before the virtual LAG links are removed
366+
"""
367+
def check_bridge_links(topology: Box) -> None:
368+
err_cache: dict = {}
369+
for link in topology.links:
370+
if '_virtual_lag' not in link: # Not a virtual LAG link
371+
continue
372+
373+
if 'bridge' not in link: # Not a multi-provider link, we're OK
374+
continue
375+
376+
nodes = sorted([ intf.node for intf in link.interfaces ])
377+
n_text = " and ".join(nodes) # Find the nodes attached to the link
378+
if n_text in err_cache: # Do not create more than one warning
379+
continue # ... for a pair of nodes
380+
381+
log.warning(
382+
text=f'The LAG link between {n_text} is using a Linux bridge. LACP will not work',
383+
more_hints = [ 'See https://netlab.tools/module/lag/#lag-multi-provider for more details' ],
384+
module='lag',
385+
flag='lag.bridge')
386+
387+
err_cache[n_text] = True # Remember we already warned the user
388+
358389
class LAG(_Module):
359390

360391
"""
@@ -402,6 +433,7 @@ def link_pre_link_transform(self, link: Box, topology: Box) -> None:
402433
def module_post_transform(self, topology: Box) -> None:
403434
if log.debug_active('lag'):
404435
print(f'LAG module_post_transform: Cleanup "virtual_lag" links')
436+
check_bridge_links(topology)
405437
topology.links = [ link for link in topology.links if '_virtual_lag' not in link ]
406438

407439
"""

0 commit comments

Comments
 (0)