Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next] sctp: diag: set sin6_scope_id for IPv6 link-local lookup addresses
@ 2026-11-23  0:48 Xin Long
  2026-11-24  0:50 ` netdev-bot+sashiko
  0 siblings, 1 reply; 2+ messages in thread
From: Xin Long @ 2026-11-23  0:48 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: davem, kuba, Eric Dumazet, Paolo Abeni, Simon Horman,
	Marcelo Ricardo Leitner

As gomaja noticed, sctp_diag_dump_one() builds IPv6 lookup addresses on the
stack but never sets sin6_scope_id. For link-local addresses,
__sctp_v6_cmp_addr() compares scope ids, so an exact SOCK_DIAG_BY_FAMILY
query can only match a link-local association when the caller's idiag_if is
propagated into the lookup addresses.

Set sin6_scope_id from req->id.idiag_if on both laddr and paddr before the
lookup, so that exact queries for IPv6 link-local associations can succeed
when the correct interface index is supplied.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/sctp/diag.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/sctp/diag.c b/net/sctp/diag.c
index c2a0de2adf6f..dc199e3e96b1 100644
--- a/net/sctp/diag.c
+++ b/net/sctp/diag.c
@@ -455,11 +455,13 @@ static int sctp_diag_dump_one(struct netlink_callback *cb,
 		memcpy(&laddr.v6.sin6_addr, req->id.idiag_src,
 		       sizeof(laddr.v6.sin6_addr));
 		laddr.v6.sin6_family = AF_INET6;
+		laddr.v6.sin6_scope_id = req->id.idiag_if;
 
 		paddr.v6.sin6_port = req->id.idiag_dport;
 		memcpy(&paddr.v6.sin6_addr, req->id.idiag_dst,
 		       sizeof(paddr.v6.sin6_addr));
 		paddr.v6.sin6_family = AF_INET6;
+		paddr.v6.sin6_scope_id = req->id.idiag_if;
 	}
 
 	return sctp_transport_lookup_process(sctp_sock_dump_one,
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-24  0:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23  0:48 [PATCH net-next] sctp: diag: set sin6_scope_id for IPv6 link-local lookup addresses Xin Long
2026-11-24  0:50 ` netdev-bot+sashiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox