Add support for IP interface loopback action#2307
Conversation
|
/azpw run Azure.sonic-swss |
|
/AzurePipelines run Azure.sonic-swss |
|
Azure Pipelines successfully started running 1 pipeline(s). |
prsunny
left a comment
There was a problem hiding this comment.
IMO, the code can be simplified. Please let me know if you prefer an offline discussion.
orchagent/port.h
Outdated
| } | ||
|
|
||
| std::string m_alias; | ||
| loopback_action_e m_loopback_action; |
There was a problem hiding this comment.
IMO, this is not a config that we apply frequently. I don't see a reason why this needs to be cached. If user sets the action, we can just go ahead with setting the value. This is slightly overcomplicating.
There was a problem hiding this comment.
@prsunny I tried to follow your approach to remove from cache but I found out that we do need it in cache, I will explain why. The cache is used not only for skipping multiple user configuration but also for skipping set flow after create flow. There are 2 flows for setting loopback action, set and create. Set flow is done when we set loopback action on an existing IP interface (func setIntfLoopbackAction). Create flow is done when loopback action set is part of the IP interface creation, this happens in init (func setIntf). Both functions I mentioned are being called one after the other and the way to skip set flow after create flow took place, is using the cache. This is the approach taken for all IP interface attributes. I did however made the code less complicated by using string instead of enum for the action type ("drop" or "forward").
There was a problem hiding this comment.
I tend to disagree. Understand your point on create and set. But what is the concern if the same value is set again. For mtu and admin state, it is done currently for sub-port and those values are anyways part of port class. Loopback setting is rare and I read its mostly as setting proxy_arp etc, for which there is no cache. This is a single event and lets get this simplified.
orchagent/intfsorch.cpp
Outdated
| attr.value.oid = vrf_id; | ||
| attrs.push_back(attr); | ||
|
|
||
| if(port.m_loopback_action != LOOPBACK_ACTION_NONE) |
There was a problem hiding this comment.
space after if. Also suggest pass this as a param instead of retrieving from port
orchagent/intfsorch.cpp
Outdated
| if ((loopbackAction != LOOPBACK_ACTION_NONE) and (port.m_loopback_action != loopbackAction)) | ||
| { | ||
| port.m_loopback_action = loopbackAction; | ||
| if(setIntfLoopbackAction(port)) |
There was a problem hiding this comment.
space after if. Please pass the action param as a string to this function.
orchagent/intfsorch.cpp
Outdated
| return true; | ||
| } | ||
|
|
||
| bool IntfsOrch::setIntfLoopbackAction(const Port &port) |
There was a problem hiding this comment.
if you pass loopback action as a string to this function, no need for getIntfLoopbackActionStr
tests/test_interface.py
Outdated
|
|
||
| # set interface loopback action in config database | ||
| action_map = {"drop": "SAI_PACKET_ACTION_DROP", "forward": "SAI_PACKET_ACTION_FORWARD"} | ||
| action = random.choice(list(action_map.keys())) |
There was a problem hiding this comment.
we dont prefer to have randomness in test. Please have coverage for both actions.
|
This pull request introduces 1 alert when merging abe328d into bf4d890 - view on LGTM.com new alerts:
|
|
/azpw run Azure.sonic-swss |
|
/AzurePipelines run Azure.sonic-swss |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Test p4rt/test_p4rt_acl.py::TestP4RTAcl::test_AclRuleAddWithoutTableDefinitionFails ERROR failed, trying to rerun. |
|
/azpw run Azure.sonic-swss |
|
/AzurePipelines run Azure.sonic-swss |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Test p4rt/test_p4rt_acl.py::TestP4RTAcl::test_AclRuleAddWithoutTableDefinitionFails ERROR failed again, trying to rerun. |
|
/azpw run Azure.sonic-swss |
|
/AzurePipelines run Azure.sonic-swss |
|
Azure Pipelines successfully started running 1 pipeline(s). |
orchagent/intfsorch.cpp
Outdated
| }; | ||
|
|
||
| // Translation of loopback action from sonic to sai type | ||
| const unordered_map<string, sai_packet_action_t> IntfsOrch::m_sai_loopback_action_map = |
There was a problem hiding this comment.
You can have it a local map variable.. Also please follow the existing naming convention in the file. No need to have it as part of IntfsOrch class
orchagent/port.h
Outdated
| } | ||
|
|
||
| std::string m_alias; | ||
| loopback_action_e m_loopback_action; |
There was a problem hiding this comment.
I tend to disagree. Understand your point on create and set. But what is the concern if the same value is set again. For mtu and admin state, it is done currently for sub-port and those values are anyways part of port class. Loopback setting is rare and I read its mostly as setting proxy_arp etc, for which there is no cache. This is a single event and lets get this simplified.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
* Add IP interface loopback action support Co-authored-by: liora <liora@nvidia.com>
Update sonic-swss submodule pointer to include the following: * Port configuration incremental update support ([sonic-net#2305](sonic-net/sonic-swss#2305)) * [VS Test] Skip failing subport tests ([sonic-net#2370](sonic-net/sonic-swss#2370)) * [teammgr]: Waiting MACsec ready before doLagMemberTask ([sonic-net#2286](sonic-net/sonic-swss#2286)) * [vnetorch] [vxlanorch] fix a set of memory usage issues ([sonic-net#2352](sonic-net/sonic-swss#2352)) * [tests] [asan] add graceful stop flag ([sonic-net#2347](sonic-net/sonic-swss#2347)) * [asan] suppress the static variable leaks ([sonic-net#2354](sonic-net/sonic-swss#2354)) * Add support for IP interface loopback action ([sonic-net#2307](sonic-net/sonic-swss#2307)) * [orchagent]: srv6orch support for uSID ([sonic-net#2335](sonic-net/sonic-swss#2335)) Signed-off-by: dprital <drorp@nvidia.com>
Update sonic-swss submodule pointer to include the following: * Port configuration incremental update support ([#2305](sonic-net/sonic-swss#2305)) * [VS Test] Skip failing subport tests ([#2370](sonic-net/sonic-swss#2370)) * [teammgr]: Waiting MACsec ready before doLagMemberTask ([#2286](sonic-net/sonic-swss#2286)) * [vnetorch] [vxlanorch] fix a set of memory usage issues ([#2352](sonic-net/sonic-swss#2352)) * [tests] [asan] add graceful stop flag ([#2347](sonic-net/sonic-swss#2347)) * [asan] suppress the static variable leaks ([#2354](sonic-net/sonic-swss#2354)) * Add support for IP interface loopback action ([#2307](sonic-net/sonic-swss#2307)) * [orchagent]: srv6orch support for uSID ([#2335](sonic-net/sonic-swss#2335)) Signed-off-by: dprital <drorp@nvidia.com>
* Add IP interface loopback action support Co-authored-by: liora <liora@nvidia.com>
This reverts commit 5043701.
* Add IP interface loopback action support Co-authored-by: liora <liora@nvidia.com>
What I did
Add support for IP interface loopback action.
Why I did it
New feature in SONiC.
How I verified it
New VS tests were added.
Details if related