mod_vpp: don't re-sample PSAMPLE when osIndex=on - #91
Conversation
When osIndex=on, VPP writes the Linux ifIndex into the PSAMPLE metadata and mod_psample already emits the flow sample in that namespace. mod_vpp's evt_psample() then calls takeSample() a second time, so every flow sample is duplicated at the collector (2x) while the VPP plugin's own counter shows 1x. Return early in that mode and let mod_psample own the flow sample; mod_vpp still provides VPP interface counter samples via its netlink channel.
c946c16 to
203b5a8
Compare
|
What does /etc/hsflowd.conf look like in this setup? It seems like there might be a misunderstanding about the use of the PSAMPLE group numbers. For a regular SONIC switch the samples appear on PSAMPLE group=1 (for ingress) or 2 (for egress). In that case mod_psample will announce the sample via HSPEVENT_PSAMPLE and then go ahead and call takeSample() itself. However when VPP sends samples they go to PSAMPLE group=3 (for ingress) and 4 (for egress). In that case mod_psample will still announce the sample via HSPEVENT_PSAMPLE, but it will not call takeSample(). Instead mod_vpp will pick them up and then call takeSample() itself after adjusting the port numbers. (Later in the pipeline, mod_sonic will translate those numbers from the Linux namespace to the SONiC namespace, but we don't need to worry about that here.) When hsflowd is compiled with FEATURES=SONIC it automatically adds the equivalent of this to the config: Plus the sonic{...} and dropmon{...} config too. None of that needs to change. I think for sonic-vpp you just need one more line in /etc/hsflowd.conf: Is this config step something I can find in the sonic-buildimage repo? I'm not sure where to look. |
|
I don't think you need to change anything in the hsflowd source code. I think you just need to get the right settings into your /etc/hsflowd.conf config file. Where is it defined? I don't know what repo to look in. Please send a link to the place where hsflowd is compiled with the VPP feature enabled, and the place where the /etc/hsflowd.conf file is set up. |
|
Everything is in sonic-buildimage, under src/sflow/hsflowd/:
Here is the live For reference on the behaviour: with this config the collector shows ingress ~2x (VPP's own |
|
I can't seem to find the string "osindex" in any of the sonic-net repos, so please let me know where I should look? What you are saying makes it sound as though hsflowd.conf has been set up with "psample{group=3}" when it should have "psample{group=1}".... or no entry for psample{} at all because "psample{group=1}" is implicit when you compile for SONIC. So if I guessed right then all you need to do is remove the "psample{group=3}" line. |
|
OK, that hsflowd.conf looks right, so there must be something else going on. If you can set a gdb breakpoint here: host-sflow/src/Linux/mod_psample.c Line 372 in 41f10e6 can you confirm that the samples coming from vpp are on psample group 3 or 4, and are therefore given no further consideration by mod_psample? |
|
As a possibly easier shortcut, you could also do this (it runs a second hsflowd at debug level 3) so you can just grep for the debug line that prints the psample group at mod_psample.c:362): docker exec sflow -it /bin/bash Running a second hsflowd is a little reckless because it will also send duplicate samples. If that's not OK you can also copy /etc/hsflowd.conf to /tmp/hsflowd.conf, edit it down to just one "collector { ip=127.0.0.1 }" and then run it with hsflowd -dddd -f /tmp/hsflowd.conf) |
|
So ingress ie being sampled on both group 1 and group 3: mod_psample exports the group-1 copy and mod_vpp exports the group-3 copy. Thats the 2x on ingress. Egress only appears on group 4 (mod_vpp), so it stays 1x. Any idea where the group-1 ingress samples are coming from in addiiton to VPP's group-3? ( |
|
That's interesting. I wonder where it is coming from. For hsflowd itself to have caused it, there would need to be a dent{} module. The mod_dent.c code can configure kernel sampling using calls to tc(1). But that is not even compiled for this profile. I wonder, the sflowmgr script inside the sflow container has a script called "psample" that is supposed to configure the hardware sampling via the SAI API. Maybe it has a mode where it detects there is no ASIC present, and falls back on configuring kernel sampling with tc(1)? I have never looked at that script, so I don't know what is in there. Naturally we'll want to find and eliminate that psample configuration for the sonic-vpp platform, but as a quick test you could try adding "psample{group=5}" to your hsflowd.conf file. I think that should override the implicit "psample{group=1}", and should therefore cause mod_psample to ignore the rogue group=1 samples. |
|
`psample {group 5 ingress=on egress=on} fixes the 2x on sonic-vpp. I re-ran with aligned window (a 30s foreground sflowtool capture backtracked by VPP's packet samples sent counter):
So the collector now tracks the VPP counter at 1x instead of 2x That confirms the root cause you pointed to: ingress was being emitted on both PSAMPLE group 1 and group 3. mod_psample exported the group-1 copy and mod_vpp exported the group-3 copy, giving the two samples per ingress packet. Moving mod_psample to group 5 makes it ingore both the stray group-1 and VPP's 3/4, so mod_vpp is the sole owner of 3/4. My full test: On a separate terminal I sent traffic: |
|
Small update, I ran the test with just group 1:
So in the current state both read 1x - the 2x is intermittent, not a fixed property of the config group. That lines up with the rogue group-1 sample that's only active some of the time, when it's off, ingress rides only VPP's group-3 and mod_vpp exports it once regardless of the |
|
Correction to my earlier comment, the "both read 1x, so it's intermittent" conclusion was wrong. That test was on a both-direction port. I re-ran a controlled A/B on an ingress-only port (Eth4, rx), comparing the collector against VPP's packet samples sent counter (the reliable 1x reference), changing only eh psample group:
Same port, same metric, only the group changed, so the duplication is real and reproducible and This matches the So |
|
Thank you for sharing the details as you track this down. Another suggestion would to to query for the tc(1) config to see if that was the mechanism that was used to add the rogue sampling on group 1. (And please respond to my comments on the patch that adds per-interface sampling to the vpp dataplane. I think that one is more important than this one, and will be more work to fix.) |
|
I will try the query for tc(1). Regarding the comment you left, could you please share the link to the PR you left a comment to, I'm not seeing it in any PRs, so I must be missing one. |
|
The So: ifindex 12 = Ethernet8, matching the earlier |
|
I've done some more testing with The group-1 sampler comes from sonic-sairedis, not hsflowd.
Ingress -> 1x, egress unchanged. This removes only the duplicate, no egress changed. The real fix belongs here, gate the tc sampler off on the VPP platform, (VPP samples natively on 3/4), leaving group 1/2 intact for real ASIC SONiC. The full test output: |
|
When the sonic-sairedis script injects the tc(1) config for psample group 1, does it say why? Is it just so that a software-switch deployment such as sonic-vm can generate sFlow, or is there a corner-case that it is addressing? Put another way, is there likely to be any port on a sonic-vpp switch that should support packet-sampling but is not actually a port in the VPP dataplane? (I'm thinking probably not, but wanted to bring it up just in case). I moved the per-interface sampling comment to the PR. Let me know if you don't see it. |
When osIndex=on, VPP writes the Linux ifIndex into the PSAMPLE metadata and mod_psample already emits the flow sample in that namespace. mod_vpp's evt_psample() then calls takeSample() a second time, so every flow sample is duplicated at the collector (2x) while the VPP plugin's own counter shows 1x. Return early in that mode and let mod_psample own the flow sample; mod_vpp still provides VPP interface counter samples via its netlink channel.