summaryrefslogtreecommitdiff
path: root/ospf6d/ospf6_abr.c
diff options
context:
space:
mode:
Diffstat (limited to 'ospf6d/ospf6_abr.c')
-rw-r--r--ospf6d/ospf6_abr.c201
1 files changed, 88 insertions, 113 deletions
diff --git a/ospf6d/ospf6_abr.c b/ospf6d/ospf6_abr.c
index 6fe3a289ce..f087289df6 100644
--- a/ospf6d/ospf6_abr.c
+++ b/ospf6d/ospf6_abr.c
@@ -82,10 +82,10 @@ static int ospf6_abr_nexthops_belong_to_area(struct ospf6_route *route,
static void ospf6_abr_delete_route(struct ospf6_route *range,
struct ospf6_route *summary,
struct ospf6_route_table *summary_table,
- struct ospf6_lsa *old)
+ struct ospf6_lsa *old, struct ospf6 *ospf6)
{
if (summary) {
- ospf6_route_remove(summary, summary_table);
+ ospf6_route_remove(summary, summary_table, ospf6);
}
if (old && !OSPF6_LSA_IS_MAXAGE(old))
@@ -117,7 +117,7 @@ void ospf6_abr_disable_area(struct ospf6_area *area)
area->ospf6->router_id, area->lsdb);
if (old)
ospf6_lsa_purge(old);
- ospf6_route_remove(ro, area->summary_prefix);
+ ospf6_route_remove(ro, area->summary_prefix, area->ospf6);
}
/* Withdraw all summary router-routes previously originated */
@@ -128,7 +128,7 @@ void ospf6_abr_disable_area(struct ospf6_area *area)
area->ospf6->router_id, area->lsdb);
if (old)
ospf6_lsa_purge(old);
- ospf6_route_remove(ro, area->summary_router);
+ ospf6_route_remove(ro, area->summary_router, area->ospf6);
}
/* Schedule Router-LSA for each area (ABR status may change) */
@@ -153,7 +153,6 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
struct ospf6_inter_router_lsa *router_lsa;
struct ospf6_route_table *summary_table = NULL;
uint16_t type;
- char buf[PREFIX2STR_BUFFER];
int is_debug = 0;
/* Only destination type network, range or ASBR are considered */
@@ -196,12 +195,10 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
if (route->type == OSPF6_DEST_TYPE_ROUTER) {
if (ADV_ROUTER_IN_PREFIX(&route->prefix)
== area->ospf6->router_id) {
- inet_ntop(AF_INET,
- &(ADV_ROUTER_IN_PREFIX(&route->prefix)), buf,
- sizeof(buf));
zlog_debug(
- "%s: Skipping ASBR announcement for ABR (%s)",
- __func__, buf);
+ "%s: Skipping ASBR announcement for ABR (%pFX)",
+ __func__,
+ &ADV_ROUTER_IN_PREFIX(&route->prefix));
return 0;
}
}
@@ -210,11 +207,10 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
if (IS_OSPF6_DEBUG_ABR
|| IS_OSPF6_DEBUG_ORIGINATE(INTER_ROUTER)) {
is_debug++;
- inet_ntop(AF_INET,
- &(ADV_ROUTER_IN_PREFIX(&route->prefix)), buf,
- sizeof(buf));
- zlog_debug("Originating summary in area %s for ASBR %s",
- area->name, buf);
+ zlog_debug(
+ "Originating summary in area %s for ASBR %pFX",
+ area->name,
+ &ADV_ROUTER_IN_PREFIX(&route->prefix));
}
summary_table = area->summary_router;
} else {
@@ -226,16 +222,13 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
route->path.origin.type ==
htons(OSPF6_LSTYPE_INTER_PREFIX)) {
if (!CHECK_FLAG(route->flag, OSPF6_ROUTE_BEST)) {
- if (is_debug) {
- inet_ntop(AF_INET,
- &(ADV_ROUTER_IN_PREFIX(
- &route->prefix)), buf,
- sizeof(buf));
+ if (is_debug)
zlog_debug(
- "%s: route %s with cost %u is not best, ignore.",
- __func__, buf,
+ "%s: route %pFX with cost %u is not best, ignore.",
+ __func__,
+ &ADV_ROUTER_IN_PREFIX(
+ &route->prefix),
route->path.cost);
- }
return 0;
}
}
@@ -243,23 +236,19 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
if (route->path.origin.type ==
htons(OSPF6_LSTYPE_INTRA_PREFIX)) {
if (!CHECK_FLAG(route->flag, OSPF6_ROUTE_BEST)) {
- if (is_debug) {
- prefix2str(&route->prefix, buf,
- sizeof(buf));
+ if (is_debug)
zlog_debug(
- "%s: intra-prefix route %s with cost %u is not best, ignore.",
- __func__, buf,
+ "%s: intra-prefix route %pFX with cost %u is not best, ignore.",
+ __func__, &route->prefix,
route->path.cost);
- }
return 0;
}
}
- if (is_debug) {
- prefix2str(&route->prefix, buf, sizeof(buf));
- zlog_debug("Originating summary in area %s for %s cost %u",
- area->name, buf, route->path.cost);
- }
+ if (is_debug)
+ zlog_debug(
+ "Originating summary in area %s for %pFX cost %u",
+ area->name, &route->prefix, route->path.cost);
summary_table = area->summary_prefix;
}
@@ -284,10 +273,11 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
"The range is not active. withdraw");
ospf6_abr_delete_route(route, summary,
- summary_table, old);
+ summary_table, old,
+ area->ospf6);
}
} else if (old) {
- ospf6_route_remove(summary, summary_table);
+ ospf6_route_remove(summary, summary_table, area->ospf6);
ospf6_lsa_purge(old);
}
return 0;
@@ -298,7 +288,8 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
zlog_debug(
"Area has been stubbed, purge Inter-Router LSA");
- ospf6_abr_delete_route(route, summary, summary_table, old);
+ ospf6_abr_delete_route(route, summary, summary_table, old,
+ area->ospf6);
return 0;
}
@@ -307,7 +298,8 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
if (is_debug)
zlog_debug("Area has been stubbed, purge prefix LSA");
- ospf6_abr_delete_route(route, summary, summary_table, old);
+ ospf6_abr_delete_route(route, summary, summary_table, old,
+ area->ospf6);
return 0;
}
@@ -343,7 +335,7 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
zlog_debug(
"This is the secondary path to the ASBR, ignore");
ospf6_abr_delete_route(route, summary, summary_table,
- old);
+ old, area->ospf6);
return 0;
}
@@ -369,13 +361,12 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
if (range && !CHECK_FLAG(range->flag, OSPF6_ROUTE_REMOVE)
&& (route->path.area_id != OSPF_AREA_BACKBONE
|| !IS_AREA_TRANSIT(area))) {
- if (is_debug) {
- prefix2str(&range->prefix, buf, sizeof(buf));
- zlog_debug("Suppressed by range %s of area %s",
- buf, route_area->name);
- }
+ if (is_debug)
+ zlog_debug(
+ "Suppressed by range %pFX of area %s",
+ &range->prefix, route_area->name);
ospf6_abr_delete_route(route, summary, summary_table,
- old);
+ old, area->ospf6);
return 0;
}
}
@@ -388,7 +379,7 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
zlog_debug(
"This is the range with DoNotAdvertise set. ignore");
ospf6_abr_delete_route(route, summary, summary_table,
- old);
+ old, area->ospf6);
return 0;
}
@@ -397,7 +388,7 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
if (is_debug)
zlog_debug("The range is not active. withdraw");
ospf6_abr_delete_route(route, summary, summary_table,
- old);
+ old, area->ospf6);
return 0;
}
}
@@ -411,15 +402,11 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
if (EXPORT_LIST(area))
if (access_list_apply(EXPORT_LIST(area), &route->prefix)
== FILTER_DENY) {
- if (is_debug) {
- inet_ntop(AF_INET,
- &(ADV_ROUTER_IN_PREFIX(
- &route->prefix)),
- buf, sizeof(buf));
+ if (is_debug)
zlog_debug(
- "prefix %s was denied by export list",
- buf);
- }
+ "prefix %pFX was denied by export list",
+ &ADV_ROUTER_IN_PREFIX(
+ &route->prefix));
return 0;
}
}
@@ -428,15 +415,10 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
if (PREFIX_LIST_OUT(area))
if (prefix_list_apply(PREFIX_LIST_OUT(area), &route->prefix)
!= PREFIX_PERMIT) {
- if (is_debug) {
- inet_ntop(
- AF_INET,
- &(ADV_ROUTER_IN_PREFIX(&route->prefix)),
- buf, sizeof(buf));
+ if (is_debug)
zlog_debug(
- "prefix %s was denied by filter-list out",
- buf);
- }
+ "prefix %pFX was denied by filter-list out",
+ &ADV_ROUTER_IN_PREFIX(&route->prefix));
return 0;
}
@@ -458,7 +440,7 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
summary->path.origin.type,
summary->path.origin.adv_router, area->lsdb);
}
- summary = ospf6_route_add(summary, summary_table);
+ summary = ospf6_route_add(summary, summary_table, area->ospf6);
} else {
summary->type = route->type;
monotime(&summary->changed);
@@ -597,7 +579,8 @@ ospf6_abr_range_summary_needs_update(struct ospf6_route *range, uint32_t cost)
return (redo_summary);
}
-static void ospf6_abr_range_update(struct ospf6_route *range)
+static void ospf6_abr_range_update(struct ospf6_route *range,
+ struct ospf6 *ospf6)
{
uint32_t cost = 0;
struct listnode *node, *nnode;
@@ -636,7 +619,7 @@ static void ospf6_abr_range_update(struct ospf6_route *range)
if (IS_OSPF6_DEBUG_ABR)
zlog_debug("Add discard route");
- ospf6_zebra_add_discard(range);
+ ospf6_zebra_add_discard(range, ospf6);
}
} else {
/* Summary removed or no summary generated as no
@@ -646,18 +629,19 @@ static void ospf6_abr_range_update(struct ospf6_route *range)
if (IS_OSPF6_DEBUG_ABR)
zlog_debug("Delete discard route");
- ospf6_zebra_delete_discard(range);
+ ospf6_zebra_delete_discard(range, ospf6);
}
}
}
}
-void ospf6_abr_originate_summary(struct ospf6_route *route)
+void ospf6_abr_originate_summary(struct ospf6_route *route, struct ospf6 *ospf6)
{
struct listnode *node, *nnode;
struct ospf6_area *oa;
struct ospf6_route *range = NULL;
+
if (route->type == OSPF6_DEST_TYPE_NETWORK) {
oa = ospf6_area_lookup(route->path.area_id, ospf6);
if (!oa) {
@@ -668,7 +652,7 @@ void ospf6_abr_originate_summary(struct ospf6_route *route)
range = ospf6_route_lookup_bestmatch(&route->prefix,
oa->range_table);
if (range) {
- ospf6_abr_range_update(range);
+ ospf6_abr_range_update(range, ospf6);
}
}
@@ -695,7 +679,7 @@ void ospf6_abr_defaults_to_stub(struct ospf6 *o)
def->path.subtype = OSPF6_PATH_SUBTYPE_DEFAULT_RT;
def->path.area_id = o->backbone->area_id;
- for (ALL_LIST_ELEMENTS(ospf6->area_list, node, nnode, oa)) {
+ for (ALL_LIST_ELEMENTS(o->area_list, node, nnode, oa)) {
if (!IS_AREA_STUB(oa)) {
/* withdraw defaults when an area switches from stub to
* non-stub */
@@ -725,7 +709,8 @@ void ospf6_abr_defaults_to_stub(struct ospf6 *o)
void ospf6_abr_old_path_update(struct ospf6_route *old_route,
struct ospf6_route *route,
- struct ospf6_route_table *table)
+ struct ospf6_route_table *table,
+ struct ospf6 *ospf6)
{
struct ospf6_path *o_path = NULL;
struct listnode *anode, *anext;
@@ -772,7 +757,7 @@ void ospf6_abr_old_path_update(struct ospf6_route *old_route,
: 0);
if (table->hook_add)
- (*table->hook_add)(old_route);
+ (*table->hook_add)(old_route, ospf6);
if (old_route->path.origin.id == route->path.origin.id &&
old_route->path.origin.adv_router ==
@@ -789,16 +774,15 @@ void ospf6_abr_old_path_update(struct ospf6_route *old_route,
}
}
-void ospf6_abr_old_route_remove(struct ospf6_lsa *lsa,
- struct ospf6_route *old,
- struct ospf6_route_table *table)
+void ospf6_abr_old_route_remove(struct ospf6_lsa *lsa, struct ospf6_route *old,
+ struct ospf6_route_table *table,
+ struct ospf6 *ospf6)
{
if (listcount(old->paths) > 1) {
struct listnode *anode, *anext, *nnode, *rnode, *rnext;
struct ospf6_path *o_path;
struct ospf6_nexthop *nh, *rnh;
bool nh_updated = false;
- char buf[PREFIX2STR_BUFFER];
for (ALL_LIST_ELEMENTS(old->paths, anode, anext, o_path)) {
if (o_path->origin.adv_router != lsa->header->adv_router
@@ -820,19 +804,16 @@ void ospf6_abr_old_route_remove(struct ospf6_lsa *lsa,
if (nh_updated) {
if (listcount(old->paths)) {
- if (IS_OSPF6_DEBUG_ABR ||
- IS_OSPF6_DEBUG_EXAMIN(INTER_PREFIX)) {
- prefix2str(&old->prefix, buf,
- sizeof(buf));
- zlog_debug("%s: old %s updated nh %u",
- __func__, buf,
+ if (IS_OSPF6_DEBUG_ABR
+ || IS_OSPF6_DEBUG_EXAMIN(INTER_PREFIX))
+ zlog_debug("%s: old %pFX updated nh %u",
+ __func__, &old->prefix,
old->nh_list ? listcount(
old->nh_list)
: 0);
- }
if (table->hook_add)
- (*table->hook_add)(old);
+ (*table->hook_add)(old, ospf6);
if ((old->path.origin.id == lsa->header->id) &&
(old->path.origin.adv_router
@@ -849,11 +830,10 @@ void ospf6_abr_old_route_remove(struct ospf6_lsa *lsa,
h_path->origin.adv_router;
}
} else
- ospf6_route_remove(old, table);
+ ospf6_route_remove(old, table, ospf6);
}
} else
- ospf6_route_remove(old, table);
-
+ ospf6_route_remove(old, table, ospf6);
}
/* RFC 2328 16.2. Calculating the inter-area routes */
@@ -968,7 +948,7 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
if (is_debug)
zlog_debug("cost is LS_INFINITY, ignore");
if (old)
- ospf6_abr_old_route_remove(lsa, old, table);
+ ospf6_abr_old_route_remove(lsa, old, table, oa->ospf6);
return;
}
if (OSPF6_LSA_IS_MAXAGE(lsa)) {
@@ -976,7 +956,7 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
zlog_debug("%s: LSA %s is MaxAge, ignore", __func__,
lsa->name);
if (old)
- ospf6_abr_old_route_remove(lsa, old, table);
+ ospf6_abr_old_route_remove(lsa, old, table, oa->ospf6);
return;
}
@@ -986,7 +966,7 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
zlog_debug("LSA %s is self-originated, ignore",
lsa->name);
if (old)
- ospf6_route_remove(old, table);
+ ospf6_route_remove(old, table, oa->ospf6);
return;
}
@@ -1002,7 +982,7 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
zlog_debug(
"Prefix is equal to address range, ignore");
if (old)
- ospf6_route_remove(old, table);
+ ospf6_route_remove(old, table, oa->ospf6);
return;
}
@@ -1013,7 +993,7 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
if (is_debug)
zlog_debug("Prefix has NU/LA bit set, ignore");
if (old)
- ospf6_route_remove(old, table);
+ ospf6_route_remove(old, table, oa->ospf6);
return;
}
}
@@ -1026,7 +1006,7 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
if (is_debug)
zlog_debug("Prefix has NU/LA bit set, ignore");
if (old)
- ospf6_route_remove(old, table);
+ ospf6_route_remove(old, table, oa->ospf6);
return;
}
@@ -1040,7 +1020,7 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
"Ignorning Inter-Router LSA for an ABR (%s)",
buf);
if (old)
- ospf6_route_remove(old, table);
+ ospf6_route_remove(old, table, oa->ospf6);
return;
}
@@ -1068,7 +1048,7 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
zlog_debug(
"%s: remove old entry: %s %p ",
__func__, buf, (void *)old);
- ospf6_route_remove(old, table);
+ ospf6_route_remove(old, table, oa->ospf6);
}
}
return;
@@ -1087,7 +1067,8 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
zlog_debug(
"Prefix was denied by import-list");
if (old)
- ospf6_route_remove(old, table);
+ ospf6_route_remove(old, table,
+ oa->ospf6);
return;
}
}
@@ -1099,7 +1080,7 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
if (is_debug)
zlog_debug("Prefix was denied by prefix-list");
if (old)
- ospf6_route_remove(old, table);
+ ospf6_route_remove(old, table, oa->ospf6);
return;
}
}
@@ -1140,13 +1121,11 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
continue;
if ((ospf6_route_cmp(route, old_route) != 0)) {
- if (is_debug) {
- prefix2str(&prefix, buf, sizeof(buf));
+ if (is_debug)
zlog_debug(
- "%s: old %p %s cost %u new route cost %u are not same",
- __func__, (void *)old_route, buf,
+ "%s: old %p %pFX cost %u new route cost %u are not same",
+ __func__, (void *)old_route, &prefix,
old_route->path.cost, route->path.cost);
- }
/* Check new route's adv. router is same in one of
* the paths with differed cost, if so remove the
@@ -1154,7 +1133,7 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
*/
if (listcount(old_route->paths) > 1)
ospf6_abr_old_path_update(old_route, route,
- table);
+ table, oa->ospf6);
continue;
}
@@ -1222,7 +1201,7 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
* For Inter-Router trigger summary update
*/
if (table->hook_add)
- (*table->hook_add)(old_route);
+ (*table->hook_add)(old_route, oa->ospf6);
/* Delete new route */
ospf6_route_delete(route);
@@ -1241,23 +1220,19 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
path = ospf6_path_dup(&route->path);
ospf6_copy_nexthops(path->nh_list, abr_entry->nh_list);
listnode_add_sort(route->paths, path);
-
/* ospf6_ia_add_nw_route (table, &prefix, route); */
- ospf6_route_add(route, table);
+ ospf6_route_add(route, table, oa->ospf6);
}
}
-void ospf6_abr_examin_brouter(uint32_t router_id)
+void ospf6_abr_examin_brouter(uint32_t router_id, struct ospf6_route *route,
+ struct ospf6 *ospf6)
{
struct ospf6_lsa *lsa;
struct ospf6_area *oa;
uint16_t type;
- if (ospf6_is_router_abr(ospf6))
- oa = ospf6->backbone;
- else
- oa = listgetdata(listhead(ospf6->area_list));
-
+ oa = ospf6_area_lookup(route->path.area_id, ospf6);
/*
* It is possible to designate a non backbone
* area first. If that is the case safely
@@ -1298,7 +1273,7 @@ void ospf6_abr_prefix_resummarize(struct ospf6 *o)
for (route = ospf6_route_head(o->route_table); route;
route = ospf6_route_next(route))
- ospf6_abr_originate_summary(route);
+ ospf6_abr_originate_summary(route, o);
if (IS_OSPF6_DEBUG_ABR)
zlog_debug("Finished re-examining Inter-Prefix Summaries");