-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
virtionet: Fix 'path too long' issues with virtio-net unixgram Support #195
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
3c19443
to
8f5a7e2
Compare
pkg/vf/virtionet.go
Outdated
if err != nil { | ||
return err | ||
} | ||
// FIXME: need to remove localSocketPath at process exit | ||
if len(localSocketPath) >= 104 { | ||
return fmt.Errorf("socket path is too long: %d", len(localSocketPath)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add the max value here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed it to
+ if len(localSocketPath) >= maxUnixgramPathLen {
+ return fmt.Errorf("unixgram path '%s' is too long: %d >= %d bytes", localSocketPath, len(localSocketPath), maxUnixgramPathLen)
+ }
dd2d840
to
5e826b5
Compare
1ac61cd
to
444dc28
Compare
I've finally updated the tests introduced in d7b2799 |
macos 12 runners are going away: actions/runner-images#10721 Signed-off-by: Christophe Fergeau <[email protected]>
With unixgram sockets, we need to specify a client endpoint, which is a path on the filesystem with a maximum length of 104 bytes on macOS. When using -device virtio-net,unixSocketPath=/tmp/vnet.sock, we need to create a client endpoint before connecting to /tmp/vnet.sock. It's currently put into `/Users/user/Library/Application Support`, which is already fairly long. Depending on the username, the 104 bytes are easily exceeded, this has been causing problems to podman machine. This commit will create the client endpoint in the same directory as the server endpoint, which gives more control to the user of vfkit wrt where this socket is going. This fixes crc-org#194 Signed-off-by: Christophe Fergeau <[email protected]>
Path used for unix socket client/server endpoints have to be less than 104. When this is not the case, `bind: invalid argument` is returned. This commit checks the path length before calling `DialUnix` in order to provide an easier to understand error message. Signed-off-by: Christophe Fergeau <[email protected]>
For communication over unixgram, both the server and the client need an endpoint. They are filesystem paths which must be smaller than 104 bytes. This commit attempts to make them shorter while keeping them unique and non-guessable. Signed-off-by: Christophe Fergeau <[email protected]>
With unixgram sockets, we need to specify a client endpoint, which is a
path on the filesystem with a maximum length of 104 bytes on macOS. When
using -device virtio-net,unixSocketPath=/tmp/vnet.sock, we need to create a
client endpoint before connecting to /tmp/vnet.sock. It's currently put
into
/Users/user/Library/Application Support
, which is already fairlylong. Depending on the username, the 104 bytes are easily exceeded, this
has been causing problems to podman machine.
This PR will move the client endpoint to the same dir as the server endpoint to give more control over its location to vfkit users. It will also report a better error when the endpoint path length is more than 104 bytes, and it tries to shorten the client endpoint filename.
This fixes #194