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

[TCP]: Fix zero port problem in IPv6

When we link a socket into the hash table, we need to make sure that we
set the num/port fields so that it shows us with a non-zero port value
in proc/netlink and on the wire. This code and comment is copied over
from the IPv4 stack as is.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Herbert Xu and committed by
David S. Miller
3759fa9c c33d4568

+5 -1
+5 -1
net/ipv6/inet6_hashtables.c
··· 87 87 struct inet_timewait_sock **twp) 88 88 { 89 89 struct inet_hashinfo *hinfo = death_row->hashinfo; 90 - const struct inet_sock *inet = inet_sk(sk); 90 + struct inet_sock *inet = inet_sk(sk); 91 91 const struct ipv6_pinfo *np = inet6_sk(sk); 92 92 const struct in6_addr *daddr = &np->rcv_saddr; 93 93 const struct in6_addr *saddr = &np->daddr; ··· 129 129 } 130 130 131 131 unique: 132 + /* Must record num and sport now. Otherwise we will see 133 + * in hash table socket with a funny identity. */ 134 + inet->num = lport; 135 + inet->sport = htons(lport); 132 136 BUG_TRAP(sk_unhashed(sk)); 133 137 __sk_add_node(sk, &head->chain); 134 138 sk->sk_hash = hash;