Skip to content

Commit

Permalink
[portconfig] Allow to configure interface mtu for physical ports only
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
dgsudharsan authored and yxieca committed Aug 8, 2022
1 parent 9751479 commit e206e2d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions scripts/portconfig
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ class portconfig(object):
self.db.mod_entry(PORT_TABLE_NAME, port, {PORT_FEC_CONFIG_FIELD_NAME: fec})

def set_mtu(self, port, mtu):
port_tables = self.db.get_table(PORT_TABLE_NAME)
if port not in port_tables:
raise Exception("Invalid port %s" % (port))
if self.verbose:
print("Setting mtu %s on port %s" % (mtu, port))
self.db.mod_entry(PORT_TABLE_NAME, port, {PORT_MTU_CONFIG_FIELD_NAME: mtu})
Expand Down
5 changes: 5 additions & 0 deletions tests/config_an_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ def test_config_adv_types(self, ctx):
result = self.basic_check("advertised-types", ["Ethernet16", "Invalid"], ctx, operator.ne)
assert "Setting RJ45 ports' advertised types is not supported" in result.output

def test_config_mtu(self, ctx):
self.basic_check("mtu", ["Ethernet0", "1514"], ctx)
result = self.basic_check("mtu", ["PortChannel0001", "1514"], ctx, operator.ne)
assert 'Invalid port PortChannel0001' in result.output

def basic_check(self, command_name, para_list, ctx, op=operator.eq, expect_result=0):
runner = CliRunner()
result = runner.invoke(config.config.commands["interface"].commands[command_name], para_list, obj = ctx)
Expand Down

0 comments on commit e206e2d

Please sign in to comment.