Skip to content

wgengine/netstack: Allow userspace networking mode to expose subnets - #1588

Merged
tendstofortytwo merged 9 commits into
mainfrom
naman/netstack-subnet-routing
Mar 29, 2021
Merged

tendstofortytwo merged 9 commits into
mainfrom
naman/netstack-subnet-routing

Conversation

@tendstofortytwo

Copy link
Copy Markdown
Member

Updates #504

Updates #707

Signed-off-by: Naman Sood [email protected]

Comment thread wgengine/netstack/netstack.go Resolved
Comment thread wgengine/netstack/netstack.go Resolved
Comment thread wgengine/netstack/netstack.go Resolved
Comment thread wgengine/netstack/netstack.go Resolved
Comment thread wgengine/netstack/netstack.go Resolved
Comment thread wgengine/netstack/netstack.go Resolved
Comment thread wgengine/netstack/netstack.go Resolved
Comment thread wgengine/netstack/netstack.go Resolved
var isTailscaleIP bool
reqDetails := r.ID()
dialAddr := reqDetails.LocalAddress
dialNetAddr, _ := netaddr.FromStdIP(net.IP(dialAddr))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you want to bail out early if this conversion fails?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I figured it shouldn't fail, given that we came this far (since there was a similar conversion done for this TCP request at the call of addSubnetAddress).

ns.connsOpenBySubnetIP[ip]++
// Only register address into netstack for first concurrent connection.
if ns.connsOpenBySubnetIP[ip] == 1 {
ns.ipstack.AddAddress(nicID, pn, tcpip.Address(ip.IPAddr().IP))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

probably doesn't matter but this doesn't really need to be done while ns.mu is held.

needAdd := ns.connsOpenBySubnetIP[ip] == 1
ns.mu.Unlock
if needAdd {
     ns.ipstack.AddAddress(nicID, pn, tcpip.Address(ip.IPAddr().IP))
}

@bradfitz

Copy link
Copy Markdown
Member

ship it. :)

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.

2 participants