Skip to content
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

Fix sFlow sampling-rate and admin-state #1728

Merged
merged 9 commits into from
Apr 30, 2021

Conversation

venkatmahalingam
Copy link
Contributor

@venkatmahalingam venkatmahalingam commented Apr 27, 2021

Fixed incorrect interface admin-status when 'all' interface is disabled but there are local sampling-rate configurations.
The original changes are present in the PR

Signed-off-by: Venkatesan Mahalingam venkatesan_mahalinga@dell.com

What I did
Fixed a bug where the interface sFlow admin-status is not correct if the user configures a custom sFlow sampling-rate. (UT performed here)

As a side-effect of this fix, users can now restore the default sFlow sampling-rate with the default option using: config sflow interface sampling-rate Ethernet4 default
This is not tested here but will be tested when the config script update PR is submitted to sonic-utilities. The sFlow corresponding HLD and command-line reference will also be updated.

Why I did it
If the user ONLY configures a custom (local) sFlow sampling-rate for a interface, the interface's admin-status should still adhere to the global interface admin-status.

How I verified it

  1. UT cases (added the sonic-vs test case)
  2. Manual testing - see below

root@L6:/home/admin# show sflow

sFlow Global Information:
  sFlow Admin State:          up
  sFlow Polling Interval:     default
  sFlow AgentID:              default

  0 Collectors configured:
root@L6:/home/admin# show sflow interface

sFlow interface configurations
+-------------+---------------+-----------------+
| Interface   | Admin State   |   Sampling Rate |
+=============+===============+=================+
| Ethernet0   | up            |             256 |
+-------------+---------------+-----------------+
| Ethernet4   | up            |             512 |
+-------------+---------------+-----------------+
| Ethernet8   | up            |          100000 |
+-------------+---------------+-----------------+
| Ethernet12  | up            |          100000 |
+-------------+---------------+-----------------+
| Ethernet16  | up            |          100000 |
+-------------+---------------+-----------------+
| Ethernet20  | up            |          100000 |
+-------------+---------------+-----------------+
| Ethernet24  | up            |          100000 |
+-------------+---------------+-----------------+
............
...........
root@L6:/home/admin# config sflow interface disable all
root@L6:/home/admin# show sflow interface

sFlow interface configurations
+-------------+---------------+-----------------+
| Interface   | Admin State   | Sampling Rate   |
+=============+===============+=================+
+-------------+---------------+-----------------+
root@L6:/home/admin#
root@L6:/home/admin#
root@L6:/home/admin# config sflow interface enable all
root@L6:/home/admin# show sflow interface

sFlow interface configurations
+-------------+---------------+-----------------+
| Interface   | Admin State   |   Sampling Rate |
+=============+===============+=================+
| Ethernet0   | up            |             256 |
+-------------+---------------+-----------------+
| Ethernet4   | up            |             512 |
+-------------+---------------+-----------------+
| Ethernet8   | up            |          100000 |
+-------------+---------------+-----------------+
| Ethernet12  | up            |          100000 |
+-------------+---------------+-----------------+
| Ethernet16  | up            |          100000 |
+-------------+---------------+-----------------+
| Ethernet20  | up            |          100000 |

.............
............
root@L6:/home/admin# config sflow interface sample-rate Ethernet0 default
root@L6:/home/admin# show sflow interface

sFlow interface configurations
+-------------+---------------+-----------------+
| Interface   | Admin State   |   Sampling Rate |
+=============+===============+=================+
| Ethernet0   | up            |          100000 |
+-------------+---------------+-----------------+
| Ethernet4   | up            |             512 |
+-------------+---------------+-----------------+
| Ethernet8   | up            |          100000 |
+-------------+---------------+-----------------+
| Ethernet12  | up            |          100000 |
+-------------+---------------+-----------------+
| Ethernet16  | up            |          100000 |
+-------------+---------------+-----------------+
| Ethernet20  | up            |          100000 |
+-------------+---------------+-----------------+
| Ethernet24  | up            |          100000 |
+-------------+---------------+-----------------+
| Ethernet28  | up            |          100000 |
+-------------+---------------+-----------------+
| Ethernet32  | up            |          100000 |
+-------------+---------------+-----------------+

...................


…ed but there are local sampling-rate configurations.

Signed-off-by: Venkatesan Mahalingam <venkatesan_mahalinga@dell.com>
Signed-off-by: Venkatesan Mahalingam <venkatesan_mahalinga@dell.com>
@venkatmahalingam
Copy link
Contributor Author

@prsunny @dgsudharsan Please review this PR.

@liat-grozovik liat-grozovik changed the title swss: Fix sFlow sampling-rate and admin-state Fix sFlow sampling-rate and admin-state Apr 27, 2021
@liat-grozovik
Copy link
Collaborator

@venkatmahalingam can you please verify if this can be taken to 202012?
The idea is to have sflow fully qualified as part of 202012 so if this is a bug fix we should consider it to be included.
But this can be done only if you can confirm it is cleanly cherry picked and working as expected. 10x

@venkatmahalingam
Copy link
Contributor Author

venkatmahalingam commented Apr 27, 2021

@venkatmahalingam can you please verify if this can be taken to 202012?
The idea is to have sflow fully qualified as part of 202012 so if this is a bug fix we should consider it to be included.
But this can be done only if you can confirm it is cleanly cherry picked and working as expected. 10x

@liat-grozovik Cherry-pick to 202012 works fine if we do it in the PR merge order i.e first Vivek's commit and then this PR commit.

build:~/202012/sonic-swss$ git cherry-pick d9f28b6
[202012 f6d4dfc] [SflowMgr] SamplingRate Update by Speed Change Added (#1721)
 Author: Vivek Reddy <vivekreddykarri98@gmail.com>
 Date: Sun Apr 25 00:43:15 2021 -0400
 2 files changed, 57 insertions(+), 4 deletions(-)
build:~/202012/sonic-swss$
build:~/202012/sonic-swss$
build:~/202012/sonic-swss$ git cherry-pick 77f6c59
[202012 ecce87d] Fixed incorrect interface admin-status when 'all' interface is disabled but there are local sampling-rate configurations.
 Date: Mon Apr 26 23:57:29 2021 +0000
 3 files changed, 67 insertions(+), 11 deletions(-)
build:~/202012/sonic-swss$ git cherry-pick bd9ce69
[202012 878f194] UT done
 Date: Tue Apr 27 05:50:57 2021 +0000
 1 file changed, 14 insertions(+), 12 deletions(-)
build:~/202012/sonic-swss$ git cherry-pick 2efe415
[202012 f3c49ea] Added new testcase.
 Date: Tue Apr 27 17:38:48 2021 +0000
 1 file changed, 36 insertions(+), 1 deletion(-)
build:~/202012/sonic-swss$

Signed-off-by: Venkatesan Mahalingam <venkatesan_mahalinga@dell.com>
@lgtm-com
Copy link

lgtm-com bot commented Apr 27, 2021

This pull request introduces 1 alert when merging 2efe415 into b962a60 - view on LGTM.com

new alerts:

  • 1 for Unused local variable

@prsunny
Copy link
Collaborator

prsunny commented Apr 27, 2021

@dgsudharsan, please review

@prsunny
Copy link
Collaborator

prsunny commented Apr 27, 2021

The PR is failing on VS test

AssertionError: Did not expect field/values to match, but they did: provided={'sample_rate': '256', 'admin_state': 'up'}, received={'sample_rate': '256', 'admin_state': 'up'}, key="Ethernet0", table="SFLOW_SESSION_TABLE"

Signed-off-by: Venkatesan Mahalingam <venkatesan_mahalinga@dell.com>
@venkatmahalingam
Copy link
Contributor Author

The PR is failing on VS test

AssertionError: Did not expect field/values to match, but they did: provided={'sample_rate': '256', 'admin_state': 'up'}, received={'sample_rate': '256', 'admin_state': 'up'}, key="Ethernet0", table="SFLOW_SESSION_TABLE"

Yes, looking into the failures.

@@ -108,7 +109,8 @@ void SflowMgr::sflowUpdatePortInfo(Consumer &consumer)
if (m_gEnable && m_intfAllConf)
{
// If the Local Conf is already present, dont't override it even though the speed is changed
if (new_port || (speed_change && !m_sflowPortConfMap[key].local_conf))
if (new_port || (speed_change &&
!(m_sflowPortConfMap[key].local_rate_cfg || m_sflowPortConfMap[key].local_admin_cfg)))
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be removed "|| m_sflowPortConfMap[key].local_admin_cfg" as the rate update based on speed change is only blocked if there is any local_rate_cfg. It doesn't depend on local_admin_cfg.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Signed-off-by: Venkatesan Mahalingam <venkatesan_mahalinga@dell.com>
dgsudharsan
dgsudharsan previously approved these changes Apr 28, 2021
Signed-off-by: Venkatesan Mahalingam <venkatesan_mahalinga@dell.com>
Signed-off-by: Venkatesan Mahalingam <venkatesan_mahalinga@dell.com>
Signed-off-by: Venkatesan Mahalingam <venkatesan_mahalinga@dell.com>
Signed-off-by: Venkatesan Mahalingam <venkatesan_mahalinga@dell.com>
@venkatmahalingam
Copy link
Contributor Author

venkatmahalingam commented Apr 30, 2021

@prsunny @dgsudharsan @vivekreddynv This PR is ready to merge, please review and approve the same.

Also, the below PRs for SONiC CLI & HLD changes.
https://github.com/Azure/sonic-utilities/pull/845/files
sonic-net/SONiC#755

@dgsudharsan
Copy link
Collaborator

@prsunny @venkatmahalingam Request for cherry-pick to 202012

qiluo-msft pushed a commit that referenced this pull request Aug 25, 2021
* Fixed incorrect interface admin-status when 'all' interface is disabled but there are local sampling-rate configurations.
Signed-off-by: Venkatesan Mahalingam <venkatesan_mahalinga@dell.com>
qiluo-msft pushed a commit to sonic-net/sonic-buildimage that referenced this pull request Aug 26, 2021
In order to include the following commits: 
d29a49a 2021-08-25 [ACL] Match TCP protocol while matching TCP_FLAG (sonic-net/sonic-swss#1854) 
2569ad9 2021-08-25 Fix sFlow sampling-rate and admin-state (sonic-net/sonic-swss#1728) 
8908a8f 2021-08-19 Change rif_rates.lua and port_rates.lua scripts to calculate rates correct (sonic-net/sonic-swss#1848) 
b42c2fb 2021-08-19 [VS Test] Skip flaky tests (sonic-net/sonic-swss#1875)
raphaelt-nvidia pushed a commit to raphaelt-nvidia/sonic-swss that referenced this pull request Oct 5, 2021
* Fixed incorrect interface admin-status when 'all' interface is disabled but there are local sampling-rate configurations.
Signed-off-by: Venkatesan Mahalingam <venkatesan_mahalinga@dell.com>
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.

6 participants