public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH pve-network 1/4] subnet: dhcp: improve Net::IP usage
@ 2025-03-07 12:50 Stefan Hanreich
  2025-03-07 12:50 ` [pve-devel] [PATCH pve-network 2/4] subnet: dhcp: fix typo in error message Stefan Hanreich
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Stefan Hanreich @ 2025-03-07 12:50 UTC (permalink / raw)
  To: pve-devel

This simplifies the comparison of IPs by using the object-oriented
interface over the procedural one. Also instantiate the ips using the
new method rather than using new, which isn't a keyword in Perl. This
fixes the respective perlcritic warning.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
 src/PVE/Network/SDN/SubnetPlugin.pm | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/PVE/Network/SDN/SubnetPlugin.pm b/src/PVE/Network/SDN/SubnetPlugin.pm
index 049f7e1..4bff2dd 100644
--- a/src/PVE/Network/SDN/SubnetPlugin.pm
+++ b/src/PVE/Network/SDN/SubnetPlugin.pm
@@ -86,13 +86,13 @@ sub validate_dhcp_ranges {
 	my $dhcp_start = $dhcp_range->{'start-address'};
 	my $dhcp_end = $dhcp_range->{'end-address'};
 
-	my $start_ip = new Net::IP($dhcp_start);
+	my $start_ip = Net::IP->new($dhcp_start);
 	raise_param_exc({ 'dhcp-range' => "start-adress is not a valid IP $dhcp_start" }) if !$start_ip;
 
-	my $end_ip = new Net::IP($dhcp_end);
+	my $end_ip = Net::IP->new($dhcp_end);
 	raise_param_exc({ 'dhcp-range' => "end-adress is not a valid IP $dhcp_end" }) if !$end_ip;
 
-	if (Net::IP::ip_bincomp($end_ip->binip(), 'lt', $start_ip->binip()) == 1) {
+	if ($start_ip->bincomp('gt', $end_ip)) {
 	    raise_param_exc({ 'dhcp-range' => "start-address $dhcp_start must be smaller than end-address $dhcp_end" })
 	}
 
-- 
2.39.5


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


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

end of thread, other threads:[~2025-04-07 16:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-07 12:50 [pve-devel] [PATCH pve-network 1/4] subnet: dhcp: improve Net::IP usage Stefan Hanreich
2025-03-07 12:50 ` [pve-devel] [PATCH pve-network 2/4] subnet: dhcp: fix typo in error message Stefan Hanreich
2025-03-07 12:50 ` [pve-devel] [PATCH pve-network 3/4] subnet: dhcp: only accept single ips and normalize them Stefan Hanreich
2025-03-07 12:50 ` [pve-devel] [PATCH pve-network 4/4] subnet: dhcp: do not allow overlapping dhcp ranges Stefan Hanreich
2025-04-07 15:37 ` [pve-devel] [PATCH pve-network 1/4] subnet: dhcp: improve Net::IP usage Hannes Duerr
2025-04-07 16:42 ` [pve-devel] applied: " Thomas Lamprecht

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