Skip to content

Commit 90611dd

Browse files
dgsudharsanjudyjoseph
authored andcommitted
[portconfig] Allow to configure interface mtu for physical ports only
- What I did Allow config interface command to allow mtu only for physical ports. This has been the behavior until sometime back where a change made broke this and allowed the MTU to be passed to orchagent through port table which results in crash. May 13 12:04:12.494964 r-tigon-20 INFO swss#buffermgrd: :- handlePortTable: Port PortChannel101: MTU updated from to 1514 May 13 12:04:12.495984 r-tigon-20 ERR swss#orchagent: :- set: switch id oid:0x0 doesn't exist May 13 12:04:12.495984 r-tigon-20 ERR swss#orchagent: :- setPortMtu: Failed to set MTU 1536 to port pid:0, rv:-5 May 13 12:04:12.495984 r-tigon-20 ERR swss#orchagent: :- handleSaiSetStatus: Encountered failure in set operation, exiting orchagent, SAI API: SAI_API_PORT, status: SAI_STATUS - How I did it Blocked MTU setting if the port is not physical port. - How to verify it Added UT to verify it
1 parent 0225195 commit 90611dd

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

scripts/portconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ class portconfig(object):
123123
self.db.mod_entry(PORT_TABLE_NAME, port, {PORT_FEC_CONFIG_FIELD_NAME: fec})
124124

125125
def set_mtu(self, port, mtu):
126+
port_tables = self.db.get_table(PORT_TABLE_NAME)
127+
if port not in port_tables:
128+
raise Exception("Invalid port %s" % (port))
126129
if self.verbose:
127130
print("Setting mtu %s on port %s" % (mtu, port))
128131
self.db.mod_entry(PORT_TABLE_NAME, port, {PORT_MTU_CONFIG_FIELD_NAME: mtu})

tests/config_an_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ def test_config_adv_types(self, ctx):
7575
assert 'duplicate' in result.output
7676
self.basic_check("advertised-types", ["Ethernet0", ""], ctx, operator.ne)
7777

78+
def test_config_mtu(self, ctx):
79+
self.basic_check("mtu", ["Ethernet0", "1514"], ctx)
80+
result = self.basic_check("mtu", ["PortChannel0001", "1514"], ctx, operator.ne)
81+
assert 'Invalid port PortChannel0001' in result.output
82+
7883
def basic_check(self, command_name, para_list, ctx, op=operator.eq, expect_result=0):
7984
runner = CliRunner()
8085
result = runner.invoke(config.config.commands["interface"].commands[command_name], para_list, obj = ctx)

0 commit comments

Comments
 (0)