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

Configure Feed

Select the types of activity you want to include in your feed.

net: mctp: Treat MCTP_NET_ANY specially in bind()

When a specific EID is passed as a bind address, it only makes sense to
interpret with an actual network ID, so resolve that to the default
network at bind time.

For bind address of MCTP_ADDR_ANY, we want to be able to capture traffic
to any network and address, so keep the current behaviour of matching
traffic from any network interface (don't interpret MCTP_NET_ANY as
the default network ID).

Signed-off-by: Matt Johnston <matt@codeconstruct.com.au>
Link: https://patch.msgid.link/20250710-mctp-bind-v4-3-8ec2f6460c56@codeconstruct.com.au
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Matt Johnston and committed by
Paolo Abeni
5000268c 39545023

+15 -1
+15 -1
net/mctp/af_mctp.c
··· 53 53 { 54 54 struct sock *sk = sock->sk; 55 55 struct mctp_sock *msk = container_of(sk, struct mctp_sock, sk); 56 + struct net *net = sock_net(&msk->sk); 56 57 struct sockaddr_mctp *smctp; 57 58 int rc; 58 59 ··· 78 77 rc = -EADDRINUSE; 79 78 goto out_release; 80 79 } 81 - msk->bind_net = smctp->smctp_network; 80 + 82 81 msk->bind_addr = smctp->smctp_addr.s_addr; 82 + 83 + /* MCTP_NET_ANY with a specific EID is resolved to the default net 84 + * at bind() time. 85 + * For bind_addr=MCTP_ADDR_ANY it is handled specially at route 86 + * lookup time. 87 + */ 88 + if (smctp->smctp_network == MCTP_NET_ANY && 89 + msk->bind_addr != MCTP_ADDR_ANY) { 90 + msk->bind_net = mctp_default_net(net); 91 + } else { 92 + msk->bind_net = smctp->smctp_network; 93 + } 94 + 83 95 msk->bind_type = smctp->smctp_type & 0x7f; /* ignore the IC bit */ 84 96 85 97 rc = sk->sk_prot->hash(sk);