zhhyu7 opened a new pull request, #21627:
URL: https://github.com/apache/nuttx/pull/21627

   ## Summary
   
   This series adds an AF_VSOCK (virtual socket) networking stack to NuttX, 
providing host–guest and guest–guest stream communication over virtio-vsock.
                                                                                
                                                                                
                                               
   Highlights:                                                                  
                                                                                
                                               
   - New net/vsock protocol family with SOCK_STREAM support and a sock_intf_s 
implementation 
(socket/bind/listen/connect/accept/send/recv/poll/getsockname/getpeername/get/setsockopt/shutdown/close).
   - A transport abstraction layer with three back-ends:
     - NET_VSOCK_VIRTIO — virtio transport (guest side)  
     - NET_VSOCK_VHOST — vhost transport (host side)
     - NET_VSOCK_LOCAL — single-host loopback transport
   - UAPI header sys/vm_sockets.h (struct sockaddr_vm, VMADDR_CID_*) and the 
virtio-vsock spec header.
   - BMP (Bound Multi-Processing) mode support for per-CPU connection/port 
state.
   - Connection diagnostics (vsock_conn_dump) and a series of correctness fixes 
(shutdown use-after-free, accept/shutdown race, nonblocking connect/close, 
credit accounting, clang build errors, debug-log 
   formatting).          
                                                      
   The work spans 32 commits touching 19 files (net/vsock/* plus supporting 
changes in net/net_initialize.c, net/socket/net_sockif.c, net/Kconfig, 
include/).
   
   ## Impact
   
   - Adds a new socket address family AF_VSOCK. All code is guarded by 
CONFIG_NET_VSOCK; when disabled there is no change to existing behavior.        
                                                        
   - New Kconfig options under "Virtual Socket networking stack API": 
NET_VSOCK, NET_VSOCK_VIRTIO, NET_VSOCK_VHOST, NET_VSOCK_LOCAL, plus tunables 
(NET_VSOCK_RX_BUFSIZE, NET_VSOCK_PKT_BUFSIZE, 
   NET_VSOCK_PKT_BUFCOUNT, NET_VSOCK_NPOLLWAITERS, NET_VSOCK_VQ_BUFCOUNT, 
NET_VSOCK_WORK_PRIORITY, NET_VSOCK_WORK_STACKSIZE).
   - NET_VSOCK_VIRTIO/NET_VSOCK_VHOST select DRIVERS_VIRTIO/DRIVERS_VHOST 
(hence OPENAMP); NET_VSOCK_LOCAL selects OPENAMP for the shared virtqueue_buf 
packet type.
   - Adds include/nuttx/percpu.h (DEFINE_PER_CPU_BMP/this_cpu_var_bmp, 
degrading to plain globals when CONFIG_BMP is off).
   - Build-system: net/vsock/{Make.defs,CMakeLists.txt} added; net/Makefile 
includes the new subdir and CMake picks it up via nuttx_add_subdirectory() 
auto-inclusion.
   
   ## Testing
   
   Platform: sim (host gcc, x86_64).
   
   Configuration:
   ./tools/configure.sh sim:nsh
   # + CONFIG_NET=y, CONFIG_NET_VSOCK=y, CONFIG_NET_VSOCK_LOCAL=y,
   #   CONFIG_NET_SOCKOPTS=y, CONFIG_EXAMPLES_VSOCK_LOOPBACK=y
   make olddefconfig && make
   
   
   - **Build**: sim + CONFIG_NET_VSOCK_LOCAL compiles and links cleanly (no 
errors/warnings).
   - **Functional (AF_VSOCK local loopback)**: added a small test app that 
starts an echo-server thread binding/listening on VMADDR_CID_ANY:1234, then a 
client connects to VMADDR_CID_LOCAL:1234, sends a 
   request and verifies the reply. Full path socket → bind → listen → connect → 
accept → send → recv passes, 19-byte payload verified in both directions:
     
   
     vsock_loopback: start (AF_VSOCK local loopback test)
     server: listening on cid=ANY port=1234
     client: connected to cid=1 port=1234
     client: sent "vsock-loopback-ping"
     server: received "vsock-loopback-ping" (19 bytes) 
     client: received "vsock-loopback-pong" (19 bytes) 
     vsock_loopback: PASS
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to