Skip to content

swss: Fix sFlow sampling-rate and admin-state#1224

Closed
GarrickHe wants to merge 1 commit intosonic-net:masterfrom
GarrickHe:sflow-fix
Closed

swss: Fix sFlow sampling-rate and admin-state#1224
GarrickHe wants to merge 1 commit intosonic-net:masterfrom
GarrickHe:sflow-fix

Conversation

@GarrickHe
Copy link

  • Fixing Add logic to allow user to revert to
    default sFlow sampling-rate on
    interface.
  • Fixing Fixed incorrect interface admin-status
    when 'all' interface is disabled but
    there are local sampling-rate configurations.

Signed-off-by: Garrick He [email protected]

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
Ran unit-test before and after the fix. See 'details' section below.

Details if related

admin@sonic:~$ show version

SONiC Software Version: SONiC.HEAD.271-7d2ebf81
Distribution: Debian 9.12
Kernel: 4.9.0-11-2-amd64
Build commit: 7d2ebf81
Build date: Thu Mar 12 12:08:35 UTC 2020
Built by: johnar@jenkins-worker-12

Platform: x86_64-kvm_x86_64-r0
HwSKU: Force10-S6000
ASIC: vs
Serial Number: 000000
Uptime: 11:32:42 up 2 min,  1 user,  load average: 2.07, 1.49, 0.62

Docker images:
REPOSITORY                    TAG                 IMAGE ID            SIZE
docker-syncd-vs               HEAD.271-7d2ebf81   801ebba2928e        293MB
docker-syncd-vs               latest              801ebba2928e        293MB
docker-router-advertiser      HEAD.271-7d2ebf81   66a01177d5e2        283MB
docker-router-advertiser      latest              66a01177d5e2        283MB
docker-platform-monitor       HEAD.271-7d2ebf81   fe5764889f0a        335MB
docker-platform-monitor       latest              fe5764889f0a        335MB
docker-dhcp-relay             HEAD.271-7d2ebf81   6fb090883a58        293MB
docker-dhcp-relay             latest              6fb090883a58        293MB
docker-database               HEAD.271-7d2ebf81   596b4fb9f0b9        283MB
docker-database               latest              596b4fb9f0b9        283MB
docker-orchagent              HEAD.271-7d2ebf81   d7ce15f59f9a        326MB
docker-orchagent              latest              d7ce15f59f9a        326MB
docker-nat                    HEAD.271-7d2ebf81   a45757c846f1        310MB
docker-nat                    latest              a45757c846f1        310MB
docker-sonic-telemetry        HEAD.271-7d2ebf81   b62ca7d52376        345MB
docker-sonic-telemetry        latest              b62ca7d52376        345MB
docker-sonic-mgmt-framework   HEAD.271-7d2ebf81   2c9db136589e        421MB
docker-sonic-mgmt-framework   latest              2c9db136589e        421MB
docker-fpm-frr                HEAD.271-7d2ebf81   c7bab662339e        328MB
docker-fpm-frr                latest              c7bab662339e        328MB
docker-sflow                  HEAD.271-7d2ebf81   7502070966f0        308MB
docker-sflow                  latest              7502070966f0        308MB
docker-lldp-sv2               HEAD.271-7d2ebf81   ce902ae9e83c        305MB
docker-lldp-sv2               latest              ce902ae9e83c        305MB
docker-snmp-sv2               HEAD.271-7d2ebf81   e3fbc3024f19        340MB
docker-snmp-sv2               latest              e3fbc3024f19        340MB
docker-teamd                  HEAD.271-7d2ebf81   2f934886b9b1        308MB
docker-teamd                  latest              2f934886b9b1        308MB

admin@sonic:~$



UT before fix:

admin@sonic:~$ sudo -i
root@sonic:~# show sflow

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

  0 Collectors configured:
root@sonic:~# config sflow enable
Created symlink /etc/systemd/system/multi-user.target.wants/sflow.service → /etc/systemd/system/sflow.service.
root@sonic:~# show sflow

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

  0 Collectors configured:
root@sonic:~# show sflow interface

sFlow interface configurations
+-------------+---------------+-----------------+
| Interface   | Admin State   |   Sampling Rate |
+=============+===============+=================+
| Ethernet0   | up            |            4000 |
+-------------+---------------+-----------------+
| Ethernet4   | up            |            4000 |
+-------------+---------------+-----------------+
| Ethernet8   | up            |            4000 |
+-------------+---------------+-----------------+
| Ethernet12  | up            |            4000 |
+-------------+---------------+-----------------+
| Ethernet16  | up            |            4000 |
+-------------+---------------+-----------------+
| Ethernet20  | up            |            4000 |
+-------------+---------------+-----------------+
| Ethernet24  | up            |            4000 |
+-------------+---------------+-----------------+
| Ethernet28  | up            |            4000 |
+-------------+---------------+-----------------+
| Ethernet32  | up            |            4000 |
+-------------+---------------+-----------------+
...<OUTPUT cut out to save room > ...

root@sonic:~# config sflow interface sample-rate Ethernet0 256
root@sonic:~# config sflow interface sample-rate Ethernet4 512
root@sonic:~# show sflow interface | less

sFlow interface configurations
+-------------+---------------+-----------------+
| Interface   | Admin State   |   Sampling Rate |
+=============+===============+=================+
| Ethernet0   | up            |             256 |
+-------------+---------------+-----------------+
| Ethernet4   | up            |             512 |
+-------------+---------------+-----------------+


root@sonic:~# config sflow interface disable all
root@sonic:~# show sflow interface | less

sFlow interface configurations
+-------------+---------------+-----------------+
| Interface   | Admin State   |   Sampling Rate |
+=============+===============+=================+
| Ethernet0   | up            |             256 |
+-------------+---------------+-----------------+
| Ethernet4   | up            |             512 |
+-------------+---------------+-----------------+

Notice the two interfaces remains 'up' even though they don't have a local admin-state configured.

UT AFTER fix:
root@sonic:~# config sflow enable
root@sonic:~# show sflow interface | less

sFlow interface configurations
+-------------+---------------+-----------------+
| Interface   | Admin State   |   Sampling Rate |
+=============+===============+=================+
| Ethernet0   | up            |            4000 |
+-------------+---------------+-----------------+
| Ethernet4   | up            |            4000 |
+-------------+---------------+-----------------+
...<OUTPUT CUT OUT TO SAVE ROOM> ...

root@sonic:~# config sflow interface sample-rate Ethernet0 256
root@sonic:~# config sflow interface sample-rate Ethernet4 512
root@sonic:~# show sflow interface | less

sFlow interface configurations
+-------------+---------------+-----------------+
| Interface   | Admin State   |   Sampling Rate |
+=============+===============+=================+
| Ethernet0   | up            |             256 |
+-------------+---------------+-----------------+
| Ethernet4   | up            |             512 |
+-------------+---------------+-----------------+

root@sonic:~# config sflow interface disable all
root@sonic:~#
root@sonic:~# show sflow interface | less

sFlow interface configurations
+-------------+---------------+-----------------+
| Interface   | Admin State   | Sampling Rate   |
+=============+===============+=================+
+-------------+---------------+-----------------+
root@sonic:~#

Notice all interfaces are disabled as they should be since they all adhere to a global admin state.

* Fixing Add logic to allow user to revert to
         default sFlow sampling-rate on
         interface.
* Fixing Fixed incorrect interface admin-status
         when 'all' interface is disabled but
         there are local sampling-rate configurations.

Signed-off-by: Garrick He <[email protected]>
@prsunny
Copy link
Collaborator

prsunny commented Mar 18, 2020

@dgsudharsan , @padmanarayana, can you review?

@GarrickHe
Copy link
Author

PR for CLICK CLI script update:
sonic-net/sonic-utilities#845

@prsunny
Copy link
Collaborator

prsunny commented Mar 19, 2020

retest this please

@lguohan
Copy link
Contributor

lguohan commented Mar 24, 2020

is there a test to cover this?

@GarrickHe
Copy link
Author

GarrickHe commented Mar 25, 2020

is there a test to cover this?
@lguohan - You're referring to automated testing, right?
@padmanarayana - you know more about the automated testing aspect.

@GarrickHe
Copy link
Author

is there a test to cover this?

@lguohan can we merge this fix first and put the test-coverage in a separate PR?

@prsunny
Copy link
Collaborator

prsunny commented Mar 27, 2020

@GarrickHe , it is better to have this tested as part of test_sflow. Just add a case to cover what you have in description.

{
for (auto it: m_sflowPortConfMap)
{
if (!it.second.local_conf)
Copy link
Contributor

Choose a reason for hiding this comment

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

In configuring admin_state field of CONFIG_DB SFLOW|global table, both sflowHandleSessionAll and sflowHandleSessionLocal will be called if m_intfAllConf is true (default value). Before your change, it.second.local_conf, to my understanding, controls the mutual exclusion that an individual port is set in either sflowHandleSessionAll or sflowHandleSessionLocal, depending on whether it has its own configuration or not. Now you remove this variable, a port having its own config can be set twice to APPL_DB by both sflowHandleSessionAll and sflowHandleSessionLocal, calling m_appSflowSessionTable.set(it.first, fvs).

Copy link
Author

@GarrickHe GarrickHe Jul 27, 2020

Choose a reason for hiding this comment

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

@wangxin - Are you asking a question or suggesting a change?

I replaced port_info.local_conf with two variables port_info.local_rate_cfg and port_info.local_admin_cfg to differeniate between a local change to the port's admin-state and a local change to the port's sampling-rate. This change is needed to address the issue at hand. Without it we will hit a case where the user configured a port's sampling-rate, but the port will not obey the global admin-status (because there is a local config), as the unfixed UT demonstrates.

Now you remove this variable, a port having its own config can be set twice to APPL_DB by both sflowHandleSessionAll and sflowHandleSessionLocal, calling m_appSflowSessionTable.set(it.first, fvs).

Not sure what you mean here. If a port has a local config (either sample-rate, admin-status, or both), APPL_DB will be set when either sflowHandleSessionAll or sFlowHandleSessionLocal is called. This behavior is exactly the same as when there was only one variable port_info.local_config, because we are doing a OR (||) check:

https://github.com/Azure/sonic-swss/pull/1224/files#diff-e3e7c0a4d48317ec70d5339d6fd3c6d1R136
https://github.com/Azure/sonic-swss/pull/1224/files#diff-e3e7c0a4d48317ec70d5339d6fd3c6d1R162

Each of those function can configure ApplDB once as needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

As you said in reply "APPL_DB will be set when either sflowHandleSessionAll or sFlowHandleSessionLocal is called", APPL_DB will be set twice here https://github.com/Azure/sonic-swss/blob/master/cfgmgr/sflowmgr.cpp#L289

Copy link
Author

Choose a reason for hiding this comment

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

Yes, once per function call and only if m_intfallConf evaluates to true. This is needed. I'm still not sure if you're trying to make a suggestion or asking a question...

@wendani
Copy link
Contributor

wendani commented Aug 29, 2020

The problem described is an expected behavior from HLD 6.2 Configuration and control flow

In control flow https://github.com/Azure/SONiC/blob/master/images/sflow/sflow_intf_disable_all.png
config sflow interface disable all only removes APPL_DB SFLOW_SESSION_TABLE:EthernetX for globally configured ports, taking no effect on individually configured ports.

@GarrickHe
Copy link
Author

The problem described is an expected behavior from HLD 6.2 Configuration and control flow

In control flow https://github.com/Azure/SONiC/blob/master/images/sflow/sflow_intf_disable_all.png
config sflow interface disable all only removes APPL_DB SFLOW_SESSION_TABLE:EthernetX for globally configured ports, taking no effect on individually configured ports.

We need to consider that there are two properties in a port that can be globally or locally configured, the sample-rate and admin-state. The issue here is, if the user configures JUST the sample-rate, the admin-status SHOULD follow what is global. Therefore, if I confiigure just the sample-rate on EthernetX then I disable sFlow on all interface, EthernetX should also be disabled. The admin-state only becomes locally configured if the user explicitly enable/disable it.

@padmanarayana @dgsudharsan, what do you think? I believe the HLD should be updated to reflect this.

@liat-grozovik
Copy link
Collaborator

liat-grozovik commented Feb 21, 2021

@GarrickHe and @wendani please note that we need this fix for 202012 where sflow should be qualified as a new feature.
if possible please make sure it can be cherry picked and the label of 'required for 202012' is added.
as this is a 6 month old PR i strongly suggest to move forward with it. any objection?

For your information the problem encountered by Nvidia on 202012 is as following "keyword 'all' is ignored when per-interface sflow is enabled/disabled " . Could it be that this PR is expected to fix the problem?

@GarrickHe
Copy link
Author

@GarrickHe and @wendani please note that we need this fix for 202012 where sflow should be qualified as a new feature.
if possible please make sure it can be cherry picked and the label of 'required for 202012' is added.
as this is a 6 month old PR i strongly suggest to move forward with it. any objection?

For your information the problem encountered by Nvidia on 202012 is as following "keyword 'all' is ignored when per-interface sflow is enabled/disabled " . Could it be that this PR is expected to fix the problem?

@liat-grozovik - I'll take care of this. the PR has been reviewed and approved. the only thing missing is test-cases to cover this fix. Sorry this PR slipped under my radar. I'll work on it. Thanks.

@liat-grozovik
Copy link
Collaborator

liat-grozovik commented Feb 25, 2021 via email

@venkatmahalingam
Copy link
Contributor

#1728 has been created to progress on this PR, please follow the new PR.

@prsunny
Copy link
Collaborator

prsunny commented Apr 30, 2021

Closing this in favor of #1728

@prsunny prsunny closed this Apr 30, 2021
EdenGri pushed a commit to EdenGri/sonic-swss that referenced this pull request Feb 28, 2022
…ble (sonic-net#1224)

- What I did
Updates to bgp config and show commands with the movement of internal bgp sessions to a new table BGP_INTERNAL_NEIGHBOR table.
With the introduction of BGP_INERNAL_NEIGHBOR table, the user cannot start/stop/remove internal neighbors which I feel is not needed as these internal bgp sessions which are supposed to be UP always.

- How I did it
Updated the show/bgp util so that it gets the internal bgp sessions from BGP_INTERNAL_NEIGHBOR table.
Removed the API's to get the local_as in config/bgp which is not required now.

- How to verify it
Made sure that the output remain same with the new internal bgp neighbor table.
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