[PATCH] nl_addr_cmp(): handle prefix length during address comparison

Brett Ciphery brett.ciphery at windriver.com
Wed Jan 11 11:40:11 EST 2012


Signed-off-by: Brett Ciphery <brett.ciphery at windriver.com>
---
 lib/addr.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

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;
-- 
1.7.0.4




More information about the libnl mailing list