[pve-devel] [PATCH pve-network 1/4] subnet: dhcp: improve Net::IP usage

Hannes Duerr h.duerr at proxmox.com
Mon Apr 7 17:37:21 CEST 2025


Tested all 4 Patches and didn't run into any regressions.
Please consider this

Tested-by: Hannes Duerr <h.duerr at proxmox.com>

On 3/7/25 13:50, Stefan Hanreich wrote:
> 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 at 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" })
>   	}
>   




More information about the pve-devel mailing list