From d2129860bfeffba37dee50669faa6992d0ac090f Mon Sep 17 00:00:00 2001 From: Din Music Date: Mon, 25 Sep 2023 13:14:27 +0200 Subject: [PATCH] lxd/device/nic_ovn: Prevent setting static IPv6 if static IPv4 is not set Signed-off-by: Din Music --- lxd/device/nic_ovn.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lxd/device/nic_ovn.go b/lxd/device/nic_ovn.go index 187fff15f540..5218de05c335 100644 --- a/lxd/device/nic_ovn.go +++ b/lxd/device/nic_ovn.go @@ -165,6 +165,11 @@ func (d *nicOVN) validateConfig(instConf instance.ConfigReader) error { return fmt.Errorf("Cannot specify %q when DHCP or %q are disabled on network %q", "ipv6.address", "ipv6.dhcp.stateful", d.config["network"]) } + // Static IPv6 is allowed only if static IPv4 is set as well. + if d.config["ipv4.address"] == "" { + return fmt.Errorf("Cannot specify %q when %q is not set", "ipv6.address", "ipv4.address") + } + ip, subnet, err := net.ParseCIDR(netConfig["ipv6.address"]) if err != nil { return fmt.Errorf("Invalid network ipv6.address: %w", err)