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

4 bytes header on macos #19

Open
ihciah opened this issue Aug 2, 2020 · 3 comments
Open

4 bytes header on macos #19

ihciah opened this issue Aug 2, 2020 · 3 comments

Comments

@ihciah
Copy link

ihciah commented Aug 2, 2020

On linux, packet_information default value is false, which means IFF_NO_PI will be used. But on macos, the 4-byte ethernet family header will be passed when read.
I think the behavior should be consistent on different platforms. Should the behavior on macos changed? Maybe packet_information can be applied for macos too to control whether remove the header?

@meh
Copy link
Owner

meh commented Aug 3, 2020

If that's how it works, yes, I do not have any macOS systems so cannot develop it myself.

@tubzby
Copy link

tubzby commented Jun 16, 2021

@ihciah I have the same problem on macos, I have been using a Golang implementation without this problem: https://github.com/songgao/water

@tubzby
Copy link

tubzby commented Jun 18, 2021

I just figured it out, the bytes are [0, 0, 0, 2], 2 stands for AF_INET/ AF_INET6.
The header need also to be sent while writing to the socket, a userspace copy is required.

I checked out broingtun: https://github.com/cloudflare/boringtun, it use sengmsg with vectors so that it will reduce data copy.

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

No branches or pull requests

3 participants