Skip to content

Add local vhost loopback example for single-machine development - #57

Closed
sarsanaee wants to merge 1 commit into
mainfrom
local-vhost-example
Closed

Add local vhost loopback example for single-machine development#57
sarsanaee wants to merge 1 commit into
mainfrom
local-vhost-example

Conversation

@sarsanaee

Copy link
Copy Markdown
Collaborator

Summary

Adds a self-contained way to develop and test Machnet locally on one Linux machine — no physical NIC, second VM, or cloud setup — by running the stack on a pair of DPDK virtual devices (net_vhost + virtio_user) wired back-to-back over a unix socket.

  • examples/local_vhost_test.sh — one-command local experiment: starts the Machnet daemon on the vhost pair, then runs the existing hello_world server (10.66.0.1) and client (10.66.0.2) and asserts the message crosses the loop (ARP, handshake, data transfer). Heavily commented so it doubles as local-dev documentation.
  • examples/local_vhost_config.json — the two-interface config for the loop.
  • machnet_config — new optional per-interface "vdev" key, passed to DPDK as --vdev (plus --no-pci when no physical ports are configured). vdev args are sorted so DPDK port ids — and hence the net_vhost MAC, which is derived from the port id (56:48:4f:53:54:<port id>) — are deterministic across runs.
  • pmd.cc — ports lacking TX checksum offloads now fall back to a basic ethernet configuration with a loud warning instead of LOG(FATAL). Virtual devices have no checksum offloads; nothing on a local loop verifies checksums, so this is safe for the intended use and keeps the fatal-by-default spirit via the warning.
  • READMEs — new "Local development without a NIC" section and vdev field docs.

Testing

  • bash -n on the script and JSON validation pass.
  • ⚠️ Not yet run end-to-end: authored on macOS where DPDK does not build. Needs a Linux run of sudo examples/local_vhost_test.sh before undrafting. Known risk to verify: the net_vhost PMD MAC assumption (56:48:4f:53:54:00 for port 0) — the script's comments explain how to reconcile against the [PMDPORT] log lines if it differs.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EFQ6Rh1j4r3i9QURDaUyXm

Machnet previously required a physical DPDK NIC (and typically a pair of
cloud VMs) to try anything end-to-end. This adds a self-contained local
test that runs the full datapath on one Linux machine using DPDK virtual
devices: a net_vhost port and a virtio_user port wired back-to-back over
a unix socket, driven by the existing hello_world app.

- examples/local_vhost_test.sh: starts the daemon on the vhost pair and
  verifies a hello_world message crosses the loop; heavily commented so
  it doubles as local-development documentation.
- examples/local_vhost_config.json: two-interface config for the loop.
- machnet_config: new optional per-interface "vdev" key, passed to DPDK
  as --vdev (plus --no-pci when no physical ports are configured). vdev
  arguments are sorted so DPDK port ids -- and thus the net_vhost MAC,
  which is derived from the port id -- are deterministic.
- pmd.cc: fall back to a basic ethernet configuration with a warning,
  instead of LOG(FATAL), when a port lacks TX checksum offloads;
  virtual devices have none, and nothing on a local loop verifies
  checksums.
- README.md / src/apps/machnet/README.md: document the new field and
  the local workflow.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFQ6Rh1j4r3i9QURDaUyXm
@sarsanaee sarsanaee closed this Jul 21, 2026
@sarsanaee
sarsanaee deleted the local-vhost-example branch July 21, 2026 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant