diff options
Diffstat (limited to 'ospfd/ospf_abr.c')
| -rw-r--r-- | ospfd/ospf_abr.c | 193 |
1 files changed, 95 insertions, 98 deletions
diff --git a/ospfd/ospf_abr.c b/ospfd/ospf_abr.c index 2131c8ee9d..634418ec5a 100644 --- a/ospfd/ospf_abr.c +++ b/ospfd/ospf_abr.c @@ -331,6 +331,7 @@ static int ospf_abr_nssa_am_elected(struct ospf_area *area) struct ospf_lsa *lsa; struct router_lsa *rlsa; struct in_addr *best = NULL; + char buf[PREFIX_STRLEN]; LSDB_LOOP (ROUTER_LSDB(area), rn, lsa) { /* sanity checks */ @@ -348,8 +349,8 @@ static int ospf_abr_nssa_am_elected(struct ospf_area *area) if (IS_ROUTER_LSA_NT(rlsa)) { if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_abr_nssa_am_elected: router %s asserts Nt", - inet_ntoa(lsa->data->id)); + "ospf_abr_nssa_am_elected: router %pI4 asserts Nt", + &lsa->data->id); return 0; } @@ -363,7 +364,8 @@ static int ospf_abr_nssa_am_elected(struct ospf_area *area) if (IS_DEBUG_OSPF_NSSA) zlog_debug( "ospf_abr_nssa_am_elected: best electable ABR is: %s", - (best) ? inet_ntoa(*best) : "<none>"); + (best) ? inet_ntop(AF_INET, best, buf, sizeof(buf)) : + "<none>"); if (best == NULL) return 1; @@ -390,8 +392,8 @@ static void ospf_abr_nssa_check_status(struct ospf *ospf) if (IS_DEBUG_OSPF(nssa, NSSA)) zlog_debug( - "ospf_abr_nssa_check_status: checking area %s", - inet_ntoa(area->area_id)); + "ospf_abr_nssa_check_status: checking area %pI4", + &area->area_id); if (!IS_OSPF_ABR(area->ospf)) { if (IS_DEBUG_OSPF(nssa, NSSA)) @@ -615,15 +617,15 @@ static int ospf_abr_translate_nssa(struct ospf_area *area, struct ospf_lsa *lsa) if (!CHECK_FLAG(lsa->data->options, OSPF_OPTION_NP)) { if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_abr_translate_nssa(): LSA Id %s, P-bit off, NO Translation", - inet_ntoa(lsa->data->id)); + "ospf_abr_translate_nssa(): LSA Id %pI4, P-bit off, NO Translation", + &lsa->data->id); return 1; } if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_abr_translate_nssa(): LSA Id %s, TRANSLATING 7 to 5", - inet_ntoa(lsa->data->id)); + "ospf_abr_translate_nssa(): LSA Id %pI4, TRANSLATING 7 to 5", + &lsa->data->id); ext7 = (struct as_external_lsa *)(lsa->data); p.prefix = lsa->data->id; @@ -632,37 +634,41 @@ static int ospf_abr_translate_nssa(struct ospf_area *area, struct ospf_lsa *lsa) if (ext7->e[0].fwd_addr.s_addr == OSPF_DEFAULT_DESTINATION) { if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_abr_translate_nssa(): LSA Id %s, Forward address is 0, NO Translation", - inet_ntoa(lsa->data->id)); + "ospf_abr_translate_nssa(): LSA Id %pI4, Forward address is 0, NO Translation", + &lsa->data->id); return 1; } /* try find existing AS-External LSA for this prefix */ - old = ospf_external_info_find_lsa(area->ospf, &p); - if (old) { - /* Do not continue if type 5 LSA not approved */ - if (!CHECK_FLAG(old->flags, OSPF_LSA_APPROVED)) { + if (CHECK_FLAG(lsa->flags, OSPF_LSA_IN_MAXAGE)) { + /* if type-7 is removed, remove old translated type-5 lsa */ + if (old) { + UNSET_FLAG(old->flags, OSPF_LSA_APPROVED); if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_abr_translate_nssa(): LSA Id %s type 5 is not approved", - inet_ntoa(old->data->id)); - return 1; + "ospf_abr_translate_nssa(): remove old translated LSA id %pI4", + &old->data->id); } + /* if type-7 is removed and type-5 does not exist, do not + * originate */ + return 1; + } + if (old && CHECK_FLAG(old->flags, OSPF_LSA_APPROVED)) { if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_abr_translate_nssa(): found old translated LSA Id %s, refreshing", - inet_ntoa(old->data->id)); + "ospf_abr_translate_nssa(): found old translated LSA Id %pI4, refreshing", + &old->data->id); /* refresh */ new = ospf_translated_nssa_refresh(area->ospf, lsa, old); if (!new) { if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_abr_translate_nssa(): could not refresh translated LSA Id %s", - inet_ntoa(old->data->id)); + "ospf_abr_translate_nssa(): could not refresh translated LSA Id %pI4", + &old->data->id); } } else { /* no existing external route for this LSA Id @@ -672,8 +678,8 @@ static int ospf_abr_translate_nssa(struct ospf_area *area, struct ospf_lsa *lsa) if (ospf_translated_nssa_originate(area->ospf, lsa) == NULL) { if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_abr_translate_nssa(): Could not translate Type-7 for %s to Type-5", - inet_ntoa(lsa->data->id)); + "ospf_abr_translate_nssa(): Could not translate Type-7 for %pI4 to Type-5", + &lsa->data->id); return 1; } } @@ -736,14 +742,10 @@ void ospf_abr_announce_network_to_area(struct prefix_ipv4 *p, uint32_t cost, lsa = ospf_lsa_refresh(area->ospf, old); if (!lsa) { - char buf[PREFIX2STR_BUFFER]; - - prefix2str((struct prefix *)p, buf, - sizeof(buf)); flog_warn(EC_OSPF_LSA_MISSING, - "%s: Could not refresh %s to %s", - __func__, buf, - inet_ntoa(area->area_id)); + "%s: Could not refresh %pFX to %pI4", + __func__, (struct prefix *)p, + &area->area_id); return; } @@ -758,12 +760,10 @@ void ospf_abr_announce_network_to_area(struct prefix_ipv4 *p, uint32_t cost, /* This will flood through area. */ if (!lsa) { - char buf[PREFIX2STR_BUFFER]; - - prefix2str((struct prefix *)p, buf, sizeof(buf)); flog_warn(EC_OSPF_LSA_MISSING, - "%s: Could not originate %s to %s", __func__, - buf, inet_ntoa(area->area_id)); + "%s: Could not originate %pFX to %pi4", + __func__, (struct prefix *)p, + &area->area_id); return; } @@ -856,8 +856,8 @@ static void ospf_abr_announce_network(struct ospf *ospf, struct prefix_ipv4 *p, for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_network(): looking at area %s", - inet_ntoa(area->area_id)); + "ospf_abr_announce_network(): looking at area %pI4", + &area->area_id); if (IPV4_ADDR_SAME(& or->u.std.area_id, &area->area_id)) continue; @@ -868,16 +868,16 @@ static void ospf_abr_announce_network(struct ospf *ospf, struct prefix_ipv4 *p, if (!ospf_abr_should_accept(p, area)) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_network(): prefix %s/%d was denied by import-list", - inet_ntoa(p->prefix), p->prefixlen); + "ospf_abr_announce_network(): prefix %pFX was denied by import-list", + p); continue; } if (!ospf_abr_plist_in_check(area, or, p)) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_network(): prefix %s/%d was denied by prefix-list", - inet_ntoa(p->prefix), p->prefixlen); + "ospf_abr_announce_network(): prefix %pFX was denied by prefix-list", + p); continue; } @@ -885,16 +885,16 @@ static void ospf_abr_announce_network(struct ospf *ospf, struct prefix_ipv4 *p, && area->no_summary) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_network(): area %s is stub and no_summary", - inet_ntoa(area->area_id)); + "ospf_abr_announce_network(): area %pI4 is stub and no_summary", + &area->area_id); continue; } if (or->path_type == OSPF_PATH_INTER_AREA) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_network(): this is inter-area route to %s/%d", - inet_ntoa(p->prefix), p->prefixlen); + "ospf_abr_announce_network(): this is inter-area route to %pFX", + p); if (!OSPF_IS_AREA_BACKBONE(area)) ospf_abr_announce_network_to_area(p, or->cost, @@ -904,8 +904,8 @@ static void ospf_abr_announce_network(struct ospf *ospf, struct prefix_ipv4 *p, if (or->path_type == OSPF_PATH_INTRA_AREA) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_network(): this is intra-area route to %s/%d", - inet_ntoa(p->prefix), p->prefixlen); + "ospf_abr_announce_network(): this is intra-area route to %pFX", + p); if ((range = ospf_area_range_match(or_area, p)) && !ospf_area_is_transit(area)) ospf_abr_update_aggregate(range, or, area); @@ -964,8 +964,8 @@ static void ospf_abr_process_nssa_translates(struct ospf *ospf) if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_abr_process_nssa_translates(): looking at area %s", - inet_ntoa(area->area_id)); + "ospf_abr_process_nssa_translates(): looking at area %pI4", + &area->area_id); LSDB_LOOP (NSSA_LSDB(area), rn, lsa) ospf_abr_translate_nssa(area, lsa); @@ -993,15 +993,15 @@ static void ospf_abr_process_network_rt(struct ospf *ospf, or->u.std.area_id))) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_process_network_rt(): area %s no longer exists", - inet_ntoa(or->u.std.area_id)); + "ospf_abr_process_network_rt(): area %pI4 no longer exists", + &or->u.std.area_id); continue; } if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_process_network_rt(): this is a route to %s/%d", - inet_ntoa(rn->p.u.prefix4), rn->p.prefixlen); + "ospf_abr_process_network_rt(): this is a route to %pFX", + &rn->p); if (or->path_type >= OSPF_PATH_TYPE1_EXTERNAL) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( @@ -1114,12 +1114,10 @@ static void ospf_abr_announce_rtr_to_area(struct prefix_ipv4 *p, uint32_t cost, } else lsa = ospf_summary_asbr_lsa_originate(p, cost, area); if (!lsa) { - char buf[PREFIX2STR_BUFFER]; - - prefix2str((struct prefix *)p, buf, sizeof(buf)); flog_warn(EC_OSPF_LSA_MISSING, - "%s: Could not refresh/originate %s to %s", - __func__, buf, inet_ntoa(area->area_id)); + "%s: Could not refresh/originate %pFX to %pI4", + __func__, (struct prefix *)p, + &area->area_id); return; } @@ -1153,8 +1151,8 @@ static void ospf_abr_announce_rtr(struct ospf *ospf, struct prefix_ipv4 *p, for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_rtr(): looking at area %s", - inet_ntoa(area->area_id)); + "ospf_abr_announce_rtr(): looking at area %pI4", + &area->area_id); if (IPV4_ADDR_SAME(& or->u.std.area_id, &area->area_id)) continue; @@ -1166,24 +1164,24 @@ static void ospf_abr_announce_rtr(struct ospf *ospf, struct prefix_ipv4 *p, if (or->u.std.external_routing == OSPF_AREA_NSSA) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_rtr(): do not generate LSA Type-4 %s from NSSA", - inet_ntoa(p->prefix)); + "ospf_abr_announce_rtr(): do not generate LSA Type-4 %pI4 from NSSA", + &p->prefix); continue; } if (area->external_routing != OSPF_AREA_DEFAULT) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_rtr(): area %s doesn't support external routing", - inet_ntoa(area->area_id)); + "ospf_abr_announce_rtr(): area %pI4 doesn't support external routing", + &area->area_id); continue; } if (or->path_type == OSPF_PATH_INTER_AREA) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_rtr(): this is inter-area route to %s", - inet_ntoa(p->prefix)); + "ospf_abr_announce_rtr(): this is inter-area route to %pI4", + &p->prefix); if (!OSPF_IS_AREA_BACKBONE(area)) ospf_abr_announce_rtr_to_area(p, or->cost, area); @@ -1192,8 +1190,8 @@ static void ospf_abr_announce_rtr(struct ospf *ospf, struct prefix_ipv4 *p, if (or->path_type == OSPF_PATH_INTRA_AREA) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_rtr(): this is intra-area route to %s", - inet_ntoa(p->prefix)); + "ospf_abr_announce_rtr(): this is intra-area route to %pI4", + &p->prefix); ospf_abr_announce_rtr_to_area(p, or->cost, area); } } @@ -1224,16 +1222,16 @@ static void ospf_abr_process_router_rt(struct ospf *ospf, if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_process_router_rt(): this is a route to %s", - inet_ntoa(rn->p.u.prefix4)); + "ospf_abr_process_router_rt(): this is a route to %pI4", + &rn->p.u.prefix4); for (ALL_LIST_ELEMENTS(l, node, nnode, or)) { if (!ospf_area_lookup_by_area_id(ospf, or->u.std.area_id)) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_process_router_rt(): area %s no longer exists", - inet_ntoa(or->u.std.area_id)); + "ospf_abr_process_router_rt(): area %pI4 no longer exists", + &or->u.std.area_id); continue; } @@ -1314,8 +1312,8 @@ ospf_abr_unapprove_translates(struct ospf *ospf) /* For NSSA Translations */ UNSET_FLAG(lsa->flags, OSPF_LSA_APPROVED); if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_abr_unapprove_translates(): approved unset on link id %s", - inet_ntoa(lsa->data->id)); + "ospf_abr_unapprove_translates(): approved unset on link id %pI4", + &lsa->data->id); } if (IS_DEBUG_OSPF_NSSA) @@ -1335,14 +1333,14 @@ static void ospf_abr_unapprove_summaries(struct ospf *ospf) for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_unapprove_summaries(): considering area %s", - inet_ntoa(area->area_id)); + "ospf_abr_unapprove_summaries(): considering area %pI4", + &area->area_id); LSDB_LOOP (SUMMARY_LSDB(area), rn, lsa) if (ospf_lsa_is_self_originated(ospf, lsa)) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_unapprove_summaries(): approved unset on summary link id %s", - inet_ntoa(lsa->data->id)); + "ospf_abr_unapprove_summaries(): approved unset on summary link id %pI4", + &lsa->data->id); UNSET_FLAG(lsa->flags, OSPF_LSA_APPROVED); } @@ -1350,8 +1348,8 @@ static void ospf_abr_unapprove_summaries(struct ospf *ospf) if (ospf_lsa_is_self_originated(ospf, lsa)) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_unapprove_summaries(): approved unset on asbr-summary link id %s", - inet_ntoa(lsa->data->id)); + "ospf_abr_unapprove_summaries(): approved unset on asbr-summary link id %pI4", + &lsa->data->id); UNSET_FLAG(lsa->flags, OSPF_LSA_APPROVED); } } @@ -1396,8 +1394,8 @@ static void ospf_abr_announce_aggregates(struct ospf *ospf) for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_aggregates(): looking at area %s", - inet_ntoa(area->area_id)); + "ospf_abr_announce_aggregates(): looking at area %pI4", + &area->area_id); for (rn = route_top(area->ranges); rn; rn = route_next(rn)) if ((range = rn->info)) { @@ -1415,9 +1413,8 @@ static void ospf_abr_announce_aggregates(struct ospf *ospf) if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_aggregates(): this is range: %s/%d", - inet_ntoa(p.u.prefix4), - p.prefixlen); + "ospf_abr_announce_aggregates(): this is range: %pFX", + &p); if (CHECK_FLAG(range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) { @@ -1486,8 +1483,8 @@ ospf_abr_send_nssa_aggregates(struct ospf *ospf) /* temporarily turned off */ if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_abr_send_nssa_aggregates(): looking at area %s", - inet_ntoa(area->area_id)); + "ospf_abr_send_nssa_aggregates(): looking at area %pI4", + &area->area_id); for (rn = route_top(area->ranges); rn; rn = route_next(rn)) { if (rn->info == NULL) @@ -1509,8 +1506,8 @@ ospf_abr_send_nssa_aggregates(struct ospf *ospf) /* temporarily turned off */ if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_abr_send_nssa_aggregates(): this is range: %s/%d", - inet_ntoa(p.prefix), p.prefixlen); + "ospf_abr_send_nssa_aggregates(): this is range: %pFX", + &p); if (CHECK_FLAG(range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) { @@ -1557,8 +1554,8 @@ static void ospf_abr_announce_stub_defaults(struct ospf *ospf) for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_stub_defaults(): looking at area %s", - inet_ntoa(area->area_id)); + "ospf_abr_announce_stub_defaults(): looking at area %pI4", + &area->area_id); if ((area->external_routing != OSPF_AREA_STUB) && (area->external_routing != OSPF_AREA_NSSA)) @@ -1569,8 +1566,8 @@ static void ospf_abr_announce_stub_defaults(struct ospf *ospf) if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_announce_stub_defaults(): announcing 0.0.0.0/0 to area %s", - inet_ntoa(area->area_id)); + "ospf_abr_announce_stub_defaults(): announcing 0.0.0.0/0 to area %pI4", + &area->area_id); ospf_abr_announce_network_to_area(&p, area->default_cost, area); } @@ -1584,8 +1581,8 @@ static int ospf_abr_remove_unapproved_translates_apply(struct ospf *ospf, if (CHECK_FLAG(lsa->flags, OSPF_LSA_LOCAL_XLT) && !CHECK_FLAG(lsa->flags, OSPF_LSA_APPROVED)) { zlog_info( - "ospf_abr_remove_unapproved_translates(): removing unapproved translates, ID: %s", - inet_ntoa(lsa->data->id)); + "ospf_abr_remove_unapproved_translates(): removing unapproved translates, ID: %pI4", + &lsa->data->id); /* FLUSH THROUGHOUT AS */ ospf_lsa_flush_as(ospf, lsa); @@ -1625,8 +1622,8 @@ static void ospf_abr_remove_unapproved_summaries(struct ospf *ospf) for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_abr_remove_unapproved_summaries(): looking at area %s", - inet_ntoa(area->area_id)); + "ospf_abr_remove_unapproved_summaries(): looking at area %pI4", + &area->area_id); LSDB_LOOP (SUMMARY_LSDB(area), rn, lsa) if (ospf_lsa_is_self_originated(ospf, lsa)) |
