Skip to content
Closed
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
6 changes: 3 additions & 3 deletions src/mctpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2103,15 +2103,15 @@ static int remove_bridged_peers(struct peer *bridge)
n = lookup_net(bridge->ctx, bridge->net);
pool_start = bridge->pool_start;

if (!sources)
return 0;
if (!n)
return -EPROTO;

for (ep = pool_start; ep <= pool_end; ep++) {
// stop endpoint polling before removing peer
// else next trigger will create peer again.
int idx = ep - pool_start;

if (sources[idx]) {
if (sources && sources[idx]) {
pctx = sd_event_source_get_userdata(sources[idx]);
rc = sd_event_source_set_enabled(sources[idx],
SD_EVENT_OFF);
Expand Down
34 changes: 34 additions & 0 deletions tests/test_mctpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,40 @@ async def test_bridged_learn_endpoint(dbus, mctpd):
assert new


async def test_bridged_learn_endpoint_remove(dbus, mctpd):
"""Test that removing a bridge node removes downstream endpoints learned via LearnEndpoint"""
iface = mctpd.system.interfaces[0]
ep = mctpd.network.endpoints[0]
br_ep = Endpoint(iface, bytes(), eid=10, types=[0, 2])
ep.add_bridged_ep(br_ep)
mctpd.network.add_endpoint(br_ep)

mctp = await mctpd_mctp_iface_obj(dbus, iface)
(bridge_eid, _, bridge_path, new) = await mctp.call_assign_endpoint(
ep.lladdr
)
assert new
assert ep.allocated_pool is not None

await mctpd.system.add_route(mctpd.system.Route(br_ep.eid, 1, iface=iface))
await mctpd.system.add_neighbour(
mctpd.system.Neighbour(iface, ep.lladdr, br_ep.eid)
)

net = await mctpd_mctp_network_obj(dbus, iface.net)
(downstream_path, new_ds) = await net.call_learn_endpoint(br_ep.eid)
assert new_ds

ds_obj = await mctpd_mctp_endpoint_common_obj(dbus, downstream_path)
assert ds_obj is not None

bridge_obj = await mctpd_mctp_endpoint_control_obj(dbus, bridge_path)
await bridge_obj.call_remove()

with pytest.raises(asyncdbus.errors.DBusError):
await mctpd_mctp_endpoint_common_obj(dbus, downstream_path)


async def test_network_learn_endpoint_absent(dbus, mctpd):
iface = mctpd.system.interfaces[0]

Expand Down
Loading