Skip to content

[vpp] Add sonic_ext RIF loopback packet action nodes and binary API - #259

Open
aaronber0614 wants to merge 5 commits into
sonic-net:masterfrom
aaronber0614:vpp-iface-loopback-sonicext
Open

[vpp] Add sonic_ext RIF loopback packet action nodes and binary API#259
aaronber0614 wants to merge 5 commits into
sonic-net:masterfrom
aaronber0614:vpp-iface-loopback-sonicext

Conversation

@aaronber0614

@aaronber0614 aaronber0614 commented Jul 9, 2026

Copy link
Copy Markdown

Why I did it

Dataplane half of the RIF loopback packet action feature. VPP needs graph nodes on the ip4-output and ip6-output arcs that drop a routed hairpin packet (a packet whose ingress RIF equals its egress RIF) and count it as tx-error, plus a binary API so the SAI layer can toggle the behavior per interface.

Feature tracking issue: sonic-net/sonic-buildimage#25788

How I did it

  • Added sonic-ext-ip4-loopback and sonic-ext-ip6-loopback output-arc nodes to the existing sonic_ext plugin.
  • Added the plugin's first binary API, iface_loopback_set_action with fields sw_if_index and action.
  • Stored the action per sw_if_index and toggled the feature arcs via vnet_feature_enable_disable, with rollback on partial failure.
  • Incremented the per-interface VNET_INTERFACE_COUNTER_TX_ERROR on drop.
  • Bumped VPP_VERSION so CI does not reuse a stale cached .deb without the new nodes.

How to verify it

Build docker-sonic-vpp. Run "vppctl show node sonic-ext-ip4-loopback" and confirm the state is active. Set "config interface ip loopback-action Ethernet0 drop", inject a hairpin packet, and confirm tx-error increments; with forward, the packet egresses and tx-error stays 0.

Which release branch to backport (provide reason below if selected)

None.

Description for the changelog

Add sonic_ext plugin nodes and a binary API for RIF loopback packet action on the VPP dataplane.

Part of sonic-net/sonic-buildimage#25788.


PR series (landing order)

Tracking issue: sonic-net/sonic-buildimage#25788

  1. HLD: [doc][vpp] HLD for Router Interface Loopback Packet Action on the VPP dataplane SONiC#2462
  2. sonic_ext plugin, nodes and binary API: [vpp] Add sonic_ext RIF loopback packet action nodes and binary API #259
  3. vslib/vpp SAI adapter and defect fixes: [vpp] SAI RIF loopback packet action and pre-existing VPP vslib defect fixes sonic-sairedis#1983 (depends on 2)
  4. Testbed virtio ctrl_vlan off: [vpp][testbed] Disable virtio ctrl_vlan on VPP KVM DUTs sonic-mgmt#26035
  5. Enablement, lands last: [vpp][ci] Enable iface_loopback_action test on the t1-lag-vpp testbed sonic-mgmt#26036 (depends on 2, 3, 4)

Fold the router-interface loopback (hairpin) packet action feature into the
consolidated sonic_ext plugin instead of a standalone plugin, so all custom
SONiC VPP dataplane nodes live in one place (see sonic-platform-vpp sonic-net#255).

- Add ip4/ip6 loopback output-arc nodes (sonic-ext-ip4-loopback /
  sonic-ext-ip6-loopback): a routed packet whose egress interface equals its
  ingress interface is dropped and the interface tx-error counter incremented
  when the per-interface action is DROP; otherwise it continues on the arc.
- Add the first binary API to sonic_ext (sonic_ext.api:
  iface_loopback_set_action) with the msg-id-base setup and reply handler, and
  a per-sw_if_index action vector in sonic_ext_main_t.
- sonic_ext_iface_loopback_set_action() toggles the output arcs only on an
  actual FORWARD<->DROP transition (VPP feature enable/disable is ref-counted),
  and rolls back both the arc state and the stored action on failure.
- Reset the action on interface delete so a recycled sw_if_index cannot inherit
  a stale DROP.
- Bump VPP_VERSION 2606-0.3 -> 2606-0.4 (plugin content changed).

Signed-off-by: Aaron Bernardino <aaronber@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

…k-sonicext

Signed-off-by: Aaron Bernardino <aaronber@microsoft.com>
Merging upstream/master brought in the sflow VPP patches (0012-0014),
changing vppbld/patches/series on this branch. Per the VPP_VERSION
convention, bump the minor suffix (0.4 -> 0.5) so CI rebuilds the VPP
and sonic_ext plugin debs against the new series instead of reusing a
stale cached 0.4 deb that predates the sflow patches.

Part of sonic-net/sonic-buildimage#25788.

Signed-off-by: Aaron Bernardino <aaronber@microsoft.com>
@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

…k-sonicext

Signed-off-by: Aaron Bernardino <aaronber@microsoft.com>
…0012

Merging upstream/master pulled the sflow phase-three change to
0012-sflow-per-port-sample-rate.patch. Since the patch series content
changed, bump the VPP_VERSION suffix so CI does not reuse a stale cached
.deb keyed on the old 0.5 content. 0.6 and 0.7 are in use by the VXLAN
branches, so 0.8 is the next free suffix.

Signed-off-by: Aaron Bernardino <aaronber@microsoft.com>
Copilot AI review requested due to automatic review settings July 28, 2026 17:01
@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds the VPP dataplane portion of SONiC’s RIF loopback (hairpin) packet action feature by extending the existing sonic_ext plugin with per-interface configuration and output-arc nodes that can drop routed hairpin packets and account them as TX errors.

Changes:

  • Added sonic-ext-ip4-loopback and sonic-ext-ip6-loopback feature nodes on the ip4-output / ip6-output arcs to drop hairpin packets and increment VNET_INTERFACE_COUNTER_TX_ERROR.
  • Introduced the plugin’s first binary API (iface_loopback_set_action) to toggle per-interface loopback action and enable/disable the feature nodes accordingly.
  • Bumped VPP_VERSION to avoid consuming cached debs that predate the new plugin content.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
vppbld/plugins/sonic_ext/sonic_ext.h Adds loopback action constants, API message-id base storage, and per-interface action vector + setter declaration.
vppbld/plugins/sonic_ext/sonic_ext.c Implements per-interface loopback action setter, API handler, message-id setup, and sw_if_index delete reset logic.
vppbld/plugins/sonic_ext/sonic_ext.api Defines the new iface_loopback_set_action binary API message.
vppbld/plugins/sonic_ext/ip4_loopback_node.c Implements IPv4 output-arc feature node to drop routed hairpin packets and count TX errors.
vppbld/plugins/sonic_ext/ip6_loopback_node.c Implements IPv6 output-arc feature node to drop routed hairpin packets and count TX errors.
vppbld/plugins/sonic_ext/FEATURE.yaml Documents the new iface-loopback feature in the plugin feature list.
vppbld/plugins/sonic_ext/CMakeLists.txt Adds new node sources and wires in API generation for sonic_ext.api.
rules/vpp.mk Bumps VPP version suffix to invalidate cached artifacts after plugin changes.

Comment on lines +277 to +284
int
sonic_ext_iface_loopback_set_action (u32 sw_if_index, u8 action)
{
sonic_ext_main_t *sem = &sonic_ext_main;
int enable = (action == SONIC_EXT_LOOPBACK_ACTION_DROP);
u8 prev;
int rv;

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.

3 participants