[vpp] saivpp VXLAN L3 decap: source-independent decap, inner source MAC, BD teardown fix - #1996
[vpp] saivpp VXLAN L3 decap: source-independent decap, inner source MAC, BD teardown fix#1996aaronber0614 wants to merge 8 commits into
Conversation
|
/azp run |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
When a packet is routed into an L3 VXLAN tunnel, VPP builds the inner Ethernet header using the tunnel interface hardware MAC as the source. The interface default is VPPs auto-generated MAC (02:fe:..), which HW ASICs and the VNET decap tests do not expect. Override the tunnel interface MAC with the router MAC after creating the encap, via a new sw_interface_set_mac_by_index binary API helper. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3446b9ac-fa7f-4d26-914b-a4f076c603aa Signed-off-by: Aaron Bernardino <aaronber@microsoft.com>
…ecap
Extend the VPP virtual-switch SAI tunnel adaptation (vslib/vpp) to
program source-independent VNET tunnel termination, so decap matches on
local dst + VNI while ignoring the outer source IP. This supports RIOT /
secondary-VTEP topologies where encapsulated traffic may arrive from a
VTEP other than the primary tunnel source, which previously failed to
decap.
vslib/vpp/TunnelManager.{cpp,h}: add the decap-any tunnel-term wiring.
Stacked on top of the existing tunnel inner-source-MAC override.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 3446b9ac-fa7f-4d26-914b-a4f076c603aa
Signed-off-by: Aaron Bernardino <aaronber@microsoft.com>
eba10f6 to
717dd0a
Compare
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Address code-review findings on the L3 VXLAN VNET decap term handling in TunnelManager: - Refcount the VRF0 local-receive route by VTEP IP. Multiple VNIs can share one secondary VTEP, so program the route on the first term and remove it only on the last. Tearing down one VNI no longer removes the shared route and breaks decap for its siblings. - Check every VPP API return in create_vxlan_decap_term (interface state, L2 bridge bind, VRF set, both BVI address adds) and roll back the BD/BVI on failure instead of proceeding half-programmed and returning success. - Set decap_any on both L3 VNET decap tunnel requests so the decap term is source-independent. This covers the secondary-VTEP path (create_vxlan_decap_term) and the primary-VTEP L3 VNET path (tunnel_encap_nexthop_action, VIRTUAL_ROUTER_ID_TO_VNI mappers). L2 EVPN tunnels (create_l2_vxlan_tunnel_for_vni) intentionally leave decap_any unset to keep exact outer-source validation. SaiVppXlate signals the flag to VPP via the high bit of decap_next_index, forcing a valid default next index so the flag stays distinguishable. - Install L3 (VNI_TO_VIRTUAL_ROUTER_ID) decap terms from the tunnel-create path as well, so a TUNNEL created after its TUNNEL_MAP_ENTRY still gets its decap term programmed. A shared install_l3_vxlan_decap_terms helper keeps the map-entry and tunnel-create paths idempotent. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3446b9ac-fa7f-4d26-914b-a4f076c603aa Signed-off-by: Aaron Bernardino <aaronber@microsoft.com>
717dd0a to
2329bf9
Compare
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
remove_vpp_vxlan_decap deleted the bridge-domain while the VXLAN tunnel interface was still a member of it. The tunnel is only removed later by remove_vpp_vxlan_encap, so at BD-delete time the BD still had a member and vpp_bridge_domain_add_del(is_add=0) failed with -120 (bridge-domain in use). This surfaced as a syncd ERR log during L3 VNET decap teardown and tripped loganalyzer in the vxlan ECMP tests, although it was functionally benign (the BD was reclaimed once the tunnel was later removed). Detach the tunnel interface from the BD (set_sw_interface_l2_bridge_by_index with is_add=false) before freeing the bd_id and deleting the bridge-domain. Validated on a t1-lag-vpp testbed: vxlan/test_vxlan_ecmp.py no longer emits the -120 bridge-domain delete error and leaves zero bridge-domains in use. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3446b9ac-fa7f-4d26-914b-a4f076c603aa Signed-off-by: Aaron Bernardino <aaronber@microsoft.com>
2329bf9 to
a9b16c4
Compare
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Bring the saivpp VXLAN branch up to date with sonic-net/sonic-sairedis master so it builds against and re-runs the current Azure pipeline. No code conflicts; merge is clean. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3446b9ac-fa7f-4d26-914b-a4f076c603aa Signed-off-by: Aaron Bernardino <aaronber@microsoft.com>
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
The sonic-sairedis swsslogentercheck.sh test requires every method to call SWSS_LOG_ENTER() as its first statement. The vxlan_decap_term_set_dst helper in TunnelManager.cpp was missing it, failing "Run sonic sairedis unit tests" (1 of 11 tests) in the Build and BuildAsan legs. Add the macro to match the rest of the file. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3446b9ac-fa7f-4d26-914b-a4f076c603aa Signed-off-by: Aaron Bernardino <aaronber@microsoft.com>
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
3af0195 to
9aa0dca
Compare
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
/azp run |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
Reviewed alongside sonic-platform-vpp#262 and sonic-mgmt#26220. The new decap-term code reads well — the rollback ladders in One thing worth fixing before merge, plus a couple of nits. Stale patch numbers in commentsTwo comments reference "patch 0014" as the VPP patch that implements the source-independent decap:
In the series as it stands in sonic-platform-vpp#262 that patch is 0017 ( For what it's worth I did check the part that actually matters: Encoding the flag in
|
Reviewer feedback on sonic-net#1996: - Fix stale VPP patch-number references: the source-independent decap patch is 0017 (0014 is now an unrelated sflow patch after the series was renumbered). Corrects the two pointers in TunnelManager.cpp and SaiVppXlate.h that a future reader follows to find the VPP half of the decap_any contract. - Document the version coupling of the decap_next_index high-bit flag: 0x80000001 against a VPP without patch 0017 is undefined behaviour, so saivpp and the VPP image must be version-locked together. - install_l3_vxlan_decap_terms(): add a comment stating the best-effort /idempotent policy (called from both the map-entry and late-tunnel hooks, so an incomplete intermediate state must return SUCCESS). - vxlan_decap_term_set_dst(): make the IPv6 placeholder correct by construction. Flipping s6_addr[8] alone could zero all top-12 bytes for a src of the form ::0100:0:xxxx:xxxx and misclassify dst as IPv4; also force a fixed non-zero, non-multicast high-order byte. - create_vxlan_decap_term(): reuse the rollback_bd_bvi lambda in the three post-tunnel failure paths instead of open-coding the same steps. Signed-off-by: Aaron Bernardino <aaronber@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3446b9ac-fa7f-4d26-914b-a4f076c603aa
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
Thanks for the careful read @yejianquan. Pushed Stale patch numbers (0014 → 0017). Fixed both pointers — the
Version coupling of the high-bit flag. Added an explicit sentence to the
IPv6
|
There was a problem hiding this comment.
Pull request overview
This PR enhances the sonic-vpp (vslib/vpp) VXLAN implementation to support correct L3 VNET decapsulation behavior (including source-independent decap) and hardens VXLAN decap setup/teardown to avoid known failure modes during tunnel lifecycle operations.
Changes:
- Add support for source-independent VXLAN decap terms (“decap_any”) by encoding a flag into
decap_next_indexfor patched VPP VXLAN behavior. - Add a VPP binary-API helper to set a tunnel interface MAC by
sw_if_index, and use it so L3 VXLAN inner source MAC matches the router MAC. - Add L3 secondary-VTEP decap term install/teardown logic and a late-tunnel hook to handle out-of-order tunnel vs. map-entry creation; adjust BD teardown ordering to avoid BD-in-use errors.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| vslib/vpp/vppxlate/SaiVppXlate.h | Adds decap-any flag encoding definitions, extends VXLAN tunnel struct, and declares sw_interface_set_mac_by_index. |
| vslib/vpp/vppxlate/SaiVppXlate.c | Implements sw_interface_set_mac_by_index and encodes decap_any into the wire decap_next_index. |
| vslib/vpp/TunnelManager.h | Introduces APIs and state for L3 secondary-VTEP decap term install/teardown and refcounting. |
| vslib/vpp/TunnelManager.cpp | Programs decap-any for L3 VNET, sets tunnel MAC to router MAC, adds L3 decap term install/remove logic, and fixes BD teardown ordering. |
| vslib/vpp/SwitchVpp.cpp | Invokes the late-tunnel hook after VXLAN tunnel creation to backfill missing L3 decap terms. |
|
Thanks — the updates in The IPv6 fix is better than what I suggested: forcing On the third stale reference at One thing I'd like to flag before this mergesI think the Copilot comment on the early return in sai_object_id_t term_oid;
sai_deserialize_object_id(map_entry_serialized_oid, term_oid);
if (m_vxlan_decap_term_map.find(term_oid) != m_vxlan_decap_term_map.end()) {
return SAI_STATUS_SUCCESS; // already installed
}but the work it guards is per-tunnel — the function goes on to loop over every tunnel referencing the mapper and create a decap term for each, storing them as a vector under that one key. So:
The pure late-tunnel case you designed the hook for is safe, because when no tunnel exists yet Making the guard per (map entry, VTEP) rather than per map entry would close it — e.g. keep the vector but skip only the tunnels whose VTEP IP already has a term recorded under that entry, so a newly-appearing tunnel still gets one. That also makes the function properly idempotent in the sense the comment claims. Worth confirming against a run of On the other three Copilot commentsFor what it's worth, I read the one about the The two about unchecked return codes ( |
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
Thanks @yejianquan — you're right on all three, and I've pushed the fix as Per-(map entry, VTEP) guardImplemented exactly as you suggested. I kept the vector under the map-entry key but replaced the whole-entry early-return with per-VTEP idempotency. The function now:
So the step-3 scenario you described — tunnel The two unchecked return codesBoth added as (non-fatal) error logs:
The
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (4)
vslib/vpp/TunnelManager.cpp:470
- remove_vpp_vxlan_decap() returns the bridge-domain id to dynamic_bd_id_pool before attempting to delete the bridge domain. If vpp_bridge_domain_add_del(bd_id, false) fails (e.g., BD still in use), the id can be reallocated while the old bridge-domain still exists; the current code also logs a successful delete unconditionally.
This issue also appears on line 1305 of the same file.
m_switch_db->dynamic_bd_id_pool.free(tunnel_data.bd_id);
refresh_interfaces_list();
//bd is create automatically when the fist interface is add to it but requires manual deletion
vpp_bridge_domain_add_del(tunnel_data.bd_id, false);
vslib/vpp/TunnelManager.cpp:1309
- remove_vxlan_decap_term() frees the bridge-domain id back to dynamic_bd_id_pool before deleting the bridge-domain (and ignores the delete return code). If vpp_bridge_domain_add_del() fails, the id can be reused while the old bridge-domain still exists; the current code also logs successful teardown regardless of BD delete result.
snprintf(hw_bvi_ifname, sizeof(hw_bvi_ifname), "bvi%u", tunnel_data.bd_id);
delete_bvi_interface(hw_bvi_ifname);
m_switch_db->dynamic_bd_id_pool.free(tunnel_data.bd_id);
refresh_interfaces_list();
vpp_bridge_domain_add_del(tunnel_data.bd_id, false);
vslib/vpp/TunnelManager.cpp:1297
- remove_vxlan_decap_term() deletes the decap-only VXLAN tunnel without setting req.decap_any=true. Since vpp_vxlan_tunnel_add_del encodes the source-independent decap behavior via the high-bit flag, omitting it on delete can leave the decap-any entry/tunnel state behind in VPP.
req.instance = ~0;
req.vni = tunnel_data.vni;
req.decap_next_index = ~0;
sai_ip_address_t src_nc = tunnel_data.src_ip;
sai_ip_address_t_to_vpp_ip_addr_t(src_nc, req.src_address);
vslib/vpp/SwitchVpp.cpp:1528
- handle_l3_vxlan_tunnel_create() is invoked unconditionally even if create_l2_vxlan_tunnel() fails and SwitchVpp::create returns a failure status. That can program L3 secondary-VTEP decap state for a tunnel create that ultimately fails, potentially leaking VPP resources.
sai_status_t status = m_tunnel_mgr.create_l2_vxlan_tunnel(object_id, sw_if_index);
SWSS_LOG_INFO("L2 VXLAN tunnel create for %s: status=%d sw_if_index=%u",
serializedObjectId.c_str(), status, sw_if_index);
// Late-tunnel hook: install any L3 secondary-VTEP decap terms whose
// TUNNEL_MAP_ENTRY was created before this tunnel existed (M3).
m_tunnel_mgr.handle_l3_vxlan_tunnel_create(object_id);
return status;
install_l3_vxlan_decap_terms() guarded idempotency on the tunnel map entry OID as a whole, but the decap terms recorded under an entry are per-tunnel (one per VTEP source IP). A tunnel created after the entry was first processed (e.g. a second VTEP referencing the same mapper) hit the whole-entry early-return and never got its own decap term, so decap for that VTEP silently failed. Make idempotency per-(map entry, VTEP): skip only VTEPs already recorded under the entry (or installed earlier in the same pass) and append newly appearing VTEPs to the entry's vector instead of overwriting it. Reuse the existing saivs::sai_ip_address_equal helper for the VTEP comparison. Also check and log the previously ignored return codes of sw_interface_set_mac_by_index() (router MAC on the encap tunnel) and the unbridge set_sw_interface_l2_bridge_by_index() in remove_vpp_vxlan_decap() so these failures are diagnosable instead of silent. Verified on a t1-lag-vpp testbed: test_vxlan_multiple_tunnels.py 16/16 passed, BGP 24/24, no new cores. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3446b9ac-fa7f-4d26-914b-a4f076c603aa Signed-off-by: Aaron Bernardino <aaronber@microsoft.com>
5553d17 to
fc3bb73
Compare
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
@yejianquan quick follow up on your cross note about the map entry granularity early return in Fixed in Worth recording for the merge notes though. I ran For the record the run stayed healthy end to end, BGP 24 of 24 and no new cores. If you think it's worth locking down I can add a dedicated multi VTEP ordering case to the sonic-mgmt set as a follow up so this path gets explicit coverage. |
Description of PR
Summary:
Enable L3 VXLAN decap on the sonic-vpp platform (saivpp / vslib/vpp) and fix
several pre-existing decap setup/teardown defects found during review.
Part of sonic-net/sonic-buildimage#25777
Depends on the VPP patch series in sonic-net/sonic-platform-vpp#262 being in the
built image first. All changes are confined to vslib/vpp.
Changes:
primary and secondary L3 VNET paths; L2 EVPN tunnels intentionally keep exact
outer-source validation.
sw_interface_set_mac_by_index binary-API helper, so the inner Ethernet header
matches what HW ASICs and the VNET decap tests expect (default was VPP's
auto-generated 02:fe:.. MAC).
shared VRF0 VTEP local-receive route so tearing down one VNI does not break
its siblings; check every VPP API return in create_vxlan_decap_term and roll
back the BD/BVI on failure instead of returning success half-programmed; and
install the L3 decap terms from the tunnel-create path too, so a tunnel
created after its map entry still gets programmed.
BD in remove_vpp_vxlan_decap: the tunnel was still a BD member at delete time
(it is removed later by remove_vpp_vxlan_encap), so
vpp_bridge_domain_add_del(is_add=0) failed with -120 (BD in use). Benign (BD
reclaimed later) but it tripped loganalyzer during teardown.
Files: vslib/vpp/{TunnelManager.cpp, TunnelManager.h, SwitchVpp.cpp,
vppxlate/SaiVppXlate.c, vppxlate/SaiVppXlate.h}.
Type of change
Approach
What is the motivation for this PR?
Enable correct L3 VXLAN decap on sonic-vpp and remove decap setup/teardown
defects: source-dependent decap, wrong inner source MAC, and the BD-in-use
teardown error.
How did you do it?
Changes in vslib/vpp (TunnelManager, SwitchVpp, SaiVppXlate) to install
source-independent decap terms, set the tunnel inner source MAC, and fix the BD
member-detach ordering on teardown.
How did you verify/test it?
Rebuilt syncd-vpp, hot-swapped onto a t1-lag-vpp testbed, and ran the VXLAN
regression suite: test_vnet_decap 4/4, test_vxlan_multiple_tunnels 16/16, and
vxlan/test_vxlan_ecmp.py with zero -120 bridge-domain-delete errors and zero
leaked bridge-domains after teardown.
Any platform specific information?
sonic-vpp (vslib/vpp) only; no other platform is affected.
Documentation
No doc/HLD changes.