public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] SPAM: [PATCH pve-network 1/2] vnet: do not skip if no range is defined, ask for allocation inside prefix instead
       [not found] <20241128170942.4717-1-lou.lecrivain@wdz.de>
@ 2024-11-28 17:09 ` Lou Lecrivain via pve-devel
  2024-12-05 16:08   ` Stefan Hanreich
  2024-11-28 17:09 ` [pve-devel] SPAM: [PATCH pve-network 2/2] dhcp: generate dhcp-range for dnsmasq even when no dhcp_ranges exist Lou Lecrivain via pve-devel
  1 sibling, 1 reply; 5+ messages in thread
From: Lou Lecrivain via pve-devel @ 2024-11-28 17:09 UTC (permalink / raw)
  To: pve-devel; +Cc: Lou Lecrivain

[-- Attachment #1: Type: message/rfc822, Size: 5055 bytes --]

From: Lou Lecrivain <lou.lecrivain@wdz.de>
To: pve-devel@lists.proxmox.com
Subject: SPAM: [PATCH pve-network 1/2] vnet: do not skip if no range is defined, ask for allocation inside prefix instead
Date: Thu, 28 Nov 2024 18:09:41 +0100
Message-ID: <20241128170942.4717-2-lou.lecrivain@wdz.de>

Signed-off-by: lou lecrivain <lou.lecrivain@wdz.de>
---
 src/PVE/Network/SDN/Vnets.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/PVE/Network/SDN/Vnets.pm b/src/PVE/Network/SDN/Vnets.pm
index 45292e3..30e8fdb 100644
--- a/src/PVE/Network/SDN/Vnets.pm
+++ b/src/PVE/Network/SDN/Vnets.pm
@@ -118,11 +118,11 @@ sub add_next_free_cidr {
 	    my $network = $subnet->{network};
 
 	    next if Net::IP::ip_get_version($network) != $ipversion || $ips->{$ipversion};
-	    next if !$subnet->{'dhcp-range'};
+	    my $subnet_dhcprange = !$subnet->{'dhcp-range'} ? 0 : $dhcprange;
 	    $subnetcount++;
 
 	    eval {
-		$ip = PVE::Network::SDN::Subnets::add_next_free_ip($zone, $subnetid, $subnet, $hostname, $mac, $vmid, $skipdns, $dhcprange);
+		$ip = PVE::Network::SDN::Subnets::add_next_free_ip($zone, $subnetid, $subnet, $hostname, $mac, $vmid, $skipdns, $subnet_dhcprange);
 	    };
 	    die $@ if $@;
 
-- 
2.39.5



[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pve-devel] SPAM: [PATCH pve-network 2/2] dhcp: generate dhcp-range for dnsmasq even when no dhcp_ranges exist
       [not found] <20241128170942.4717-1-lou.lecrivain@wdz.de>
  2024-11-28 17:09 ` [pve-devel] SPAM: [PATCH pve-network 1/2] vnet: do not skip if no range is defined, ask for allocation inside prefix instead Lou Lecrivain via pve-devel
@ 2024-11-28 17:09 ` Lou Lecrivain via pve-devel
  2024-12-05 16:20   ` Stefan Hanreich
  1 sibling, 1 reply; 5+ messages in thread
From: Lou Lecrivain via pve-devel @ 2024-11-28 17:09 UTC (permalink / raw)
  To: pve-devel; +Cc: Lou Lecrivain

[-- Attachment #1: Type: message/rfc822, Size: 5939 bytes --]

From: Lou Lecrivain <lou.lecrivain@wdz.de>
To: pve-devel@lists.proxmox.com
Subject: SPAM: [PATCH pve-network 2/2] dhcp: generate dhcp-range for dnsmasq even when no dhcp_ranges exist
Date: Thu, 28 Nov 2024 18:09:42 +0100
Message-ID: <20241128170942.4717-3-lou.lecrivain@wdz.de>

Signed-off-by: lou lecrivain <lou.lecrivain@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



[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [pve-devel] SPAM: [PATCH pve-network 1/2] vnet: do not skip if no range is defined, ask for allocation inside prefix instead
  2024-11-28 17:09 ` [pve-devel] SPAM: [PATCH pve-network 1/2] vnet: do not skip if no range is defined, ask for allocation inside prefix instead Lou Lecrivain via pve-devel
@ 2024-12-05 16:08   ` Stefan Hanreich
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Hanreich @ 2024-12-05 16:08 UTC (permalink / raw)
  To: Proxmox VE development discussion

we could just pass $subnet->{'dhcp-range'} directly instead of adding
the ternary, it will be undefined then and add_next_free_ip just checks
for truthiness.


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [pve-devel] SPAM: [PATCH pve-network 2/2] dhcp: generate dhcp-range for dnsmasq even when no dhcp_ranges exist
  2024-11-28 17:09 ` [pve-devel] SPAM: [PATCH pve-network 2/2] dhcp: generate dhcp-range for dnsmasq even when no dhcp_ranges exist Lou Lecrivain via pve-devel
@ 2024-12-05 16:20   ` Stefan Hanreich
  2024-12-06 10:33     ` Lou Lecrivain via pve-devel
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Hanreich @ 2024-12-05 16:20 UTC (permalink / raw)
  To: Proxmox VE development discussion

Seems like this still is a remnant from when we used to configure the
ranges explicitly dhcp-range. But adding two DHCP ranges just generates
two identical lines in the dnsmasq config:

> dhcp-range=set:public-172.20.44.0-24,172.20.44.0,static,255.255.255.0,infinite
> dhcp-range=set:public-172.20.44.0-24,172.20.44.0,static,255.255.255.0,infinite

Maybe it would make sense to move the whole code of configure_range to
configure_subnet in the Dnsmasq plugin, since the whole subnet gets
configured anyway and make configure_range a noop?


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [pve-devel] SPAM: [PATCH pve-network 2/2] dhcp: generate dhcp-range for dnsmasq even when no dhcp_ranges exist
  2024-12-05 16:20   ` Stefan Hanreich
@ 2024-12-06 10:33     ` Lou Lecrivain via pve-devel
  0 siblings, 0 replies; 5+ messages in thread
From: Lou Lecrivain via pve-devel @ 2024-12-06 10:33 UTC (permalink / raw)
  To: s.hanreich, pve-devel; +Cc: Lou.Lecrivain

[-- Attachment #1: Type: message/rfc822, Size: 13357 bytes --]

From: <Lou.Lecrivain@wdz.de>
To: <s.hanreich@proxmox.com>, <pve-devel@lists.proxmox.com>
Subject: RE: Re: [pve-devel] SPAM: [PATCH pve-network 2/2] dhcp: generate dhcp-range for dnsmasq even when no dhcp_ranges exist
Date: Fri, 6 Dec 2024 10:33:12 +0000
Message-ID: <BE1P281MB2116CD2E4955A8FC9A86907085312@BE1P281MB2116.DEUP281.PROD.OUTLOOK.COM>

Re,

Seems like I did not test this enough, whoops.

> Maybe it would make sense to move the whole code of configure_range to
> configure_subnet in the Dnsmasq plugin, since the whole subnet gets
> configured anyway and make configure_range a noop?
Yes, do agree on this one. I think it'd be cleaner in terms of code.

I'll take this into account for next version. Thanks.

BR
________________________________________
De : Stefan Hanreich <s.hanreich@proxmox.com>
Envoyé : jeudi 5 décembre 2024 17:20
À : Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Cc : Lecrivain, Lou (WDZ) <Lou.Lecrivain@wdz.de>
Objet : [!!ACHTUNG extern!!] - Re: [pve-devel] SPAM: [PATCH pve-network 2/2] dhcp: generate dhcp-range for dnsmasq even when no dhcp_ranges exist
 
Seems like this still is a remnant from when we used to configure the
ranges explicitly dhcp-range. But adding two DHCP ranges just generates
two identical lines in the dnsmasq config:

> dhcp-range=set:public-172.20.44.0-24,172.20.44.0,static,255.255.255.0,infinite
> dhcp-range=set:public-172.20.44.0-24,172.20.44.0,static,255.255.255.0,infinite

Maybe it would make sense to move the whole code of configure_range to
configure_subnet in the Dnsmasq plugin, since the whole subnet gets
configured anyway and make configure_range a noop?


[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-12-06 10:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20241128170942.4717-1-lou.lecrivain@wdz.de>
2024-11-28 17:09 ` [pve-devel] SPAM: [PATCH pve-network 1/2] vnet: do not skip if no range is defined, ask for allocation inside prefix instead Lou Lecrivain via pve-devel
2024-12-05 16:08   ` Stefan Hanreich
2024-11-28 17:09 ` [pve-devel] SPAM: [PATCH pve-network 2/2] dhcp: generate dhcp-range for dnsmasq even when no dhcp_ranges exist Lou Lecrivain via pve-devel
2024-12-05 16:20   ` Stefan Hanreich
2024-12-06 10:33     ` Lou Lecrivain via pve-devel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal