Skip to content

Commit 8b72c19

Browse files
authored
Merge pull request #1781 from gwenya/dhcp-expiry-ovn
Add ipv4.dhcp.expiry option for ovn networks
2 parents 44028f2 + 0979cbe commit 8b72c19

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

doc/api-extensions.md

+4
Original file line numberDiff line numberDiff line change
@@ -2744,3 +2744,7 @@ This allows specifying IPv4 and IPv6 DNS server addresses to be announced by the
27442744
## `acme_http01_port`
27452745

27462746
Adds `acme.http.port` to control an alternative HTTP port for `HTTP-01` validation.
2747+
2748+
## `network_ovn_ipv4_dhcp_expiry`
2749+
2750+
Introduces `ipv4.dhcp.expiry` for OVN networks.

doc/reference/network_ovn.md

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Key | Type | Condition | Defau
5353
`dns.zone.reverse.ipv6` | string | - | - | DNS zone name for IPv6 reverse DNS records
5454
`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)
5555
`ipv4.dhcp` | bool | IPv4 address | `true` | Whether to allocate addresses using DHCP
56+
`ipv4.dhcp.expiry` | string | IPv4 DHCP | `1h` | When to expire DHCP leases
5657
`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)
5758
`ipv4.l3only` | bool | IPv4 address | `false` | Whether to enable layer 3 only mode.
5859
`ipv4.nat` | bool | IPv4 address | `false` (initial value on creation if `ipv4.address` is set to `auto`: `true`) | Whether to NAT

internal/server/network/driver_ovn.go

+16-2
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,11 @@ func (n *ovn) Validate(config map[string]string) error {
398398

399399
return validate.IsNetworkAddressCIDRV4(value)
400400
}),
401-
"ipv4.dhcp": validate.Optional(validate.IsBool),
401+
"ipv4.dhcp": validate.Optional(validate.IsBool),
402+
"ipv4.dhcp.expiry": validate.Optional(func(value string) error {
403+
_, err := time.ParseDuration(value)
404+
return err
405+
}),
402406
"ipv4.dhcp.ranges": validate.Optional(validate.IsListOf(validate.IsNetworkRangeV4)),
403407
"ipv4.dhcp.routes": validate.Optional(validate.IsDHCPRouteList),
404408
"ipv6.address": validate.Optional(func(value string) error {
@@ -2675,12 +2679,22 @@ func (n *ovn) setup(update bool) error {
26752679
dhcpV4Netmask = "255.255.255.255"
26762680
}
26772681

2682+
leaseTime := time.Hour * 1
2683+
if n.config["ipv4.dhcp.expiry"] != "" {
2684+
duration, err := time.ParseDuration(n.config["ipv4.dhcp.expiry"])
2685+
if err != nil {
2686+
return fmt.Errorf("Failed to parse expiry: %w", err)
2687+
}
2688+
2689+
leaseTime = duration
2690+
}
2691+
26782692
opts := &networkOVN.OVNDHCPv4Opts{
26792693
ServerID: routerIntPortIPv4,
26802694
ServerMAC: routerMAC,
26812695
Router: routerIntPortIPv4,
26822696
DomainName: n.getDomainName(),
2683-
LeaseTime: time.Duration(time.Hour * 1),
2697+
LeaseTime: leaseTime,
26842698
MTU: bridgeMTU,
26852699
Netmask: dhcpV4Netmask,
26862700
DNSSearchList: n.getDNSSearchList(),

internal/version/api.go

+1
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ var APIExtensions = []string{
470470
"network_state_ovn_ls",
471471
"network_dns_nameservers",
472472
"acme_http01_port",
473+
"network_ovn_ipv4_dhcp_expiry",
473474
}
474475

475476
// APIExtensionsCount returns the number of available API extensions.

0 commit comments

Comments
 (0)