All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ruilin Mao" <zibuyu423@gmail.com>, mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-next 2/2] selftests: mptcp: exercise socket option propagation and behavior
Date: Thu, 03 Dec 2026 15:22:17 +0000	[thread overview]
Message-ID: <sashiko-outbox-248099@kernel.org> (raw)
In-Reply-To: <179630953225.20.15369199654780650380.mptcp-525-0002@gmail.com>

Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] selftests/mptcp: rx_timestamp test races with async
  net_enable_timestamp()
- [Low] selftests/mptcp: uninitialized buffer read in
  check_bound_device()
- [Low] selftests/mptcp: buffer_sizes SO_SNDBUF 8192 doubles to default
  tcp_wmem[1]
- [Low] selftests: mptcp: missing netns isolation and EADDRNOTAVAIL skip
--

commit 10945eef75cc34706855384a71c16cd54ded5d2b
Author: Ruilin Mao <zibuyu423@gmail.com>

selftests: mptcp: exercise socket option propagation and behavior

This commit adds a new kselftest harness binary, mptcp_sockopt_test, to
verify listener socket option propagation onto fallback TCP children and
software RX timestamping on MPTCP connections.

Link: https://github.com/multipath-tcp/mptcp_net-next/issues/525

> diff --git a/tools/testing/selftests/net/mptcp/Makefile b/tools/testing/selftests/net/mptcp/Makefile
> index 22ba0da2adb85..a4c2a611dd5ed 100644
> --- a/tools/testing/selftests/net/mptcp/Makefile
> +++ b/tools/testing/selftests/net/mptcp/Makefile
> @@ -19,6 +19,8 @@ TEST_PROGS := \
>  	userspace_pm.sh \
>  # end of TEST_PROGS
>  
> +TEST_GEN_PROGS := mptcp_sockopt_test
> +
>  TEST_GEN_FILES := \
>  	mptcp_connect \
>  	mptcp_diag \

[Severity: Low]
Can running mptcp_sockopt_test directly in the host network namespace cause
spurious failures from host sysctl settings?

With net.ipv4.tcp_syncookies=2 on the host, tcp_conn_request() issues a SYN
cookie and the peer's bare ACK bypasses tcp_check_req() where
rskq_defer_accept drops bare ACKs, waking the listener early and failing the
poll() check in defer_accept.  Running the test in an isolated network
namespace (like the other MPTCP selftests, while keeping unprivileged runs
working) avoids host sysctl interference.

Separately, when IPv6 is disabled on lo via net.ipv6.conf.lo.disable_ipv6=1
or ipv6.disable_ipv6=1, socket(AF_INET6, ...) still succeeds in
FIXTURE_SETUP() and bind() in start_listener() fails with EADDRNOTAVAIL
instead of skipping the IPv6 variant.

> diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt_test.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt_test.c
> new file mode 100644
> index 0000000000000..48ca5522ed0b7
> --- /dev/null
> +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt_test.c

[ ... ]

> +TEST_F(sockopt, rx_timestamp)
> +{

[ ... ]

> +		connect_pair(_metadata, &self->server, IPPROTO_MPTCP, &client, &child);
> +		ASSERT_EQ(setsockopt(child, SOL_SOCKET, SO_TIMESTAMPING_NEW, &opt, optlen), 0);
> +		ASSERT_EQ(write(client, &byte, 1), 1);
> +		ASSERT_EQ(recvmsg(child, &msg, 0), 1);
> +		ASSERT_EQ(msg.msg_flags & MSG_CTRUNC, 0);
> +		cmsg = CMSG_FIRSTHDR(&msg);
> +		ASSERT_NE(cmsg, NULL);

[Severity: Medium]
Can rx_timestamp race with asynchronous timestamping activation and fail
flakily?

Under CONFIG_JUMP_LABEL, when no other socket holds RX software timestamping
active, net_enable_timestamp() defers enabling netstamp_needed_key to
netstamp_work instead of enabling it synchronously:

CPU0 (test / softirq)           kworker
setsockopt(SO_TIMESTAMPING_NEW)
  net_enable_timestamp()
    schedule_work(&netstamp_work)
write(client, &byte, 1)
  loopback_xmit()
    skb_clear_tstamp(skb)
    __netif_rx(skb)
      net_timestamp_check()     <-- netstamp_needed_key still off
recvmsg(child, &msg, 0)         <-- no cmsg, ASSERT_NE fails
                                netstamp_clear()
                                  static_branch_enable(&netstamp_needed_key)

Without a timestamp, __mptcp_recvmsg_mskq() omits the SO_TIMESTAMPING_NEW
control message and ASSERT_NE(cmsg, NULL) fails.  Waiting briefly before
sending traffic (as tools/testing/selftests/net/rxtimestamp.c does) or
retrying would avoid the race.

[ ... ]

> +static void check_bound_device(struct __test_metadata *_metadata,
> +			       struct listener *server)
> +{
> +	int client, child;
> +	socklen_t len;
> +	char name[IFNAMSIZ];
> +
> +	start_listener(_metadata, server);
> +	connect_pair(_metadata, server, IPPROTO_TCP, &client, &child);
> +	len = sizeof(name);
> +	ASSERT_EQ(getsockopt(child, SOL_SOCKET, SO_BINDTODEVICE, name, &len), 0);
> +	ASSERT_STREQ(name, "lo");

[Severity: Low]
Can ASSERT_STREQ() read uninitialized stack bytes from name[] if the child
socket is not bound to a device?

In net/core/sock.c, sock_getbindtodevice() returns 0 with *optlen set to 0
and leaves the caller's buffer untouched when bound_dev_if == 0.  On a
regression where the binding does not propagate, ASSERT_STREQ() passes an
uninitialized, non-NUL-terminated name[] to strcmp() and failure formatting.
Zero-initializing name and checking ASSERT_EQ(len, sizeof("lo")) before
ASSERT_STREQ() prevents that.

[ ... ]

> +TEST_F(sockopt, buffer_sizes)
> +{
> +	static const int opts[] = { SO_SNDBUF, SO_RCVBUF };
> +	int child, client, size = 8192;
> +	unsigned int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(opts); i++)
> +		ASSERT_EQ(setsockopt(self->server.fd, SOL_SOCKET, opts[i],
> +				     &size, sizeof(size)), 0);
> +	start_listener(_metadata, &self->server);
> +	connect_pair(_metadata, &self->server, IPPROTO_TCP, &client, &child);
> +	for (i = 0; i < ARRAY_SIZE(opts); i++)
> +		ASSERT_EQ(read_int_opt(_metadata, child, SOL_SOCKET, opts[i]),
> +			  read_int_opt(_metadata, self->server.fd, SOL_SOCKET, opts[i]));

[Severity: Low]
Does setting SO_SNDBUF to 8192 leave sk_sndbuf at its initial default?

sk_setsockopt() doubles the requested value to 16384, which equals the
default sysctl_tcp_wmem[1] (16 * 1024) used for new TCP and MPTCP sockets,
so this test would not catch a regression that fails to copy sk_sndbuf onto
the child.  Using a size whose doubled value differs from both default
tcp_wmem[1] and tcp_rmem[1] (for example 12288) avoids matching the default.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/179630953224.20.3586549954582163150.mptcp-525-0000@gmail.com?part=2

  reply	other threads:[~2026-12-03 15:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 14:52 [PATCH mptcp-next 0/2] selftests: mptcp: exercise socket options across listen and accept Ruilin Mao
2026-12-03 14:52 ` [PATCH mptcp-next 1/2] selftests/net: use the fixture protocol in the late bind test Ruilin Mao
2026-12-03 17:32   ` Matthieu Baerts
2026-12-03 14:52 ` [PATCH mptcp-next 2/2] selftests: mptcp: exercise socket option propagation and behavior Ruilin Mao
2026-12-03 15:22   ` sashiko-bot [this message]
2026-12-05  4:09   ` netdev-bot+sashiko
2026-12-03 17:29 ` [PATCH mptcp-next 0/2] selftests: mptcp: exercise socket options across listen and accept Matthieu Baerts

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=sashiko-outbox-248099@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=zibuyu423@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.