|
|
@ -76,6 +76,21 @@ func RingOneAddress(region RegionID, zone ZoneID, node NodeID) (addr netip.Addr, |
|
|
|
return addr, err |
|
|
|
return addr, err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// RingThreePrefix returns the subnet corresponding to
|
|
|
|
|
|
|
|
// the pods of a cluster.
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// Ring 3 is a `10.(region_id << 4).0.0/12` network
|
|
|
|
|
|
|
|
func RingThreePrefix(region RegionID) (subnet netip.Prefix, err error) { |
|
|
|
|
|
|
|
switch { |
|
|
|
|
|
|
|
case !region.Valid(): |
|
|
|
|
|
|
|
err = ErrOutOfRange(region, "region") |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
addr := unsafeRingThreeAddress(region, 0) |
|
|
|
|
|
|
|
subnet = netip.PrefixFrom(addr, RingThreeBits) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return subnet, err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func unsafeRingZeroAddress(region RegionID, zone ZoneID, node NodeID) netip.Addr { |
|
|
|
func unsafeRingZeroAddress(region RegionID, zone ZoneID, node NodeID) netip.Addr { |
|
|
|
r := uint(region) |
|
|
|
r := uint(region) |
|
|
|
z := uint(zone) |
|
|
|
z := uint(zone) |
|
|
@ -93,3 +108,13 @@ func unsafeRingOneAddress(region RegionID, zone ZoneID, node NodeID) netip.Addr |
|
|
|
|
|
|
|
|
|
|
|
return AddrFrom4(10, r, z<<4+n1, n0) |
|
|
|
return AddrFrom4(10, r, z<<4+n1, n0) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func unsafeRingThreeAddress(region RegionID, n uint) netip.Addr { |
|
|
|
|
|
|
|
r := uint(region) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
n2 := n >> 16 |
|
|
|
|
|
|
|
n1 := n >> 8 |
|
|
|
|
|
|
|
n0 := n >> 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return AddrFrom4(10, r<<4+n2, n1, n0) |
|
|
|
|
|
|
|
} |
|
|
|