From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (unknown [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 6F5DA802A5 for ; Thu, 24 Sep 2026 11:54:45 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 68OBrWpK014873; Thu, 24 Sep 2026 14:53:33 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 68OBrWpK014873 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="Q1nvNk2x" Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 68OBrQgY014856 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Thu, 24 Sep 2026 14:53:26 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 68OBrQgY014856 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-49e745d5dabso19642695e9.0 for ; Thu, 24 Sep 2026 04:53:26 -0700 (PDT) X-Forwarded-Encrypted: i=2; AKwUvBxS2a5D12p0041TsIRmActy0CmHm7oAb8ycMCXzojeU4OPw/rI8VlukMBhdYrXe7OykOQxQ6A==@openvz.org X-Gm-Message-State: AFuF++nGEkMEd9AZTppi+wWUPHW/mw/inpjGXz74Xpui6qHqsmp3sZvU vNL+hsTPONbuN5aXRDCg/8tPlWMxOBE7gG5WnRM+kr504y+7uk50RSY+fT/e4ddr6JF0XXobkK0 o77tUNo9ngsjYNAagbcVpxrIxv0cyicfpe8nYvWbKEeA+X79ZD1o1Jg== X-Gm-Gg: AYBFou1oP5GQhCT/OuV6ySsDERePNOk5TuC7j2m31qUjrNRcCdh5OBFMTxPAuQIVgSB vvGgStyb0ATLABdiPUYx1RO9D6umQbUlhTMweGCQD9yeFQarmWlJnEY1KhJM0mOiG2X2I/opbiB ELXW1EgGNmWvvrPMMlEJ4oHKeFVtsQRkOyFPIE8QHEIrfej9Az9ikcPRAQwd/qM8Dmm5TwfsSdj VHWTparlNbmMaMIvnB0PtQEBU4QeuaQSYIMJLRUP/m/ByFWI5uM5GwGZSqCpmFs0MsBylRyNNvL mazru9lwjsEzqeCG3rXepr9Z05fkeSrO+OkAz1OnfBmYJcFC1sptHf8WSYC3QRnJpo288fzCSs0 qnCypXRsLU0HHuZuyAQ== X-Received: by 2002:a05:600c:348a:b0:49c:cee0:e7c1 with SMTP id 5b1f17b1804b1-49fe66f4ce7mr35424125e9.16.1790250806162; Thu, 24 Sep 2026 04:53:26 -0700 (PDT) X-Received: by 2002:a05:600c:348a:b0:49c:cee0:e7c1 with SMTP id 5b1f17b1804b1-49fe66f4ce7mr35423785e9.16.1790250805579; Thu, 24 Sep 2026 04:53:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1790250805; cv=none; d=google.com; s=arc-20260327; b=DsZpKGKH3hNfTF4E0lGY3NJnfe1JhCrOs1YFNy0KdicKTMlcPqHqVsYVlLzaQJ4vz3 blUrgPpRe1aox2f6Oix/Ut+PjiOfsbCsVHFhe8ms4LIXPmTSnKvJkGVNniXV97kO/sWR ZrlFPfed1Ef4ZbVC5mSZPV6R3maOGqe0DKuATMemYWCm/lFyz9yFvgBnjSVQZBoCM8TO I2NQ8SsLc3ZnnrQ6IiOWkzDJI2xNtmb3Jmrd1ORLxQsNJlovJIHv6riWhNK+TJzy7w5F UHmYUtqcvvE6bOIWVUNKjZ++iaX4EOnM+oLd4g4by2qb6PefrEu4Ofk4vaMbCbU0aeqp 1gdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=message-id:date:references:in-reply-to:cc:to:from:subject :content-transfer-encoding:mime-version:dkim-signature; bh=vNCy38YI8p1oUAqCBAHU6aiTX0PvGIXIY0Rp99qe2wE=; fh=CTF2GHyV+XdzB5TROrdG4fdLri6JSHNOBC+LNuNq5bA=; b=ZcbWpBrEdbefKlsmMBZpbx9DlO6ZJGsIROsp3+gmuvATzc84Oiv0T2N7NJJMpK0WFM Cpgf4VmKhpPnQe32XdLjK+KMJkYAo99TznlxXpwfbDnIYwdyuXns2IwJt4rmFHkLDPKS tXIhrQBRk2iMiKA57E4LLzmMXQivo70YtNXDewyN4E8oKKScn6Uk3uzjEpNNKnuan84Y IpNSbLHPyBs0hQaCD6WHIcufeeET4ueiYWQPgomvEr6Vze9vVH2r9xKsLjPNcmafDghQ ZhyUHVoqYByZH/Hu/vJgCY3+rp3io+lEQYZJUANrRz1tBQIn3PwsfjbSOpDZKuzyfSMX xWgw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=Q1nvNk2x; spf=pass (google.com: domain of khorenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=khorenko@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id ffacd0b85a97d-488688dfc3asi9937020f8f.384.2026.09.24.04.53.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2026 04:53:25 -0700 (PDT) Received-SPF: pass (google.com: domain of khorenko@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=Q1nvNk2x; spf=pass (google.com: domain of khorenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=khorenko@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=Message-Id:Date:From:Subject:Content-Type: MIME-Version; bh=vNCy38YI8p1oUAqCBAHU6aiTX0PvGIXIY0Rp99qe2wE=; b=Q1nvNk2xDZxj mSxTc3Q43pM6dnFRLvhyJzCZt7QUOFF4JnvsDkLYhnRDttfKtdOxHGt7BZGpS1V3xQedDz0oB+s7b 2OFEwCVegSmH0sR9Rmuy8bmGnswzkrgysMjW/hAiNoEHa/5WnxYLEt8+e1HHOAEHLNRXFrNsUrevT 9Kq0SaMUYqAbrdJKLIaNaIFPGoUZZaAHqaXg5Bs1xq2SAq4EzHZyJX/P7jSes30SjRQfmHAeNx7l8 OdJ5aUXjQ9IpjOU1PiwLfmWmKCpZ/By/FgKx6tYRANBBbdoh/TnabESfrBFFSAM5hUQPKu3xa0TeA i48fHq+WMCjfw5r1g0xtkA==; Received: from ch-demo-asa.virtuozzo.com ([130.117.225.8] helo=f0.sw.ru) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1x9hy2-00DWwF-2T; Thu, 24 Sep 2026 13:53:23 +0200 MIME-Version: 1.0 From: Konstantin Khorenko To: Eva Kurchatova In-Reply-To: <20260831234411.1649762-2-eva.kurchatova@virtuozzo.com> References: <20260831234411.1649762-1-eva.kurchatova@virtuozzo.com> <20260831234411.1649762-2-eva.kurchatova@virtuozzo.com> Date: Thu, 24 Sep 2026 13:53:20 +0200 Message-Id: <179025080051.3192281.6518771407582829890.b4-review@b4> X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5060; i=khorenko@virtuozzo.com; h=from:subject:message-id; bh=AYakdbQEb0Kf1nR4SWTfsM3PD60qohjvyXfbMQMCdjM=; b=owEBbQKS/ZANAwAKAVGWCkf5YVwqAcsmYgBqtQ8zsJbd9UFxdB32x1u4DhmdR/74Xfj/Uo8Ip h9NdAbQt56JAjMEAAEKAB0WIQRWD23IPcXT0GO9CCxRlgpH+WFcKgUCarUPMwAKCRBRlgpH+WFc KrO5D/sFtHM1gOmpAKMeaCjhhFraC1A2l1jLzhM8HXPVdrBuoYYld/Lu3y5BKCntkigHbGNJdaS 1gAUuWBvATE3u9D6YfX3eqViFqMgpQEwuA/380CeaqABIx32R+/pE5t9buy1p4LDo9YsUk2A4+Y 7ilBT/js0vqZ3iGaNr1YI7pZrco3KcwdUIDFEbcVIUivduy/UKaCx8y0zmH7/Mwec5i9n1+tKPg EYQxmkqJrXnhsUYO9wODk5cfo3ZUrPWdBiGMay4b3pXSS6flGLMyht3ipzwsXQrcHpYYwf9myER WdwkGyMjiocmjV2ohoC1tM/16mOOdGK2h27bJ0awySGBwTQIJ4EsGnwKsE+mmSHDvsQ3+2qxAI1 x5nX0W6qOf7FEXw+zApuJ1sMygg1FmXmIIgPptbXswxv68qjemw42XYp4zqUH+1gOHCFzVo/vBE FhTkp8E3v4KoNRkATC0xx7aQZ/0fU8R+vrBHcxOzLElrVAXWcHqxavI154ewPDd2qY3sVjfQ9ys 5oIXJ2eAp7iIo2ov6O1CvxH7skxZbZBOUJhITLmPyOzENuZBbdOc5dmdV46vY3bcAAGcAihqQ14 APemch2hR8CZtsmF44KyBn3me99rPKNX2DgJRlrmOBj+AUUSRk9I586MPPtHFhtWANDxOD5sMJ5 XUI2ldsUA2bNPBw== X-Developer-Key: i=khorenko@virtuozzo.com; a=openpgp; fpr=560F6DC83DC5D3D063BD082C51960A47F9615C2A X-OZ-Fwd: true Cc: devel@openvz.org Subject: Re: [Devel] [PATCH vz10 2/3] selftests: drv-net: run ping in its own netns X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org > In netdevsim mode NetDrvEpEnv gives the remote end a namespace of its > own and leaves the local end in the one the test was started in, so > the filtering of the host applies to the traffic the test sends to > itself. A host that drops it fails the test: > > # nft add rule inet t input ip saddr 192.0.2.0/24 tcp flags syn drop > # ./ping.py > ok 1 ping.test_v4 > ok 2 ping.test_v6 > not ok 3 ping.test_tcp > # Stopping tests due to KsftTerminate. > > ICMP is let through where TCP is not, which is why the first two pass > and the test then sits there until it is killed. > > Re-execute the test in a namespace of its own, the way nft_audit.sh and > nft_concat_range.sh already do, and mount sysfs again there so that the > netdevsim devices the test creates are the ones it sees. > > https://virtuozzo.atlassian.net/browse/VSTOR-139651 > Feature: fix selftests > Signed-off-by: Eva Kurchatova > > diff --git a/tools/testing/selftests/drivers/net/lib/py/__init__.py b/tools/testing/selftests/drivers/net/lib/py/__init__.py > index fce5d9218f1d6..2d3fdaa815504 100644 > --- a/tools/testing/selftests/drivers/net/lib/py/__init__.py > +++ b/tools/testing/selftests/drivers/net/lib/py/__init__.py > @@ -15,7 +15,7 @@ KSFT_DIR = (Path(__file__).parent / "../../../..").resolve() > NlError, RtnlFamily, DevlinkFamily > from net.lib.py import CmdExitFailure > from net.lib.py import bkg, cmd, defer, ethtool, fd_read_timeout, ip, \ > - rand_port, tool, wait_port_listen > + rand_port, rexec_in_netns, tool, wait_port_listen > from net.lib.py import fd_read_timeout > from net.lib.py import KsftSkipEx, KsftFailEx, KsftXfailEx > from net.lib.py import ksft_disruptive, ksft_exit, ksft_pr, ksft_run, \ > diff --git a/tools/testing/selftests/drivers/net/ping.py b/tools/testing/selftests/drivers/net/ping.py > index eb83e7b487978..e1cc74084a244 100755 > --- a/tools/testing/selftests/drivers/net/ping.py > +++ b/tools/testing/selftests/drivers/net/ping.py > @@ -5,6 +5,7 @@ from lib.py import ksft_run, ksft_exit > from lib.py import ksft_eq > from lib.py import NetDrvEpEnv > from lib.py import bkg, cmd, wait_port_listen, rand_port > +from lib.py import rexec_in_netns > > > def test_v4(cfg) -> None: > @@ -42,6 +43,10 @@ from lib.py import bkg, cmd, wait_port_listen, rand_port > > > def main() -> None: > + # In netdevsim mode the local end of the test stays in the namespace > + # the test was started in, so the rules of the host apply to it. > + rexec_in_netns(__file__) > + This re-execs unconditionally, but ping.py lives in drivers/net/, and per the README the tests there run against a real driver as well, with NETIF set in the environment or in net.config. _load_env_file() starts from os.environ, so NETIF survives the exec, but the device itself stays in init_net, and "ip link show dev $NETIF" fails in the new namespace. The commit message says "in netdevsim mode"; the code does not check for it. Please re-exec only when NETIF is not set. Either in main(), or better inside rexec_in_netns() itself, since the helper went into the shared library and every caller will need the same check. > with NetDrvEpEnv(__file__) as cfg: > ksft_run(globs=globals(), case_pfx={"test_"}, args=(cfg, )) > ksft_exit() > diff --git a/tools/testing/selftests/net/lib/py/utils.py b/tools/testing/selftests/net/lib/py/utils.py > index afce547bcab09..13d7a7e6562e6 100644 > --- a/tools/testing/selftests/net/lib/py/utils.py > +++ b/tools/testing/selftests/net/lib/py/utils.py > @@ -8,6 +8,7 @@ import re > import select > import socket > import subprocess > +import sys > import time > > > @@ -131,6 +132,29 @@ global_defer_queue = [] > return tool('ethtool', args, json=json, ns=ns, host=host) > > > +def rexec_in_netns(path): > + """ > + Re-exec the test in a network namespace of its own. > + > + A test that puts one end of its traffic in the namespace it was > + started in otherwise depends on what the host filters. sysfs is drop double spaces > + mounted again in the new namespace, without it the netdevsim > + devices the test creates are not the ones it sees. The test is drop double spaces > + left where it is if unshare is not there to move it. > + """ > + if os.environ.get("KSFT_IN_NETNS"): > + return > + > + os.environ["KSFT_IN_NETNS"] = "1" > + try: > + os.execvp("unshare", > + ["unshare", "-n", "-m", > + "sh", "-c", 'mount -t sysfs sysfs /sys && exec "$@"', lo is down in the new namespace. ping.py does not depend on loopback and rand_port() binds to "", so nothing breaks today, but the helper is shared, and the next test that talks to 127.0.0.1 will trip over it. An "ip link set lo up" in the wrapper closes that for one line. -- Konstantin Khorenko _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel