From 5a9914a92fa72d61510b5f2aacd6665e3f8fa659 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 16 Dec 2021 13:55:41 -0800 Subject: [PATCH] wgengine/netstack: don't remove 255.255.255.255/32 from netstack The intent of the updateIPs code is to add & remove IP addresses to netstack based on what we get from the netmap. But netstack itself adds 255.255.255.255/32 apparently and we always fight it (and it adds it back?). So stop fighting it. Updates #2642 (maybe fixes? maybe.) Change-Id: I37cb23f8e3f07a42a1a55a585689ca51c2be7c60 Signed-off-by: Brad Fitzpatrick --- wgengine/netstack/netstack.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/wgengine/netstack/netstack.go b/wgengine/netstack/netstack.go index 5e5a5aaa0..64db617af 100644 --- a/wgengine/netstack/netstack.go +++ b/wgengine/netstack/netstack.go @@ -229,12 +229,21 @@ func ipPrefixToAddressWithPrefix(ipp netaddr.IPPrefix) tcpip.AddressWithPrefix { } } +var v4broadcast = netaddr.IPv4(255, 255, 255, 255) + func (ns *Impl) updateIPs(nm *netmap.NetworkMap) { ns.atomicIsLocalIPFunc.Store(tsaddr.NewContainsIPFunc(nm.Addresses)) oldIPs := make(map[tcpip.AddressWithPrefix]bool) for _, protocolAddr := range ns.ipstack.AllAddresses()[nicID] { - oldIPs[protocolAddr.AddressWithPrefix] = true + ap := protocolAddr.AddressWithPrefix + ip := netaddrIPFromNetstackIP(ap.Address) + if ip == v4broadcast && ap.PrefixLen == 32 { + // Don't delete this one later. It seems to be important. + // Related to Issue 2642? Likely. + continue + } + oldIPs[ap] = true } newIPs := make(map[tcpip.AddressWithPrefix]bool)