-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move FRR bond logic to generic Linux template
- Loading branch information
Showing
4 changed files
with
55 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{% macro create_bond_dev(l) %} | ||
{% if l.type=='lag' %} | ||
{% set _m = l.lag.mode|default(lag.mode) %} | ||
{% if _m=="802.3ad" %} | ||
{% set _lacp = l.lag.lacp|default(lag.lacp) %} | ||
{% set lacp_act = 'off' if _lacp=='off' else 'on' %} | ||
{% set lacp_rate = (' lacp_rate ' + _lacp) if _lacp!='off' else '' %} | ||
{% set _m = _m + " xmit_hash_policy encap3+4" + lacp_rate %} | ||
{% if node_provider == 'clab' %} | ||
{% set _m = _m + " lacp_active " + lacp_act %} | ||
{% endif %} | ||
{% endif %} | ||
{% if node_provider != 'clab' %} | ||
# | ||
# Make sure 'bonding' module is loaded | ||
# | ||
if [[ ! -e /sys/module/bonding ]]; then | ||
modprobe bonding miimon=100 mode=802.3ad lacp_rate=fast | ||
fi | ||
{% endif %} | ||
if [[ ! -e /sys/class/net/{{l.ifname}} ]]; then | ||
ip link add dev {{l.ifname}} type bond mode {{_m}} | ||
fi | ||
{% endif %} | ||
{% endmacro -%} | ||
#!/bin/bash | ||
# | ||
set -e # Exit immediately when any command fails | ||
# | ||
# Create bonds for LAGs, if any. Requires kernel bonding module loaded | ||
# | ||
{% for l in interfaces if 'lag' in l %} | ||
{{ create_bond_dev(l) }} | ||
ip link set dev {{ l.ifname }} down | ||
{% endfor -%} | ||
|
||
{% for l in interfaces if 'lag' in l and l.type != 'lag' %} | ||
{% if l.type=='p2p' %} | ||
{% if node_provider != 'clab' %} | ||
ethtool -s {{ l.ifname }} autoneg off speed 1000 duplex full | ||
{% endif %} | ||
ip link set dev {{ l.ifname }} master {% | ||
for i in interfaces if i.type=='lag' and i.linkindex==l.lag._parentindex %}{{ i.ifname }} | ||
{% endfor %} | ||
{% endif %} | ||
ip link set dev {{ l.ifname }} up | ||
{% endfor %} | ||
{% for l in interfaces if 'lag' in l and l.type == 'lag' %} | ||
ip link set dev {{ l.ifname }} up | ||
{% endfor %} | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters