From: Paolo Abeni <pabeni@redhat.com>
To: Xiao Liang <shaw.leon@gmail.com>,
netdev@vger.kernel.org, linux-kselftest@vger.kernel.org,
Kuniyuki Iwashima <kuniyu@amazon.com>,
Jakub Kicinski <kuba@kernel.org>,
Donald Hunter <donald.hunter@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
David Ahern <dsahern@kernel.org>,
Eric Dumazet <edumazet@google.com>,
Ido Schimmel <idosch@nvidia.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Simon Horman <horms@kernel.org>, Shuah Khan <shuah@kernel.org>,
Jiri Pirko <jiri@resnulli.us>, Hangbin Liu <liuhangbin@gmail.com>,
linux-rdma@vger.kernel.org, linux-can@vger.kernel.org,
osmocom-net-gprs@lists.osmocom.org, bpf@vger.kernel.org,
linux-ppp@vger.kernel.org, wireguard@lists.zx2c4.com,
linux-wireless@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org,
bridge@lists.linux.dev, linux-wpan@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v5 5/5] selftests: net: Add two test cases for link netns
Date: Thu, 12 Dec 2024 10:40:53 +0100 [thread overview]
Message-ID: <4a2fe99a-772d-4df1-a8ef-14338682b69e@redhat.com> (raw)
In-Reply-To: <20241209140151.231257-6-shaw.leon@gmail.com>
On 12/9/24 15:01, Xiao Liang wrote:
> - Add test for creating link in another netns when a link of the same
> name and ifindex exists in current netns.
> - Add test for link netns atomicity - create link directly in target
> netns, and no notifications should be generated in current netns.
>
> Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
> ---
> tools/testing/selftests/net/Makefile | 1 +
> tools/testing/selftests/net/netns-name.sh | 10 ++++++
> tools/testing/selftests/net/netns_atomic.py | 39 +++++++++++++++++++++
> 3 files changed, 50 insertions(+)
> create mode 100755 tools/testing/selftests/net/netns_atomic.py
>
> diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
> index cb2fc601de66..f9f7a765d645 100644
> --- a/tools/testing/selftests/net/Makefile
> +++ b/tools/testing/selftests/net/Makefile
> @@ -34,6 +34,7 @@ TEST_PROGS += gre_gso.sh
> TEST_PROGS += cmsg_so_mark.sh
> TEST_PROGS += cmsg_time.sh cmsg_ipv6.sh
> TEST_PROGS += netns-name.sh
> +TEST_PROGS += netns_atomic.py
> TEST_PROGS += nl_netdev.py
> TEST_PROGS += srv6_end_dt46_l3vpn_test.sh
> TEST_PROGS += srv6_end_dt4_l3vpn_test.sh
> diff --git a/tools/testing/selftests/net/netns-name.sh b/tools/testing/selftests/net/netns-name.sh
> index 6974474c26f3..0be1905d1f2f 100755
> --- a/tools/testing/selftests/net/netns-name.sh
> +++ b/tools/testing/selftests/net/netns-name.sh
> @@ -78,6 +78,16 @@ ip -netns $NS link show dev $ALT_NAME 2> /dev/null &&
> fail "Can still find alt-name after move"
> ip -netns $test_ns link del $DEV || fail
>
> +#
> +# Test no conflict of the same name/ifindex in different netns
> +#
> +ip -netns $NS link add name $DEV index 100 type dummy || fail
> +ip -netns $NS link add netns $test_ns name $DEV index 100 type dummy ||
> + fail "Can create in netns without moving"
> +ip -netns $test_ns link show dev $DEV >> /dev/null || fail "Device not found"
> +ip -netns $NS link del $DEV || fail
> +ip -netns $test_ns link del $DEV || fail
> +
> echo -ne "$(basename $0) \t\t\t\t"
> if [ $RET_CODE -eq 0 ]; then
> echo "[ OK ]"
> diff --git a/tools/testing/selftests/net/netns_atomic.py b/tools/testing/selftests/net/netns_atomic.py
> new file mode 100755
> index 000000000000..d350a3fc0a91
> --- /dev/null
> +++ b/tools/testing/selftests/net/netns_atomic.py
> @@ -0,0 +1,39 @@
> +#!/usr/bin/env python3
> +# SPDX-License-Identifier: GPL-2.0
> +
> +import time
> +
> +from lib.py import ksft_run, ksft_exit, ksft_true
> +from lib.py import ip
> +from lib.py import NetNS, NetNSEnter
> +from lib.py import RtnlFamily
> +
> +
> +def test_event(ns1, ns2) -> None:
> + with NetNSEnter(str(ns1)):
> + rtnl = RtnlFamily()
> +
> + rtnl.ntf_subscribe("rtnlgrp-link")
> +
> + ip(f"netns set {ns1} 0", ns=str(ns2))
> +
> + ip(f"link add netns {ns2} link-netnsid 0 dummy1 type dummy")
> + ip(f"link add netns {ns2} dummy2 type dummy", ns=str(ns1))
> +
> + ip("link del dummy1", ns=str(ns2))
> + ip("link del dummy2", ns=str(ns2))
> +
> + time.sleep(1)
> + rtnl.check_ntf()
> + ksft_true(rtnl.async_msg_queue.empty(),
> + "Received unexpected link notification")
I think we need a much larger coverage here, possibly testing all the
update drivers and more 'netns', 'link-netnsid', 'peer netns'
permutations for the devices that allow them.
Thanks,
Paolo
next prev parent reply other threads:[~2024-12-12 9:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-09 14:01 [PATCH net-next v5 0/5] net: Improve netns handling in RTNL and ip_tunnel Xiao Liang
2024-12-09 14:01 ` [PATCH net-next v5 1/5] net: ip_tunnel: Build flow in underlay net namespace Xiao Liang
2024-12-09 14:01 ` [PATCH net-next v5 2/5] rtnetlink: Lookup device in target netns when creating link Xiao Liang
2024-12-09 14:01 ` [PATCH net-next v5 3/5] rtnetlink: Decouple net namespaces in rtnl_newlink_create() Xiao Liang
2024-12-12 9:27 ` Paolo Abeni
2024-12-12 12:41 ` Xiao Liang
2024-12-09 14:01 ` [PATCH net-next v5 4/5] selftests: net: Add python context manager for netns entering Xiao Liang
2024-12-09 14:01 ` [PATCH net-next v5 5/5] selftests: net: Add two test cases for link netns Xiao Liang
2024-12-12 9:40 ` Paolo Abeni [this message]
2024-12-12 13:06 ` Xiao Liang
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=4a2fe99a-772d-4df1-a8ef-14338682b69e@redhat.com \
--to=pabeni@redhat.com \
--cc=andrew+netdev@lunn.ch \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
--cc=bpf@vger.kernel.org \
--cc=bridge@lists.linux.dev \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=kuniyu@amazon.com \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-ppp@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linux-wpan@vger.kernel.org \
--cc=liuhangbin@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=osmocom-net-gprs@lists.osmocom.org \
--cc=shaw.leon@gmail.com \
--cc=shuah@kernel.org \
--cc=wireguard@lists.zx2c4.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