(ip netip.Addr)
| 656 | } |
| 657 | |
| 658 | func (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 | |
| 680 | func (ns *Impl) removeSubnetAddress(ip netip.Addr) { |
| 681 | ns.mu.Lock() |
no test coverage detected