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 --- 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