Skip to content

Commit 37eb2b3

Browse files
add lacp_rate to portchannel (sonic-net#2036)
#### What I did Make lacp_rate configurable for portchannel. ``` Option specifying the rate in which we'll ask our link partner to transmit LACPDU packets in 802.3ad mode. Possible values are: slow Request partner to transmit LACPDUs every 30 seconds fast Request partner to transmit LACPDUs every 1 second The default is slow. ``` #### Why I did it In case of slow lacp_rate configuration link down will be detected in 60-90 seconds, it may be to long (for example for MCLAG high availability), in case of using ` --fast-rate=true` link down will be detected in 2-3 seconds. #### How I did it * add optional argument to `config portchannel` command, default=slow for backward compatibility. (this PR) * parse argument in `teammgr` and forward it to `teamd` (other PR: sonic-net/sonic-swss#2121) * update docs sonic-net/SONiC#937 #### How to verify it Confgiure bond on other side, then configure portchannel and sniff the traffic from it. ``` config portchannel add PortChannel0001 --fast-rate=true config portchannel member add PortChannel0001 Ethernet0 config interface ip add PortChannel0001 192.168.1.2/24 tcpdump -ne ```
1 parent 28b6ba5 commit 37eb2b3

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

config/main.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -1967,8 +1967,11 @@ def portchannel(db, ctx, namespace):
19671967
@click.argument('portchannel_name', metavar='<portchannel_name>', required=True)
19681968
@click.option('--min-links', default=1, type=click.IntRange(1,1024))
19691969
@click.option('--fallback', default='false')
1970+
@click.option('--fast-rate', default='false',
1971+
type=click.Choice(['true', 'false'],
1972+
case_sensitive=False))
19701973
@click.pass_context
1971-
def add_portchannel(ctx, portchannel_name, min_links, fallback):
1974+
def add_portchannel(ctx, portchannel_name, min_links, fallback, fast_rate):
19721975
"""Add port channel"""
19731976
if is_portchannel_name_valid(portchannel_name) != True:
19741977
ctx.fail("{} is invalid!, name should have prefix '{}' and suffix '{}'"
@@ -1979,9 +1982,12 @@ def add_portchannel(ctx, portchannel_name, min_links, fallback):
19791982
if is_portchannel_present_in_db(db, portchannel_name):
19801983
ctx.fail("{} already exists!".format(portchannel_name))
19811984

1982-
fvs = {'admin_status': 'up',
1983-
'mtu': '9100',
1984-
'lacp_key': 'auto'}
1985+
fvs = {
1986+
'admin_status': 'up',
1987+
'mtu': '9100',
1988+
'lacp_key': 'auto',
1989+
'fast_rate': fast_rate.lower(),
1990+
}
19851991
if min_links != 0:
19861992
fvs['min_links'] = str(min_links)
19871993
if fallback != 'false':

doc/Command-Reference.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -6925,12 +6925,13 @@ When any port is already member of any other portchannel and if user tries to ad
69256925
Command takes two optional arguements given below.
69266926
1) min-links - minimum number of links required to bring up the portchannel
69276927
2) fallback - true/false. LACP fallback feature can be enabled / disabled. When it is set to true, only one member port will be selected as active per portchannel during fallback mode. Refer https://github.com/Azure/SONiC/blob/master/doc/lag/LACP%20Fallback%20Feature%20for%20SONiC_v0.5.md for more details about fallback feature.
6928+
3) fast-rate - true/false, default is false (slow). Option specifying the rate in which we'll ask our link partner to transmit LACPDU packets in 802.3ad mode. slow - request partner to transmit LACPDUs every 30 seconds, fast - request partner to transmit LACPDUs every 1 second. In slow mode 60-90 seconds needed to detect linkdown, in fast mode only 2-3 seconds.
69286929
69296930
A port channel can be deleted only if it does not have any members or the members are already deleted. When a user tries to delete a port channel and the port channel still has one or more members that exist, the deletion of port channel is blocked.
69306931
69316932
- Usage:
69326933
```
6933-
config portchannel (add | del) <portchannel_name> [--min-links <num_min_links>] [--fallback (true | false)]
6934+
config portchannel (add | del) <portchannel_name> [--min-links <num_min_links>] [--fallback (true | false) [--fast-rate (true | false)]
69346935
```
69356936
69366937
- Example (Create the portchannel with name "PortChannel0011"):
@@ -11020,4 +11021,4 @@ ZTP will be restarted. You may lose switch data and connectivity, continue? [y/N
1102011021
Running command: ztp run -y
1102111022
```
1102211023
11023-
Go Back To [Beginning of the document](#SONiC-COMMAND-LINE-INTERFACE-GUIDE) or [Beginning of this section](#ztp-configuration-and-show-commands)
11024+
Go Back To [Beginning of the document](#SONiC-COMMAND-LINE-INTERFACE-GUIDE) or [Beginning of this section](#ztp-configuration-and-show-commands)

tests/portchannel_test.py

+27-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import pytest
23
import traceback
34

45
from click.testing import CliRunner
@@ -60,7 +61,32 @@ def test_delete_non_existing_portchannel(self):
6061
print(result.output)
6162
assert result.exit_code != 0
6263
assert "Error: PortChannel0005 is not present." in result.output
63-
64+
65+
@pytest.mark.parametrize("fast_rate", ["False", "True", "false", "true"])
66+
def test_add_portchannel_with_fast_rate(self, fast_rate):
67+
runner = CliRunner()
68+
db = Db()
69+
obj = {'db':db.cfgdb}
70+
71+
# add a portchannel with fats rate
72+
result = runner.invoke(config.config.commands["portchannel"].commands["add"], ["PortChannel0005", "--fast-rate", fast_rate], obj=obj)
73+
print(result.exit_code)
74+
print(result.output)
75+
assert result.exit_code == 0
76+
77+
@pytest.mark.parametrize("fast_rate", ["Fls", "tru"])
78+
def test_add_portchannel_with_invalid_fast_rate(self, fast_rate):
79+
runner = CliRunner()
80+
db = Db()
81+
obj = {'db':db.cfgdb}
82+
83+
# add a portchannel with invalid fats rate
84+
result = runner.invoke(config.config.commands["portchannel"].commands["add"], ["PortChannel0005", "--fast-rate", fast_rate], obj=obj)
85+
print(result.exit_code)
86+
print(result.output)
87+
assert result.exit_code != 0
88+
assert 'Invalid value for "--fast-rate"' in result.output
89+
6490
def test_add_portchannel_member_with_invalid_name(self):
6591
runner = CliRunner()
6692
db = Db()

0 commit comments

Comments
 (0)