SPAM: [PATCH pve-network 2/2] dhcp: generate dhcp-range for dnsmasq even when no dhcp_ranges exist
Lou Lecrivain
lou.lecrivain at wdz.de
Thu Nov 28 18:09:42 CET 2024
Signed-off-by: lou lecrivain <lou.lecrivain at wdz.de>
---
src/PVE/Network/SDN/Dhcp.pm | 6 ++++--
src/PVE/Network/SDN/Dhcp/Dnsmasq.pm | 5 ++++-
src/PVE/Network/SDN/Dhcp/Plugin.pm | 2 +-
3 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/PVE/Network/SDN/Dhcp.pm b/src/PVE/Network/SDN/Dhcp.pm
index d48de34..6c4ad10 100644
--- a/src/PVE/Network/SDN/Dhcp.pm
+++ b/src/PVE/Network/SDN/Dhcp.pm
@@ -98,11 +98,13 @@ sub regenerate_config {
my $subnet_config = $subnets->{$subnet_id};
my $dhcp_ranges = PVE::Network::SDN::Subnets::get_dhcp_ranges($subnet_config);
+ next if !$dhcp_ranges;
+ my $with_ranges = (scalar $dhcp_ranges->@* > 0);
my ($zone, $subnet_network, $subnet_mask) = split(/-/, $subnet_id);
next if $zone ne $zoneid;
- next if !$dhcp_ranges;
- eval { $dhcp_plugin->configure_subnet($config, $zoneid, $vnetid, $subnet_config) };
+ eval { $dhcp_plugin->configure_subnet($config, $zoneid, $vnetid, $subnet_config, $with_ranges) };
+
warn "Could not configure subnet $subnet_id: $@\n" if $@;
foreach my $dhcp_range (@$dhcp_ranges) {
diff --git a/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm b/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm
index ae52d31..0271e19 100644
--- a/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm
+++ b/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm
@@ -122,7 +122,7 @@ sub add_ip_mapping {
}
sub configure_subnet {
- my ($class, $config, $dhcpid, $vnetid, $subnet_config) = @_;
+ my ($class, $config, $dhcpid, $vnetid, $subnet_config, $with_ranges) = @_;
die "No gateway defined for subnet $subnet_config->{id}"
if !$subnet_config->{gateway};
@@ -140,6 +140,9 @@ sub configure_subnet {
push @{$config}, "dhcp-option=tag:$tag,$option_string:dns-server,$subnet_config->{'dhcp-dns-server'}"
if $subnet_config->{'dhcp-dns-server'};
+ if (!$with_ranges) {
+ $class->configure_range($config, $dhcpid, $vnetid, $subnet_config, undef);
+ }
}
sub configure_range {
diff --git a/src/PVE/Network/SDN/Dhcp/Plugin.pm b/src/PVE/Network/SDN/Dhcp/Plugin.pm
index 1757915..3ad4b7f 100644
--- a/src/PVE/Network/SDN/Dhcp/Plugin.pm
+++ b/src/PVE/Network/SDN/Dhcp/Plugin.pm
@@ -33,7 +33,7 @@ sub configure_range {
}
sub configure_subnet {
- my ($class, $config, $dhcpid, $vnetid, $subnet_config) = @_;
+ my ($class, $config, $dhcpid, $vnetid, $subnet_config, $with_ranges) = @_;
die 'implement in sub class';
}
--
2.39.5
More information about the pve-devel
mailing list