Skip to content

Commit e206e2d

Browse files
dgsudharsanyxieca
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 9751479 commit e206e2d

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

scripts/portconfig

+3
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ class portconfig(object):
127127
self.db.mod_entry(PORT_TABLE_NAME, port, {PORT_FEC_CONFIG_FIELD_NAME: fec})
128128

129129
def set_mtu(self, port, mtu):
130+
port_tables = self.db.get_table(PORT_TABLE_NAME)
131+
if port not in port_tables:
132+
raise Exception("Invalid port %s" % (port))
130133
if self.verbose:
131134
print("Setting mtu %s on port %s" % (mtu, port))
132135
self.db.mod_entry(PORT_TABLE_NAME, port, {PORT_MTU_CONFIG_FIELD_NAME: mtu})

tests/config_an_test.py

+5
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ def test_config_adv_types(self, ctx):
7979
result = self.basic_check("advertised-types", ["Ethernet16", "Invalid"], ctx, operator.ne)
8080
assert "Setting RJ45 ports' advertised types is not supported" in result.output
8181

82+
def test_config_mtu(self, ctx):
83+
self.basic_check("mtu", ["Ethernet0", "1514"], ctx)
84+
result = self.basic_check("mtu", ["PortChannel0001", "1514"], ctx, operator.ne)
85+
assert 'Invalid port PortChannel0001' in result.output
86+
8287
def basic_check(self, command_name, para_list, ctx, op=operator.eq, expect_result=0):
8388
runner = CliRunner()
8489
result = runner.invoke(config.config.commands["interface"].commands[command_name], para_list, obj = ctx)

0 commit comments

Comments
 (0)