netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
	David Ahern <dsahern@kernel.org>,
	Martin KaFai Lau <martin.lau@kernel.org>
Cc: Craig Gallek <kraig@google.com>,
	Willem de Bruijn <willemb@google.com>,
	Kuniyuki Iwashima <kuniyu@amazon.com>,
	Kuniyuki Iwashima <kuni1840@gmail.com>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: [PATCH v1 net 0/3] soreuseport: Fix issues related to the faster selection algorithm.
Date: Mon, 10 Oct 2022 10:43:48 -0700	[thread overview]
Message-ID: <20221010174351.11024-1-kuniyu@amazon.com> (raw)

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


             reply	other threads:[~2022-10-10 17:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-10 17:43 Kuniyuki Iwashima [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221010174351.11024-1-kuniyu@amazon.com \
    --to=kuniyu@amazon.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=kraig@google.com \
    --cc=kuba@kernel.org \
    --cc=kuni1840@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.com \
    --cc=yoshfuji@linux-ipv6.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).