Skip to content

Commit 4e683f4

Browse files
committed
Merge branch 'net-fix-reuseaddr-regression'
Josef Bacik says: ==================== net: fix reuseaddr regression I introduced a regression when reworking the fastreuse port stuff that allows bind conflicts to occur once a reuseaddr successfully opens on an existing tb. The root cause is I reversed an if statement which caused us to set the tb as if there were no owners on the socket if there were, which obviously is not correct. Dave could you please queue these changes up for -stable, I've run them through the net tests and added another test to check for this problem specifically. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 581fe0e + fbed24b commit 4e683f4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

net/ipv4/inet_connection_sock.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ static inline int sk_reuseport_match(struct inet_bind_bucket *tb,
266266
#if IS_ENABLED(CONFIG_IPV6)
267267
if (tb->fast_sk_family == AF_INET6)
268268
return ipv6_rcv_saddr_equal(&tb->fast_v6_rcv_saddr,
269-
&sk->sk_v6_rcv_saddr,
269+
inet6_rcv_saddr(sk),
270270
tb->fast_rcv_saddr,
271271
sk->sk_rcv_saddr,
272272
tb->fast_ipv6_only,
@@ -321,13 +321,14 @@ int inet_csk_get_port(struct sock *sk, unsigned short snum)
321321
goto fail_unlock;
322322
}
323323
success:
324-
if (!hlist_empty(&tb->owners)) {
324+
if (hlist_empty(&tb->owners)) {
325325
tb->fastreuse = reuse;
326326
if (sk->sk_reuseport) {
327327
tb->fastreuseport = FASTREUSEPORT_ANY;
328328
tb->fastuid = uid;
329329
tb->fast_rcv_saddr = sk->sk_rcv_saddr;
330330
tb->fast_ipv6_only = ipv6_only_sock(sk);
331+
tb->fast_sk_family = sk->sk_family;
331332
#if IS_ENABLED(CONFIG_IPV6)
332333
tb->fast_v6_rcv_saddr = sk->sk_v6_rcv_saddr;
333334
#endif
@@ -354,6 +355,7 @@ int inet_csk_get_port(struct sock *sk, unsigned short snum)
354355
tb->fastuid = uid;
355356
tb->fast_rcv_saddr = sk->sk_rcv_saddr;
356357
tb->fast_ipv6_only = ipv6_only_sock(sk);
358+
tb->fast_sk_family = sk->sk_family;
357359
#if IS_ENABLED(CONFIG_IPV6)
358360
tb->fast_v6_rcv_saddr = sk->sk_v6_rcv_saddr;
359361
#endif

0 commit comments

Comments
 (0)