Commit 0de55a7d authored by Jeremy Kerr's avatar Jeremy Kerr Committed by David S. Miller

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: default avatarJeremy Kerr <jk@codeconstruct.com.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8069b22d
...@@ -76,7 +76,7 @@ static struct mctp_sock *mctp_lookup_bind(struct net *net, struct sk_buff *skb) ...@@ -76,7 +76,7 @@ static struct mctp_sock *mctp_lookup_bind(struct net *net, struct sk_buff *skb)
static bool mctp_key_match(struct mctp_sk_key *key, mctp_eid_t local, static bool mctp_key_match(struct mctp_sk_key *key, mctp_eid_t local,
mctp_eid_t peer, u8 tag) mctp_eid_t peer, u8 tag)
{ {
if (key->local_addr != local) if (!mctp_address_matches(key->local_addr, local))
return false; return false;
if (key->peer_addr != peer) if (key->peer_addr != peer)
...@@ -616,7 +616,7 @@ static struct mctp_sk_key *mctp_alloc_local_tag(struct mctp_sock *msk, ...@@ -616,7 +616,7 @@ static struct mctp_sk_key *mctp_alloc_local_tag(struct mctp_sock *msk,
continue; continue;
if (!(mctp_address_matches(tmp->peer_addr, daddr) && if (!(mctp_address_matches(tmp->peer_addr, daddr) &&
tmp->local_addr == saddr)) mctp_address_matches(tmp->local_addr, saddr)))
continue; continue;
spin_lock(&tmp->lock); spin_lock(&tmp->lock);
......
...@@ -645,6 +645,14 @@ static const struct mctp_route_input_sk_keys_test mctp_route_input_sk_keys_tests ...@@ -645,6 +645,14 @@ static const struct mctp_route_input_sk_keys_test mctp_route_input_sk_keys_tests
.hdr = RX_HDR(1, 11, 8, FL_S | FL_E | FL_T(1)), .hdr = RX_HDR(1, 11, 8, FL_S | FL_E | FL_T(1)),
.deliver = true, .deliver = true,
}, },
{
.name = "any local match",
.key_peer_addr = 12,
.key_local_addr = MCTP_ADDR_ANY,
.key_tag = 1,
.hdr = RX_HDR(1, 12, 8, FL_S | FL_E | FL_T(1)),
.deliver = true,
},
}; };
static void mctp_route_input_sk_keys_to_desc( static void mctp_route_input_sk_keys_to_desc(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment