[pve-devel] [PATCH v2 common 01/14] network: is_ip_in_cidr: correctly handle the CIDR being a singleton range
Fabian Ebner
f.ebner at proxmox.com
Mon May 10 14:18:13 CEST 2021
i.e. is_ip_in_cidr('127.0.0.1', '127.0.0.1/32', 4) should return 1;
Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
New in v2.
src/PVE/Network.pm | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/PVE/Network.pm b/src/PVE/Network.pm
index 38019f7..366d242 100644
--- a/src/PVE/Network.pm
+++ b/src/PVE/Network.pm
@@ -592,7 +592,9 @@ sub is_ip_in_cidr {
my $ip_obj = Net::IP->new($ip, $version);
return undef if !$ip_obj;
- return $cidr_obj->overlaps($ip_obj) == $Net::IP::IP_B_IN_A_OVERLAP;
+ my $overlap = $cidr_obj->overlaps($ip_obj);
+
+ return $overlap == $Net::IP::IP_B_IN_A_OVERLAP || $overlap == $Net::IP::IP_IDENTICAL;
}
--
2.20.1
More information about the pve-devel
mailing list