Skip to content

pktmon: add support for dynamic pktmon registration#1034

Merged
nigriMSFT merged 12 commits into
mainfrom
nigriMSFT/pktmon-dynamic
Jun 29, 2026
Merged

pktmon: add support for dynamic pktmon registration#1034
nigriMSFT merged 12 commits into
mainfrom
nigriMSFT/pktmon-dynamic

Conversation

@nigriMSFT

Copy link
Copy Markdown
Contributor

Description

Add support for dynamic pktmon registration (pktmon can load after XDP bindings are established).

Testing

  • Adds a new functional test case to cover the handful of registration scenarios
  • Existing spin test coverage exists

Documentation

N/A

Installation

N/A

nigriMSFT and others added 2 commits June 15, 2026 16:09
When pktmon loads after XDP has already established bindings, the
XdpPktMonRegistrationCallback is invoked by the NMR provider attach.
Previously this callback was a no-op, so XDP bindings established
before pktmon would not appear in pktmon traces.

Maintain a global list of active XDP_LWF_GENERIC instances protected
by an EX_PUSH_LOCK. On generic attach, add the instance to the list;
on detach, remove it. When the pktmon registration callback fires,
iterate the list and register (or re-register) pktmon component
contexts for each active generic. Use WritePointerRelease when
publishing PktMonContext to ensure the datapath sees consistent state.

Fix a pre-existing race between the control path freeing PktMonContext
and the datapath reading it at DISPATCH_LEVEL. Add EX_RUNDOWN_REF to
XDP_LWF_GENERIC so the datapath acquires rundown protection before
accessing PktMonContext, and the control path waits for all in-flight
references to drain before freeing the context.

Add TryDisable/TryEnable helpers to TestInterface and a functional
test (GenericPktMonRegistration) that exercises four scenarios:
1. Adapter enabled while pktmon is loaded -> xdp.sys registered.
2. Adapter disabled -> xdp.sys unregistered.
3. Adapter enabled before pktmon is loaded -> xdp.sys registered.
4. Pktmon restarted while adapter is enabled -> xdp.sys re-registered.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nigriMSFT nigriMSFT requested a review from a team as a code owner June 16, 2026 00:32
Comment thread src/xdplwf/pktmon.c Outdated
Comment thread src/xdplwf/pktmon.c Outdated
Comment thread test/functional/lib/tests.cpp
@nigriMSFT

nigriMSFT commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Clearly something broken according to CI, investigating...

UPDATE: narrowed down to Mellanox issue. Disabling Mellanox Virtual Adapter during the test case as a workaround

Comment thread src/xdplwf/pktmon.c Outdated
@nigriMSFT nigriMSFT merged commit 09f9e3f into main Jun 29, 2026
94 checks passed
@nigriMSFT nigriMSFT deleted the nigriMSFT/pktmon-dynamic branch June 29, 2026 21:03
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.

2 participants