Skip to content

Commit

Permalink
Network: Allow OVN subnets smaller than /64 when stateful DHCPv6 is e…
Browse files Browse the repository at this point in the history
…nabled (#14284)

We can allow IPv6 subnets smaller than /64 for the case when stateful
DHCPv6 is used or DHCP is completely disabled.

Suggested-by: Thomas Parrott <[email protected]>

See also:
canonical/lxd-ci#321
#14276
  • Loading branch information
tomponline authored Oct 16, 2024
2 parents e444ef3 + 48451e8 commit dcd70b1
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lxd/network/driver_ovn.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,13 +596,16 @@ func (n *ovn) Validate(config map[string]string) error {
return err
}

// Check that if IPv6 enabled then the network size must be at least a /64 as both RA and DHCPv6
// in OVN (as it generates addresses using EUI64) require at least a /64 subnet to operate.
_, ipv6Net, _ := net.ParseCIDR(config["ipv6.address"])
if ipv6Net != nil {
ones, _ := ipv6Net.Mask.Size()
if ones > 64 {
return fmt.Errorf("IPv6 subnet must be at least a /64")
// Check that if stateless DHCPv6 is enabled and IPv6 subnet is set then the network size
// must be at least a /64 as both RA and DHCPv6 in OVN (as it generates addresses using EUI64)
// require at least a /64 subnet to operate.
if shared.IsTrueOrEmpty(config["ipv6.dhcp"]) && shared.IsFalseOrEmpty(config["ipv6.dhcp.stateful"]) {
_, ipv6Net, _ := net.ParseCIDR(config["ipv6.address"])
if ipv6Net != nil {
ones, _ := ipv6Net.Mask.Size()
if ones > 64 {
return fmt.Errorf("IPv6 subnet must be at least a /64 when stateless DHCPv6 is enabled")
}
}
}

Expand Down

0 comments on commit dcd70b1

Please sign in to comment.