Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
re-use outgoing control protocol instance IDs (IIDs) when we re-send
commands. More instances of commands now have retry logic too.

3. When running in endpoint mode, `mctpd` will now issue responses to incoming
Set Endpoint ID commands before performing enumeration on the (bus-owner)
peer.

## [2.5] - 2026-02-17

### Added
Expand Down
43 changes: 29 additions & 14 deletions src/mctpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -894,27 +894,44 @@ static int handle_control_set_endpoint_id(struct ctx *ctx, int sd,
if (rc < 0) {
warnx("ERR: cannot add local eid %d to ifindex %d",
req->eid, addr->smctp_ifindex);
resp_len = sizeof(struct mctp_ctrl_resp);
resp->completion_code = MCTP_CTRL_CC_ERROR_NOT_READY;
reply_message(ctx, sd, resp, resp_len, addr);
return rc;
}

rc = add_peer_from_addr(ctx, addr, &peer);
if (rc == 0) {
rc = setup_added_peer(peer);
}
if (rc < 0) {
warnx("ERR: cannot add bus owner to object lists");
if (rc) {
errno = -rc;
warn("failed setting up bus owner, rejecting Set EID");
resp->completion_code = MCTP_CTRL_CC_ERROR;
resp_len = sizeof(struct mctp_ctrl_resp);
reply_message(ctx, sd, resp, resp_len, addr);
return rc;
}

if (link_data->discovered != DISCOVERY_UNSUPPORTED) {
add_peer_route(peer);

if (link_data->discovered != DISCOVERY_UNSUPPORTED)
link_data->discovered = DISCOVERY_DISCOVERED;
}

resp->status =
SET_MCTP_EID_ASSIGNMENT_STATUS(MCTP_SET_EID_ACCEPTED) |
SET_MCTP_EID_ALLOCATION_STATUS(MCTP_SET_EID_POOL_NONE);
resp->eid_set = req->eid;
resp->eid_pool_size = 0;
fprintf(stderr, "Accepted set eid %d\n", req->eid);
return reply_message(ctx, sd, resp, resp_len, addr);
rc = reply_message(ctx, sd, resp, resp_len, addr);
if (rc) {
errno = -rc;
warn("failed responding to set eid request");
return rc;
}

rc = setup_added_peer(peer);
if (rc < 0)
warnx("ERR: cannot add bus owner to object lists");

return 0;

case MCTP_SET_EID_DISCOVERED:
if (link_data->discovered == DISCOVERY_UNSUPPORTED) {
Expand Down Expand Up @@ -2591,6 +2608,8 @@ static int get_endpoint_peer(struct ctx *ctx, sd_bus_error *berr,
rc = add_peer(ctx, dest, eid, net, &peer, false);
if (rc < 0)
return rc;

add_peer_route(peer);
}

peer->endpoint_type = ep_type;
Expand Down Expand Up @@ -2970,6 +2989,7 @@ static int method_setup_endpoint(sd_bus_message *call, void *data,
} else if (rc < 0) {
goto err;
} else {
add_peer_route(peer);
peer->endpoint_type = ep_type;
peer->medium_spec = medium_spec;
rc = setup_added_peer(peer);
Expand Down Expand Up @@ -3296,11 +3316,6 @@ static int setup_added_peer(struct peer *peer)
// this with .SetMTU as needed
peer->mtu = mctp_nl_min_mtu_byindex(peer->ctx->nl, peer->phys.ifindex);

// add route before querying for non-bridged endpoints.
// bridged endpoints will use the bridge's pool range route.
if (!is_eid_in_bridge_pool(n, peer->ctx, peer->eid))
add_peer_route(peer);

rc = query_peer_properties(peer);
if (rc < 0)
goto out;
Expand Down
4 changes: 2 additions & 2 deletions tests/test_mctpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ async def test_setup_endpoint(dbus, mctpd):
assert neigh.eid == ep.eid

# we should have a route for the new endpoint too
assert len(mctpd.system.routes) == 2
assert len(mctpd.system.routes) == 1


async def test_setup_endpoint_conflict(dbus, mctpd):
Expand Down Expand Up @@ -356,7 +356,7 @@ async def test_assign_endpoint_static(dbus, mctpd):
neigh = mctpd.system.neighbours[0]
assert neigh.lladdr == dev.lladdr
assert neigh.eid == static_eid
assert len(mctpd.system.routes) == 2
assert len(mctpd.system.routes) == 1


async def test_assign_endpoint_static_allocated(dbus, mctpd):
Expand Down
Loading