From 794ac78c5618ee81a45e4f58694ee27b3403ebd7 Mon Sep 17 00:00:00 2001 From: Brett Ciphery Date: Wed, 11 Jan 2012 11:40:11 -0500 Subject: [PATCH] nl_addr_cmp(): handle prefix length during address comparison Signed-off-by: Brett Ciphery --- lib/addr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/addr.c b/lib/addr.c index c8c4ca4..30c708d 100644 --- a/lib/addr.c +++ b/lib/addr.c @@ -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; -- 2.40.0