summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Hanreich <s.hanreich@proxmox.com>2025-03-07 13:50:53 +0100
committerThomas Lamprecht <t.lamprecht@proxmox.com>2025-04-07 18:35:34 +0200
commit1a698b27f4e959bb2b63b9393a2c223d32fea020 (patch)
treedaee9ef3005d5988d85fe7a2fd5266997dfe56d1
parent2eb697c39edc9bd95a1ede9f9d3b44c30629ae16 (diff)
subnet: dhcp: improve Net::IP usage
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> Tested-by: Hannes Duerr <h.duerr@proxmox.com> Link: https://lore.proxmox.com/20250307125056.169575-1-s.hanreich@proxmox.com Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
-rw-r--r--src/PVE/Network/SDN/SubnetPlugin.pm6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/PVE/Network/SDN/SubnetPlugin.pm b/src/PVE/Network/SDN/SubnetPlugin.pm
index e73d97a..faf1a05 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" })
}