]> git.puffer.fish Git - matthieu/frr.git/commitdiff
[ospfd] Bug #234. Fix nbr_self reinitialisation after down/up.
authorpaul <paul>
Wed, 11 Jan 2006 01:08:19 +0000 (01:08 +0000)
committerpaul <paul>
Wed, 11 Jan 2006 01:08:19 +0000 (01:08 +0000)
2006-01-10 Len Sorensen <lennartsorensen@ruggedcom.com>

* (general) Bug #234, see also [quagga-dev 3902].
  Fix problem with nbr_self not being properly reinitialised
  when an interface comes up, after having been down.
  Some re-arrangement done by Paul Jakma, any bugs introduced
  on top of Len's suggested changes are his.
* ospf_neighbor.c: (ospf_nbr_add_self) centralise
  initialisation of nbr_self parameters here.
* ospf_interface.c: (ospf_if_new) deleting initialisation of
  parameters of nbr_self, just rely on call to
  ospf_nbr_add_self.
  (ospf_if_cleanup) ditto.
* ospfd.c: (ospf_network_run) ditto.

ospfd/ChangeLog
ospfd/ospf_interface.c
ospfd/ospf_neighbor.c
ospfd/ospfd.c

index 23a109affdb61c88c329fb56fc3e5fb030be936a..bc7b5e20b67097812b3194c8b50fe8ef795c858f 100644 (file)
@@ -3,6 +3,8 @@
        * (general) Bug #234, see also [quagga-dev 3902].
          Fix problem with nbr_self not being properly reinitialised
          when an interface comes up, after having been down.
+         Some re-arrangement done by Paul Jakma, any bugs introduced
+         on top of Len's suggested changes are his.
        * ospf_neighbor.c: (ospf_nbr_add_self) centralise
          initialisation of nbr_self parameters here.
        * ospf_interface.c: (ospf_if_new) deleting initialisation of
index d21dea3b38fe8630f8fb99aab3eed6e2801ce403..82c4baee91db61b941e2bd8b02d268900594a548 100644 (file)
@@ -237,9 +237,6 @@ ospf_if_new (struct ospf *ospf, struct interface *ifp, struct prefix *p)
 
   /* Add pseudo neighbor. */
   oi->nbr_self = ospf_nbr_new (oi);
-  oi->nbr_self->state = NSM_TwoWay;
-  oi->nbr_self->priority = OSPF_IF_PARAM (oi, priority);
-  oi->nbr_self->options = OSPF_OPTION_E;
 
   oi->ls_upd_queue = route_table_init ();
   oi->t_ls_upd_event = NULL;
@@ -267,7 +264,7 @@ ospf_if_cleanup (struct ospf_interface *oi)
   struct ospf_nbr_nbma *nbr_nbma;
   struct ospf_lsa *lsa;
 
-  /* oi->nbrs and oi->nbr_nbma should be deletete on InterafceDown event */
+  /* oi->nbrs and oi->nbr_nbma should be deleted on InterfaceDown event */
   /* delete all static neighbors attached to this interface */
   for (ALL_LIST_ELEMENTS (oi->nbr_nbma, node, nnode, nbr_nbma))
     {
@@ -300,26 +297,11 @@ ospf_if_cleanup (struct ospf_interface *oi)
   /* Empty link state update queue */
   ospf_ls_upd_queue_empty (oi);
   
/* Handle pseudo neighbor. */
 /* Reset pseudo neighbor. */
   ospf_nbr_delete (oi->nbr_self);
   oi->nbr_self = ospf_nbr_new (oi);
-  oi->nbr_self->state = NSM_TwoWay;
-  oi->nbr_self->priority = OSPF_IF_PARAM (oi, priority);
-
-  switch (oi->area->external_routing)
-    {
-    case OSPF_AREA_DEFAULT:
-      SET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
-      break;
-    case OSPF_AREA_STUB:
-      UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
-      break;
-    case OSPF_AREA_NSSA:
-      UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
-      SET_FLAG (oi->nbr_self->options, OSPF_OPTION_NP);
-      break;
-    }
-
+  ospf_nbr_add_self (oi);
+  
   ospf_lsa_unlock (oi->network_lsa_self);
   oi->network_lsa_self = NULL;
   OSPF_TIMER_OFF (oi->t_network_lsa_self);
index 5c1a7627a8d7e21da92051e14c44865bd435ac6d..58752366ebe5efe6cb998b24e12d4fbf2a1e43a4 100644 (file)
@@ -202,6 +202,27 @@ ospf_nbr_add_self (struct ospf_interface *oi)
     }
   else
     rn->info = oi->nbr_self;
+  
+  /* Initial state */
+  oi->nbr_self->address = *oi->address;
+  oi->nbr_self->priority = OSPF_IF_PARAM (oi, priority);
+  oi->nbr_self->router_id = oi->ospf->router_id;
+  oi->nbr_self->src = oi->address->u.prefix4;
+  oi->nbr_self->state = NSM_TwoWay;
+  
+  switch (oi->area->external_routing)
+    {
+      case OSPF_AREA_DEFAULT:
+        SET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
+        break;
+      case OSPF_AREA_STUB:
+        UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
+        break;
+      case OSPF_AREA_NSSA:
+        UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
+        SET_FLAG (oi->nbr_self->options, OSPF_OPTION_NP);
+        break;
+    }
 }
 
 /* Get neighbor count by status.
index 7c993655735999048ecfeeef1a97ad03dcdf8f71..680a5006848ae991348f528e9ae9101a70642af4 100644 (file)
@@ -859,24 +859,14 @@ ospf_network_run (struct ospf *ospf, struct prefix *p, struct ospf_area *area)
                oi = ospf_if_new (ospf, ifp, co->address);
                oi->connected = co;
                
-               oi->nbr_self->address = *oi->address;
-
                oi->area = area;
 
                oi->params = ospf_lookup_if_params (ifp, oi->address->u.prefix4);
                oi->output_cost = ospf_if_get_output_cost (oi);
                
-               if (area->external_routing != OSPF_AREA_DEFAULT)
-                 UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
-               oi->nbr_self->priority = OSPF_IF_PARAM (oi, priority);
-               
                /* Add pseudo neighbor. */
                ospf_nbr_add_self (oi);
 
-               /* Make sure pseudo neighbor's router_id. */
-               oi->nbr_self->router_id = ospf->router_id;
-               oi->nbr_self->src = oi->address->u.prefix4;
-               
                /* Relate ospf interface to ospf instance. */
                oi->ospf = ospf;
 
@@ -885,21 +875,6 @@ ospf_network_run (struct ospf *ospf, struct prefix *p, struct ospf_area *area)
                   skip network type setting. */
                oi->type = IF_DEF_PARAMS (ifp)->type;
                
-               /* Set area flag. */
-               switch (area->external_routing)
-                 {
-                 case OSPF_AREA_DEFAULT:
-                   SET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
-                   break;
-                 case OSPF_AREA_STUB:
-                   UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
-                   break;
-                 case OSPF_AREA_NSSA:
-                   UNSET_FLAG (oi->nbr_self->options, OSPF_OPTION_E);
-                   SET_FLAG (oi->nbr_self->options, OSPF_OPTION_NP);
-                   break;
-                 }
-
                ospf_area_add_if (oi->area, oi);
                
                /* if router_id is not configured, dont bring up