Skip to contentSkip to conversation

Revert "net: Add a second bind table hashed by port and address"

PATCH In review Joanne Koong 4 participants 8 messages Jun 15, 2022 – Jun 16, 2022

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Revert "net: Add a second bind table hashed by port and address"

This reverts:

commit d5a42de8bdbe ("net: Add a second bind table hashed by port and address")
commit 538aaf9b2383 ("selftests: Add test for timing a bind request to a port with a populated bhash entry")

There are a few things that need to be fixed here:
* Updating bhash2 in cases where the socket's rcv saddr changes
* Adding bhash2 hashbucket locks

Links to syzbot reports:
https://lore.kernel.org/netdev/[email protected]/
https://lore.kernel.org/netdev/[email protected]/

Fixes d5a42de8bdbe ("net: Add a second bind table hashed by port and address")
---
 include/net/inet_connection_sock.h            |   3 -
 include/net/inet_hashtables.h                 |  68 +----
 include/net/sock.h                            |  14 -
 net/dccp/proto.c                              |  33 +--
 net/ipv4/inet_connection_sock.c               | 247 +++++-------------
 net/ipv4/inet_hashtables.c                    | 193 +-------------
 net/ipv4/tcp.c                                |  14 +-
 tools/testing/selftests/net/.gitignore        |   1 -
 tools/testing/selftests/net/Makefile          |   2 -
 tools/testing/selftests/net/bind_bhash_test.c | 119 ---------
 10 files changed, 83 insertions(+), 611 deletions(-)
 delete mode 100644 tools/testing/selftests/net/bind_bhash_test.c
include/net/inet_connection_sock.h +0 -3
index 077cd730ce2f..85cd695e7fd1 100644
@@ -25,7 +25,6 @@
 #undef INET_CSK_CLEAR_TIMERS
 
 struct inet_bind_bucket;
-struct inet_bind2_bucket;
 struct tcp_congestion_ops;
 
 /*
@@ -58,7 +57,6 @@ struct inet_connection_sock_af_ops {
  *
  * @icsk_accept_queue:	   FIFO of established children
  * @icsk_bind_hash:	   Bind node
- * @icsk_bind2_hash:	   Bind node in the bhash2 table
  * @icsk_timeout:	   Timeout
  * @icsk_retransmit_timer: Resend (no ack)
  * @icsk_rto:		   Retransmit timeout
@@ -85,7 +83,6 @@ struct inet_connection_sock {
 	struct inet_sock	  icsk_inet;
 	struct request_sock_queue icsk_accept_queue;
 	struct inet_bind_bucket	  *icsk_bind_hash;
-	struct inet_bind2_bucket  *icsk_bind2_hash;
 	unsigned long		  icsk_timeout;
  	struct timer_list	  icsk_retransmit_timer;
  	struct timer_list	  icsk_delack_timer;
include/net/inet_hashtables.h +1 -67

103 lines not on this page · raw message

include/net/sock.h +0 -14
index 304a5e39d41e..5bed1ea7a722 100644
@@ -348,7 +348,6 @@ struct sk_filter;
   *	@sk_txtime_report_errors: set report errors mode for SO_TXTIME
   *	@sk_txtime_unused: unused txtime flags
   *	@ns_tracker: tracker for netns reference
-  *	@sk_bind2_node: bind node in the bhash2 table
   */
 struct sock {
 	/*
@@ -538,7 +537,6 @@ struct sock {
 #endif
 	struct rcu_head		sk_rcu;
 	netns_tracker		ns_tracker;
-	struct hlist_node	sk_bind2_node;
 };
 
 enum sk_pacing {
@@ -819,16 +817,6 @@ static inline void sk_add_bind_node(struct sock *sk,
 	hlist_add_head(&sk->sk_bind_node, list);
 }
 
-static inline void __sk_del_bind2_node(struct sock *sk)
-{
-	__hlist_del(&sk->sk_bind2_node);
-}
-
-static inline void sk_add_bind2_node(struct sock *sk, struct hlist_head *list)
-{
-	hlist_add_head(&sk->sk_bind2_node, list);
-}
-
 #define sk_for_each(__sk, list) \
 	hlist_for_each_entry(__sk, list, sk_node)
 #define sk_for_each_rcu(__sk, list) \
@@ -846,8 +834,6 @@ static inline void sk_add_bind2_node(struct sock *sk, struct hlist_head *list)
 	hlist_for_each_entry_safe(__sk, tmp, list, sk_node)
 #define sk_for_each_bound(__sk, list) \
 	hlist_for_each_entry(__sk, list, sk_bind_node)
-#define sk_for_each_bound_bhash2(__sk, list) \
-	hlist_for_each_entry(__sk, list, sk_bind2_node)
 
 /**
  * sk_for_each_entry_offset_rcu - iterate over a list at a given struct offset
net/dccp/proto.c +5 -28
index 2e78458900f2..eb8e128e43e8 100644
@@ -1120,12 +1120,6 @@ static int __init dccp_init(void)
 				  SLAB_HWCACHE_ALIGN | SLAB_ACCOUNT, NULL);
 	if (!dccp_hashinfo.bind_bucket_cachep)
 		goto out_free_hashinfo2;
-	dccp_hashinfo.bind2_bucket_cachep =
-		kmem_cache_create("dccp_bind2_bucket",
-				  sizeof(struct inet_bind2_bucket), 0,
-				  SLAB_HWCACHE_ALIGN | SLAB_ACCOUNT, NULL);
-	if (!dccp_hashinfo.bind2_bucket_cachep)
-		goto out_free_bind_bucket_cachep;
 
 	/*
 	 * Size and allocate the main established and bind bucket
@@ -1156,7 +1150,7 @@ static int __init dccp_init(void)
 
 	if (!dccp_hashinfo.ehash) {
 		DCCP_CRIT("Failed to allocate DCCP established hash table");
-		goto out_free_bind2_bucket_cachep;
+		goto out_free_bind_bucket_cachep;
 	}
 
 	for (i = 0; i <= dccp_hashinfo.ehash_mask; i++)
@@ -1182,23 +1176,14 @@ static int __init dccp_init(void)
 		goto out_free_dccp_locks;
 	}
 
-	dccp_hashinfo.bhash2 = (struct inet_bind2_hashbucket *)
-		__get_free_pages(GFP_ATOMIC | __GFP_NOWARN, bhash_order);
-
-	if (!dccp_hashinfo.bhash2) {
-		DCCP_CRIT("Failed to allocate DCCP bind2 hash table");
-		goto out_free_dccp_bhash;
-	}
-
 	for (i = 0; i < dccp_hashinfo.bhash_size; i++) {
 		spin_lock_init(&dccp_hashinfo.bhash[i].lock);
 		INIT_HLIST_HEAD(&dccp_hashinfo.bhash[i].chain);
-		INIT_HLIST_HEAD(&dccp_hashinfo.bhash2[i].chain);
 	}
 
 	rc = dccp_mib_init();
 	if (rc)
-		goto out_free_dccp_bhash2;
+		goto out_free_dccp_bhash;
 
 	rc = dccp_ackvec_init();
 	if (rc)
@@ -1222,38 +1207,30 @@ static int __init dccp_init(void)
 	dccp_ackvec_exit();
 out_free_dccp_mib:
 	dccp_mib_exit();
-out_free_dccp_bhash2:
-	free_pages((unsigned long)dccp_hashinfo.bhash2, bhash_order);
 out_free_dccp_bhash:
 	free_pages((unsigned long)dccp_hashinfo.bhash, bhash_order);
 out_free_dccp_locks:
 	inet_ehash_locks_free(&dccp_hashinfo);
 out_free_dccp_ehash:
 	free_pages((unsigned long)dccp_hashinfo.ehash, ehash_order);
-out_free_bind2_bucket_cachep:
-	kmem_cache_destroy(dccp_hashinfo.bind2_bucket_cachep);
 out_free_bind_bucket_cachep:
 	kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep);
 out_free_hashinfo2:
 	inet_hashinfo2_free_mod(&dccp_hashinfo);
 out_fail:
 	dccp_hashinfo.bhash = NULL;
-	dccp_hashinfo.bhash2 = NULL;
 	dccp_hashinfo.ehash = NULL;
 	dccp_hashinfo.bind_bucket_cachep = NULL;
-	dccp_hashinfo.bind2_bucket_cachep = NULL;
 	return rc;
 }
 
 static void __exit dccp_fini(void)
 {
-	int bhash_order = get_order(dccp_hashinfo.bhash_size *
-				    sizeof(struct inet_bind_hashbucket));
-
 	ccid_cleanup_builtins();
 	dccp_mib_exit();
-	free_pages((unsigned long)dccp_hashinfo.bhash, bhash_order);
-	free_pages((unsigned long)dccp_hashinfo.bhash2, bhash_order);
+	free_pages((unsigned long)dccp_hashinfo.bhash,
+		   get_order(dccp_hashinfo.bhash_size *
+			     sizeof(struct inet_bind_hashbucket)));
 	free_pages((unsigned long)dccp_hashinfo.ehash,
 		   get_order((dccp_hashinfo.ehash_mask + 1) *
 			     sizeof(struct inet_ehash_bucket)));
net/ipv4/inet_connection_sock.c +64 -183

337 lines not on this page · raw message

net/ipv4/inet_hashtables.c +11 -182

300 lines not on this page · raw message

net/ipv4/tcp.c +2 -12
index 14ebb4ec4a51..0db0ec6b0a96 100644
@@ -4599,12 +4599,6 @@ void __init tcp_init(void)
 				  SLAB_HWCACHE_ALIGN | SLAB_PANIC |
 				  SLAB_ACCOUNT,
 				  NULL);
-	tcp_hashinfo.bind2_bucket_cachep =
-		kmem_cache_create("tcp_bind2_bucket",
-				  sizeof(struct inet_bind2_bucket), 0,
-				  SLAB_HWCACHE_ALIGN | SLAB_PANIC |
-				  SLAB_ACCOUNT,
-				  NULL);
 
 	/* Size and allocate the main established and bind bucket
 	 * hash tables.
@@ -4627,9 +4621,8 @@ void __init tcp_init(void)
 	if (inet_ehash_locks_alloc(&tcp_hashinfo))
 		panic("TCP: failed to alloc ehash_locks");
 	tcp_hashinfo.bhash =
-		alloc_large_system_hash("TCP bind bhash tables",
-					sizeof(struct inet_bind_hashbucket) +
-					sizeof(struct inet_bind2_hashbucket),
+		alloc_large_system_hash("TCP bind",
+					sizeof(struct inet_bind_hashbucket),
 					tcp_hashinfo.ehash_mask + 1,
 					17, /* one slot per 128 KB of memory */
 					0,
@@ -4638,12 +4631,9 @@ void __init tcp_init(void)
 					0,
 					64 * 1024);
 	tcp_hashinfo.bhash_size = 1U << tcp_hashinfo.bhash_size;
-	tcp_hashinfo.bhash2 =
-		(struct inet_bind2_hashbucket *)(tcp_hashinfo.bhash + tcp_hashinfo.bhash_size);
 	for (i = 0; i < tcp_hashinfo.bhash_size; i++) {
 		spin_lock_init(&tcp_hashinfo.bhash[i].lock);
 		INIT_HLIST_HEAD(&tcp_hashinfo.bhash[i].chain);
-		INIT_HLIST_HEAD(&tcp_hashinfo.bhash2[i].chain);
 	}
 
 
tools/testing/selftests/net/.gitignore +0 -1
index b984f8c8d523..a29f79618934 100644
@@ -37,4 +37,3 @@ gro
 ioam6_parser
 toeplitz
 cmsg_sender
-bind_bhash_test
tools/testing/selftests/net/Makefile +0 -2
index 464df13831f2..7ea54af55490 100644
@@ -59,7 +59,6 @@ TEST_GEN_FILES += toeplitz
 TEST_GEN_FILES += cmsg_sender
 TEST_GEN_FILES += stress_reuseport_listen
 TEST_PROGS += test_vxlan_vnifiltering.sh
-TEST_GEN_FILES += bind_bhash_test
 
 TEST_FILES := settings
 
@@ -70,5 +69,4 @@ include bpf/Makefile
 
 $(OUTPUT)/reuseport_bpf_numa: LDLIBS += -lnuma
 $(OUTPUT)/tcp_mmap: LDLIBS += -lpthread
-$(OUTPUT)/bind_bhash_test: LDLIBS += -lpthread
 $(OUTPUT)/tcp_inq: LDLIBS += -lpthread
tools/testing/selftests/net/bind_bhash_test.c deleted +0 -119

119 lines not on this page · raw message

Signature · 1 line
2.30.2
#1 lore raw
Quoted 11 lines · Joanne Koong

This reverts:

commit d5a42de8bdbe ("net: Add a second bind table hashed by port and address")
commit 538aaf9b2383 ("selftests: Add test for timing a bind request to a port with a populated bhash entry")

There are a few things that need to be fixed here:
* Updating bhash2 in cases where the socket's rcv saddr changes
* Adding bhash2 hashbucket locks

Quoted 7 lines

Links to syzbot reports:
https://lore.kernel.org/netdev/[email protected]/
https://lore.kernel.org/netdev/[email protected]/

Fixes d5a42de8bdbe ("net: Add a second bind table hashed by port and address")

---

Do we really need to remove the test ? It is a benchmark, and should not 'fail' on old kernels.

maintainer
#2 lore raw
Quoted 16 lines · Eric Dumazet
Quoted 15 lines · Joanne Koong

This reverts:

commit d5a42de8bdbe ("net: Add a second bind table hashed by port and address")
commit 538aaf9b2383 ("selftests: Add test for timing a bind request to a port with a populated bhash entry")

There are a few things that need to be fixed here:
* Updating bhash2 in cases where the socket's rcv saddr changes
* Adding bhash2 hashbucket locks

Links to syzbot reports:
https://lore.kernel.org/netdev/[email protected]/
https://lore.kernel.org/netdev/[email protected]/

Quoted 7 lines
Quoted 3 lines
Fixes d5a42de8bdbe ("net: Add a second bind table hashed by port and address")

---

Do we really need to remove the test ? It is a benchmark, and should not 'fail' on old kernels.

I agree it's nice to keep the self-test alive.

Side notes, not strictly related to the revert: the self test is not currently executed by make run_tests and requires some additional
setup: ulimit -n <high number>, 2001:db8:0:f101::1 being a locally available address, and a mandatory command line argument.

@Joanne: you should additionally provide a wrapper script to handle the above and update TEST_PROGS accordingly. As for this revert, could you please re-post it touching the kernel code only?

Thanks,

Paolo

maintainer
#3 lore raw
Quoted 5 lines · On Thu, 16 Jun 2022 12:01:36 +0200 Paolo Abeni wrote:
Quoted 2 lines

Do we really need to remove the test ? It is a benchmark, and should not 'fail' on old kernels.

I agree it's nice to keep the self-test alive.

Quoted 8 lines

Side notes, not strictly related to the revert: the self test is not currently executed by make run_tests and requires some additional
setup: ulimit -n <high number>, 2001:db8:0:f101::1 being a locally available address, and a mandatory command line argument.

@Joanne: you should additionally provide a wrapper script to handle the above and update TEST_PROGS accordingly. As for this revert, could you please re-post it touching the kernel code only?

Let me take the revert in for today's PR. Hope that's okay. We can revive the test in -next with the wrapper/setup issue addressed. I don't want more people to waste time bisecting the warnings this generates.

#4 lore raw
Quoted 12 lines · Jakub Kicinski
Quoted 10 lines · On Thu, 16 Jun 2022 12:01:36 +0200 Paolo Abeni wrote:
Quoted 2 lines

Do we really need to remove the test ? It is a benchmark, and should not 'fail' on old kernels.

I agree it's nice to keep the self-test alive.

Side notes, not strictly related to the revert: the self test is not currently executed by make run_tests and requires some additional
setup: ulimit -n <high number>, 2001:db8:0:f101::1 being a locally available address, and a mandatory command line argument.

Quoted 8 lines
Quoted 3 lines

@Joanne: you should additionally provide a wrapper script to handle the above and update TEST_PROGS accordingly. As for this revert, could you please re-post it touching the kernel code only?

Let me take the revert in for today's PR. Hope that's okay. We can revive the test in -next with the wrapper/setup issue addressed. I don't want more people to waste time bisecting the warnings this generates.

Note we have missing Reported-... tags to please syzbot.

#5 lore raw
Quoted 14 lines · Eric Dumazet
Quoted 12 lines · Jakub Kicinski
Quoted 10 lines · On Thu, 16 Jun 2022 12:01:36 +0200 Paolo Abeni wrote:
Quoted 2 lines

Do we really need to remove the test ? It is a benchmark, and should not 'fail' on old kernels.

I agree it's nice to keep the self-test alive.

Side notes, not strictly related to the revert: the self test is not currently executed by make run_tests and requires some additional
setup: ulimit -n <high number>, 2001:db8:0:f101::1 being a locally available address, and a mandatory command line argument.

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

@Joanne: you should additionally provide a wrapper script to handle the above and update TEST_PROGS accordingly. As for this revert, could you please re-post it touching the kernel code only?

Let me take the revert in for today's PR. Hope that's okay. We can revive the test in -next with the wrapper/setup issue addressed. I don't want more people to waste time bisecting the warnings this generates.

I'll make sure to include a wrapper script when I resubmit it.

Quoted 2 lines

Note we have missing Reported-... tags to please syzbot.

Jakub, please let me know if you want me to resubmit v2 of this with the Reported- tag added, or if you'll add that part in.

maintainer
#6 lore raw
In reply to Eric Dumazet
Quoted 7 lines · On Thu, 16 Jun 2022 19:28:49 +0200 Eric Dumazet wrote:
Quoted 4 lines · Jakub Kicinski

Let me take the revert in for today's PR. Hope that's okay. We can revive the test in -next with the wrapper/setup issue addressed. I don't want more people to waste time bisecting the warnings this generates.

Note we have missing Reported-... tags to please syzbot.

Eish, thanks! These two only:

Reported-by [email protected]
Reported-by [email protected]

or this one as well?

Reported-by [email protected]

https://syzkaller.appspot.com/bug?id=a63b46bf74a20d1a6b2893cedcda421620344479

#7 lore raw
Quoted 12 lines · Jakub Kicinski
Quoted 7 lines · On Thu, 16 Jun 2022 19:28:49 +0200 Eric Dumazet wrote:
Quoted 4 lines · Jakub Kicinski

Let me take the revert in for today's PR. Hope that's okay. We can revive the test in -next with the wrapper/setup issue addressed. I don't want more people to waste time bisecting the warnings this generates.

Note we have missing Reported-... tags to please syzbot.

Eish, thanks! These two only:

Quoted 7 lines
Reported-by [email protected]
Reported-by [email protected]

or this one as well?

Reported-by [email protected]

https://syzkaller.appspot.com/bug?id=a63b46bf74a20d1a6b2893cedcda421620344479

All of them :)
It will allow syzbot to retry its logic and perhaps find other bugs with similar signature.