diff --git a/CHANGELOG.md b/CHANGELOG.md index ce2989cd..b3fed7ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Dynamically write `$tftpdir/warewulf/grub.cfg` to the configured value from `warewulf.conf` - Absolute paths specified with `{{ file }}` in an overlay now write to that absolute path. - Use opencontainers/selinux to manage SELinux in wwclient. +- Replace unused/unneeded IPv6net with IpCIDR6 to align with IPv4 +- Add IPv6 DHCP range ### Fixed diff --git a/internal/pkg/config/dhcp.go b/internal/pkg/config/dhcp.go index 419ca266..851a87a9 100644 --- a/internal/pkg/config/dhcp.go +++ b/internal/pkg/config/dhcp.go @@ -11,6 +11,8 @@ type DHCPConf struct { Template string `yaml:"template,omitempty" default:"default"` RangeStart string `yaml:"range start,omitempty"` RangeEnd string `yaml:"range end,omitempty"` + Range6Start string `yaml:"range6 start,omitempty"` + Range6End string `yaml:"range6 end,omitempty"` SystemdName string `yaml:"systemd name,omitempty" default:"dhcpd"` } diff --git a/internal/pkg/config/root.go b/internal/pkg/config/root.go index f649bd35..5a2d2eda 100644 --- a/internal/pkg/config/root.go +++ b/internal/pkg/config/root.go @@ -29,6 +29,7 @@ type WarewulfYaml struct { Ipaddr6 string `yaml:"ipaddr6,omitempty"` Netmask string `yaml:"netmask,omitempty"` Network string `yaml:"network,omitempty"` + IpCIDR6 string `yaml:"-"` Fqdn string `yaml:"fqdn,omitempty"` Warewulf *WarewulfConf `yaml:"warewulf,omitempty"` API *APIConf `yaml:"api,omitempty"` @@ -140,7 +141,13 @@ func (conf *WarewulfYaml) Parse(data []byte, autodetect bool) error { } if conf.Ipaddr6 != "" { - if _, _, err := net.ParseCIDR(conf.Ipaddr6); err != nil { + if ip, _, err := net.ParseCIDR(conf.Ipaddr6); err == nil { + if ip.To4() != nil { + return fmt.Errorf("invalid ipv6 address: ip address is ipv4: %s", conf.Ipaddr6) + } + conf.IpCIDR6 = conf.Ipaddr6 + conf.Ipaddr6 = ip.String() + } else { return fmt.Errorf("invalid ipv6 address: must use CIDR notation: %s", conf.Ipaddr6) } } diff --git a/internal/pkg/config/root_test.go b/internal/pkg/config/root_test.go index db4b9a86..9f9d9fd7 100644 --- a/internal/pkg/config/root_test.go +++ b/internal/pkg/config/root_test.go @@ -152,7 +152,7 @@ api: ipaddr6: "2001:db8::1/64" `, result: ` -ipaddr6: "2001:db8::1/64" +ipaddr6: "2001:db8::1" warewulf: autobuild overlays: true grubboot: false diff --git a/internal/pkg/overlay/datastructure.go b/internal/pkg/overlay/datastructure.go index 25779c25..0d64572e 100644 --- a/internal/pkg/overlay/datastructure.go +++ b/internal/pkg/overlay/datastructure.go @@ -26,6 +26,7 @@ type TemplateStruct struct { Ipaddr string IpCIDR string Ipaddr6 string + IpCIDR6 string Netmask string Network string NetworkCIDR string @@ -70,6 +71,10 @@ func InitStruct(overlayName string, nodeData node.Node, allNodes []node.Node) (T tstruct.Ipaddr = controller.Ipaddr tstruct.IpCIDR = controller.IpCIDR() tstruct.Ipaddr6 = controller.Ipaddr6 + tstruct.IpCIDR6 = controller.IpCIDR6 + if controller.Ipaddr6 != "" && controller.IpCIDR6 != "" { + tstruct.Ipv6 = true + } tstruct.Netmask = controller.Netmask tstruct.Network = controller.Network tstruct.NetworkCIDR = controller.NetworkCIDR() diff --git a/overlays/debug/internal/debug_test.go b/overlays/debug/internal/debug_test.go index 5463e5e2..58cb1259 100644 --- a/overlays/debug/internal/debug_test.go +++ b/overlays/debug/internal/debug_test.go @@ -91,6 +91,7 @@ data from other structures. - Ipaddr: 192.168.0.1 - IpCIDR: 192.168.0.1/24 - Ipaddr6: +- IpCIDR6: - Netmask: 255.255.255.0 - Network: 192.168.0.0 - NetworkCIDR: 192.168.0.0/24 @@ -102,6 +103,8 @@ data from other structures. - Dhcp.Template: default - Dhcp.RangeStart: - Dhcp.RangeEnd: +- Dhcp.Range6Start: +- Dhcp.Range6End: - Dhcp.SystemdName: dhcpd ### NFS diff --git a/overlays/debug/rootfs/tstruct.md.ww b/overlays/debug/rootfs/tstruct.md.ww index 2d30f140..58540fb7 100644 --- a/overlays/debug/rootfs/tstruct.md.ww +++ b/overlays/debug/rootfs/tstruct.md.ww @@ -31,6 +31,7 @@ data from other structures. - Ipaddr: {{ .Ipaddr }} - IpCIDR: {{ .IpCIDR }} - Ipaddr6: {{ .Ipaddr6 }} +- IpCIDR6: {{ .IpCIDR6 }} - Netmask: {{ .Netmask }} - Network: {{ .Network }} - NetworkCIDR: {{ .NetworkCIDR }} @@ -42,6 +43,8 @@ data from other structures. - Dhcp.Template: {{ .Dhcp.Template }} - Dhcp.RangeStart: {{ .Dhcp.RangeStart }} - Dhcp.RangeEnd: {{ .Dhcp.RangeEnd }} +- Dhcp.Range6Start: {{ .Dhcp.Range6Start }} +- Dhcp.Range6End: {{ .Dhcp.Range6End }} - Dhcp.SystemdName: {{ .Dhcp.SystemdName }} ### NFS