-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add a port index mapper service for sFlow #4794
Conversation
This pull request introduces 1 alert when merging f1123c4 into edf3160 - view on LGTM.com new alerts:
|
from pyroute2 import IPDB | ||
from swsssdk import SonicV2Connector, port_util | ||
|
||
RTM_NEWLINK = 16 |
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.
Does pyroute2.netlink has these definitions?. I don't think we should define these values explicitly.
_hash = '{}|{}'.format(PORT_INDEX_TABLE_NAME, ifname) | ||
|
||
if msgtype == RTM_NEWLINK: | ||
state_db.set(state_db.STATE_DB, _hash, 'index', str(index)) |
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 think its better to put updating STATE DB to a separate function, as it is called from multiple places.
This pull request introduces 1 alert when merging 4033024 into 7c2f5a0 - view on LGTM.com new alerts:
|
retest vsimage please |
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.
Code lgtm. Can you add this new stateDb entry PORT_INDEX_TABLE_NAME
to swss-schema.md
retest vsimage please |
2 similar comments
retest vsimage please |
retest vsimage please |
- Why I did it
sFlow generates both counter samples and flow samples. While the counter samples contain the ifName, the flow samples have only the interface index - and the index is the Linux ifindex (and not the SONiC port index (as is typically seen in the PORT_TABLE). Any external application (sflow collector / end user) then has to map the index to port index (that's obtained from IF-MIB, say) which is not intuitive.
The SAI driver generates the samples using the Linux indexing scheme. While it is possible to address the issue from SAI driver/SDK perspective, we believe providing a mapping service and letting applications handle the mapping may be a more flexible alternative (which could benefit other applications in future).
- How I did it
Introduce a port_index_mapper script in sflow docker which will:
Note that this currently supports only interfaces supported by port_util.
- How to verify it
Verify that the index/ifindex mapping matches that of "ip link show".
- Description for the changelog
Add a port index mapper service for sFlow
- A picture of a cute animal (not mandatory but encouraged)