diff options
| author | Matt Johnston <[email protected]> | 2025-07-10 08:55:58 +0000 |
|---|---|---|
| committer | Paolo Abeni <[email protected]> | 2025-07-15 10:08:39 +0000 |
| commit | 1aeed732f4f885ad36280ca4afb331fa42bf7263 (patch) | |
| tree | 3dba6739897c5d804057e8f20acd98054ef32ceb /net/mctp/af_mctp.c | |
| parent | net: mctp: Add test for conflicting bind()s (diff) | |
| download | kernel-1aeed732f4f885ad36280ca4afb331fa42bf7263.tar.gz kernel-1aeed732f4f885ad36280ca4afb331fa42bf7263.zip | |
net: mctp: Use hashtable for binds
Ensure that a specific EID (remote or local) bind will match in
preference to a MCTP_ADDR_ANY bind.
This adds infrastructure for binding a socket to receive messages from a
specific remote peer address, a future commit will expose an API for
this.
Signed-off-by: Matt Johnston <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Paolo Abeni <[email protected]>
Diffstat (limited to 'net/mctp/af_mctp.c')
| -rw-r--r-- | net/mctp/af_mctp.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/net/mctp/af_mctp.c b/net/mctp/af_mctp.c index 20edaf840a60..16341de5cf28 100644 --- a/net/mctp/af_mctp.c +++ b/net/mctp/af_mctp.c @@ -626,17 +626,17 @@ static int mctp_sk_hash(struct sock *sk) struct net *net = sock_net(sk); struct sock *existing; struct mctp_sock *msk; + u32 hash; int rc; msk = container_of(sk, struct mctp_sock, sk); - /* Bind lookup runs under RCU, remain live during that. */ - sock_set_flag(sk, SOCK_RCU_FREE); + hash = mctp_bind_hash(msk->bind_type, msk->bind_addr, MCTP_ADDR_ANY); mutex_lock(&net->mctp.bind_lock); /* Prevent duplicate binds. */ - sk_for_each(existing, &net->mctp.binds) { + sk_for_each(existing, &net->mctp.binds[hash]) { struct mctp_sock *mex = container_of(existing, struct mctp_sock, sk); @@ -648,7 +648,10 @@ static int mctp_sk_hash(struct sock *sk) } } - sk_add_node_rcu(sk, &net->mctp.binds); + /* Bind lookup runs under RCU, remain live during that. */ + sock_set_flag(sk, SOCK_RCU_FREE); + + sk_add_node_rcu(sk, &net->mctp.binds[hash]); rc = 0; out: |
