From: netdev-bot+sashiko@kernel.org
To: bobbyeshleman@meta.com
Cc: sgarzare@redhat.com, davem@davemloft.net, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, corbet@lwn.net,
skhan@linuxfoundation.org, stefanha@redhat.com, mst@redhat.com,
jasowangio@gmail.com, xuanzhuo@linux.alibaba.com,
eperezma@redhat.com, shuah@kernel.org, rdunlap@infradead.org,
donald.hunter@gmail.com, edumazet@kernel.org,
georgezhang@vmware.com, acking@vmware.com, dtor@vmware.com,
virtualization@lists.linux.dev, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
sargun@sargun.me, jlinbox@meta.com, bobbyeshleman@gmail.com
Subject: Re: [PATCH net-next v6 7/8] selftests/vsock: test the guest vsock device network namespace
Date: Sun, 15 Nov 2026 04:01:33 +0000 [thread overview]
Message-ID: <179471529389.2199510.13389069542322602119@kernel.org> (raw)
In-Reply-To: <20261113-vsock-guest-ns-v6-7-3737ce4673c0@meta.com>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] test_ns_guest_assign_g2h_netns_pins_ns_ok in
tools/testing/selftests/vsock/vmtest.sh checks less than its…
- [Low] The ynl CLI's output goes straight onto the script's stdout,
which is also the KTAP stream.
- [Low] vm_ns_stop() (vmtest.sh:657-667) waits for the namespace holder
to go away with `kill ${nspid}` followed by up to WAIT_PERIOD_MAX (60)…
--
selftests/vsock: test the guest vsock device network namespace
This adds vmtest.sh tests for assigning the guest vsock device to a
network namespace. They cover namespace destruction and the device moving
between namespaces. The tests use the ynl cli.py and unshare, and a
missing dependency skips only the ns_guest_ tests.
> diff --git a/tools/testing/selftests/vsock/vmtest.sh b/tools/testing/selftests/vsock/vmtest.sh
> index 310dfc2a39ad5..a800b63dfbb11 100755
> --- a/tools/testing/selftests/vsock/vmtest.sh
> +++ b/tools/testing/selftests/vsock/vmtest.sh
[ ... ]
> @@ -528,6 +618,82 @@ vm_wait_for_ssh() {
> done
> }
>
> +# Create a local mode namespace in the VM and echo the pid holding it open.
> +vm_ns_start() {
[ ... ]
> + nspid=$(vm_ssh "${ns}" -- "unshare -n sleep infinity" \
> + '>/dev/null 2>&1 & echo $!')
> + if [[ -z "${nspid}" ]]; then
> + return
> + fi
[ ... ]
> +# Returns once the holder is gone, so that the namespace is unreferenced and
> +# the kernel can start tearing it down.
> +vm_ns_stop() {
> + local ns=$1
> + local nspid=$2
> +
> + vm_ssh "${ns}" <<-EOF &>/dev/null
> + kill ${nspid}
> + for ((i = 0; i < ${WAIT_PERIOD_MAX}; i++)); do
> + kill -0 ${nspid} 2>/dev/null || break
> + sleep 1
> + done
> + EOF
> +}
[Severity: Low]
Can this loop run for the full WAIT_PERIOD_MAX seconds even after the
holder has exited?
vm_ns_start() starts the holder in the background from an ssh shell that
exits right away. The sleep process is then reparented to the guest's
PID 1, and nothing in the script waits on it.
kill -0 succeeds on an unreaped zombie. If the guest init does not reap
adopted orphans, every vm_ns_stop() call would run all 60 iterations,
even though the task has already dropped its netns reference.
vm_ns_stop() runs at least once in each of the seven ns_guest_ tests.
That could add 7+ minutes, against the 1200 second timeout in
tools/testing/selftests/vsock/settings. Whether this happens depends on
whether virtme-ng's init reaps orphans, and I could not confirm that.
Would checking /proc/${nspid}/status for state Z, or comparing
/proc/${nspid}/ns/net, remove that dependency?
[ ... ]
> +vm_ns_assign_g2h() {
> + local ns=$1
> + local nspid=$2
> +
> + vm_ns_exec "${ns}" "${nspid}" "python3 /root/ynl/cli.py --no-schema \
> + --spec /root/ynl/vsock.yaml --do dev-netns-set"
> +}
> +
> +vm_reset_g2h() {
> + vm_ns_assign_g2h "init_ns" "" &>/dev/null
> +}
[Severity: Low]
Does the cli.py output end up mixed into the KTAP stream here?
dev-netns-set has no reply attributes. For the empty response, ynl.py
_ops() appends None, and cli.py main() then pprints it:
tools/net/ynl/pyynl/cli.py:main() {
...
reply = ynl.do(args.do, attrs, args.flags)
output(reply)
...
except NlError as e:
print(e)
}
As a result, every successful assign prints a bare "None" line. On
failure, cli.py prints the NlError to stdout as well.
Only vm_reset_g2h() redirects this output. Five tests call
"if ! vm_ns_assign_g2h ...", and test_ns_guest_assign_g2h_netns_by_pid_ok()
calls cli.py directly. In all of these, the output passes through ssh
onto the script's stdout, in between the "ok N <test>" lines that
check_result() prints. Assign failures also never reach ${LOG} through
log_host.
Should these calls redirect the output, or capture it and pass it to
log_host?
[ ... ]
> @@ -1421,6 +1603,354 @@ test_ns_delete_both_ok() {
[ ... ]
> +test_ns_guest_assign_g2h_netns_pins_ns_ok() {
[ ... ]
> + vm_ns_stop "init_ns" "${nspid}"
> + sleep "${WAIT_PERIOD}"
> +
> + outfile=$(mktemp)
> + guest_send_to_host "init_ns" "" "${port}" "${outfile}"
> + result=$(cat "${outfile}")
> + if [[ "${result}" == TEST ]]; then
> + log_host "device returned to the init ns instead of pinning it"
> + rm -f "${outfile}"
> + vm_reset_g2h
> + return "${KSFT_FAIL}"
> + fi
> +
> + # Assigning it back is what releases the deleted namespace.
> + vm_reset_g2h
> +
> + guest_send_to_host "init_ns" "" "$(( port + 1 ))" "${outfile}"
> + result=$(cat "${outfile}")
> + rm -f "${outfile}"
> +
> + if [[ "${result}" != TEST ]]; then
> + log_host "device did not come back on reassign: [${result}]"
> + return "${KSFT_FAIL}"
> + fi
[Severity: Low]
Does this test check what its TEST_DESCS entry says?
"Check the assignment keeps the ns alive when deleted, and that
reassigning releases it."
Both assertions are connectivity checks run from the guest's init ns.
The first one only shows that the device did not return to init_net
after the holder exited. A dangling or freed netns would also make that
connect fail, and would only be caught if it happened to oops or warn.
The second one only shows that init_net works again after
vm_reset_g2h(). Nothing checks that the reference taken by
get_net_track() in vsock_g2h_net_swap() is later dropped by
put_net_track() in vsock_g2h_net_release(). So the claim in the comment
above vm_reset_g2h() is never verified.
If a later change leaked the netns reference on reassign, would this
test still return KSFT_PASS? Could the description be narrowed, or the
test extended to check that the namespace is actually released?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113-vsock-guest-ns-v6-0-3737ce4673c0%40meta.com
next prev parent reply other threads:[~2026-11-15 4:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-14 3:14 [PATCH net-next v6 0/8] vsock: assign the guest vsock device to a " Bobby Eshleman
2026-11-14 3:14 ` [PATCH net-next v6 1/8] vsock: only undo SS_CONNECTING when connect() fails Bobby Eshleman
2026-11-15 4:01 ` netdev-bot+sashiko
2026-11-14 3:14 ` [PATCH net-next v6 2/8] vsock: constify the transport in vsock_for_each_connected_socket() Bobby Eshleman
2026-11-14 3:14 ` [PATCH net-next v6 3/8] vsock: rename the vsock pernet operations Bobby Eshleman
2026-11-14 3:14 ` [PATCH net-next v6 4/8] vsock: pass the netns to ->has_remote_cid() Bobby Eshleman
2026-11-14 3:14 ` [PATCH net-next v6 5/8] vsock: add a netlink command to assign the g2h device to a netns Bobby Eshleman
2026-11-15 4:01 ` netdev-bot+sashiko
2026-11-14 3:14 ` [PATCH net-next v6 6/8] vsock/virtio: support guest device network namespace Bobby Eshleman
2026-11-15 4:01 ` netdev-bot+sashiko
2026-11-14 3:14 ` [PATCH net-next v6 7/8] selftests/vsock: test the guest vsock " Bobby Eshleman
2026-11-15 4:01 ` netdev-bot+sashiko [this message]
2026-11-14 3:14 ` [PATCH net-next v6 8/8] selftests/vsock: test the netns assign privilege checks Bobby Eshleman
2026-11-15 4:01 ` netdev-bot+sashiko
2026-11-14 3:22 ` [PATCH net-next v6 0/8] vsock: assign the guest vsock device to a network namespace netdev-bot+sinfo
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=179471529389.2199510.13389069542322602119@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=acking@vmware.com \
--cc=bobbyeshleman@gmail.com \
--cc=bobbyeshleman@meta.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=dtor@vmware.com \
--cc=edumazet@kernel.org \
--cc=eperezma@redhat.com \
--cc=georgezhang@vmware.com \
--cc=horms@kernel.org \
--cc=jasowangio@gmail.com \
--cc=jlinbox@meta.com \
--cc=kuba@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rdunlap@infradead.org \
--cc=sargun@sargun.me \
--cc=sgarzare@redhat.com \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=stefanha@redhat.com \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.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
all inboxes | Powered by JetHome®