Skip to content

Commit 07ee8a2

Browse files
deran1980anand-kumar-subramanian
authored andcommitted
Prevent configuring IP interface on a port which is a member of VLAN (sonic-net#1374)
**- What I did** Fixed bug sonic-net/sonic-buildimage#6426 Added a validation in config/main.py to prevent configuring IP interface on a port which is a member of VLAN **- How I did it** Change config/main.py **- How to verify it** Add interface as member in vlan Try to configure IP address on same interface **- Previous command output (if the output of a command-line utility has changed)** Success in the above scenario. **- New command output (if the output of a command-line utility has changed)** prevent configuration: "Interface Ethernet0 is a member of vlan Aborting!"
1 parent 8d8b47e commit 07ee8a2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

config/main.py

+7
Original file line numberDiff line numberDiff line change
@@ -2733,6 +2733,13 @@ def add(ctx, interface_name, ip_addr, gw):
27332733
if interface_name is None:
27342734
ctx.fail("'interface_name' is None!")
27352735

2736+
# Add a validation to check this interface is not a member in vlan before
2737+
# changing it to a router port
2738+
vlan_member_table = config_db.get_table('VLAN_MEMBER')
2739+
if (interface_is_in_vlan(vlan_member_table, interface_name)):
2740+
click.echo("Interface {} is a member of vlan\nAborting!".format(interface_name))
2741+
return
2742+
27362743
try:
27372744
net = ipaddress.ip_network(ip_addr, strict=False)
27382745
if '/' not in ip_addr:

0 commit comments

Comments
 (0)