From 5276691a12f0cdad1b359bdccaaf2f9199c79690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20Wanzenb=C3=B6ck?= Date: Fri, 11 Oct 2024 09:32:13 +0200 Subject: [PATCH] network: fix calculation of DHCP range for /16 networks When generating DHCP ranges for /16 networks, we are right at the limits of what libvirt supports. We try to limit the number of hosts to at most 2^16-1 in case of large subnets. However, the check was incorrect, as for a /16 network we would define the end range as being .255.255, i.e. the broadcast address. So when we have a /16 network, we are still in the default case of having to decrement the "last" IP by one. --- cmd/network_add.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/network_add.go b/cmd/network_add.go index d8d7ca5..4cfd765 100644 --- a/cmd/network_add.go +++ b/cmd/network_add.go @@ -144,7 +144,7 @@ func buildNetworkDHCP(ip net.IP, n *net.IPNet, dhcpMAC string, dhcpID uint, dhcp prefix, hostBits := n.Mask.Size() // libvirt does not support more than 2^16-1 hosts in the dhcp range - if hostBits-prefix >= 16 { + if hostBits-prefix > 16 { end, _ = cidr.Host(n, 65535) } else { end = cidr.Dec(end)