public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 net 0/3] soreuseport: Fix issues related to the faster selection algorithm.
@ 2022-10-10 17:43 Kuniyuki Iwashima
  2022-10-10 17:43 ` [PATCH v1 net 1/3] udp: Update reuse->has_conns under reuseport_lock Kuniyuki Iwashima
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Kuniyuki Iwashima @ 2022-10-10 17:43 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Hideaki YOSHIFUJI, David Ahern, Martin KaFai Lau
  Cc: Craig Gallek, Willem de Bruijn, Kuniyuki Iwashima,
	Kuniyuki Iwashima, netdev, linux-kernel

setsockopt(SO_INCOMING_CPU) for UDP/TCP is broken since 4.5/4.6 due to
these commits:

  * e32ea7e74727 ("soreuseport: fast reuseport UDP socket selection")
  * c125e80b8868 ("soreuseport: fast reuseport TCP socket selection")

These commits introduced the O(1) socket selection algorithm and removed
O(n) iteration over the list, but it ignores the score calculated by
compute_score().  As a result, it caused two misbehaviours:

  * Unconnected sockets receive packets sent to connected sockets
  * SO_INCOMING_CPU does not work

The former is fixed by commit acdcecc61285 ("udp: correct reuseport
selection with connected sockets"), but it introduced a rare race,
which the first patch fixes.  The second patch fixes the latter, and
the third adds a test for SO_INCOMING_CPU.


Kuniyuki Iwashima (3):
  udp: Update reuse->has_conns under reuseport_lock.
  soreuseport: Fix socket selection for SO_INCOMING_CPU.
  selftest: Add test for SO_INCOMING_CPU.

 include/net/sock_reuseport.h                  |  25 ++-
 net/core/sock.c                               |   5 +-
 net/core/sock_reuseport.c                     |  88 ++++++++++-
 net/ipv4/datagram.c                           |   2 +-
 net/ipv4/udp.c                                |   2 +-
 net/ipv6/datagram.c                           |   2 +-
 net/ipv6/udp.c                                |   2 +-
 tools/testing/selftests/net/.gitignore        |   1 +
 tools/testing/selftests/net/Makefile          |   1 +
 tools/testing/selftests/net/so_incoming_cpu.c | 148 ++++++++++++++++++
 10 files changed, 260 insertions(+), 16 deletions(-)
 create mode 100644 tools/testing/selftests/net/so_incoming_cpu.c

-- 
2.30.2


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

end of thread, other threads:[~2022-10-11 15:46 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-10 17:43 [PATCH v1 net 0/3] soreuseport: Fix issues related to the faster selection algorithm Kuniyuki Iwashima
2022-10-10 17:43 ` [PATCH v1 net 1/3] udp: Update reuse->has_conns under reuseport_lock Kuniyuki Iwashima
2022-10-11  1:43   ` kernel test robot
2022-10-11 10:50   ` Paolo Abeni
2022-10-11 15:16     ` Kuniyuki Iwashima
2022-10-10 17:43 ` [PATCH v1 net 2/3] soreuseport: Fix socket selection for SO_INCOMING_CPU Kuniyuki Iwashima
2022-10-11 11:28   ` Paolo Abeni
2022-10-11 15:19     ` Kuniyuki Iwashima
2022-10-10 17:43 ` [PATCH v1 net 3/3] selftest: Add test " Kuniyuki Iwashima
2022-10-11 11:34   ` Paolo Abeni
2022-10-11 15:21     ` Kuniyuki Iwashima

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox