Skip to content

many: add vsock support for the bridge#30

Open
mvo5 wants to merge 6 commits intosystemd:mainfrom
mvo5:add-vsock-support
Open

many: add vsock support for the bridge#30
mvo5 wants to merge 6 commits intosystemd:mainfrom
mvo5:add-vsock-support

Conversation

@mvo5
Copy link
Copy Markdown
Contributor

@mvo5 mvo5 commented Mar 27, 2026

[build on top of https://github.com//pull/29]

This PR adds vsock support for the varlink-http-bridge. from the user PoV it looks like this:

Inside the vm (there is also a default data/varlink-httpd-vsock.socket so this can start automaticall):

$ varlink-httpd --bind=vsock --authorized-keys=~/.ssh/authorized_keys

And on the host (assume the right ssh keys are available):

$ varlinkctl call vsock://3/ws/sockets/io.systemd.Hostname iio.systemd.Hostname.Describe '{}'

mvo5 added 3 commits March 27, 2026 17:22
The tls code is now logging the connectins in `connect_info()`
just like PlainListener and the coming VsockListener.

This way the code becomes more symmetrical.
Our TlsListener::new() code was syncronous - so slow clients
could stall/block the server. This commit adds a new AsyncTlsListener
that avoids this problem by using tokio::spawn() and a `mpsc`
(multi-producer, single-consume) channel.

This is very similar to the `tls-listener` crate but that does
not implement the axum `serve::Listener` trait so using it is
a bit cumbersome and its not much code that we add here.
No need to specify the default for --bind in the unit file. Its
already the default so it is redundant.
@mvo5 mvo5 force-pushed the add-vsock-support branch from eff88c5 to dac5176 Compare March 27, 2026 16:38
mvo5 added 2 commits March 27, 2026 17:47
This commit adds support to use the vsock protocol instead of
tcp. This allows us to run the bridge in VMs even if there is
no networking (yet). Both socket actviation and --bind options
are supported.

Usage examples for the server:
```
$ varlink-httpd --bind=vsock --insecure
varlink-httpd --bind=vsock::5000 --insecure
```

Client examples:
```
$ varlinkctl-http call vsock://3:5000/io.systemd.Hostname/Describe '{}'
```
Because vsock is just a transport we need to provide mTLS auth
there too. Its a bit silly to encrypt the traffic over vsock
as its not snifable but the mTLS certs are useful and it would
be strange to not support all auth methods over all transports.
@mvo5 mvo5 force-pushed the add-vsock-support branch from dac5176 to b9e5938 Compare March 27, 2026 16:47
With rust-vsock/tokio-vsock#72 being merged
we can remove the unsafe block and use the From<OwnedFd> in the
vsock listener code.

# SSH authorized keys (see systemd.system-credentials(7))
ImportCredential=ssh.authorized_keys.root
ImportCredential=ssh.ephemeral-authorized_keys-all
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could add some hardening options here. I guess this needs to run as run, so the effect will be limited, but it'd still be better than nothing.

# This file is part of varlink-http-bridge.

[Unit]
Description=Varlink HTTP Bridge (vsock)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So maybe I'm misunderstanding something, but why not have a single .service unit with one or more sockets that are enabled/disabled independently? In other words, I don't think a new service file is needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Silly me, fixing.

Comment on lines +1131 to +1132
--bind=ADDR address to bind to (default: 0.0.0.0:{DEFAULT_PORT})
use vsock::PORT for vsock (e.g. vsock::{DEFAULT_PORT})
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess we'd need to allow more than one address here. But in practice this is going to be needed anyway, e.g. to bind to a specific IPv4 and IPv6 addresses.

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.

2 participants