Skip to content

Commit

Permalink
IP Assignment Issue (sonic-net#3408)
Browse files Browse the repository at this point in the history
#### What I did

Added Check for IP Assignment on Port when a Vlan is configured.
This PR is created in response to [Issue](sonic-net/sonic-buildimage#19505)

#### How I did it

Modified config/main.py to add check for IP Assignment when Port has vlan membership 
#### How to verify it

After this, ip cannot be assigned on port which is configured to a VLAN.
  • Loading branch information
ridahanif96 committed Jul 23, 2024
1 parent f196622 commit 772ee79
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4853,6 +4853,14 @@ def add_interface_ip(ctx, interface_name, ip_addr, gw, secondary):
interface_name = interface_alias_to_name(config_db, interface_name)
if interface_name is None:
ctx.fail("'interface_name' is None!")
# Add a validation to check this interface is not a member in vlan before
# changing it to a router port mode
vlan_member_table = config_db.get_table('VLAN_MEMBER')

if (interface_is_in_vlan(vlan_member_table, interface_name)):
click.echo("Interface {} is a member of vlan\nAborting!".format(interface_name))
return


portchannel_member_table = config_db.get_table('PORTCHANNEL_MEMBER')

Expand Down
2 changes: 1 addition & 1 deletion tests/vlan_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1426,7 +1426,7 @@ def test_config_set_router_port_on_member_interface(self):
["Ethernet4", "10.10.10.1/24"], obj=obj)
print(result.exit_code, result.output)
assert result.exit_code == 0
assert 'Interface Ethernet4 is in trunk mode and needs to be in routed mode!' in result.output
assert 'Interface Ethernet4 is a member of vlan\nAborting!\n' in result.output

def test_config_vlan_add_member_of_portchannel(self):
runner = CliRunner()
Expand Down

0 comments on commit 772ee79

Please sign in to comment.