ospfd: Ensure correct handling of router-id change

Upon router-id change, one object that needs to be updated is the "nbr_self"
structure that is created to contain information about the local router and
is used during DR election, among other things. In the past, the code used to
just change the router-id field of this structure. This is actually not
sufficient - the neighbor has to be deleted and re-added into the tree. This
was fixed upstream and the fix is now available in our tree, but those changes
don't work well with prior Cumulus changes to defer updating the router-id
in the OSPF instance until other cleanup has happened.

Fixed code to update the "nbr_self" structure correctly while continuing to
defer the router_id update in the OSPF structure.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>

Ticket: CM-11861
Reviewed By: CCR-4980
Testing Done: Manual, failed test
This commit is contained in:
vivek 2016-07-19 19:17:38 -07:00
parent 5be7afc8bb
commit 58136de99d
4 changed files with 11 additions and 11 deletions

View File

@ -297,7 +297,7 @@ ospf_if_cleanup (struct ospf_interface *oi)
ospf_ls_upd_queue_empty (oi); ospf_ls_upd_queue_empty (oi);
/* Reset pseudo neighbor. */ /* Reset pseudo neighbor. */
ospf_nbr_self_reset (oi); ospf_nbr_self_reset (oi, oi->ospf->router_id);
} }
void void
@ -926,7 +926,7 @@ ospf_vl_new (struct ospf *ospf, struct ospf_vl_data *vl_data)
zlog_debug ("ospf_vl_new(): set associated area to the backbone"); zlog_debug ("ospf_vl_new(): set associated area to the backbone");
/* Add pseudo neighbor. */ /* Add pseudo neighbor. */
ospf_nbr_self_reset (voi); ospf_nbr_self_reset (voi, voi->ospf->router_id);
ospf_area_add_if (voi->area, voi); ospf_area_add_if (voi->area, voi);

View File

@ -238,18 +238,18 @@ ospf_nbr_bidirectional (struct in_addr *router_id,
/* reset nbr_self */ /* reset nbr_self */
void void
ospf_nbr_self_reset (struct ospf_interface *oi) ospf_nbr_self_reset (struct ospf_interface *oi, struct in_addr router_id)
{ {
if (oi->nbr_self) if (oi->nbr_self)
ospf_nbr_delete (oi->nbr_self); ospf_nbr_delete (oi->nbr_self);
oi->nbr_self = ospf_nbr_new (oi); oi->nbr_self = ospf_nbr_new (oi);
ospf_nbr_add_self (oi); ospf_nbr_add_self (oi, router_id);
} }
/* Add self to nbr list. */ /* Add self to nbr list. */
void void
ospf_nbr_add_self (struct ospf_interface *oi) ospf_nbr_add_self (struct ospf_interface *oi, struct in_addr router_id)
{ {
struct prefix p; struct prefix p;
struct route_node *rn; struct route_node *rn;
@ -260,7 +260,7 @@ ospf_nbr_add_self (struct ospf_interface *oi)
/* Initial state */ /* Initial state */
oi->nbr_self->address = *oi->address; oi->nbr_self->address = *oi->address;
oi->nbr_self->priority = OSPF_IF_PARAM (oi, priority); oi->nbr_self->priority = OSPF_IF_PARAM (oi, priority);
oi->nbr_self->router_id = oi->ospf->router_id; oi->nbr_self->router_id = router_id;
oi->nbr_self->src = oi->address->u.prefix4; oi->nbr_self->src = oi->address->u.prefix4;
oi->nbr_self->state = NSM_TwoWay; oi->nbr_self->state = NSM_TwoWay;

View File

@ -102,8 +102,8 @@ extern struct ospf_neighbor *ospf_nbr_new (struct ospf_interface *);
extern void ospf_nbr_free (struct ospf_neighbor *); extern void ospf_nbr_free (struct ospf_neighbor *);
extern void ospf_nbr_delete (struct ospf_neighbor *); extern void ospf_nbr_delete (struct ospf_neighbor *);
extern int ospf_nbr_bidirectional (struct in_addr *, struct in_addr *, int); extern int ospf_nbr_bidirectional (struct in_addr *, struct in_addr *, int);
extern void ospf_nbr_self_reset (struct ospf_interface *); extern void ospf_nbr_self_reset (struct ospf_interface *, struct in_addr);
extern void ospf_nbr_add_self (struct ospf_interface *); extern void ospf_nbr_add_self (struct ospf_interface *, struct in_addr);
extern int ospf_nbr_count (struct ospf_interface *, int); extern int ospf_nbr_count (struct ospf_interface *, int);
#ifdef HAVE_OPAQUE_LSA #ifdef HAVE_OPAQUE_LSA
extern int ospf_nbr_count_opaque_capable (struct ospf_interface *); extern int ospf_nbr_count_opaque_capable (struct ospf_interface *);

View File

@ -124,7 +124,7 @@ ospf_router_id_update (struct ospf *ospf)
* oi->nbr_self->router_id = router_id for * oi->nbr_self->router_id = router_id for
* !(virtual | ptop) links * !(virtual | ptop) links
*/ */
ospf_nbr_self_reset (oi); ospf_nbr_self_reset (oi, router_id);
} }
/* If AS-external-LSA is queued, then flush those LSAs. */ /* If AS-external-LSA is queued, then flush those LSAs. */
@ -888,7 +888,7 @@ add_ospf_interface (struct interface *ifp, struct ospf_area *area,
oi->type = IF_DEF_PARAMS (ifp)->type; oi->type = IF_DEF_PARAMS (ifp)->type;
/* Add pseudo neighbor. */ /* Add pseudo neighbor. */
ospf_nbr_self_reset (oi); ospf_nbr_self_reset (oi, oi->ospf->router_id);
ospf_area_add_if (oi->area, oi); ospf_area_add_if (oi->area, oi);
@ -1160,7 +1160,7 @@ ospf_network_run_interface (struct prefix *p, struct ospf_area *area,
oi->output_cost = ospf_if_get_output_cost (oi); oi->output_cost = ospf_if_get_output_cost (oi);
/* Add pseudo neighbor. */ /* Add pseudo neighbor. */
ospf_nbr_add_self (oi); ospf_nbr_add_self (oi, oi->ospf->router_id);
/* Relate ospf interface to ospf instance. */ /* Relate ospf interface to ospf instance. */
oi->ospf = area->ospf; oi->ospf = area->ospf;