OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
To: khorenko@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH vz10 2/7] selftests: net: run the fdb and bind tests in their own netns
Date: Tue,  1 Sep 2026 01:48:20 +0300	[thread overview]
Message-ID: <20260831224850.1642265-2-eva.kurchatova@virtuozzo.com> (raw)
In-Reply-To: <20260831224850.1642265-1-eva.kurchatova@virtuozzo.com>

Three tests share the initial namespace with the machine and fail on
what is already in it.

fdb_notify and test_vxlan_fdb_changelink bring up a vxlan device on the
default port 4789. Where the machine already has one there, and that
one is metadata based, as the device open vswitch keeps is, the port
cannot be shared and the test device is never created:

  # ip link add vxs type vxlan external dstport 4789
  # ip link add name vx up type vxlan id 2000 dstport 4789
  RTNETLINK answers: Address already in use
  # ./test_vxlan_fdb_changelink.sh
  Cannot find device "vx"
  expected two remotes after link set	[FAIL]

Run both in a fresh namespace by re-executing them there, the way
nft_audit.sh, nft_concat_range.sh and br_netfilter_queue.sh already do.

bind_wildcard binds 0.0.0.0 and expects to know which sockets exist.
With 432 foreign sockets on 0.0.0.0 on the machine it failed 6 runs out
of 10; unsharing a namespace in FIXTURE_SETUP took that to 0 out of 10.
This is what commit a897e194c475 ("selftests: net: run reuseport in an
isolated netns") does for the reuseport tests.

https://virtuozzo.atlassian.net/browse/VSTOR-139651
Feature: fix selftests
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
 tools/testing/selftests/net/bind_wildcard.c         | 13 +++++++++++++
 tools/testing/selftests/net/fdb_notify.sh           |  7 +++++++
 .../selftests/net/test_vxlan_fdb_changelink.sh      |  7 +++++++
 3 files changed, 27 insertions(+)

diff --git a/tools/testing/selftests/net/bind_wildcard.c b/tools/testing/selftests/net/bind_wildcard.c
index b7b54d646b93..5ebf21c97df1 100644
--- a/tools/testing/selftests/net/bind_wildcard.c
+++ b/tools/testing/selftests/net/bind_wildcard.c
@@ -1,6 +1,10 @@
 // SPDX-License-Identifier: GPL-2.0
 /* Copyright Amazon.com Inc. or its affiliates. */
 
+#define _GNU_SOURCE
+#include <sched.h>
+
+#include <stdlib.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 
@@ -716,6 +720,15 @@ static void setup_addr(FIXTURE_DATA(bind_wildcard) *self, int i,
 
 FIXTURE_SETUP(bind_wildcard)
 {
+	/* The port is picked by the kernel and the test then expects every
+	 * conflict on it to be one it caused itself.  A socket the rest of
+	 * the system holds on that port breaks that: a v6only bind to ::
+	 * is given a port whose 0.0.0.0 counterpart is taken, and the
+	 * binds that follow fail with EADDRINUSE the test does not expect.
+	 */
+	ASSERT_EQ(unshare(CLONE_NEWNET), 0);
+	ASSERT_EQ(system("ip link set lo up"), 0);
+
 	setup_addr(self, 0, variant->family[0], variant->addr[0]);
 	setup_addr(self, 1, variant->family[1], variant->addr[1]);
 
diff --git a/tools/testing/selftests/net/fdb_notify.sh b/tools/testing/selftests/net/fdb_notify.sh
index c159230c9b62..4f65f6720b1b 100755
--- a/tools/testing/selftests/net/fdb_notify.sh
+++ b/tools/testing/selftests/net/fdb_notify.sh
@@ -1,6 +1,13 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
 
+# The test brings up a vxlan device on the default port, which fails where
+# the host already has one, as a metadata-based device holding that port is
+# not compatible with the one the test asks for:
+#   RTNETLINK answers: Address already in use
+# Run in a fresh network namespace, like the netfilter tests do.
+[ "${1}" != "run" ] && { unshare -n "${0}" run; exit $?; }
+
 source lib.sh
 
 ALL_TESTS="
diff --git a/tools/testing/selftests/net/test_vxlan_fdb_changelink.sh b/tools/testing/selftests/net/test_vxlan_fdb_changelink.sh
index 2d442cdab11e..7319bbcc4fbc 100755
--- a/tools/testing/selftests/net/test_vxlan_fdb_changelink.sh
+++ b/tools/testing/selftests/net/test_vxlan_fdb_changelink.sh
@@ -3,6 +3,13 @@
 
 # Check FDB default-remote handling across "ip link set".
 
+# The test brings up a vxlan device on the default port, which fails where
+# the host already has one, as a metadata-based device holding that port is
+# not compatible with the one the test asks for:
+#   RTNETLINK answers: Address already in use
+# Run in a fresh network namespace, like the netfilter tests do.
+[ "${1}" != "run" ] && { unshare -n "${0}" run; exit $?; }
+
 check_remotes()
 {
 	local what=$1; shift
-- 
2.55.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  reply	other threads:[~2026-08-31 22:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 22:48 [Devel] [PATCH vz10 1/7] ms/vxlan: do not reuse cached ip_hdr() value after skb_tunnel_check_pmtu() Eva Kurchatova
2026-08-31 22:48 ` Eva Kurchatova [this message]
2026-08-31 22:48 ` [Devel] [PATCH vz10 3/7] selftests: net: skip what this kernel and iproute2 do not have Eva Kurchatova
2026-08-31 22:48 ` [Devel] [PATCH vz10 4/7] selftests: net: make the veth GRO checks independent of host tunnels Eva Kurchatova
2026-08-31 22:48 ` [Devel] [PATCH vz10 5/7] selftests: net: install pmtu.sh, the script pmtu_wrapper.sh runs Eva Kurchatova
2026-08-31 22:48 ` [Devel] [PATCH vz10 6/7] selftests: net: mark test_ingress_egress_chaining.sh executable Eva Kurchatova
2026-08-31 22:48 ` [Devel] [PATCH vz10 7/7] selftests: net: let the bridged PMTU tests take the ICMP they ask for Eva Kurchatova

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=20260831224850.1642265-2-eva.kurchatova@virtuozzo.com \
    --to=eva.kurchatova@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=khorenko@virtuozzo.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox