Skip to content

mctpd: Support MCTP Discovery Notify command - #165

Open
chajasmine-bit wants to merge 1 commit into
CodeConstruct:mainfrom
chajasmine-bit:discovery-notify
Open

mctpd: Support MCTP Discovery Notify command#165
chajasmine-bit wants to merge 1 commit into
CodeConstruct:mainfrom
chajasmine-bit:discovery-notify

Conversation

@chajasmine-bit

Copy link
Copy Markdown

Implement support for the MCTP Discovery Notify control command in mctpd. When an MCTP endpoint issues a Discovery Notify control request to the Bus Owner, mctpd immediately acknowledges the request over the physical socket and defers EID assignment to the main systemd event loop.

This avoids blocking the event thread during control message processing and safely handles EID re-assignments via change_peer_eid(), keeping D-Bus object paths and netlink kernel routing tables synchronized. Also include unit test coverage for Discovery Notify in the test suite.

Assisted-by: Antigravity:Gemini-Next

@chajasmine-bit
chajasmine-bit force-pushed the discovery-notify branch 4 times, most recently from 4bee8eb to 9274ea2 Compare August 3, 2026 05:23
In MCTP networks, endpoints broadcast or send a Discovery Notify control
request (0x0D) to inform the Bus Owner when they boot up, reset, or are
hot-plugged. Currently, mctpd relies on active bus scanning or static
configurations, leaving newly online endpoints undiscovered until the next
poll cycle.

This change adds support for handling Discovery Notify requests when mctpd
is in the Bus Owner role:
 - Immediately acknowledges Discovery Notify requests over the physical
   socket with MCTP_CTRL_CC_SUCCESS inside handle_control_discovery_notify()
   to prevent hardware endpoints (e.g. PCIe VDMs / SMBus sequencers) from
   dropping subsequent Set Endpoint ID requests while waiting for an ACK.
 - Asynchronously defers EID assignment and route programming (RTM_NEWROUTE)
   to the systemd event loop (sd_event_add_defer) to prevent thread blocking.
 - Safely handles event deferral failures by dropping the request and
   returning -ENOMEM rather than executing synchronously in receive context,
   eliminating re-entrance and event loop corruption risks.
 - Scopes request deduplication to (ifindex, dest_phys) composite keys to
   prevent cross-bus address collisions on multi-bus platforms.
 - Enforces per-interface rate-limiting (maximum 5 discovery requests per
   second) to protect against discovery request floods.
 - Correctly supports Bridge Endpoints by reserving EID pools and
   invoking endpoint_allocate_eids() for downstream pool allocation and
   gateway routing.
 - Includes comprehensive unit test coverage in test_mctpd.py and
   test_mctpd_endpoint.py.

Assisted-by: Antigravity:Gemini-Next
Signed-off-by: Jasmine Cha <chajasmine@google.com>
@jk-ozlabs

Copy link
Copy Markdown
Member

I see there's been a few updates; let me know when this is stable and you'd like a review.

@chajasmine-bit

Copy link
Copy Markdown
Author

I see there's been a few updates; let me know when this is stable and you'd like a review.

The code is ready for review, please take a look at this. Thanks.

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