src/devices/src/virtio/vsock/ — guest↔host socket bridge with transparent impersonation
Intercepts AF_INET and AF_INET6 socket operations inside the guest kernel. connect() to a host IP:port is transparently bridged via a vsock tunnel to the actual host socket. Guest applications need zero modification.
Intercepts AF_UNIX socket operations. Guest connects to a unix socket path, TSI maps the path to a vsock port via the port map, and the muxer bridges to the real host unix socket.
Guest initiates a connection to a host port. The muxer receives this packet, looks up the port in the TSI port map or connection table, and opens a real host socket. Responds with OP_RESPONSE on success.
Host (muxer) responds to a guest OP_REQUEST after successfully opening the host-side socket. Includes initial credit (buffer space) so data transfer can begin immediately.
Immediately tears down a connection. Sent when an error occurs (host socket closed unexpectedly, protocol violation, unknown connection). The reaper thread periodically cleans up connections in RST state.
Signals that one side has finished sending (SHUT_WR) or will stop receiving (SHUT_RD). Flags field indicates which directions are shutting down. Full shutdown requires both sides to signal.
Carries actual payload data. Guest TX: guest driver writes data to TX virtqueue → muxer reads → forwards to host socket. Guest RX: muxer reads from host socket → builds OP_RW packet → places in RX virtqueue → guest driver delivers to application.
Each side advertises how many bytes the peer can send (buf_alloc - fwd_cnt). The sender must not exceed the peer's advertised credit. Prevents buffer overflow without per-packet ACKs.
Sent when a sender has run out of credit and needs to know if the peer has freed buffer space. The peer responds with OP_CREDIT_UPDATE.