Skip to content

Commit 0de55a7

Browse files
jk-ozlabsdavem330
authored andcommitted
mctp: Allow keys matching any local address
Currently, we require an exact match on an incoming packet's dest address, and the key's local_addr field. In a future change, we may want to set up a key before packets are routed, meaning we have no local address to match on. This change allows key lookups to match on local_addr = MCTP_ADDR_ANY. Signed-off-by: Jeremy Kerr <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8069b22 commit 0de55a7

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

net/mctp/route.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ static struct mctp_sock *mctp_lookup_bind(struct net *net, struct sk_buff *skb)
7676
static bool mctp_key_match(struct mctp_sk_key *key, mctp_eid_t local,
7777
mctp_eid_t peer, u8 tag)
7878
{
79-
if (key->local_addr != local)
79+
if (!mctp_address_matches(key->local_addr, local))
8080
return false;
8181

8282
if (key->peer_addr != peer)
@@ -616,7 +616,7 @@ static struct mctp_sk_key *mctp_alloc_local_tag(struct mctp_sock *msk,
616616
continue;
617617

618618
if (!(mctp_address_matches(tmp->peer_addr, daddr) &&
619-
tmp->local_addr == saddr))
619+
mctp_address_matches(tmp->local_addr, saddr)))
620620
continue;
621621

622622
spin_lock(&tmp->lock);

net/mctp/test/route-test.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,14 @@ static const struct mctp_route_input_sk_keys_test mctp_route_input_sk_keys_tests
645645
.hdr = RX_HDR(1, 11, 8, FL_S | FL_E | FL_T(1)),
646646
.deliver = true,
647647
},
648+
{
649+
.name = "any local match",
650+
.key_peer_addr = 12,
651+
.key_local_addr = MCTP_ADDR_ANY,
652+
.key_tag = 1,
653+
.hdr = RX_HDR(1, 12, 8, FL_S | FL_E | FL_T(1)),
654+
.deliver = true,
655+
},
648656
};
649657

650658
static void mctp_route_input_sk_keys_to_desc(

0 commit comments

Comments
 (0)