netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] Add IP_LOCAL_PORT_RANGE socket option
@ 2023-01-06 10:37 Jakub Sitnicki
  2023-01-06 10:37 ` [PATCH net-next 1/2] inet: " Jakub Sitnicki
  2023-01-06 10:37 ` [PATCH net-next 2/2] selftests/net: Cover the " Jakub Sitnicki
  0 siblings, 2 replies; 6+ messages in thread
From: Jakub Sitnicki @ 2023-01-06 10:37 UTC (permalink / raw)
  To: netdev, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni
  Cc: kernel-team

This patch set is a follow up to the "How to share IPv4 addresses by
partitioning the port space" talk given at LPC 2022 [1].

Please see patch #1 for the motivation & the use case description.
Patch #2 adds tests exercising the new option in various scenarios.

If the changes were to be accepted, here is the proposed update to the ip(7)
man-page:

  IP_LOCAL_PORT_RANGE (since Linux X.Y)
         Set  or get the per-socket default local port range. This option
         can be used to clamp down the global local port  range,  defined
         by  the ip_local_port_range /proc interface described below, for
         a socket. The option takes a uint32_t value  with  the  high  16
         bits  set  to  the upper range bound, and the low 16 bits set to
         the lower range bound. Range bounds are inclusive. If the speci‐
         fied  high  or  low  bound  is  outside of the global local port
         range, or is set to zero, the set bound has no effect.

Changelog:
---------
RFC -> v1
RFC: https://lore.kernel.org/netdev/20220912225308.93659-1-jakub@cloudflare.com/

 * Allow either the high bound or the low bound, or both, to be zero
 * Add getsockopt support
 * Add selftests

Links:
------
[1]: https://lpc.events/event/16/contributions/1349/

To: netdev@vger.kernel.org
To: "David S. Miller" <davem@davemloft.net>
To: Eric Dumazet <edumazet@google.com>
To: Jakub Kicinski <kuba@kernel.org>
To: Paolo Abeni <pabeni@redhat.com>
Cc: kernel-team@cloudflare.com
Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>

---
Jakub Sitnicki (2):
      inet: Add IP_LOCAL_PORT_RANGE socket option
      selftests/net: Cover the IP_LOCAL_PORT_RANGE socket option

 include/net/inet_sock.h                            |   4 +
 include/net/ip.h                                   |   3 +-
 include/uapi/linux/in.h                            |   1 +
 net/ipv4/inet_connection_sock.c                    |  22 +-
 net/ipv4/inet_hashtables.c                         |   2 +-
 net/ipv4/ip_sockglue.c                             |  18 +
 net/ipv4/udp.c                                     |   2 +-
 tools/testing/selftests/net/Makefile               |   2 +
 tools/testing/selftests/net/ip_local_port_range.c  | 439 +++++++++++++++++++++
 tools/testing/selftests/net/ip_local_port_range.sh |   5 +
 10 files changed, 493 insertions(+), 5 deletions(-)
---
base-commit: 3d759e9e24c38758abc19a4f5e1872a6460d5745
change-id: 20221221-sockopt-port-range-e142de700f4d

Best regards,
-- 
Jakub Sitnicki <jakub@cloudflare.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-01-09 13:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-06 10:37 [PATCH net-next 0/2] Add IP_LOCAL_PORT_RANGE socket option Jakub Sitnicki
2023-01-06 10:37 ` [PATCH net-next 1/2] inet: " Jakub Sitnicki
2023-01-06 17:16   ` Kuniyuki Iwashima
2023-01-09 10:11     ` Jakub Sitnicki
2023-01-09 13:58       ` Kuniyuki Iwashima
2023-01-06 10:37 ` [PATCH net-next 2/2] selftests/net: Cover the " Jakub Sitnicki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).