Skip to content
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

Remove Linux-Only Features #4046

Closed
JonasGessner opened this issue May 17, 2021 · 2 comments · Fixed by #4507
Closed

Remove Linux-Only Features #4046

JonasGessner opened this issue May 17, 2021 · 2 comments · Fixed by #4507

Comments

@JonasGessner
Copy link

I'm using SCION on Darwin OSes (iOS and macOS) and dispatcher and sciond can be almost compiled straight out of the box if it weren't for one unsupported sycall flag in underlay/conn.go: MSG_WAITFORONE

In this case the affected code can simply be commented out because it appears to be unused anyway. But going forward I suggest removing this specific syscall flag so that dispatcher can be compiled with no modifications on macOS and other OSes that aren't Linux. Surely there must be some way to work without this flag.

Generally it should be avoided to use OS-specific features such as this MSG_WAITFORONE flag – I think it just unnecessarily hurts the possibilities for broader adoption.

@matzf
Copy link
Contributor

matzf commented Jun 8, 2021

Which part of SCION are you running on this macOS? This underlay/conn.go is (only) used by the router and dispatcher components.

The router and dispatcher use x/net library's ReadBatch, as this (supposedly) allows to achieve higher throughput. As the documentation for ReadBatch notes, this only uses recmmsg on Linux, so this is normally portable: "On Linux, a batch read will be optimized. On other platforms, this method will read only a single message."
Now, setting MSG_WAITFORONE is critical when recvmmsg is used; otherwise, the call would block indefinitely until the full batch was read which is obviously undesirable when there is a lower rate of incoming packets.
You could move the definition for the flags passed to ReadBatch to a platform specific file (// +build linux) to make this more portable.

@JonasGessner
Copy link
Author

Which part of SCION are you running on this macOS? This underlay/conn.go is (only) used by the router and dispatcher components.

I'm running the full stack, so sciond and dispatcher.

The router and dispatcher use x/net library's ReadBatch, as this (supposedly) allows to achieve higher throughput. As the documentation for ReadBatch notes, this only uses recmmsg on Linux, so this is normally portable: "On Linux, a batch read will be optimized. On other platforms, this method will read only a single message."
Now, setting MSG_WAITFORONE is critical when recvmmsg is used; otherwise, the call would block indefinitely until the full batch was read which is obviously undesirable when there is a lower rate of incoming packets.
You could move the definition for the flags passed to ReadBatch to a platform specific file (// +build linux) to make this more portable.

Sounds good to me!

matzf pushed a commit that referenced this issue Apr 18, 2024
The use of the platform-dependent flag syscall.MSG_WAITFORONE prevents
building the router on platforms other than Linux. This change isolates
this dependency. Behavior on non-Linux platforms will be less efficient
but still semantically correct because ReadBatch will only read a single
message on those platforms anyway.

Together with the previous PR #4499 and the dispatcher removal PR #4344
this set of changes will, e.g., enable running local development
topologies on platforms other than Linux.

Fixes #4046.
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 a pull request may close this issue.

2 participants