]> git.ipfire.org Git - thirdparty/linux.git/commit
selftests/net: Test tcp port reuse after unbinding a socket
authorJakub Sitnicki <jakub@cloudflare.com>
Wed, 17 Sep 2025 13:22:05 +0000 (15:22 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 23 Sep 2025 08:12:15 +0000 (10:12 +0200)
commit8a8241cdaa343c4bdb5ae11fa6cef09a2476d73b
tree3ebeb02bca04008cb2b88127207fe5ba8fd07f20
parentd57f4b874946e997be52f5ebb5e0e1dad368c16f
selftests/net: Test tcp port reuse after unbinding a socket

Exercise the scenario described in detail in the cover letter:

  1) socket A: connect() from ephemeral port X
  2) socket B: explicitly bind() to port X
  3) check that port X is now excluded from ephemeral ports
  4) close socket B to release the port bind
  5) socket C: connect() from ephemeral port X

As well as a corner case to test that the connect-bind flag is cleared:

  1) connect() from ephemeral port X
  2) disconnect the socket with connect(AF_UNSPEC)
  3) bind() it explicitly to port X
  4) check that port X is now excluded from ephemeral ports

Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
Link: https://patch.msgid.link/20250917-update-bind-bucket-state-on-unhash-v5-2-57168b661b47@cloudflare.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
tools/testing/selftests/net/Makefile
tools/testing/selftests/net/tcp_port_share.c [new file with mode: 0644]