From f8b7f92baf79c51fb712fe537c232bc3002f1b42 Mon Sep 17 00:00:00 2001 From: vnxme <46669194+vnxme@users.noreply.github.com> Date: Thu, 10 Dec 2020 15:09:24 +0300 Subject: [PATCH] DHCPv6: Fix sorting of IPv6 static mappings (#4513) * DHCPv6: Fix sorting of IPv6 static mappings The ipcmp() function doesn't seem to return a correct result for IPv6 addresses. That's why the DHCPv6 static mappings are shown in the order they were added. This commit introduces ip6cmp() function and fixes sorting of IPv6 static mappings. * DHCPv6: Fix sorting of IPv6 static mappings Move ip6cmp() approach to ipcmp(), use single function for both IPv4 and IPv6. * DHCPv6: Fix sorting of IPv6 static mappings Oops, fixed a typo in ipcmp() --- src/etc/inc/util.inc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc index 92183e796..50d0c53a4 100644 --- a/src/etc/inc/util.inc +++ b/src/etc/inc/util.inc @@ -1190,9 +1190,11 @@ function check_subnets_overlap($subnet1, $bits1, $subnet2, $bits2) /* compare two IP addresses */ function ipcmp($a, $b) { - if (ip_less_than($a, $b)) { + $na = inet_pton($a); + $nb = inet_pton($b); + if ($na < $nb) { return -1; - } elseif (ip_greater_than($a, $b)) { + } elseif ($na > $nb) { return 1; } else { return 0;