Skip to content

Commit e748dac

Browse files
committed
mctpd: Rename net_learn argument for add_peer, and explain in comments
`net_learn` only specifies the usage scenario, not the behaviour. Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
1 parent c3ac2cc commit e748dac

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/mctpd.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ static int emit_interface_removed(struct link *link);
239239
static int emit_net_added(struct ctx *ctx, struct net *net);
240240
static int emit_net_removed(struct ctx *ctx, struct net *net);
241241
static int add_peer(struct ctx *ctx, const dest_phys *dest, mctp_eid_t eid,
242-
uint32_t net, struct peer **ret_peer, bool net_learn);
242+
uint32_t net, struct peer **ret_peer, bool allow_bridged);
243243
static int add_peer_from_addr(struct ctx *ctx,
244244
const struct sockaddr_mctp_ext *addr,
245245
struct peer **ret_peer);
@@ -1600,10 +1600,13 @@ static bool is_eid_in_bridge_pool(struct net *n, struct ctx *ctx,
16001600
return false;
16011601
}
16021602

1603-
/* Returns the newly added peer.
1604-
* Error is -EEXISTS if it exists */
1603+
/* Returns the newly added peer. If @allow_bridged is set, we do not conflict
1604+
* with EIDs that are within bridge pool allocations.
1605+
*
1606+
* Error is -EEXISTS if it exists
1607+
*/
16051608
static int add_peer(struct ctx *ctx, const dest_phys *dest, mctp_eid_t eid,
1606-
uint32_t net, struct peer **ret_peer, bool net_learn)
1609+
uint32_t net, struct peer **ret_peer, bool allow_bridged)
16071610
{
16081611
struct peer *peer, **tmp;
16091612
struct net *n;
@@ -1622,11 +1625,10 @@ static int add_peer(struct ctx *ctx, const dest_phys *dest, mctp_eid_t eid,
16221625
*ret_peer = peer;
16231626
return 0;
16241627
}
1625-
/* only LearnEndpoint methods of au.com.codeconstruct.MCTP.Network1
1626-
* interface will approve peer structure if eid belongs to a bridge
1627-
* pool space else never allow.
1628+
/* In some cases, we want to allow adding a peer that exists within
1629+
* a bridged range - typically when the peer is behind that bridge.
16281630
*/
1629-
if (!net_learn & is_eid_in_bridge_pool(n, ctx, eid))
1631+
if (!allow_bridged & is_eid_in_bridge_pool(n, ctx, eid))
16301632
return -EEXIST;
16311633

16321634
if (ctx->num_peers == MAX_PEER_SIZE)

0 commit comments

Comments
 (0)