-
Notifications
You must be signed in to change notification settings - Fork 670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[config] Prevent deleting VLAN with IP addresses. #1429
[config] Prevent deleting VLAN with IP addresses. #1429
Conversation
Signed-off-by: d-dashkov <[email protected]>
@@ -46,6 +46,13 @@ def del_vlan(db, vid): | |||
if clicommon.check_if_vlanid_exist(db.cfgdb, vlan) == False: | |||
ctx.fail("{} does not exist".format(vlan)) | |||
|
|||
intf_table = db.cfgdb.get_table('VLAN_INTERFACE') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One concern is , by removing it in background, user may not be aware that ip address association is removed. Also in the current Sonic image, you can add an ip address to a vlan interface for which vlan is non-existent.
For e.g: config interface ip add Vlan200 2.3.4.6/24
<== This would be accepted, even if Vlan200 doesn't exist.
My suggestion would be to log warning to user that Vlan still have IP address and let user remove the ip. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made an update as per your suggestion to warn the user, but it requires some changes in the tests.
Also is this the correct behavior of adding IP to non-existent entries? There is an issue on same problem with my PR.(sonic-net/sonic-buildimage#6358).
Signed-off-by: d-dashkov <[email protected]>
Signed-off-by: d-dashkov <[email protected]>
Signed-off-by: d-dashkov <[email protected]>
Signed-off-by: d-dashkov <[email protected]>
Signed-off-by: d-dashkov <[email protected]>
Signed-off-by: d-dashkov <[email protected]>
Warn user while deleting VLAN if it has IP addresses. Signed-off-by: d-dashkov <[email protected]>
Warn user while deleting VLAN if it has IP addresses. Signed-off-by: d-dashkov <[email protected]>
What I did
Prevent deleting VLAN if it has IP addresses.
fixes: sonic-net/sonic-buildimage#6769
Currently, if an IP was added to the vlan, it creates entries in the VLAN_INTERFACE table and increments the reference counter for the vlan:
But after deleting the vlan, they get stuck in the table and throw an error:
Therefore, to prevent this error, make sure that the entries do not exist before deleting the VLAN.
How I did it
Added check of the VLAN INTERFACE table and if there are records, the delete operation is not available and an error is displayed.
How to verify it
Signed-off-by: d-dashkov [email protected]