You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(xdp): propagate XDP rule plumbing failures to caller (#5948)
Fixes#5935
## Problem
`CxPlatDpRawPlumbRulesOnSocket`, `CxPlatDpRawInterfaceAddRules`, and
`CxPlatDpRawInterfaceUpdateRules` all returned `void`, silently dropping
failures from `XdpCreateProgram`, allocation failures, and rule
overflow. When XDP is required without OS socket fallback (e.g. CIBIR +
XDP server sockets as introduced in #5798), a silent failure means the
socket accepts no traffic with no indication to the application.
## Fix
Changed all three functions to return `QUIC_STATUS` and propagate errors
up through the call chain to the caller.
**`CxPlatDpRawInterfaceUpdateRules`:** Tracks the first
`XdpCreateProgram` failure across all queues and returns it after all
queues are attempted.
**`CxPlatDpRawInterfaceAddRules`:** Returns
`QUIC_STATUS_BUFFER_TOO_SMALL` on rule overflow,
`QUIC_STATUS_OUT_OF_MEMORY` on alloc failure, and propagates the return
value from `CxPlatDpRawInterfaceUpdateRules`. Fixed a pre-existing
PortSet memory leak — the buffer is now freed when `AddRules` fails
before copying the rule into `Interface->Rules`.
**`CxPlatDpRawPlumbRulesOnSocket`:** Propagates failures from
`CxPlatDpRawInterfaceAddRules`. On failure, both Wildcard and
non-Wildcard branches now break at the first failure and perform
best-effort rollback of already-configured interfaces before returning.
The Wildcard branch calls `CxPlatDpRawInterfaceRemoveRules` on
interfaces that were already configured. The non-Wildcard branch clears
the port bit on interfaces that were already configured.
**`datapath_raw.h`:** Updated declaration from `void` to `QUIC_STATUS`.
**`datapath_raw.c` (`RawSocketDelete`):** Deletion is best-effort — logs
a warning on failure rather than silently discarding the return value.
**`datapath_raw_win.c`:** Creation path now checks the return value of
`CxPlatDpRawPlumbRulesOnSocket` and calls `CxPlatRemoveSocket` to roll
back on failure.
Note: `CxPlatDpRawInterfaceRemoveRules` is intentionally left as `void`
— rule removal failures are out of scope for this fix.
## Testing
All 30 `DataPathTest` cases pass on Linux (`msquicplatformtest
--gtest_filter="DataPathTest*"`).
The XDP rule plumbing cleanup paths in `CxPlatDpRawPlumbRulesOnSocket`
are Windows-only — `datapath_raw_xdp_win.c` is excluded from the Linux
build entirely. The existing `QUIC_TEST_DATAPATH_HOOKS` infrastructure
operates at the packet layer in `binding.c` and cannot reach
`CxPlatDpRawInterfaceAddRules` in the XDP platform layer. Wiring failure
injection there would require adding a new callback to the hook struct —
happy to do this if the team considers it worth the effort.
---------
Co-authored-by: Jack He <jackhe@microsoft.com>
0 commit comments