[management] Add IPv6 overlay addressing and capability gating (#5698)

This commit is contained in:
Viktor Liu
2026-04-08 22:40:51 +08:00
committed by GitHub
parent 86f1b53bd4
commit a1e7db2713
51 changed files with 2622 additions and 394 deletions

View File

@@ -14,10 +14,15 @@ import (
)
// EncodePrefix encodes a netip.Prefix into compact bytes.
// The address is always unmapped before encoding.
// The address is always unmapped before encoding. If unmapping produces a v4
// address, the prefix length is clamped to 32.
func EncodePrefix(p netip.Prefix) []byte {
addr := p.Addr().Unmap()
return append(addr.AsSlice(), byte(p.Bits()))
bits := p.Bits()
if addr.Is4() && bits > 32 {
bits = 32
}
return append(addr.AsSlice(), byte(bits))
}
// DecodePrefix decodes compact bytes into a netip.Prefix.