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

Merge pull request #404 from cozystack/fix/allowed-location-ips-overlap

fix(topology): allow allowed-location-ips to contain node IPs
Lucas Servén Marín 2 месяцев назад
Родитель
Сommit
9a45ea4df2
1 измененных файлов с 8 добавлено и 3 удалено
  1. 8 3
      pkg/mesh/topology.go

+ 8 - 3
pkg/mesh/topology.go

@@ -263,17 +263,22 @@ CheckIPs:
 				}
 			}
 			// Check if allowed location IPs intersect with the allowed IPs.
+			// If the allowed location IP strictly contains an allowed IP, that's
+			// fine - the more specific route will be used. Reject if the allowed
+			// IP contains or equals the allowed location IP.
 			for _, i := range s.allowedIPs {
-				if intersect(ip, i) {
+				if i.Contains(ip.IP) {
 					_ = level.Warn(t.logger).Log("msg", "overlapping allowed location IPnet with allowed IPnets", "IP", ip.String(), "IP2", i.String(), "segment-location", s.location)
 					continue CheckIPs
 				}
 			}
 			// Check if allowed location IPs intersect with the private IPs of the segment.
+			// If the allowed location IP fully contains a private IP, that's fine.
 			for _, i := range s.privateIPs {
 				if ip.Contains(i) {
-					_ = level.Warn(t.logger).Log("msg", "overlapping allowed location IPnet with privateIP", "IP", ip.String(), "IP2", i.String(), "segment-location", s.location)
-					continue CheckIPs
+					// This is OK - the allowed location IP contains the private IP,
+					// so the more specific route to the private IP will still work.
+					_ = level.Debug(t.logger).Log("msg", "allowed location IPnet contains privateIP", "IP", ip.String(), "IP2", i.String(), "segment-location", s.location)
 				}
 			}
 		}