All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Edoardo Canepa <edoardo.canepa@canonical.com>
Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Shuah Khan <shuah@kernel.org>, Xu Du <xudu@redhat.com>,
	Po-Hsu Lin <po-hsu.lin@canonical.com>,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v3] selftests/net: run tun tests in a dedicated network namespace
Date: Mon, 21 Sep 2026 14:09:01 +0100	[thread overview]
Message-ID: <20260921130901.GP13925@horms.kernel.org> (raw)
In-Reply-To: <20260917111520.2614448-1-edoardo.canepa@canonical.com>

On Thu, Sep 17, 2026 at 01:15:20PM +0200, Edoardo Canepa wrote:
> The tun_vnet_udptnl fixture creates a fresh tap device, assigns it a
> fixed MAC address and installs the outer neighbor entry as
> NUD_PERMANENT.  On systems where systemd-udevd is running and a systemd
> .link file sets
> 
>     MACAddressPolicy=persistent
> 
> (the default shipped by systemd in 99-default.link, so this is what
> most systemd-based hosts inherit), systemd-udevd's net_setup_link
> builtin asynchronously sends an RTM_SETLINK to reassign the freshly
> created tap device's MAC to a machine-persistent value.  When that
> lands after the fixture has configured the device, both directions
> break:
> 
> - recv_gso_packet transmits through the tap, and the address change
>   flushes the neighbor entry the fixture installed:
> 
>     do_setlink
>     -> netif_set_mac_address
>        -> call_netdevice_notifiers(NETDEV_CHANGEADDR)
>           -> ndisc_netdev_event (arp_netdev_event for an IPv4 outer)
>              -> neigh_changeaddr
>                 -> neigh_flush_dev(tbl, dev, /* skip_perm = */ false)
> 
>   so the packet hits __neigh_create() and waits on neighbor resolution
>   that never completes.
> 
> - send_gso_packet writes frames addressed to the MAC the fixture
>   assigned.  Once the tap has a different address, eth_type_trans()
>   marks them PACKET_OTHERHOST and the IP receive path drops them.
> 
> Either way nothing arrives before the receive timeout, and the test
> fails with, for example:
> 
>   tun.c:947:send_gso_packet:Expected ret (0) == variant->data_size (1)
>   tun.c:948:send_gso_packet:Expected r_num_mss (0) == variant->r_num_mss (1)
>   tun.c:962:recv_gso_packet:Expected ret (0) == variant->data_size (1)
> 
> The failure is non-deterministic and reproduces on a plain
> systemd-based VM with no containers.
> 
> Fix by calling unshare(CLONE_NEWNET) from both fixture setups.  The
> harness runs each test in its own forked process, so every test gets a
> private network namespace that is torn down with it, and all tap and
> geneve devices are created in a namespace that systemd-udevd (running
> in the init netns) does not watch, so its RTM_SETLINK never fires
> against them.
> 
> Creating a network namespace needs CAP_SYS_ADMIN in the current user
> namespace and CONFIG_NET_NS=y, neither of which the tests required
> before.  Where they are unavailable the unshare() is reported with
> SKIP() rather than aborting, so the binary still emits a full TAP
> stream and a runner can tell "network namespaces unavailable" apart
> from a real tun/tap regression.
> 
> Verified on a plain systemd-based VM running the affected kernel.
> Without the fix, 1000 sequential invocations of
> 
>   tun -r tun_vnet_udptnl.4in6_nogsosz_1byte.recv_gso_packet
> 
> fail 10 times, and 2 out of 20 full runs of the test binary fail.  With
> the fix there are no failures in either case.
> 
> Reported-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
> Closes: https://bugs.launchpad.net/bugs/2158217
> Fixes: 24e59f26eef2 ("selftest: tun: Add helpers for GSO over UDP tunnel")
> Assisted-by: LLM
> Signed-off-by: Edoardo Canepa <edoardo.canepa@canonical.com>
> ---
> v3:
>   - Drop the claim that a failure leaves the tap and geneve devices
>     behind.  The failing checks are EXPECT_EQ()s in the test body, so
>     FIXTURE_TEARDOWN still runs (Sashiko).
>   - Explain the send_gso_packet failure correctly: its frames are
>     dropped as PACKET_OTHERHOST once the tap's MAC changes.  The
>     neighbor flush only affects recv_gso_packet.
>   - Redo the measurements on a freshly booted host.  The v2 numbers
>     were taken in an unclean environment.  The v1 numbers were fine,
>     and the v2 entry saying otherwise was wrong.
>   - Go back to "Assisted-by: LLM", the current format in
>     Documentation/process/coding-assistants.rst.  v2 followed an older
>     copy of that document (Sashiko).
> v2: https://lore.kernel.org/netdev/20260914211921.3786609-1-edoardo.canepa@canonical.com/
>   - Add the unshare(CLONE_NEWNET) to FIXTURE_SETUP(tun) and
>     FIXTURE_SETUP(tun_vnet_udptnl) instead of replacing
>     TEST_HARNESS_MAIN with a hand-written main() (Jakub).
>   - Report an unshare() failure with SKIP() instead of aborting the
>     binary before the harness starts (Sashiko).
>   - Mention the new CAP_SYS_ADMIN / CONFIG_NET_NS prerequisite in the
>     commit message (Sashiko).
>   - Change the Assisted-by: format (reverted in v3).
>   - Redo the measurements (redone again in v3).
> v1: https://lore.kernel.org/netdev/20260905085318.3416670-1-edoardo.canepa@canonical.com/

Reviewed-by: Simon Horman <horms@kernel.org>


  reply	other threads:[~2026-09-21 13:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17 11:15 [PATCH net v3] selftests/net: run tun tests in a dedicated network namespace Edoardo Canepa
2026-09-21 13:09 ` Simon Horman [this message]
2026-09-22  0:30 ` patchwork-bot+netdevbpf

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=20260921130901.GP13925@horms.kernel.org \
    --to=horms@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edoardo.canepa@canonical.com \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=po-hsu.lin@canonical.com \
    --cc=shuah@kernel.org \
    --cc=xudu@redhat.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.