From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-network 1/4] subnet: dhcp: improve Net::IP usage
Date: Fri, 7 Mar 2025 13:50:53 +0100 [thread overview]
Message-ID: <20250307125056.169575-1-s.hanreich@proxmox.com> (raw)
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
next reply other threads:[~2025-03-07 12:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-07 12:50 Stefan Hanreich [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250307125056.169575-1-s.hanreich@proxmox.com \
--to=s.hanreich@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal