[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Mon, 10 Oct 2022 10:43:48 -0700
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
David Ahern <dsahern@...nel.org>,
Martin KaFai Lau <martin.lau@...nel.org>
CC: Craig Gallek <kraig@...gle.com>,
Willem de Bruijn <willemb@...gle.com>,
Kuniyuki Iwashima <kuniyu@...zon.com>,
Kuniyuki Iwashima <kuni1840@...il.com>,
<netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: [PATCH v1 net 0/3] soreuseport: Fix issues related to the faster selection algorithm.
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
Powered by blists - more mailing lists