From 3670d1d2429a15c5f50d9898d8b6c91c8734f3c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Mon, 17 Mar 2025 15:26:43 -0400 Subject: [PATCH 1/3] api: network_ovn_ipv4_dhcp_expiry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- doc/api-extensions.md | 4 ++++ internal/version/api.go | 1 + 2 files changed, 5 insertions(+) diff --git a/doc/api-extensions.md b/doc/api-extensions.md index fbd64eded03..b58b23749db 100644 --- a/doc/api-extensions.md +++ b/doc/api-extensions.md @@ -2744,3 +2744,7 @@ This allows specifying IPv4 and IPv6 DNS server addresses to be announced by the ## `acme_http01_port` Adds `acme.http.port` to control an alternative HTTP port for `HTTP-01` validation. + +## `network_ovn_ipv4_dhcp_expiry` + +Introduces `ipv4.dhcp.expiry` for OVN networks. diff --git a/internal/version/api.go b/internal/version/api.go index 47549f93c34..8a11fa8b702 100644 --- a/internal/version/api.go +++ b/internal/version/api.go @@ -470,6 +470,7 @@ var APIExtensions = []string{ "network_state_ovn_ls", "network_dns_nameservers", "acme_http01_port", + "network_ovn_ipv4_dhcp_expiry", } // APIExtensionsCount returns the number of available API extensions. From 483216de66f46cdff29adc16a6c913e9b15d80fd Mon Sep 17 00:00:00 2001 From: Gwendolyn Date: Mon, 17 Mar 2025 13:54:37 +0100 Subject: [PATCH 2/3] incusd/network/ovn: Add option ipv4.dhcp.expiry for OVN networks Signed-off-by: Gwendolyn --- internal/server/network/driver_ovn.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/internal/server/network/driver_ovn.go b/internal/server/network/driver_ovn.go index 86cc67d35b8..99dbf6a8ee7 100644 --- a/internal/server/network/driver_ovn.go +++ b/internal/server/network/driver_ovn.go @@ -398,7 +398,11 @@ func (n *ovn) Validate(config map[string]string) error { return validate.IsNetworkAddressCIDRV4(value) }), - "ipv4.dhcp": validate.Optional(validate.IsBool), + "ipv4.dhcp": validate.Optional(validate.IsBool), + "ipv4.dhcp.expiry": validate.Optional(func(value string) error { + _, err := time.ParseDuration(value) + return err + }), "ipv4.dhcp.ranges": validate.Optional(validate.IsListOf(validate.IsNetworkRangeV4)), "ipv4.dhcp.routes": validate.Optional(validate.IsDHCPRouteList), "ipv6.address": validate.Optional(func(value string) error { @@ -2675,12 +2679,22 @@ func (n *ovn) setup(update bool) error { dhcpV4Netmask = "255.255.255.255" } + leaseTime := time.Hour * 1 + if n.config["ipv4.dhcp.expiry"] != "" { + duration, err := time.ParseDuration(n.config["ipv4.dhcp.expiry"]) + if err != nil { + return fmt.Errorf("Failed to parse expiry: %w", err) + } + + leaseTime = duration + } + opts := &networkOVN.OVNDHCPv4Opts{ ServerID: routerIntPortIPv4, ServerMAC: routerMAC, Router: routerIntPortIPv4, DomainName: n.getDomainName(), - LeaseTime: time.Duration(time.Hour * 1), + LeaseTime: leaseTime, MTU: bridgeMTU, Netmask: dhcpV4Netmask, DNSSearchList: n.getDNSSearchList(), From 0979cbe6e3526e41ce920ade6803dcb729d792d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Mon, 17 Mar 2025 15:25:05 -0400 Subject: [PATCH 3/3] doc/reference/network_ovn: Add ipv4.dhcp.expiry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- doc/reference/network_ovn.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/reference/network_ovn.md b/doc/reference/network_ovn.md index b051e771381..fff61ff7238 100644 --- a/doc/reference/network_ovn.md +++ b/doc/reference/network_ovn.md @@ -53,6 +53,7 @@ Key | Type | Condition | Defau `dns.zone.reverse.ipv6` | string | - | - | DNS zone name for IPv6 reverse DNS records `ipv4.address` | string | standard mode | - (initial value on creation: `auto`) | IPv4 address for the bridge (use `none` to turn off IPv4 or `auto` to generate a new random unused subnet) (CIDR) `ipv4.dhcp` | bool | IPv4 address | `true` | Whether to allocate addresses using DHCP +`ipv4.dhcp.expiry` | string | IPv4 DHCP | `1h` | When to expire DHCP leases `ipv4.dhcp.routes` | string | IPv4 DHCP | - | Static routes to provide via DHCP option 121, as a comma-separated list of alternating subnets (CIDR) and gateway addresses (same syntax as dnsmasq and OVN) `ipv4.l3only` | bool | IPv4 address | `false` | Whether to enable layer 3 only mode. `ipv4.nat` | bool | IPv4 address | `false` (initial value on creation if `ipv4.address` is set to `auto`: `true`) | Whether to NAT