-
-
Notifications
You must be signed in to change notification settings - Fork 297
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
Adding --add-payload-offset flag (macos only) [and 1.48 updates] #192
Conversation
@thepacketgeek @imsnif the logic here seems to be based off a libpnet example, but the logic seems to differ: https://github.com/libpnet/libpnet/blob/master/examples/packetdump.rs#L255 |
Correct, utun interfaces are not loopback, but loopback interfaces do have a payload offset. In my testing, some utun interfaces have a payload offset (which is why #129 works) but not all. For example, when using bandwhich to monitor a Wireguard utun interface, this PR's Looking at this code, it seems the offset should only apply to loopback interfaces, so I'm really not sure why packet parsing is different for some utun interfaces. |
Hey @thepacketgeek - could you help me understand what's the current status here? What do we know, what aren't we sure about, which types of interfaces need it, which don't, what will break, etc? It'll help me make a decision about how to include this change. Thanks! |
Hey @imsnif , sorry for the delay. I latest update is here. I suspect that with the libpnet change utun/P2P interfaces no longer need an offset (only loopback interfaces on mac do), which greatly simplifies this PR (no So I was hoping someone that has a client that previously needed the offset to work test out the patch. I can update this PR with the simplified change, but would need external help to test it out on more interfaces. |
Aha. I sadly don't have access to one either. Do you think we can go with that assumption and provide some workaround flag in case we're either wrong or half right in one way or another? :) |
I think that's a great idea :) I'll revert back to the version with a flag, but make the default only add offsets for loopbacks, but with a flag to add it for utun interfaces. |
Hey @thepacketgeek - looking good. I re-ran the failing test because it's sometimes a little flaky. It's okay now (sorry about that :) ). Is this strictly a mac behaviour? If we're adding this as a manual flag, would it be wrong to have the flag be cross-platform and not mac-only? |
It does appear to be macos only: https://github.com/libpnet/libpnet/blob/07e73e2c60dcec7a3655ea79876058037a57fff6/examples/packetdump.rs#L252,L264 I suspect adding a payload offset for any combination other than macos & loopback/utun would end up breaking packet parsing for anything other than macos? |
@imsnif I agree that the change is greatly simplified without the I was finally able to confirm that the payload flag is still required for some VPN interfaces (like Cisco AnyConnect). I really wish there was a way to deterministically know :\ |
Sure. Let's add it as an option. Would definitely be better to deterministically know, but this way we can at least have a built-in workaround. |
|
Oh shoot, I got caught in 1.48 clippy changes. I'll make another PR to update those lints and rebase this PR on top |
Actually, if you could do it in this PR that would be helpful for me :) My apologies - I don't have a lot of time for bandwhich these days as I'm sure you noticed. I'd be happy to try and make time for this patch in the next few days though. |
@imsnif I'm running into another gift of 1.48, an issue with the LruCache used in trust-dns (happens on main, this is not new to this PR):
This only happens when DNS resolution is enabled, so I suggest waiting for a release |
Alright, sorry for all the noise. Seems this issue has already been resolved in (I believe by the change that no longer requires This PR should be ready to go finally :) |
Thanks for this, i came here from the reference PR which may help the maintainers of bandwich. |
The default payload status is what should work for most cases: - offset on for macos loopbacks - offset off for macos utun
Follow-up for #129: Not all "macos" Point-to-point (E.g. utun) interfaces use a payload offset, according to libpnet. This PR removes the offset for VPN interfaces by default and adds an
--add-payload-offset
flag to allow the offset when desired.cfg!
conditions onceSniffer
only affectscfg!(target_os = "macos")