diff options
Diffstat (limited to 'ospf6d/ospf6_asbr.c')
| -rw-r--r-- | ospf6d/ospf6_asbr.c | 293 |
1 files changed, 157 insertions, 136 deletions
diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c index b52f1cef6c..c23fe99bc8 100644 --- a/ospf6d/ospf6_asbr.c +++ b/ospf6d/ospf6_asbr.c @@ -164,9 +164,10 @@ int ospf6_orig_as_external_lsa(struct thread *thread) adv_router = oi->area->ospf6->router_id; for (ALL_LSDB_TYPED_ADVRTR(ospf6->lsdb, type, adv_router, lsa)) { if (IS_OSPF6_DEBUG_ASBR) - zlog_debug("%s: Send update of AS-External LSA %s seq 0x%x", - __PRETTY_FUNCTION__, lsa->name, - ntohl(lsa->header->seqnum)); + zlog_debug( + "%s: Send update of AS-External LSA %s seq 0x%x", + __PRETTY_FUNCTION__, lsa->name, + ntohl(lsa->header->seqnum)); ospf6_flood_interface(NULL, lsa, oi); } @@ -216,34 +217,36 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old, for (old_route = old; old_route; old_route = old_route->next) { bool route_updated = false; - if (!ospf6_route_is_same(old_route, route) || - (old_route->path.type != route->path.type)) + if (!ospf6_route_is_same(old_route, route) + || (old_route->path.type != route->path.type)) continue; /* Current and New route has same origin, * delete old entry. */ for (ALL_LIST_ELEMENTS(old_route->paths, anode, anext, - o_path)) { + o_path)) { /* Check old route path and route has same * origin. */ - if (o_path->area_id != route->path.area_id || - (memcmp(&(o_path)->origin, &(route)->path.origin, - sizeof(struct ospf6_ls_origin)) != 0)) + if (o_path->area_id != route->path.area_id + || (memcmp(&(o_path)->origin, &(route)->path.origin, + sizeof(struct ospf6_ls_origin)) + != 0)) continue; /* Cost is not same then delete current path */ - if ((o_path->cost == route->path.cost) && - (o_path->u.cost_e2 == route->path.u.cost_e2)) + if ((o_path->cost == route->path.cost) + && (o_path->u.cost_e2 == route->path.u.cost_e2)) continue; if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { prefix2str(&old_route->prefix, buf, sizeof(buf)); - zlog_debug("%s: route %s cost old %u new %u is not same, replace route", - __PRETTY_FUNCTION__, buf, - o_path->cost, route->path.cost); + zlog_debug( + "%s: route %s cost old %u new %u is not same, replace route", + __PRETTY_FUNCTION__, buf, o_path->cost, + route->path.cost); } /* Remove selected current rout path's nh from @@ -251,11 +254,11 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old, */ for (ALL_LIST_ELEMENTS_RO(o_path->nh_list, nnode, nh)) { for (ALL_LIST_ELEMENTS(old_route->nh_list, - rnode, rnext, rnh)) { + rnode, rnext, rnh)) { if (!ospf6_nexthop_is_same(rnh, nh)) continue; listnode_delete(old_route->nh_list, - rnh); + rnh); ospf6_nexthop_delete(rnh); route_updated = true; } @@ -270,14 +273,16 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old, * Update FIB with effective NHs. */ if (listcount(old_route->paths)) { - if (old_route->path.origin.id == - route->path.origin.id && - old_route->path.origin.adv_router == - route->path.origin.adv_router) { + if (old_route->path.origin.id + == route->path.origin.id + && old_route->path.origin.adv_router + == route->path.origin + .adv_router) { struct ospf6_path *h_path; h_path = (struct ospf6_path *) - listgetdata(listhead(old_route->paths)); + listgetdata(listhead( + old_route->paths)); old_route->path.origin.type = h_path->origin.type; old_route->path.origin.id = @@ -288,7 +293,8 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old, if (route_updated) { for (ALL_LIST_ELEMENTS(old_route->paths, - anode, anext, o_path)) { + anode, anext, + o_path)) { ospf6_merge_nexthops( old_route->nh_list, o_path->nh_list); @@ -297,18 +303,19 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old, * nh_list */ if (ospf6->route_table->hook_add) - (*ospf6->route_table->hook_add) - (old_route); + (*ospf6->route_table->hook_add)( + old_route); break; } } else { if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { prefix2str(&old_route->prefix, buf, sizeof(buf)); - zlog_debug("%s: route %s old cost %u new cost %u, delete old entry.", - __PRETTY_FUNCTION__, buf, - old_route->path.cost, - route->path.cost); + zlog_debug( + "%s: route %s old cost %u new cost %u, delete old entry.", + __PRETTY_FUNCTION__, buf, + old_route->path.cost, + route->path.cost); } ospf6_route_remove(old_route, ospf6->route_table); @@ -325,21 +332,22 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old, /* Current and New Route prefix or route type * is not same skip this current node. */ - if (!ospf6_route_is_same(old_route, route) || - (old_route->path.type != route->path.type)) + if (!ospf6_route_is_same(old_route, route) + || (old_route->path.type != route->path.type)) continue; /* Old Route and New Route have Equal Cost, Merge NHs */ - if ((old_route->path.cost == route->path.cost) && - (old_route->path.u.cost_e2 == route->path.u.cost_e2)) { + if ((old_route->path.cost == route->path.cost) + && (old_route->path.u.cost_e2 == route->path.u.cost_e2)) { if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { prefix2str(&old_route->prefix, buf, sizeof(buf)); - zlog_debug("%s: old route %s path cost %u e2 %u", - __PRETTY_FUNCTION__, buf, - old_route->path.cost, - old_route->path.u.cost_e2); + zlog_debug( + "%s: old route %s path cost %u e2 %u", + __PRETTY_FUNCTION__, buf, + old_route->path.cost, + old_route->path.u.cost_e2); } route_found = true; /* check if this path exists already in @@ -348,10 +356,11 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old, */ for (ALL_LIST_ELEMENTS_RO(old_route->paths, anode, o_path)) { - if (o_path->area_id == route->path.area_id && - (memcmp(&(o_path)->origin, - &(route)->path.origin, - sizeof(struct ospf6_ls_origin)) == 0)) + if (o_path->area_id == route->path.area_id + && (memcmp(&(o_path)->origin, + &(route)->path.origin, + sizeof(struct ospf6_ls_origin)) + == 0)) break; } /* If path is not found in old_route paths's list, @@ -370,8 +379,8 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old, /* Update RIB/FIB */ if (ospf6->route_table->hook_add) - (*ospf6->route_table->hook_add) - (old_route); + (*ospf6->route_table->hook_add)( + old_route); /* Add the new path to route's path list */ listnode_add_sort(old_route->paths, ecmp_path); @@ -379,20 +388,23 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old, if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { prefix2str(&route->prefix, buf, sizeof(buf)); - zlog_debug("%s: route %s another path added with nh %u, effective paths %u nh %u", + zlog_debug( + "%s: route %s another path added with nh %u, effective paths %u nh %u", __PRETTY_FUNCTION__, buf, listcount(ecmp_path->nh_list), - old_route->paths ? - listcount(old_route->paths) - : 0, + old_route->paths + ? listcount( + old_route + ->paths) + : 0, listcount(old_route->nh_list)); } } else { for (ALL_LIST_ELEMENTS_RO(o_path->nh_list, nnode, nh)) { for (ALL_LIST_ELEMENTS( - old_route->nh_list, - rnode, rnext, rnh)) { + old_route->nh_list, rnode, + rnext, rnh)) { if (!ospf6_nexthop_is_same(rnh, nh)) continue; @@ -405,27 +417,28 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old, } list_delete_all_node(o_path->nh_list); ospf6_copy_nexthops(o_path->nh_list, - route->nh_list); + route->nh_list); /* Merge nexthop to existing route's nh_list */ - ospf6_route_merge_nexthops(old_route, - route); + ospf6_route_merge_nexthops(old_route, route); if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { - prefix2str(&route->prefix, - buf, sizeof(buf)); - zlog_debug("%s: existing route %s with effective nh count %u", - __PRETTY_FUNCTION__, buf, - old_route->nh_list ? - listcount(old_route->nh_list) - : 0); + prefix2str(&route->prefix, buf, + sizeof(buf)); + zlog_debug( + "%s: existing route %s with effective nh count %u", + __PRETTY_FUNCTION__, buf, + old_route->nh_list + ? listcount( + old_route + ->nh_list) + : 0); } /* Update RIB/FIB */ if (ospf6->route_table->hook_add) - (*ospf6->route_table->hook_add) - (old_route); - + (*ospf6->route_table->hook_add)( + old_route); } /* Delete the new route its info added to existing * route. @@ -524,9 +537,9 @@ void ospf6_asbr_lsa_add(struct ospf6_lsa *lsa) prefix2str(&route->prefix, buf, sizeof(buf)); zlog_debug("%s: AS-External %u route add %s cost %u(%u) nh %u", __PRETTY_FUNCTION__, - (route->path.type == OSPF6_PATH_TYPE_EXTERNAL1) - ? 1 : 2, buf, route->path.cost, - route->path.u.cost_e2, + (route->path.type == OSPF6_PATH_TYPE_EXTERNAL1) ? 1 + : 2, + buf, route->path.cost, route->path.u.cost_e2, listcount(route->nh_list)); } @@ -542,7 +555,6 @@ void ospf6_asbr_lsa_add(struct ospf6_lsa *lsa) */ ospf6_asbr_update_route_ecmp_path(old, route); } - } void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa, @@ -587,9 +599,8 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa, } else { route_to_del->path.type = OSPF6_PATH_TYPE_EXTERNAL1; route_to_del->path.metric_type = 1; - route_to_del->path.cost = - asbr_entry->path.cost + - OSPF6_ASBR_METRIC(external); + route_to_del->path.cost = asbr_entry->path.cost + + OSPF6_ASBR_METRIC(external); route_to_del->path.u.cost_e2 = 0; } } @@ -610,15 +621,15 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa, if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { prefix2str(&prefix, buf, sizeof(buf)); - zlog_debug("%s: Current route %s cost %u e2 %u, route to del cost %u e2 %u", - __PRETTY_FUNCTION__, buf, route->path.cost, - route->path.u.cost_e2, - route_to_del->path.cost, - route_to_del->path.u.cost_e2); + zlog_debug( + "%s: Current route %s cost %u e2 %u, route to del cost %u e2 %u", + __PRETTY_FUNCTION__, buf, route->path.cost, + route->path.u.cost_e2, route_to_del->path.cost, + route_to_del->path.u.cost_e2); } - for (ospf6_route_lock(route); route && - ospf6_route_is_prefix(&prefix, route); route = nroute) { + for (ospf6_route_lock(route); + route && ospf6_route_is_prefix(&prefix, route); route = nroute) { nroute = ospf6_route_next(route); if (route->type != OSPF6_DEST_TYPE_NETWORK) @@ -640,34 +651,36 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa, * replace from paths list. */ for (ALL_LIST_ELEMENTS(route->paths, anode, anext, - o_path)) { + o_path)) { if ((o_path->origin.type != lsa->header->type) - || (o_path->origin.adv_router != - lsa->header->adv_router) || - (o_path->origin.id != lsa->header->id)) + || (o_path->origin.adv_router + != lsa->header->adv_router) + || (o_path->origin.id != lsa->header->id)) continue; /* Compare LSA cost with current * route info. */ - if (!asbr_entry && (o_path->cost != - route_to_del->path.cost || - o_path->u.cost_e2 != - route_to_del->path.u.cost_e2)) { + if (!asbr_entry + && (o_path->cost != route_to_del->path.cost + || o_path->u.cost_e2 + != route_to_del->path.u + .cost_e2)) { if (IS_OSPF6_DEBUG_EXAMIN( - AS_EXTERNAL)) { + AS_EXTERNAL)) { prefix2str(&prefix, buf, sizeof(buf)); zlog_debug( - "%s: route %s to delete is not same, cost %u del cost %u. skip", - __PRETTY_FUNCTION__, buf, - route->path.cost, - route_to_del->path.cost); + "%s: route %s to delete is not same, cost %u del cost %u. skip", + __PRETTY_FUNCTION__, + buf, route->path.cost, + route_to_del->path + .cost); } continue; } - if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { + if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { prefix2str(&prefix, buf, sizeof(buf)); zlog_debug( "%s: route %s path found with nh %u to remove.", @@ -681,9 +694,10 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa, for (ALL_LIST_ELEMENTS_RO(o_path->nh_list, nnode, nh)) { for (ALL_LIST_ELEMENTS(route->nh_list, - rnode, rnext, rnh)) { + rnode, rnext, + rnh)) { if (!ospf6_nexthop_is_same(rnh, - nh)) + nh)) continue; listnode_delete(route->nh_list, rnh); @@ -711,13 +725,15 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa, if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { prefix2str(&route->prefix, buf, sizeof(buf)); - zlog_debug("%s: AS-External %u route %s update paths %u nh %u" - , __PRETTY_FUNCTION__, - (route->path.type == - OSPF6_PATH_TYPE_EXTERNAL1) - ? 1 : 2, buf, - listcount(route->paths), - listcount(route->nh_list)); + zlog_debug( + "%s: AS-External %u route %s update paths %u nh %u", + __PRETTY_FUNCTION__, + (route->path.type + == OSPF6_PATH_TYPE_EXTERNAL1) + ? 1 + : 2, + buf, listcount(route->paths), + listcount(route->nh_list)); } /* Update RIB/FIB with effective nh_list */ @@ -728,13 +744,14 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa, * replace route's primary path with * route's paths list head. */ - if (route->path.origin.id == lsa->header->id && - route->path.origin.adv_router == - lsa->header->adv_router) { + if (route->path.origin.id == lsa->header->id + && route->path.origin.adv_router + == lsa->header->adv_router) { struct ospf6_path *h_path; h_path = (struct ospf6_path *) - listgetdata(listhead(route->paths)); + listgetdata( + listhead(route->paths)); route->path.origin.type = h_path->origin.type; route->path.origin.id = @@ -749,36 +766,39 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa, /* Compare LSA origin and cost with current route info. * if any check fails skip del this route node. */ - if (asbr_entry && (!ospf6_route_is_same_origin(route, - route_to_del) || - (route->path.type != route_to_del->path.type) || - (route->path.cost != route_to_del->path.cost) || - (route->path.u.cost_e2 != - route_to_del->path.u.cost_e2))) { + if (asbr_entry + && (!ospf6_route_is_same_origin(route, route_to_del) + || (route->path.type != route_to_del->path.type) + || (route->path.cost != route_to_del->path.cost) + || (route->path.u.cost_e2 + != route_to_del->path.u.cost_e2))) { if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { prefix2str(&prefix, buf, sizeof(buf)); - zlog_debug("%s: route %s to delete is not same, cost %u del cost %u. skip", - __PRETTY_FUNCTION__, buf, - route->path.cost, - route_to_del->path.cost); + zlog_debug( + "%s: route %s to delete is not same, cost %u del cost %u. skip", + __PRETTY_FUNCTION__, buf, + route->path.cost, + route_to_del->path.cost); } continue; } - if ((route->path.origin.type != lsa->header->type) || - (route->path.origin.adv_router != - lsa->header->adv_router) || - (route->path.origin.id != lsa->header->id)) + if ((route->path.origin.type != lsa->header->type) + || (route->path.origin.adv_router + != lsa->header->adv_router) + || (route->path.origin.id != lsa->header->id)) continue; } if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { prefix2str(&route->prefix, buf, sizeof(buf)); - zlog_debug("%s: AS-External %u route remove %s cost %u(%u) nh %u", - __PRETTY_FUNCTION__, - route->path.type == OSPF6_PATH_TYPE_EXTERNAL1 - ? 1 : 2, buf, route->path.cost, - route->path.u.cost_e2, - listcount(route->nh_list)); + zlog_debug( + "%s: AS-External %u route remove %s cost %u(%u) nh %u", + __PRETTY_FUNCTION__, + route->path.type == OSPF6_PATH_TYPE_EXTERNAL1 + ? 1 + : 2, + buf, route->path.cost, route->path.u.cost_e2, + listcount(route->nh_list)); } ospf6_route_remove(route, ospf6->route_table); } @@ -852,8 +872,8 @@ static int ospf6_asbr_routemap_update_timer(struct thread *thread) ospf6->t_distribute_update = NULL; if (ospf6->rmap[arg_type].name) - ospf6->rmap[arg_type].map = route_map_lookup_by_name( - ospf6->rmap[arg_type].name); + ospf6->rmap[arg_type].map = + route_map_lookup_by_name(ospf6->rmap[arg_type].name); if (ospf6->rmap[arg_type].map) { if (IS_OSPF6_DEBUG_ASBR) zlog_debug("%s: route-map %s update, reset redist %s", @@ -876,7 +896,7 @@ void ospf6_asbr_distribute_list_update(int type) if (ospf6->t_distribute_update) return; - args = XCALLOC(MTYPE_OSPF6_DIST_ARGS, sizeof(void *)*2); + args = XCALLOC(MTYPE_OSPF6_DIST_ARGS, sizeof(void *) * 2); args[0] = ospf6; args[1] = (void *)((ptrdiff_t)type); @@ -903,12 +923,13 @@ static void ospf6_asbr_routemap_update(const char *mapname) ospf6->rmap[type].map = route_map_lookup_by_name( ospf6->rmap[type].name); - if (mapname && ospf6->rmap[type].map && - (strcmp(ospf6->rmap[type].name, mapname) == 0)) { + if (mapname && ospf6->rmap[type].map + && (strcmp(ospf6->rmap[type].name, mapname) == 0)) { if (IS_OSPF6_DEBUG_ASBR) - zlog_debug("%s: route-map %s update, reset redist %s", - __PRETTY_FUNCTION__, mapname, - ZROUTE_NAME(type)); + zlog_debug( + "%s: route-map %s update, reset redist %s", + __PRETTY_FUNCTION__, mapname, + ZROUTE_NAME(type)); ospf6_asbr_distribute_list_update(type); } } else @@ -923,8 +944,8 @@ static void ospf6_asbr_routemap_event(route_map_event_t event, const char *name) if (ospf6 == NULL) return; for (type = 0; type < ZEBRA_ROUTE_MAX; type++) { - if ((ospf6->rmap[type].name) && - (strcmp(ospf6->rmap[type].name, name) == 0)) { + if ((ospf6->rmap[type].name) + && (strcmp(ospf6->rmap[type].name, name) == 0)) { ospf6_asbr_distribute_list_update(type); } } @@ -1064,8 +1085,9 @@ void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex, inet_ntop(AF_INET, &prefix_id.u.prefix4, ibuf, sizeof(ibuf)); prefix2str(prefix, pbuf, sizeof(pbuf)); - zlog_debug("Advertise as AS-External Id:%s prefix %s metric %u", - ibuf, pbuf, match->path.metric_type); + zlog_debug( + "Advertise as AS-External Id:%s prefix %s metric %u", + ibuf, pbuf, match->path.metric_type); } match->path.origin.id = htonl(info->id); @@ -1797,8 +1819,7 @@ struct ospf6_lsa_handler as_external_handler = { .lh_short_name = "ASE", .lh_show = ospf6_as_external_lsa_show, .lh_get_prefix_str = ospf6_as_external_lsa_get_prefix_str, - .lh_debug = 0 -}; + .lh_debug = 0}; void ospf6_asbr_init(void) { |
