Skip to content

conn,device: support conn.ReceiveFunc nonzero packet offset #36

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

Open
wants to merge 1 commit into
base: tailscale
Choose a base branch
from

Conversation

jwhited
Copy link
Collaborator

@jwhited jwhited commented May 21, 2025

This enables a conn.Bind to leverage wireguard-go packet memory for reading packets containing layers that wireguard-go should ignore, e.g. a VXLAN or Geneve header preceeding WireGuard.

This enables a conn.Bind to leverage wireguard-go packet memory for
reading packets containing layers that wireguard-go should ignore, e.g.
a VXLAN or Geneve header preceeding WireGuard.

Signed-off-by: Jordan Whited <[email protected]>
@jwhited jwhited requested review from raggi and bradfitz May 21, 2025 22:21
Copy link

@sfllaw sfllaw left a comment

Choose a reason for hiding this comment

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

Just some notes about sources of confusion from someone unfamiliar with this codebase. Feel free to ignore.

Comment on lines +24 to +25
// sizes, packets, and endpoints that should be evaluated. A sizes element
// includes both the starting and ending offset for an element of packets. Some
Copy link

Choose a reason for hiding this comment

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

❓ Confused: Is the sizes element defined as [start, end)? It would be nice if the documentation were more explicit about ranges.

❓ Confused: Is this the name sizes still the right name for this, now that it is some kind of range or interval? Granted, I cannot come up with a better name.

sizes []int,
sizes [][2]int,
Copy link

Choose a reason for hiding this comment

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

❓ Confused: Is this tuple always going to be a range? Would it be more clear as a type size struct{ start, end int } or is that worse somehow?

Copy link
Member

@danderson danderson left a comment

Choose a reason for hiding this comment

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

LGTM. Reflecting some discussion off-github: we're balancing extending the functionality of this API for a pressing need, vs. doing a larger scale refactor to improve the packet wrangling API as a whole.

The latter is tempting, but is likely to spiral into a large change as it bubbles through more of the API. We'd rather tackle a broader redesign separately (and we're gearing up to, available bandwidth notwithstanding), rather than end up pulling refactors into this targeted feature change.

@@ -268,8 +268,8 @@ func (s *StdNetBind) receiveIP(
}
for i := 0; i < numMsgs; i++ {
msg := &(*msgs)[i]
sizes[i] = msg.N
if sizes[i] == 0 {
sizes[i][0], sizes[i][1] = 0, msg.N
Copy link
Member

Choose a reason for hiding this comment

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

minor suggestion, optional: move the continue branch below further up, and make the condition look at msg.N instead of the sizes array? As written here it took me a beat to translate the branch condition to "oh, skip empty messages".

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.

3 participants