Add IPv6 support for Dnsmasq and NetworkManager

Signed-off-by: Timothy Middelkoop <tmiddelkoop@internet2.edu>
This commit is contained in:
Timothy Middelkoop
2025-11-27 01:56:18 +00:00
parent 07eee48a6a
commit 4f58845a9e
25 changed files with 417 additions and 106 deletions

View File

@@ -4,6 +4,7 @@ import (
"net"
"reflect"
"sort"
"strconv"
"strings"
"github.com/warewulf/warewulf/internal/pkg/util"
@@ -426,6 +427,28 @@ func (netdev *NetDev) IpCIDR() string {
return ipCIDR.String()
}
/*
Return the ipv6 address with prefix CIDR format. Aimed for the use in
template, symmetric with IpCIDR.
*/
func (netdev *NetDev) IpCIDR6() string {
if netdev.Ipaddr6 == nil || netdev.Ipaddr6.IsUnspecified() || netdev.PrefixLen6 == "" {
return ""
}
if netdev.Ipaddr6.To4() != nil {
return ""
}
prefix, err := strconv.Atoi(netdev.PrefixLen6)
if err != nil || prefix < 0 || prefix > 128 {
return ""
}
ipCIDR6 := net.IPNet{
IP: netdev.Ipaddr6,
Mask: net.CIDRMask(prefix, 128),
}
return ipCIDR6.String()
}
var unsetValues = []string{"UNSET", "UNDEF"}
func isUnsetValue(value string) bool {