From c601fa3f9d07ab5f36cbc019da1338f71a3d93e3 Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Mon, 12 Mar 2018 16:37:06 -0700 Subject: [PATCH] ospf6d: retain inter area border router type-4 During Intra area border router calculation, all border routers are marked for remove from brouter table. Once SPF calculation is done, retain inter area border router if the adv. intra border router (abr) is present in SPF table. Ticket:CM-20171 Testing Done: Validated inter area ASBR (L1) is retained at R1 and R2 post intra border router calculation. L1 -- (area 1)-- L2 -- (area 0) -- R1 --- R2 Signed-off-by: Chirag Shah --- ospf6d/ospf6_abr.c | 8 +++++--- ospf6d/ospf6_intra.c | 30 ++++++++++++++++++++++++++++++ ospf6d/ospf6_route.c | 9 +++++---- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/ospf6d/ospf6_abr.c b/ospf6d/ospf6_abr.c index 67d18566ae..7ffb80724b 100644 --- a/ospf6d/ospf6_abr.c +++ b/ospf6d/ospf6_abr.c @@ -912,8 +912,9 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa) ospf6_route_merge_nexthops(old, route); if (is_debug) - zlog_debug("%s: Update route: %s nh count %u", - __PRETTY_FUNCTION__, buf, + zlog_debug("%s: Update route: %s old cost %u new cost %u nh count %u", + __PRETTY_FUNCTION__, + buf, old->path.cost, route->path.cost, listcount(route->nh_list)); /* Update RIB/FIB */ @@ -924,7 +925,8 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa) ospf6_route_delete(route); } else { if (is_debug) - zlog_debug("Install route: %s nh count %u", buf, + zlog_debug("%s: Install route: %s cost %u nh count %u", + __PRETTY_FUNCTION__, buf, route->path.cost, listcount(route->nh_list)); /* ospf6_ia_add_nw_route (table, &prefix, route); */ ospf6_route_add(route, table); diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c index c9e2ff9eb5..0b7755a3f4 100644 --- a/ospf6d/ospf6_intra.c +++ b/ospf6d/ospf6_intra.c @@ -1631,8 +1631,10 @@ void ospf6_intra_brouter_calculation(struct ospf6_area *oa) brouter_id = ADV_ROUTER_IN_PREFIX(&brouter->prefix); inet_ntop(AF_INET, &brouter_id, brouter_name, sizeof(brouter_name)); + if (brouter->path.area_id != oa->area_id) continue; + SET_FLAG(brouter->flag, OSPF6_ROUTE_REMOVE); if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID(brouter_id) @@ -1651,8 +1653,10 @@ void ospf6_intra_brouter_calculation(struct ospf6_area *oa) if (brouter->type != OSPF6_DEST_TYPE_LINKSTATE) continue; + if (ospf6_linkstate_prefix_id(&brouter->prefix) != htonl(0)) continue; + if (!CHECK_FLAG(brouter->path.router_bits, OSPF6_ROUTER_BIT_E) && !CHECK_FLAG(brouter->path.router_bits, OSPF6_ROUTER_BIT_B)) @@ -1704,10 +1708,36 @@ void ospf6_intra_brouter_calculation(struct ospf6_area *oa) if (CHECK_FLAG(brouter->flag, OSPF6_ROUTE_WAS_REMOVED)) continue; + /* After iterating spf_table for all routers including + * intra brouter, clear mark for remove flag for + * inter border router if its adv router present in + * SPF table. + */ + if (brouter->path.type == OSPF6_PATH_TYPE_INTER) { + struct prefix adv_prefix; + + ospf6_linkstate_prefix(brouter->path.origin.adv_router, + htonl(0), &adv_prefix); + + if (ospf6_route_lookup(&adv_prefix, oa->spf_table)) { + if (IS_OSPF6_DEBUG_BROUTER) { + zlog_debug("%s: keep inter brouter %s as adv router 0x%x found in spf", + __PRETTY_FUNCTION__, + brouter_name, + brouter->path.origin.adv_router); + ospf6_brouter_debug_print(brouter); + } + UNSET_FLAG(brouter->flag, OSPF6_ROUTE_REMOVE); + } + } + if (CHECK_FLAG(brouter->flag, OSPF6_ROUTE_REMOVE) && CHECK_FLAG(brouter->flag, OSPF6_ROUTE_ADD)) { UNSET_FLAG(brouter->flag, OSPF6_ROUTE_REMOVE); UNSET_FLAG(brouter->flag, OSPF6_ROUTE_ADD); + zlog_debug("%s: EVENT unset REOUTE_REMOVE and ROUTE_ADD brouter %s", + __PRETTY_FUNCTION__, brouter_name); + ospf6_brouter_debug_print(brouter); } if (CHECK_FLAG(brouter->flag, OSPF6_ROUTE_REMOVE)) { diff --git a/ospf6d/ospf6_route.c b/ospf6d/ospf6_route.c index 5b36f6300a..87f3f6edca 100644 --- a/ospf6d/ospf6_route.c +++ b/ospf6d/ospf6_route.c @@ -719,10 +719,11 @@ struct ospf6_route *ospf6_route_add(struct ospf6_route *route, SET_FLAG(route->flag, OSPF6_ROUTE_BEST); if (IS_OSPF6_DEBUG_ROUTE(MEMORY)) zlog_info( - "%s %p: route add %p: replacing previous best: %p", + "%s %p: route add %p cost %u: replacing previous best: %p cost %u", ospf6_route_table_name(table), (void *)table, (void *)route, - (void *)next); + route->path.cost, + (void *)next, next->path.cost); } route->installed = now; @@ -743,9 +744,9 @@ struct ospf6_route *ospf6_route_add(struct ospf6_route *route, /* Else, this is the brand new route regarding to the prefix */ if (IS_OSPF6_DEBUG_ROUTE(MEMORY)) - zlog_debug("%s %p: route add %p %s : brand new route", + zlog_debug("%s %p: route add %p %s cost %u: brand new route", ospf6_route_table_name(table), (void *)table, - (void *)route, buf); + (void *)route, buf, route->path.cost); else if (IS_OSPF6_DEBUG_ROUTE(TABLE)) zlog_debug("%s: route add: brand new route", ospf6_route_table_name(table)); -- 2.39.5