Skip to content

[mirrororch] Port Mirroring implementation#1314

Merged
lguohan merged 9 commits intosonic-net:masterfrom
rupesh-k:port_mirroring_initial
Jul 1, 2020
Merged

[mirrororch] Port Mirroring implementation#1314
lguohan merged 9 commits intosonic-net:masterfrom
rupesh-k:port_mirroring_initial

Conversation

@rupesh-k
Copy link
Contributor

@rupesh-k rupesh-k commented Jun 4, 2020

Signed-off-by: Rupesh Kumar rupesh-k.kumar@broadcom.com

What I did

Port mirroring implementation in swss.
HLD @ sonic-net/SONiC#580

Why I did it
To support port mirroring in SONiC

How I verified it
Verified using pytests and manual UT.

Details if related
pytests will updated in next commit.

rupesh-k added 2 commits June 4, 2020 12:24
Signed-off-by: Rupesh Kumar <rupesh-k.kumar@broadcom.com>
Modified to support LAG as source port.
vector<Port> portv;
m_portsOrch->getLagMember(port, portv);
for (const auto p : portv)
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Validate member port using 'gPortsOrch->getPort' before calling SAI set_port API

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. will take care.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And the port here is coming from internal LAG port . do u see extra validation is needed?
I just saw the other usage of this function in portsorch.cpp and don't see any validation.
So Please suggest. I can take care based on your response.

@prsunny prsunny requested a review from daall June 23, 2020 20:35
@rupesh-k
Copy link
Contributor Author

Hi @daall

Can u please help with the review. I hope we can make this feature for 202006 release :)

Thanks

@daall
Copy link
Contributor

daall commented Jun 25, 2020

Hi @daall

Can u please help with the review. I hope we can make this feature for 202006 release :)

Thanks

ack, will review this + utilities today :)

Copy link
Contributor

@daall daall left a comment

Choose a reason for hiding this comment

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

I think overall this looks pretty good, I just have a few clarifying questions about edge cases and some broad suggestions for the test code.

@rupesh-k
Copy link
Contributor Author

I think overall this looks pretty good, I just have a few clarifying questions about edge cases and some broad suggestions for the test code.

hi @daall ,

Thanks a lot for the review and good suggestions, I have taken care of the changes. Can you please help with review again.

Thanks

@rupesh-k rupesh-k requested a review from daall June 29, 2020 17:03
@lgtm-com
Copy link

lgtm-com bot commented Jun 29, 2020

This pull request introduces 3 alerts when merging b92c3d4 into c05601c - view on LGTM.com

new alerts:

  • 1 for First parameter of a method is not named 'self'
  • 1 for Unused local variable
  • 1 for Unused import

Copy link
Contributor

@daall daall left a comment

Choose a reason for hiding this comment

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

See comments, just a few minor things in the tests. :)

Port port;
if (!m_portsOrch->getPort(dstPort, port) && port.m_type != Port::PHY)
{
SWSS_LOG_ERROR("Failed to locate port %s", dstPort.c_str());
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the log message should also specify if type is not phy. Can you add that to log and print type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Added log

bool MirrorOrch::validateSrcPort(const string& srcPort)
{
auto ports = tokenize(srcPort, ',');

Copy link
Collaborator

Choose a reason for hiding this comment

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

Delete this line, to be consistent with above function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is source port list, so modified function name to reflect it.

status = sai_port_api->set_port_attribute(port.m_port_id, &port_attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to configure %s session on port %s, status %d, sessionId %x\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

You've used \n inconsistently. Some places have and some not. \n is not required, kindly remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. taken care of this. There were some existing code also wrongly doing .fixed those too.

@amin-alavi
Copy link

@prsunny, @kperumalbfn, @daall , Can this PR be merged and any further updates will be made in 202006 branch?

Same for sonic-net/sonic-utilities#936

Thanks!

@rupesh-k
Copy link
Contributor Author

Thanks @daall @prsunny for review. I have taken care of all comments. Please review.

@rupesh-k rupesh-k requested review from daall and prsunny June 30, 2020 17:23
Copy link
Contributor

@daall daall left a comment

Choose a reason for hiding this comment

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

LGTM, double-check with other reviewers to make sure their feedback is addressed.

@daall
Copy link
Contributor

daall commented Jun 30, 2020

retest this please

@lguohan lguohan merged commit 86b5e99 into sonic-net:master Jul 1, 2020
const auto& name = it->first;
auto& session = it->second;

// Check the following conditions:

Choose a reason for hiding this comment

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

if mirror session src port is port+lag, then lag member update to null, the mirror session status will set to inactive ?

Janetxxx pushed a commit to Janetxxx/sonic-swss that referenced this pull request Nov 10, 2025
Signed-off-by: Rupesh Kumar <rupesh-k.kumar@broadcom.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants