Skip to content

[vpp] CoPP dataplane enablement HLD - #2539

Open
nhegde-microsoft wants to merge 8 commits into
sonic-net:masterfrom
nhegde-microsoft:copp-vpp-enablement
Open

nhegde-microsoft wants to merge 8 commits into
sonic-net:masterfrom
nhegde-microsoft:copp-vpp-enablement

Conversation

@nhegde-microsoft

@nhegde-microsoft nhegde-microsoft commented Sep 3, 2026

Copy link
Copy Markdown

Why I did it

Adds a High-Level Design document for CoPP (Control Plane Policing) dataplane enablement on SONiC-VPP.

sonic-buildimage#25801 asks for CoPP test coverage on the SONiC-VPP KVM testbed (t1-lag-vpp). The SAI config-plane path already worked (orchagent's CoppOrch issues normal SAI calls, accepted and stored by saivpp), but no VPP dataplane mechanism actually classified, rate-limited, or punted control-plane traffic to the CPU. This HLD documents the design that closes that gap: two new VPP core plugins — copp_punt_policer (device-input arc, ethertype-keyed traps) and copp_ip2me_policer (ip4-punt arc, IP2ME/SNMP/SSH).

Companion PRs

Test result

Manually validated on vlab-vpp-01 (t1-lag-vpp testbed): all 24 tests/copp/test_copp.py subtests pass, zero skips. Full details in the HLD's Status section.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

@aaronber0614

Copy link
Copy Markdown

Multi-model review: SONiC #2539 (CoPP dataplane enablement HLD)

I ran the CoPP series (this HLD plus sonic-platform-vpp #281 and sonic-sairedis #2070) through a three model consensus review and an adversarial follow up. The design reads well and the punt plus policer approach is sound. My comments here are about accuracy between the HLD and what the two code PRs actually do, so the doc does not over promise.

1. REQ-5 (policer statistics) is not met by the current implementation

REQ-5 implies the SAI policer stat counters are populated. In the implementation, the #281 data path meters with the raw vnet_police_packet(...), which updates token buckets only and never increments the VPP stats segment counters /net/policer/{conform,exceed,violate}. Those are incremented only by VPP's policer_police() wrapper, which the plugin does not call. #2070's getPolicerStats reads exactly those /net/policer/* counters, so SAI_POLICER_STAT_* return 0 for every CoPP ethertype. Please either de-scope the stats claim in this HLD, or track the counter wiring fix (I left the concrete fix on #281 and #2070) as a requirement before REQ-5 can be called done.

2. REQ-2 trap scope is broader than what is bound in the dataplane

The requirement text lists a broad set of control plane protocols (for example SNMP, SSH, and others), but the implementation binds a policer for only the five ethertype based traps that the plugin keys on (ARP, LACP, LLDP, UDLD, and TTL error / IP2ME style punt). It would help readers to state explicitly which traps get dataplane policing in this phase and which are out of scope, so the HLD scope matches the shipped SwitchVppHostifTrap mapping.

3. The validation status table claims passes that the code PR calls not yet exercised

The status table marks cases such as the trap config save after reboot case and the policer MTU (BGP) case as passing, but the #2070 PR description says those paths are not yet exercised. Please reconcile the two so the HLD status reflects the actual test coverage.

4. Cosmetic

The added markdown file is committed with mode 100755 (executable). Doc files are normally 100644.

None of these block the design discussion. They are about keeping the HLD claims aligned with #281 and #2070 so REQ-5 in particular is not marked complete while the policer stats read all zeros. This HLD can land any time once the REQ-5 and REQ-2 scope wording is reconciled.

Reviewed by AI agent on behalf of aaronber0614.

@lolyu lolyu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Strong HLD overall — above the median for this repo. It does the three things design docs usually skip: (1) states why VPP's stock policer-classify can't cover this traffic with precise arc-level detail (ARP/LACP/LLDP/UDLD on linux-cp-paired L3 ports go ethernet-input → arp-input/linux-cp-punt-xc → TAP and never touch the l2-input/ip4-unicast/ip6-unicast arcs where policer-classify lives — correct, and it's the real justification for a new plugin); (2) documents alternates that were built and disproven (the tc ingress-qdisc-ordering fact — AF_PACKET copy happens before the ingress qdisc — is a real, subtle reason that approach fails); (3) carries a concrete pass/fail validation table. REQ-1..REQ-8 are well-formed and testable, and REQ-8 is unusually honest about testbed/harness blockers. Nice work.

Four technical questions I'd want answered before design-approval (inline), plus doc hygiene below. Flagging as Comment, not blocking — these are "clarify the design," not "the design is wrong."

Doc hygiene:

  • Revisions table author is "Vesper" while the work is under nhegde-microsoft — codename/placeholder? Merged HLDs normally carry the real handle.
  • Background says the ask is for t1-lag topology, but the testbed is t1-lag-vpp / vms-kvm-vpp-t1-lag — drop of the -vpp suffix.
  • REQ-2 lists SNMP/SSH in its trap enumeration, but neither the in-scope table nor the Status table covers them — are they in scope for this effort or aspirational? The "etc." is doing a lot of work in a requirement.
  • REQ-4 calls out runtime add/remove (test_add_new_trap/test_remove_trap) but only test_trap_config_save_after_reboot (REQ-6) appears in the Status table — is the runtime add/remove path passing too?
  • Consider a one-line VPP node-graph fragment (device-input → copp_punt_policer → {police → interface-output(TAP) | drop} vs the bypassed ethernet-input → arp-input/linux-cp-punt-xc) — it would make the whole design legible at a glance, and HLDs here usually carry one.

Comment thread doc/vpp/vpp_copp_HLD.md
Comment thread doc/vpp/vpp_copp_HLD.md
Comment thread doc/vpp/vpp_copp_HLD.md
Comment thread doc/vpp/vpp_copp_HLD.md
@nhegde-microsoft

Copy link
Copy Markdown
Author

Thanks for the thorough review — addressed all of this in eeffa10, replies inline on the four technical questions. Doc hygiene:

  • Author handle: fixed, Revisions table now says nhegde-microsoft.
  • t1-lag vs t1-lag-vpp: fixed, Background now says t1-lag-vpp / vms-kvm-vpp-t1-lag.
  • REQ-2 SNMP/SSH: clarified — they're pre-existing (ride the same ip4-unicast/ip6-unicast path as BGP/DHCP/IP2ME), not part of this effort's new plugin. Trimmed the "etc." accordingly.
  • REQ-4 runtime add/remove: test_add_new_trap/test_remove_trap are not yet validated (blocked on an unrelated testbed harness issue) — now marked explicitly as not-yet-validated in both REQ-4 and the Status table, rather than implying REQ-6's reboot-persistence result covers it.
  • Node-graph fragment: added, contrasting the bypassed ethernet-input -> arp-input/linux-cp-punt-xc default path with device-input -> copp_punt_policer -> police -> {interface-output(TAP) | drop}.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

Documents the copp_punt_policer VPP device-input plugin design that
implements SAI POLICER/HOSTIF_TRAP/HOSTIF_TRAP_GROUP dataplane
enforcement for control-plane protocols (ARP, LACP, LLDP, UDLD,
TTL_ERROR) on SONiC-VPP. All CoPP policer tests pass on vlab-vpp-01
with this design (test_verify_copp_configuration_cli plus
test_policer for ARP/LACP/LLDP/UDLD/Default/DHCP/DHCP6).

Companion code: sonic-sairedis and sonic-platform-vpp branch
copp-vpp-enablement.

Signed-off-by: Nikhil Hegde <nikhilhegde@microsoft.com>
…cer_mtu[BGP] pass

Also documents the known, unresolved test_policer_mtu[IP2ME/SNMP/SSH]
failure (zero packets received) as a separate, pre-existing gap
unrelated to the copp_punt_policer plugin.

Signed-off-by: Nikhil Hegde <nikhilhegde@microsoft.com>
Signed-off-by: Nikhil Hegde <nikhilhegde@microsoft.com>
- Fix author handle (nhegde-microsoft, not placeholder), t1-lag-vpp
  topology name in Background.
- REQ-2: clarify SNMP/SSH are pre-existing (ip4/ip6-unicast path),
  not part of this effort's plugin scope.
- REQ-4: mark test_add_new_trap/test_remove_trap as not yet
  validated in both the requirement and Status table.
- Add a node-graph fragment contrasting the bypassed
  arp-input/linux-cp-punt-xc path with the new
  copp_punt_policer -> police -> {TAP|drop} path.
- Add explicit design notes: tagged/VLAN frames are out of scope
  (fixed 14-byte parse assumes untagged Ethernet); metering is
  pps-based so the fixed 256-byte token-bucket reference length is
  deliberately packet-size-independent (reconciled with REQ-5's
  byte counters); the node consumes matched packets so VPP's
  arp-input ARP-learning side effect is lost for punted ARP
  (expected to happen at the CPU/Linux TAP side instead); fast-path
  cost for non-punted traffic is a 14-byte header read plus a
  linear scan of a small bounded (<=16 entry) table.

Signed-off-by: Nikhil Hegde <nikhilhegde@microsoft.com>
- Remove the two 'not yet validated' test_add_new_trap/test_remove_trap
  rows from the Status table (and matching REQ-4 'see Status' pointer) --
  per standing instruction, the Status table only carries confirmed
  passes and legitimate skips-with-reason, never in-progress or failing
  items.
- Add a 'Legitimately skipped' subsection documenting
  test_trap_neighbor_miss: gated to T0-family topologies only in the
  generic (non-VPP) conditional-mark file, and this testbed
  (vms-kvm-vpp-t1-lag) is T1, so the skip is topology-driven and
  unrelated to asic_type or this effort's CoPP dataplane work.

Signed-off-by: Nikhil Hegde <nikhilhegde@microsoft.com>
Per feedback, use the same table/format as the other Status rows
instead of a separate subsection: SKIPPED with a green check and a
short (t0 only) note, consistent with how the rest of the table
reads.

Signed-off-by: Nikhil Hegde <nikhilhegde@microsoft.com>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

REQ-4 validated live; Status table + Key files changed updated to reflect
the dynamic trap add/remove tests passing, plus the sairedis reply-handler
fix and sonic-mgmt test-harness asic_type fix that unblocked them.

Signed-off-by: Nikhil Hegde <nikhilhegde@microsoft.com>
Signed-off-by: Nikhil Hegde <nikhilhegde@microsoft.com>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

@nhegde-microsoft nhegde-microsoft changed the title [vpp] Add CoPP dataplane enablement HLD [vpp] CoPP dataplane enablement HLD Sep 10, 2026
Comment thread doc/vpp/vpp_copp_HLD.md

## Background

[sonic-buildimage#25801](https://github.com/sonic-net/sonic-buildimage/issues/25801) asks to enable Control Plane Policing (CoPP) testing for the `t1-lag-vpp` topology (`vms-kvm-vpp-t1-lag` testbed) on the SONiC-VPP KVM testbed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the design should not limit the scope to t1-lag topology. We should at least include t0 to make sure it is compatible. we don't want to redesign it to work for both t1 and t0

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fair point, I did not make it generic enough to cover t0. I believe the primary difference is the VLAN/bridge setup in t0 versus the L3 routed ports in t1-lag. t0 still uses the same linux-cp tap pairing, so I think this should work just fine, but I'd like to run a quick test first. I will update here and in the document when done. Thanks for the suggestion.

Comment thread doc/vpp/vpp_copp_HLD.md
2. **Police**: applies VPP's existing `vnet_police_packet()` token-bucket primitive against the same VPP policer object `SwitchVppPolicer.cpp` already creates from SAI `POLICER` attributes — no new metering implementation. Uses a fixed 256-byte reference packet length since VPP's pps→token-bucket conversion assumes that fixed size internally.
3. **Deliver**: for a conforming packet, sets the buffer's TX interface directly to the mapped linux-cp TAP and dispatches straight to `interface-output`. Resolves against the raw ingress port for every ethertype uniformly, matching what this project's PTF test harness (`ptf_nn_agent`) actually observes.

SAI wiring (`SwitchVppHostifTrap.cpp`) mirrors the existing per-trap dispatch pattern used for bookkeeping: on `createHostifTrap`/`setHostifTrap`/`setHostifTrapGroup`, resolve the trap's bound policer to its VPP policer name and call the plugin's `copp_punt_policer_bind` API — switch-wide, since the plugin auto-enables its feature on every interface as it's created (`VNET_SW_INTERFACE_ADD_DEL_FUNCTION`), no per-port bind needed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have concern with adding this node to device input, which will affect every packets. Most of the protocols listed (except UDLD and TTL expiry requiring investigation) are already punted to control plane today. Can we add the policer to the punt path? For example, in the interface output arc of tap interface?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I did have the same concern but it seemed like the best option while I was trying this out. I also ran some tests and found the added delay was ~50ns per packet and the protocol match list was small (<16). The advantage was that this would work for any topology.
Having said that, your other point about policing it in the output path is interesting because that is the first option I tried and ran into issues. However, after several other changes, I suspect the issue was not related to the location of the policer because I just ran it again now with the policer in tap interface output and it seems to work, which I am surprised to see myself. I am going to do a couple of more runs to be sure, but if it is stable, I will switch the design to use this instead. Should be a small change.

Comment thread doc/vpp/vpp_copp_HLD.md
| Rev | Date | Author(s) | Changes |
|-----|------|-----------|---------|
| 1.0 | 2026-09-02 | nhegde-microsoft | Initial HLD for `copp_punt_policer` design. |
| 1.1 | 2026-09-10 | nhegde-microsoft | Added `copp_ip2me_policer` plugin (IP2ME/SNMP/SSH enforcement on `ip4-punt`); updated status table. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

so far sonic-ext plugin is used for multiple features for sonic. Please consider if it is better to use the same plugin. The benefit is we can avoid too many plugins. But we lose the flexibility to enable/disable a feature through plugin infra. Currently, we use API in the sonic-ext plugin to enable/disable individual feature.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fair point. Let me look into feasibility of moving this into sonic-ext.

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.

5 participants