MCPcopy Index your code
hub / github.com/tailscale/tailscale / addSubnetAddress

Method addSubnetAddress

wgengine/netstack/netstack.go:658–678  ·  view source on GitHub ↗
(ip netip.Addr)

Source from the content-addressed store, hash-verified

656}
657
658func (ns *Impl) addSubnetAddress(ip netip.Addr) {
659 ns.mu.Lock()
660 ns.connsOpenBySubnetIP[ip]++
661 needAdd := ns.connsOpenBySubnetIP[ip] == 1
662 ns.mu.Unlock()
663 // Only register address into netstack for first concurrent connection.
664 if needAdd {
665 pa := tcpip.ProtocolAddress{
666 AddressWithPrefix: tcpip.AddrFromSlice(ip.AsSlice()).WithPrefix(),
667 }
668 if ip.Is4() {
669 pa.Protocol = ipv4.ProtocolNumber
670 } else if ip.Is6() {
671 pa.Protocol = ipv6.ProtocolNumber
672 }
673 ns.ipstack.AddProtocolAddress(nicID, pa, stack.AddressProperties{
674 PEB: stack.CanBePrimaryEndpoint, // zero value default
675 ConfigType: stack.AddressConfigStatic, // zero value default
676 })
677 }
678}
679
680func (ns *Impl) removeSubnetAddress(ip netip.Addr) {
681 ns.mu.Lock()

Callers 2

Calls 3

LockMethod · 0.65
UnlockMethod · 0.65
AsSliceMethod · 0.45

Tested by

no test coverage detected