Skip to content

mctpd: Remove downstream peers when bridge node is removed - #173

Open
potinlai wants to merge 1 commit into
CodeConstruct:mainfrom
potinlai:potin-remove-learn-eid
Open

mctpd: Remove downstream peers when bridge node is removed#173
potinlai wants to merge 1 commit into
CodeConstruct:mainfrom
potinlai:potin-remove-learn-eid

Conversation

@potinlai

Copy link
Copy Markdown
Contributor

Currently, remove_bridged_peers() checks 'if (!sources)' and returns
early if bridge_ep_poll.sources is NULL. The sources array is only
allocated when periodic bridge endpoint polling is enabled.

However, downstream endpoints within the allocated bridge pool range
can still be discovered and added to the network via the LearnEndpoint
D-Bus method (or static assignment) even when periodic polling is not
active.

When a bridge node is removed, the early return in
remove_bridged_peers() causes the pool iteration loop to be skipped if
polling was inactive. As a result, downstream node EID objects remain
registered in mctpd and published on D-Bus as orphaned endpoints.

Fix this by:

  1. Replacing the early 'if (!sources) return 0;' check with network
    validation ('if (!n) return -EPROTO;').
  2. Guarding polling timer teardown with 'if (sources && sources[idx])'.

This ensures remove_bridged_peers() always iterates across the bridge's
allocated pool range [pool_start, pool_end] and invokes remove_peer() on
all existing downstream node EID objects when the parent bridge node is
removed.

Currently, remove_bridged_peers() checks 'if (!sources)' and returns
early if bridge_ep_poll.sources is NULL. The sources array is only
allocated when periodic bridge endpoint polling is enabled.

However, downstream endpoints within the allocated bridge pool range
can still be discovered and added to the network via the LearnEndpoint
D-Bus method (or static assignment) even when periodic polling is not
active.

When a bridge node is removed, the early return in
remove_bridged_peers() causes the pool iteration loop to be skipped if
polling was inactive. As a result, downstream node EID objects remain
registered in mctpd and published on D-Bus as orphaned endpoints.

Fix this by:
1. Replacing the early 'if (!sources) return 0;' check with network
   validation ('if (!n) return -EPROTO;').
2. Guarding polling timer teardown with 'if (sources && sources[idx])'.

This ensures remove_bridged_peers() always iterates across the bridge's
allocated pool range [pool_start, pool_end] and invokes remove_peer() on
all existing downstream node EID objects when the parent bridge node is
removed.

Signed-off-by: Potin Lai <potin.lai@quantatw.com>
@jk-ozlabs jk-ozlabs self-assigned this Aug 21, 2026
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