OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 v3 1/5] selftests: net: run the fdb and bind tests in their own netns
Date: Tue, 22 Sep 2026 17:00:44 +0200	[thread overview]
Message-ID: <20260922-b4-kh-self1-v3-1-4548b8d45755@virtuozzo.com> (raw)
In-Reply-To: <20260922-b4-kh-self1-v3-0-4548b8d45755@virtuozzo.com>

From: Eva Kurchatova <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>
Reviewed-by: Vladimir Riabchun <vladimir.riabchun@virtuozzo.com>
---
 tools/testing/selftests/net/bind_wildcard.c              | 13 +++++++++++++
 tools/testing/selftests/net/fdb_notify.sh                |  7 +++++++
 tools/testing/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 b7b54d646b937..5ebf21c97df1a 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 c159230c9b623..4f65f6720b1b8 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 2d442cdab11e1..7319bbcc4fbc2 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.43.0

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

  reply	other threads:[~2026-09-22 15:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22 15:00 [Devel] [PATCH hci-8.1 v3 0/5] selftests: net: make the net tests pass on a vz10 host Konstantin Khorenko
2026-09-22 15:00 ` Konstantin Khorenko [this message]
2026-09-22 15:00 ` [Devel] [PATCH hci-8.1 v3 2/5] selftests: net: skip what this kernel and iproute2 do not have Konstantin Khorenko
2026-09-22 15:00 ` [Devel] [PATCH hci-8.1 v3 3/5] selftests: net: install pmtu.sh, the script pmtu_wrapper.sh runs Konstantin Khorenko
2026-09-22 15:00 ` [Devel] [PATCH hci-8.1 v3 4/5] selftests: net: mark test_ingress_egress_chaining.sh executable Konstantin Khorenko
2026-09-22 15:00 ` [Devel] [PATCH hci-8.1 v3 5/5] ms/tunnels: Drop stale dst when building an ICMP error for PMTUD Konstantin Khorenko
2026-09-22 15:05 ` [Devel] [PATCH hci-8.1 v3 0/5] selftests: net: make the net tests pass on a vz10 host Konstantin Khorenko

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=20260922-b4-kh-self1-v3-1-4548b8d45755@virtuozzo.com \
    --to=khorenko@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=eva.kurchatova@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