How sridhardv/secured-usbip works
Purpose and execution model
Secured-USBIP is a GPLv2-derived USB/IP userspace implementation intended as a basis for adding a security protocol. It manages Linux kernel USB/IP drivers: exporting physical USB devices or gadget-backed virtual devices from a server, discovering them remotely, and importing them through a client VHCI controller over TCP (default port 3240).
Primary executables are the usbip management CLI (src/usbip.c) and the server daemon usbipd (src/usbipd.c).
CLI command dispatcher
usbip parses global options and dispatches subcommands to focused command implementations:
• Export lifecycle: src/usbip_bind.c, src/usbip_unbind.c
• Client lifecycle: src/usbip_attach.c, src/usbip_detach.c
• Discovery/status: src/usbip_list.c, src/usbip_port.c
The CLI is the principal control-plane boundary between operators/scripts and kernel-driver sysfs interfaces or the remote USB/IP daemon.
Server daemon and protocol boundary
usbipd accepts TCP USB/IP control connections, enumerates exportable devices, and services attach/import requests. src/usbipd.c owns daemon startup and server behavior; src/usbip_network.c and src/usbip_network.h provide protocol/network operations shared with client-side remote discovery and attachment.
Any security-protocol work is most likely centered at this wire boundary, while preserving compatibility with the kernel USB/IP transport and management flows.
Device export path
For physical USB devices, an operator binds a bus ID to the kernel usbip-host/stub driver. Userspace discovers devices and writes/reads driver state through sysfs-oriented abstractions:
• Generic device and driver operations: libsrc/usbip_device_driver.c, libsrc/usbip_device_driver.h
• Physical host-driver operations: libsrc/usbip_host_driver.c, libsrc/usbip_host_common.c
• Sysfs access: libsrc/sysfs_utils.c
The kernel modules themselves are external prerequisites, not included in this repository: usbip-core, usbip-host, vhci-hcd, and optionally usbip-vudc.
Client import path
usbip attach contacts a remote daemon, requests a bus ID, then attaches the received connection to an available local virtual host-controller port via the VHCI kernel driver. usbip detach removes it; usbip port reports local attachment state.
The VHCI-specific kernel/sysfs boundary is encapsulated by libsrc/vhci_driver.c and consumed by src/usbip_attach.c, src/usbip_detach.c, and src/usbip_port.c. Once attached, ordinary local Linux USB drivers consume the imported device.
Shared models and presentation
Shared USB/IP protocol structures, device metadata, and common operations reside in libsrc/usbip_common.c and libsrc/usbip_common.h. Host enumeration/building of exportable-device information is in libsrc/usbip_host_common.c. USB vendor/product/class naming is resolved through libsrc/names.c, optionally using hwdata USB ID data.
Virtual gadget export
The daemon can also export USB Gadget instances attached to the external usbip-vudc kernel module rather than physical host devices. vudc/vudc_server_example.sh demonstrates the ConfigFS gadget-to-vUDC setup. This path shares daemon/network control flow but relies on gadget ConfigFS and vUDC naming instead of physical bus-ID binding.
Runtime and build dependencies
This is native Linux C software built with Autotools (configure.ac, Makefile.am). Runtime dependencies include libudev for device/sysfs discovery and optional libwrap TCP wrappers for daemon connection policy. The operational environment requires privileged access to sysfs, loaded USB/IP kernel modules, network reachability to TCP/3240, and potentially ConfigFS for gadget export.
Main entry points: usbip.c usbip CLI · usbipd.c usbipd daemon · usbip_network.c USB/IP network protocol · usbip_attach.c Client lifecycle
Components 17
Operator Control
- Operator or scripts
- usbip CLI · Dispatches export, import, discovery, and status commands.
src/usbip.c - Export lifecycle
src/usbip_bind.c - Client lifecycle
src/usbip_attach.c - Discovery and status
src/usbip_list.c
USB/IP Userspace
- usbipd daemon · Accepts USB/IP control connections and services exports.
src/usbipd.c - USB/IP network protocol · Shared client/server TCP control operations; primary security-protocol boundary.
src/usbip_network.c - Shared USB/IP models
libsrc/usbip_common.c - Host export enumeration
libsrc/usbip_host_common.c - Device-driver sysfs layer
libsrc/usbip_device_driver.c - VHCI sysfs layer · Allocates ports, attaches connections, and reports local imports.
libsrc/vhci_driver.c
Linux Kernel Boundaries
- usbip-host kernel driver · Exports bound physical USB devices.
- vhci-hcd kernel driver · Provides local virtual host-controller ports.
- Local Linux USB drivers · Consume imported devices after VHCI attachment.
Remote Export Host
- Remote usbipd · Provides discovery and requested device exports over TCP/3240.
src/usbipd.c - Physical USB devices
- Gadget ConfigFS and usbip-vudc · Optional gadget-backed export path.
vudc/vudc_server_example.sh
Connections 20
- Operator or scripts → usbip CLI: runs
- usbip CLI → Export lifecycle: bind / unbind
- usbip CLI → Client lifecycle: attach / detach
- usbip CLI → Discovery and status: list / port
- Export lifecycle → Device-driver sysfs layer: manages binding
- Device-driver sysfs layer → usbip-host kernel driver: sysfs control
- usbip-host kernel driver → Physical USB devices: exports
- Client lifecycle → USB/IP network protocol: requests remote device
- Discovery and status → USB/IP network protocol: remote discovery
- USB/IP network protocol → Remote usbipd: TCP/3240
- Remote usbipd → usbipd daemon: same daemon role
- usbipd daemon → USB/IP network protocol: serves protocol
- usbipd daemon → Host export enumeration: enumerates exports
- Host export enumeration → Shared USB/IP models: builds device metadata
- Host export enumeration → Device-driver sysfs layer: reads driver state
- Client lifecycle → VHCI sysfs layer: attach / detach
- Discovery and status → VHCI sysfs layer: reads port state
- VHCI sysfs layer → vhci-hcd kernel driver: sysfs control
- vhci-hcd kernel driver → Local Linux USB drivers: presents imported USB device
- Gadget ConfigFS and usbip-vudc → usbipd daemon: optional virtual export