Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/mrouted Fix bug in mrouted about aging neighbors.



details:   https://anonhg.NetBSD.org/src/rev/f401bbfb9502
branches:  trunk
changeset: 335995:f401bbfb9502
user:      gdt <gdt%NetBSD.org@localhost>
date:      Thu Feb 05 16:50:19 2015 +0000

description:
Fix bug in mrouted about aging neighbors.

mrouted will periodically age its neighbors and will remove a neighbor
if it hasn't heard from it for NEIGHBOR_EXPIRE_TIME. Unfortunately, the
neighbor pointers 'a' and 'prev_a' were never advanced when timer was
not expired. Therefore it would get stuck in a tight loop, advancing
'al_timer' until it would be greater than NEIGHBOR_EXPIRE_TIME. This
caused the neighbor to allways get timed out and dropped. Furthermore,
there was a second bug in this loop when deleting an item that was not
at the head of the list (i.e., prev_a should stay the same instead of
advancing).

This bug fix is the work of Konrad Lorincz.  Bug found and fix made on
netbsd-6.

This material is based upon work supported by the Defense Advanced
Research Projects Agency and Space and Naval Warfare Systems Center,
Pacific, under Contract No. N66001-09-C-2073.  Any opinions, findings
and conclusions or recommendations expressed in this material are
those of the author(s) and do not necessarily reflect the views of the
Defense Advanced Research Project Agency and Space and Naval Warfare
Systems Center, Pacific.
Approved for Public Release, Distribution Unlimited

diffstat:

 usr.sbin/mrouted/vif.c |  15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diffs (43 lines):

diff -r 208e8232b57f -r f401bbfb9502 usr.sbin/mrouted/vif.c
--- a/usr.sbin/mrouted/vif.c    Thu Feb 05 16:07:15 2015 +0000
+++ b/usr.sbin/mrouted/vif.c    Thu Feb 05 16:50:19 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vif.c,v 1.18 2006/05/25 01:43:58 christos Exp $        */
+/*     $NetBSD: vif.c,v 1.19 2015/02/05 16:50:19 gdt Exp $     */
 
 /*
  * The mrouted program is covered by the license in the accompanying file
@@ -1201,10 +1201,13 @@
                v->uv_flags |= VIFF_LEAF;
        }
 
-       for (prev_a = a = v->uv_neighbors; a != NULL;) {
+       for (prev_a = NULL, a = v->uv_neighbors; a != NULL;) {
 
-           if ((a->al_timer += TIMER_INTERVAL) < NEIGHBOR_EXPIRE_TIME)
+           if ((a->al_timer += TIMER_INTERVAL) < NEIGHBOR_EXPIRE_TIME) {
+               prev_a = a;
+               a = a->al_next;
                continue;
+           }
 
            /*
             * Neighbor has expired; delete it from the neighbor list,
@@ -1213,14 +1216,14 @@
             * another neighbor with a lower IP address than mine.
             */
            addr = a->al_addr;
-           if (a == v->uv_neighbors) {
+           if (a == v->uv_neighbors) { /* implies prev_a == NULL */
                v->uv_neighbors = a->al_next;
                free((char *)a);
-               prev_a = a = v->uv_neighbors;
+               a = v->uv_neighbors;    /* prev_a stays NULL */
            } else {
                prev_a->al_next = a->al_next;
                free((char *)a);
-               prev_a = a = prev_a->al_next;
+               a = prev_a->al_next;    /* prev_a stays the same */
            }
 
            delete_neighbor_from_routes(addr, vifi);



Home | Main Index | Thread Index | Old Index