Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] vsock_test: vsock_dgram_check_vmci_host() skips when vhost_vsock is unloaded - [Medium] vsock_test: local CID tests fail when VMCI coexists with vhost and loopback --
commit 792ed67e2ec454b7d9e33e144a3b395a0eb9843c Author: Sergio Lopez <[email protected]> vsock: add datagram tests to vsock_test This commit adds SOCK_DGRAM test cases to vsock_test covering local loopback semantics, host/guest transfers, transport routing, and queue accounting, along with capability-based skip checks and a --local mode. > diff --git a/tools/testing/vsock/vsock_test_dgram.c > b/tools/testing/vsock/vsock_test_dgram.c > new file mode 100644 > index 0000000000000..16c3a6e59f792 > --- /dev/null > +++ b/tools/testing/vsock/vsock_test_dgram.c [ ... ] > +static bool usable_local_cid(void) > +{ > + unsigned int cid; > + int fd, ret; > + > + fd = open("/dev/vsock", O_RDONLY | O_CLOEXEC); > + if (fd < 0) > + return false; > + ret = ioctl(fd, IOCTL_VM_SOCKETS_GET_LOCAL_CID, &cid); > + close(fd); > + return ret == 0 && cid != VMADDR_CID_ANY && cid > VMADDR_CID_LOCAL; > +} [Severity: Medium] Can usable_local_cid() enable the local-CID loopback tests when VMCI owns VMADDR_CID_HOST? When vhost_vsock, vsock_loopback, and vmw_vsock_vmci_transport are loaded together in a global namespace without a guest-to-host transport, IOCTL_VM_SOCKETS_GET_LOCAL_CID returns VMADDR_CID_HOST (from vhost_vsock), so vsock_dgram_check_local_cid() enables test_dgram_bound_lookup() and test_dgram_connected_cid(). However, VMCI is the datagram owner in a global namespace and its local CID is also VMADDR_CID_HOST, so vsock_select_transport() routes packets addressed to VMADDR_CID_HOST through vmci_transport instead of vsock_loopback. As a result, test_dgram_bound_lookup() fails with EADDRNOTAVAIL when sending from a socket bound to VMADDR_CID_LOCAL to one bound to VMADDR_CID_HOST, and test_dgram_connected_cid() times out because the receiver connects to VMADDR_CID_HOST (selecting vmci_transport) while the packet arrives over loopback_transport and is dropped by virtio_transport_dgram_source_allow(). [ ... ] > +const char *vsock_dgram_check_vmci_host(const struct test_opts *opts) > +{ > + unsigned int caps = dgram_capabilities(opts, 0); > + unsigned int cid; > + char mode[16]; > + FILE *file; > + int fd; > + > + if (!(caps & DGRAM_SOCKET)) > + return "datagrams unavailable locally"; > + if (!(caps & DGRAM_VMCI_MODULE)) > + return "requires VMCI datagram transport"; > + > + file = fopen("/proc/sys/net/vsock/ns_mode", "r"); > + if (!file) > + return "requires a mounted vsock namespace sysctl"; > + if (!fgets(mode, sizeof(mode), file)) { > + fclose(file); > + return "cannot read vsock namespace mode"; > + } > + fclose(file); > + if (strncmp(mode, "global", 6)) > + return "requires a global vsock namespace"; > + > + fd = open("/dev/vsock", O_RDONLY | O_CLOEXEC); > + if (fd < 0) > + return "cannot open /dev/vsock"; > + if (ioctl(fd, IOCTL_VM_SOCKETS_GET_LOCAL_CID, &cid)) { > + close(fd); > + return "cannot read local CID"; > + } > + close(fd); > + if (cid != VMADDR_CID_HOST) > + return "requires VMCI host CID without an active guest CID"; > + return NULL; > +} [Severity: Medium] Does checking IOCTL_VM_SOCKETS_GET_LOCAL_CID == VMADDR_CID_HOST skip test_dgram_vmci_host_routes() whenever vhost_vsock is unloaded and no /dev/vmci host context is active? Loading vmw_vsock_vmci_transport only registers transport_dgram_fallback; vmci_register_vsock_callback() registers transport_h2g only while vmci_host_users() > 0. Because vsock_dev_do_ioctl() queries only transport_g2h, transport_h2g, and transport_local for IOCTL_VM_SOCKETS_GET_LOCAL_CID (never transport_dgram_fallback), the ioctl returns VMADDR_CID_ANY or VMADDR_CID_LOCAL when vhost_vsock is not loaded, causing vsock_dgram_check_vmci_host() to skip the test even though VMCI host datagram sockets can bind and send to VMADDR_CID_HOST. Instead of requiring the ioctl to return VMADDR_CID_HOST, could this verify that the ioctl does not return a guest CID (> VMADDR_CID_HOST) and probe binding a datagram socket to VMADDR_CID_HOST? -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=8
