Skip to content

Avoid adding loopback interface (ip link add) when setting nat zone on loopback interface#1411

Merged
prsunny merged 2 commits intosonic-net:masterfrom
AkhileshSamineni:skip_loopback_add
Aug 20, 2020
Merged

Avoid adding loopback interface (ip link add) when setting nat zone on loopback interface#1411
prsunny merged 2 commits intosonic-net:masterfrom
AkhileshSamineni:skip_loopback_add

Conversation

@AkhileshSamineni
Copy link
Contributor

Issue (#1311) :

Add Loopback interface to NAT zone 1
sudo config nat add interface Loopback0 -nat_zone 1

Seeing below error logs when NAT zone for Loopback changed to 1.

Apr 21 11:44:33.805637 cab18-3-dut INFO swss#supervisord: intfmgrd RTNETLINK answers: File exists
Apr 21 11:44:33.805637 cab18-3-dut ERR swss#intfmgrd: :- exec: /sbin/ip link add Loopback0 mtu 65536 type dummy && /sbin/ip link set Loopback0 up: Success
Apr 21 11:44:33.805637 cab18-3-dut ERR swss#intfmgrd: :- addLoopbackIntf: Command '/sbin/ip link add Loopback0 mtu 65536 type dummy && /sbin/ip link set Loopback0 up' failed with rc 512

Root cause for logs:

Whenever the ip address is assigned to Loopback1 using below command, "ip link" gets added for Loopback1 like shown below
config interface ip add Loopback1 20.20.20.20/32

82: Loopback1: <BROADCAST,NOARP,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/ether 86:68:3c:f4:25:b7 brd ff:ff:ff:ff:ff:ff

Then when setting the nat zone for the Loopback1 interface to 1, it tries to add "ip link" for Loopback1 again and leads to syslog errors.

Note : These syslog errors for Loopback will seen for all fields like vrf_name, mac_addr, admin_status, proxy_arp, errors are not specific to nat_zone field. Fields are https://github.com/Azure/sonic-swss/blob/master/cfgmgr/intfmgr.cpp#L383

Fix:

Added a set container to hold the Loopback string whenever loopback interface is created and using it to avoid the "addLoopbackIntf" call for the fields setting like nat_zone.

Signed-off-by: Akhilesh Samineni [email protected]

if (is_lo)
{
addLoopbackIntf(alias);
if (m_loopbackIntfList.find(alias) == m_loopbackIntfList.end())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so nat_zone handling is done only if not is_lo. Where is it applying nat_zone on loopback interface?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not pushing the nat_zone value to APPL_DB when it got applied for loopback interface. nat_zone for loopback interface gets handled in natmgr code for setting iptables mangle tables rules (https://github.com/Azure/sonic-swss/blob/master/cfgmgr/natmgr.cpp#L901)

@prsunny prsunny merged commit db9a1d2 into sonic-net:master Aug 20, 2020
@kperumalbfn
Copy link
Contributor

@arlakshm These changes are needed in 201911 branch as well. We could double commit along with #1372.

@abdosi
Copy link
Contributor

abdosi commented Sep 3, 2020

@arlakshm Cherry-pick has conflict.

@AkhileshSamineni

Please create PR for 201911.

@kperumalbfn
Copy link
Contributor

@AkhileshSamineni could you double commit this change to 201911

@AkhileshSamineni
Copy link
Contributor Author

@arlakshm These changes are needed in 201911 branch as well. We could double commit along with #1372.

@arlakshm Cherry-pick has conflict.

@AkhileshSamineni

Please create PR for 201911.

@abdosi
Sure, will create new PR for 201911 branch.
BTW, could you merge this one - #1391

@AkhileshSamineni
Copy link
Contributor Author

@abdosi
Created a new PR on 201911 branch - #1434

EdenGri pushed a commit to EdenGri/sonic-swss that referenced this pull request Feb 28, 2022
… naming mode "alias" sonic-net#1397 (sonic-net#1411)

#### What I did
Added fix for Issue in CLI output alignment with shorter alias names in intf naming mode "alias"

#### How I did it
Added code to remove last few extra characters from string (-------…) using Slicing & Positive Indexing in python, to match the width to alias's name(not interface)
Janetxxx pushed a commit to Janetxxx/sonic-swss that referenced this pull request Nov 10, 2025
…n loopback interface (sonic-net#1411)

* Avoid adding loopback interface (ip link add) when nat zone is set on loopback interface

Signed-off-by: Akhilesh Samineni <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants