Skip to content

host: add opt-in networking with host-proxied sockets - #23

Merged
danbugs merged 15 commits into
mainfrom
networking
May 14, 2026
Merged

host: add opt-in networking with host-proxied sockets#23
danbugs merged 15 commits into
mainfrom
networking

Conversation

@danbugs

@danbugs danbugs commented May 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add host-proxied socket tools (net_socket, net_bind, net_connect, net_send, net_recv, net_sendto, net_recvfrom, net_close, net_getsockopt) that let Unikraft guests make TCP/UDP connections through the host
  • Networking is opt-in: disabled by default, enabled via --net (allow all) or --net-allow HOST (allowlist) on both the hyperlight-unikraft CLI and pyhl
  • NetworkPolicy type with AllowAll and AllowList variants; enforcement at net_connect and net_sendto (outbound-only gating)
  • AllowList::from_hosts resolves hostnames to IPs at construction time (fail-closed on resolution failure)
  • Plumbed through SandboxBuilder, evolve_*, snapshot loading, and the pyhl library API
  • networking-py example with HTTP GET, urllib, HTTPS/TLS, and echo server demos
  • python-agent-driver kraft.yaml updated to enable hostsock + FD infrastructure; Dockerfile updated with DNS config and CA certificates for TLS

Depends on the networking branch of danbugs/unikraft for the guest-side lib/hostsock socket driver.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linux Benchmarks

Details
Benchmark suite Current: fceb11f Previous: f3c3ce4 Ratio
hello_world (median) 20 ms 20 ms 1
pandas (median) 110 ms 110 ms 1
density (per VM) 7 MB 7 MB 1
snapshot (disk) 385 MiB 384 MiB 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows Benchmarks

Details
Benchmark suite Current: fceb11f Previous: f3c3ce4 Ratio
hello_world (median) 191 ms 215 ms 0.89
pandas (median) 550 ms 634 ms 0.87
density (per VM) 6 MB 6 MB 1
snapshot (disk) 393 MiB 392 MiB 1.00

This comment was automatically generated by workflow using github-action-benchmark.

danbugs added 14 commits May 14, 2026 14:56
Adds a SocketTable and net_* tool handlers (net_socket, net_connect,
net_bind, net_listen, net_accept, net_send, net_sendto, net_recv,
net_recvfrom, net_close, net_shutdown, net_setsockopt, net_getsockopt,
net_getpeername, net_getsockname) using socket2 for cross-platform
socket management. Registered automatically via register_net_tools.

Signed-off-by: danbugs <danilochiarlone@gmail.com>
Python networking test using host-proxied sockets (hostsock).
Includes HTTP GET client (raw sockets, no DNS needed) and a
TCP echo server. kraft.yaml enables LIBPOSIX_SOCKET + LIBHOSTSOCK
and points to danbugs/unikraft:networking for the hostsock driver.

Signed-off-by: danbugs <danilochiarlone@gmail.com>
Signed-off-by: danbugs <danilochiarlone@gmail.com>
Signed-off-by: danbugs <danilochiarlone@gmail.com>
Signed-off-by: danbugs <danilochiarlone@gmail.com>
Signed-off-by: danbugs <danilochiarlone@gmail.com>
Signed-off-by: danbugs <danilochiarlone@gmail.com>
Signed-off-by: danbugs <danilochiarlone@gmail.com>
Signed-off-by: danbugs <danilochiarlone@gmail.com>
…pyhl

Signed-off-by: danbugs <danilochiarlone@gmail.com>
Add hostsock networking config to kraft.yaml (pointing to
danbugs/unikraft networking branch) and bundle DNS resolv.conf,
nsswitch.conf, hosts, and CA certificates into the CPIO rootfs
so the guest can resolve hostnames and make TLS connections.

Signed-off-by: danbugs <danilochiarlone@gmail.com>
Signed-off-by: danbugs <danilochiarlone@gmail.com>
Signed-off-by: danbugs <danilochiarlone@gmail.com>
…ged upstream)

Signed-off-by: danbugs <danilochiarlone@gmail.com>
@danbugs
danbugs marked this pull request as ready for review May 14, 2026 14:56
Signed-off-by: danbugs <danilochiarlone@gmail.com>
@danbugs
danbugs merged commit 5f424bb into main May 14, 2026
78 checks passed
@danbugs
danbugs deleted the networking branch May 14, 2026 15:28
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