Skip to content

Commit

Permalink
[WIP] Add support for ipv4.dhcp.ranges
Browse files Browse the repository at this point in the history
As long as discussed here [1], OVN has a configuration to exclude IPs from DHCP
pool and it was not supported yet. So using 'ipv4.dhcp.ranges', we get
reserverd IPs using negative logic for provided subnet

[1]: `https://discuss.linuxcontainers.org/t/ovn-dhcp-ranges/21290/3`i

Signed-off-by: Winicius Silva <winiciusab12@gmail.com>
  • Loading branch information
winiciusallan committed Sep 7, 2024
1 parent c562b5b commit 00801dc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/server/network/driver_ovn.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ 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.ranges": validate.Optional(validate.IsListOf(validate.IsNetworkRangeV4)),
"ipv6.address": validate.Optional(func(value string) error {
if validate.IsOneOf("none", "auto")(value) == nil {
return nil
Expand Down Expand Up @@ -1971,6 +1972,12 @@ func (n *ovn) getDHCPv4Reservations() ([]iprange.Range, error) {
return nil, err
}

allowedNets := []*net.IPNet{n.DHCPv4Subnet()}
dhcpRanges, err := parseIPRange(n.config["ipv4.dhcp.ranges"], allowedNets...)

Check failure on line 1976 in internal/server/network/driver_ovn.go

View workflow job for this annotation

GitHub Actions / Code (oldstable)

dhcpRanges declared and not used

Check failure on line 1976 in internal/server/network/driver_ovn.go

View workflow job for this annotation

GitHub Actions / Code (stable)

declared and not used: dhcpRanges

Check failure on line 1976 in internal/server/network/driver_ovn.go

View workflow job for this annotation

GitHub Actions / Code (tip)

declared and not used: dhcpRanges

Check failure on line 1976 in internal/server/network/driver_ovn.go

View workflow job for this annotation

GitHub Actions / System (stable, cluster, dir)

declared and not used: dhcpRanges

Check failure on line 1976 in internal/server/network/driver_ovn.go

View workflow job for this annotation

GitHub Actions / System (stable, cluster, btrfs)

declared and not used: dhcpRanges

Check failure on line 1976 in internal/server/network/driver_ovn.go

View workflow job for this annotation

GitHub Actions / System (stable, cluster, lvm)

declared and not used: dhcpRanges

Check failure on line 1976 in internal/server/network/driver_ovn.go

View workflow job for this annotation

GitHub Actions / System (stable, cluster, zfs)

declared and not used: dhcpRanges

Check failure on line 1976 in internal/server/network/driver_ovn.go

View workflow job for this annotation

GitHub Actions / System (stable, cluster, ceph)

declared and not used: dhcpRanges

Check failure on line 1976 in internal/server/network/driver_ovn.go

View workflow job for this annotation

GitHub Actions / System (stable, cluster, random)

declared and not used: dhcpRanges

Check failure on line 1976 in internal/server/network/driver_ovn.go

View workflow job for this annotation

GitHub Actions / System (stable, standalone, dir)

declared and not used: dhcpRanges

Check failure on line 1976 in internal/server/network/driver_ovn.go

View workflow job for this annotation

GitHub Actions / System (stable, standalone, btrfs)

declared and not used: dhcpRanges

Check failure on line 1976 in internal/server/network/driver_ovn.go

View workflow job for this annotation

GitHub Actions / System (stable, standalone, lvm)

declared and not used: dhcpRanges

Check failure on line 1976 in internal/server/network/driver_ovn.go

View workflow job for this annotation

GitHub Actions / System (stable, standalone, zfs)

declared and not used: dhcpRanges

Check failure on line 1976 in internal/server/network/driver_ovn.go

View workflow job for this annotation

GitHub Actions / System (stable, standalone, ceph)

declared and not used: dhcpRanges

Check failure on line 1976 in internal/server/network/driver_ovn.go

View workflow job for this annotation

GitHub Actions / System (stable, standalone, random)

declared and not used: dhcpRanges

Check failure on line 1976 in internal/server/network/driver_ovn.go

View workflow job for this annotation

GitHub Actions / System (oldstable, cluster, dir)

dhcpRanges declared and not used

Check failure on line 1976 in internal/server/network/driver_ovn.go

View workflow job for this annotation

GitHub Actions / System (oldstable, standalone, dir)

dhcpRanges declared and not used

Check failure on line 1976 in internal/server/network/driver_ovn.go

View workflow job for this annotation

GitHub Actions / System (tip, cluster, dir)

declared and not used: dhcpRanges

Check failure on line 1976 in internal/server/network/driver_ovn.go

View workflow job for this annotation

GitHub Actions / System (tip, standalone, dir)

declared and not used: dhcpRanges
if err != nil {
return nil, err
}

return dhcpReserveIPv4s, nil
}

Expand Down

0 comments on commit 00801dc

Please sign in to comment.