[prev in list] [next in list] [prev in thread] [next in thread] 

List:       quagga-dev
Subject:    [quagga-dev 492] PATCH: fix rip_peer_list_cmp()
From:       Krzysztof Oledzki <oleq () ans ! pl>
Date:       2003-11-19 22:46:31
[Download RAW message or body]

Hello,

Around the 0.96.3 relase of quagga the listnode_add_sort() function from
the lib/linklist.c file was changed. Now, it has one additional check:
+	  if ((*list->cmp) (val, n->data) == 0)
+	    return;

Current rip_peer_list_cmp() function looks like this:

int
rip_peer_list_cmp (struct rip_peer *p1, struct rip_peer *p2)
{
  return htonl (p1->addr.s_addr) > htonl (p2->addr.s_addr);
}

So, if first RIP packet comes from for example 192.168.0.3 then peers
with lower IPs (ex. 192.168.0.2, 192.168.0.1) will not be added. This
patch fix this, changing the rip_peer_list_cmp() function to one which
really compares p1 and p2, like other "cmp" functions:

diff -Nur quagga-0.96.4-orig/ripd/rip_peer.c quagga-0.96.4/ripd/rip_peer.c
--- quagga-0.96.4-orig/ripd/rip_peer.c	2002-12-13 21:15:30.000000000 +0100
+++ quagga-0.96.4/ripd/rip_peer.c	2003-11-19 23:25:44.000000000 +0100
@@ -200,7 +200,13 @@
 int
 rip_peer_list_cmp (struct rip_peer *p1, struct rip_peer *p2)
 {
-  return htonl (p1->addr.s_addr) > htonl (p2->addr.s_addr);
+  if (htonl (p1->addr.s_addr) > htonl (p2->addr.s_addr))
+    return 1;
+
+  if (htonl (p1->addr.s_addr) < htonl (p2->addr.s_addr))
+    return -1;
+
+  return 0;
 }

 void

With this patch "show ip rip status" works now as expected, without
missing peers.

Best regards,

					Krzysztof Olędzki
["quagga-0.96.4-rip_peer_list_cmp-fix.patch.gz" (APPLICATION/octet-stream)]

_______________________________________________
Quagga-dev mailing list
Quagga-dev@lists.quagga.net
http://lists.quagga.net/mailman/listinfo/quagga-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic