Просмотр исходного кода

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 <[email protected]>
Brad Fitzpatrick 4 лет назад
Родитель
Сommit
5a9914a92f
1 измененных файлов с 10 добавлено и 1 удалено
  1. 10 1
      wgengine/netstack/netstack.go

+ 10 - 1
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)