Skip to content

Add listen to BSDs #259

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

Closed
wants to merge 1 commit into from

Conversation

tuxillo
Copy link

@tuxillo tuxillo commented Aug 15, 2023

Copy over Darwin's code and reuse it for the most common BSDs. It is untested in all BSDs added but in DragonFly BSD but at least it'll allow the build to succeed.

Might want to merge darwin and BSD file together but for now they are separate because we might need to add something BSD-specific.

Build might fail in DragonFly BSD because it depends on insomniacslk/dhcp#510 , which is still not upstream. So a bump will also be needed for this specific OS.

This is for the ongoing issue lima-vm/lima#892

Copy over Darwin's code and reuse it for the most common BSDs. It is
untested in all BSDs added but in DragonFly BSD but at least
it'll allow the build to succeed.

TODO: Might want to merge darwin and BSD file together but for now
they are separate because we might need to add something BSD-specific.
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 15, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: tuxillo
Once this PR has been reviewed and has the lgtm label, please assign baude for approval. For more information see the Kubernetes Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@@ -0,0 +1,58 @@
//go:build freebsd || netbsd || openbsd || dragonfly
// +build freebsd netbsd openbsd dragonfly
Copy link
Contributor

Choose a reason for hiding this comment

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

darwin.go can be merged here too?

Copy link
Author

Choose a reason for hiding this comment

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

I left it in different files just in case there was something BSD-y required that's not present in Darwin. I can't try all BSDs tho.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems like it would be easy enough to duplicate this file when BSD-specific support would be needed? I'd prefer to only have //go:build darwin || dragonfly || freebsd || netbsd || openbsd for now, instead of adding more duplicate listen code.
If you duplicate the code, I'd remove the case "vsock" block which is hyperkit specific, and ListenUnixgram is also not expected to be used as it's vfkit-specific, so this could error out.

Choose a reason for hiding this comment

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

Seems like a good reason to have two, one for darwin and one for bsd

Copy link
Collaborator

Choose a reason for hiding this comment

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

If the BSD files are different from the darwin files, yes, this is a good reason for having 2 files. As the PR is right now, the files are the same.

@cfergeau
Copy link
Collaborator

The commit log is missing a Signed-off-by (git commit --amend -s)

@cfergeau
Copy link
Collaborator

My take on this is https://github.com/cfergeau/gvisor-tap-vsock/tree/bsd - It's more involved than this PR as this refactors the existing code so that the platform files only contain platform specific code. Then this adds a generic Listen method which is used on platforms which are not darwin, not linux, not windows.
I've only tested that this builds, I haven't tried to run it yet.

@tuxillo
Copy link
Author

tuxillo commented Aug 17, 2023

My take on this is https://github.com/cfergeau/gvisor-tap-vsock/tree/bsd - It's more involved than this PR as this refactors the existing code so that the platform files only contain platform specific code. Then this adds a generic Listen method which is used on platforms which are not darwin, not linux, not windows. I've only tested that this builds, I haven't tried to run it yet.

Have some questions.

  • If the vsock case is Hyperkit specific (MacOS), why is it still present in Linux code?
  • Can the DefaultURL be defined per platforms so that all the unix stuff can be merged into a single file?

@cfergeau
Copy link
Collaborator

cfergeau commented Aug 17, 2023

If the vsock case is Hyperkit specific (MacOS), why is it still present in Linux code?

The vsock implementation in listen_darwin.go is hyperkit-specific, the use of unix sockets, and the naming of the corresponding file (cid.port) is something only hyperkit uses.
On linux, vsock can also be used, but in a different, more generic way through mdlayher/vsock (which wraps AF_VSOCK sockets)

Can the DefaultURL be defined per platforms so that all the unix stuff can be merged into a single file?

I'm not sure which "unix stuff" you are referring to?

@tuxillo
Copy link
Author

tuxillo commented Aug 17, 2023

Can the DefaultURL be defined per platforms so that all the unix stuff can be merged into a single file?

I'm not sure which "unix stuff" you are referring to?

I was referring to all unix-like systems (linux, bsds, probably solaris) but not Darwin. But now that vsock is still needed in Linux for the vsock implementation you mentioned this makes less sense.

@tuxillo
Copy link
Author

tuxillo commented Aug 18, 2023

@cfergeau what are the next steps then?

@cfergeau
Copy link
Collaborator

@cfergeau what are the next steps then?

I filed #262 , though I have only tested it on linux.

I'm also fine with just adding the BSD build tags to the darwin code for now, and with a Signed-off-by added to the commit log.

@cfergeau
Copy link
Collaborator

cfergeau commented Aug 24, 2023

With #262 merged, *bsd builds should be fixed, closing this PR.

@cfergeau cfergeau closed this Aug 24, 2023
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.

4 participants