Skip to content

Commit 1303e95

Browse files
mctpd: fix route creation for bridged gatewayed endpoints
if ifindex is zero and mctp_fq_addr is valid then only gateway routes are created. Immediately after birdge allocates the EID to downstream endpoint, they could initiate communication to bridge -> busowner which requires routes to those endpoints for busowner to respond back. Fix: update ifindex as zero for gateway route creation and deletion. Also setup routes for downstream endpoints right allocation of eid happens by the bridge. Signed-off-by: Faizan Ali <[email protected]>
1 parent cc7ea36 commit 1303e95

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

src/mctpd.c

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2839,8 +2839,8 @@ static int peer_route_update(struct peer *peer, uint16_t type)
28392839
gw_addr.net = peer->net;
28402840
gw_addr.eid = peer->eid;
28412841
rc = mctp_nl_route_del(peer->ctx->nl, peer->pool_start,
2842-
peer->pool_size - 1,
2843-
peer->phys.ifindex, &gw_addr);
2842+
peer->pool_size - 1, 0,
2843+
&gw_addr);
28442844
if (rc < 0)
28452845
warnx("failed to delete route for peer pool eids %d-%d %s",
28462846
peer->pool_start,
@@ -4704,12 +4704,35 @@ static int endpoint_allocate_eids(struct peer *peer)
47044704
warnx("Invalid pool start %d", peer->pool_start);
47054705
return -1;
47064706
}
4707+
/* add gateway route for all bridge's downstream eids
4708+
* after allocation the endpoint may initiate communication
4709+
* immediately, so setup routes for downstream endpoints priorly
4710+
*/
4711+
struct mctp_fq_addr gw_addr = { 0 };
4712+
gw_addr.net = peer->net;
4713+
gw_addr.eid = peer->eid;
4714+
rc = mctp_nl_route_add(peer->ctx->nl, peer->pool_start,
4715+
peer->pool_size - 1, 0, &gw_addr, peer->mtu);
4716+
if (rc < 0 && rc != -EEXIST) {
4717+
warnx("Failed to add gateway route for EID %d: %s", gw_addr.eid,
4718+
strerror(-rc));
4719+
return rc;
4720+
}
4721+
47074722
rc = endpoint_send_allocate_endpoint_ids(
47084723
peer, peer->pool_start, peer->pool_size,
47094724
mctp_ctrl_cmd_allocate_eids_alloc_eids, &allocated_pool_size,
47104725
&allocated_pool_start);
47114726
if (rc) {
47124727
warnx("Failed to allocate downstream EIDs");
4728+
// delete prior set routes for downstream endpoints
4729+
rc = mctp_nl_route_del(peer->ctx->nl, peer->pool_start,
4730+
peer->pool_size - 1, 0, &gw_addr);
4731+
if (rc < 0)
4732+
warnx("failed to delete route for peer pool eids %d-%d %s",
4733+
peer->pool_start,
4734+
peer->pool_start + peer->pool_size - 1,
4735+
strerror(-rc));
47134736
//reset peer pool
47144737
peer->pool_size = 0;
47154738
peer->pool_start = 0;
@@ -4721,19 +4744,6 @@ static int endpoint_allocate_eids(struct peer *peer)
47214744
if (!peer->pool_size)
47224745
return 0;
47234746

4724-
// add gateway route for all bridge's downstream eids
4725-
struct mctp_fq_addr gw_addr = { 0 };
4726-
gw_addr.net = peer->net;
4727-
gw_addr.eid = peer->eid;
4728-
rc = mctp_nl_route_add(peer->ctx->nl, peer->pool_start,
4729-
peer->pool_size - 1, peer->phys.ifindex,
4730-
&gw_addr, peer->mtu);
4731-
if (rc < 0 && rc != -EEXIST) {
4732-
warnx("Failed to add gateway route for EID %d: %s", gw_addr.eid,
4733-
strerror(-rc));
4734-
return rc;
4735-
}
4736-
47374747
sd_bus_add_object_vtable(peer->ctx->bus, &peer->slot_bridge, peer->path,
47384748
CC_MCTP_DBUS_IFACE_BRIDGE, bus_endpoint_bridge,
47394749
peer);

0 commit comments

Comments
 (0)