[quagga-dev 10820] [PATCH] zebra: Change the mechanism for comparing route ID's.

Ken Williams ken.williams at windriver.com
Sat Oct 19 19:42:56 BST 2013


The current format uses subtraction of two ints. Unfortunately, the
subtraction method does not work for all combinations of numbers.
For example, the with numbers represented by 10.x.x.x and 192.x.x.x,
10.x.x.x - 192.x.x.x will yield a very large positive number indicating
that 10.x.x.x is larger.
---
 zebra/router-id.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/zebra/router-id.c b/zebra/router-id.c
index 3d6b511..b738027 100644
--- a/zebra/router-id.c
+++ b/zebra/router-id.c
@@ -230,10 +230,8 @@ router_id_cmp (void *a, void *b)
 {
   const struct connected *ifa = (const struct connected *)a;
   const struct connected *ifb = (const struct connected *)b;
-  unsigned int A = ntohl(ifa->address->u.prefix4.s_addr);
-  unsigned int B = ntohl(ifb->address->u.prefix4.s_addr);
 
-  return (int) (A - B);
+  return IPV4_ADDR_CMP(&ifa->address->u.prefix4.s_addr,&ifb->address->u.prefix4.s_addr);
 }
 
 void
-- 
1.7.0.4





More information about the Quagga-dev mailing list