Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <jk@codeconstruct.com.au>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jeremy Kerr and committed by
David S. Miller
0de55a7d 8069b22d

+10 -2
+2 -2
net/mctp/route.c
··· 76 76 static bool mctp_key_match(struct mctp_sk_key *key, mctp_eid_t local, 77 77 mctp_eid_t peer, u8 tag) 78 78 { 79 - if (key->local_addr != local) 79 + if (!mctp_address_matches(key->local_addr, local)) 80 80 return false; 81 81 82 82 if (key->peer_addr != peer) ··· 616 616 continue; 617 617 618 618 if (!(mctp_address_matches(tmp->peer_addr, daddr) && 619 - tmp->local_addr == saddr)) 619 + mctp_address_matches(tmp->local_addr, saddr))) 620 620 continue; 621 621 622 622 spin_lock(&tmp->lock);
+8
net/mctp/test/route-test.c
··· 645 645 .hdr = RX_HDR(1, 11, 8, FL_S | FL_E | FL_T(1)), 646 646 .deliver = true, 647 647 }, 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 + }, 648 656 }; 649 657 650 658 static void mctp_route_input_sk_keys_to_desc(