Skip to content

Commit

Permalink
Prevent configuring IP interface on a port which is a member of VLAN (s…
Browse files Browse the repository at this point in the history
…onic-net#1374)

**- What I did**
Fixed bug sonic-net#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!"
  • Loading branch information
deran1980 authored Jan 25, 2021
1 parent f1522b9 commit ff226d0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2645,6 +2645,13 @@ def add(ctx, interface_name, ip_addr, gw):
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
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

try:
net = ipaddress.ip_network(ip_addr, strict=False)
if '/' not in ip_addr:
Expand Down

0 comments on commit ff226d0

Please sign in to comment.