]> granicus.if.org Git - libnl/commitdiff
nl_addr_cmp(): handle prefix length during address comparison
authorBrett Ciphery <brett.ciphery@windriver.com>
Wed, 11 Jan 2012 16:40:11 +0000 (11:40 -0500)
committerThomas Graf <tgraf@redhat.com>
Thu, 12 Jan 2012 09:18:35 +0000 (10:18 +0100)
Signed-off-by: Brett Ciphery <brett.ciphery@windriver.com>
lib/addr.c

index c8c4ca47fbd7f4340369584bcb06656b720a3d2a..30c708d2976553b75e6c0ac07c6a1f560a14e046 100644 (file)
@@ -497,7 +497,10 @@ int nl_addr_cmp(struct nl_addr *a, struct nl_addr *b)
                d = a->a_len - b->a_len;
 
                if (a->a_len && d == 0)
-                       return memcmp(a->a_addr, b->a_addr, a->a_len);
+                       d = memcmp(a->a_addr, b->a_addr, a->a_len);
+
+                       if (d == 0)
+                               return (a->a_prefixlen - b->a_prefixlen);
        }
 
        return d;