From: Igor Ryzhov Date: Fri, 20 Nov 2020 01:13:52 +0000 (+0300) Subject: ospf6: get instance from route table scope X-Git-Tag: base_7.6~175^2~3 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=e285b70d3c802606cb7e9b6b18bcf9534168bc5d;p=matthieu%2Ffrr.git ospf6: get instance from route table scope Signed-off-by: Igor Ryzhov --- diff --git a/ospf6d/ospf6_abr.c b/ospf6d/ospf6_abr.c index c71b30a2d4..8cfdf2642c 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 *ospf6) + struct ospf6_lsa *old) { if (summary) { - ospf6_route_remove(summary, summary_table, ospf6); + ospf6_route_remove(summary, summary_table); } 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, area->ospf6); + ospf6_route_remove(ro, area->summary_prefix); } /* 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, area->ospf6); + ospf6_route_remove(ro, area->summary_router); } /* Schedule Router-LSA for each area (ABR status may change) */ @@ -271,11 +271,10 @@ 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, - area->ospf6); + summary_table, old); } } else if (old) { - ospf6_route_remove(summary, summary_table, area->ospf6); + ospf6_route_remove(summary, summary_table); ospf6_lsa_purge(old); } return 0; @@ -286,8 +285,7 @@ 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, - area->ospf6); + ospf6_abr_delete_route(route, summary, summary_table, old); return 0; } @@ -296,8 +294,7 @@ 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, - area->ospf6); + ospf6_abr_delete_route(route, summary, summary_table, old); return 0; } @@ -333,7 +330,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, area->ospf6); + old); return 0; } @@ -364,7 +361,7 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route, "Suppressed by range %pFX of area %s", &range->prefix, route_area->name); ospf6_abr_delete_route(route, summary, summary_table, - old, area->ospf6); + old); return 0; } } @@ -377,7 +374,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, area->ospf6); + old); return 0; } @@ -386,7 +383,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, area->ospf6); + old); return 0; } } @@ -437,7 +434,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, area->ospf6); + summary = ospf6_route_add(summary, summary_table); } else { summary->type = route->type; monotime(&summary->changed); @@ -706,8 +703,7 @@ 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 *ospf6) + struct ospf6_route_table *table) { struct ospf6_path *o_path = NULL; struct listnode *anode, *anext; @@ -754,7 +750,7 @@ void ospf6_abr_old_path_update(struct ospf6_route *old_route, : 0); if (table->hook_add) - (*table->hook_add)(old_route, ospf6); + (*table->hook_add)(old_route); if (old_route->path.origin.id == route->path.origin.id && old_route->path.origin.adv_router == @@ -772,8 +768,7 @@ 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, - struct ospf6 *ospf6) + struct ospf6_route_table *table) { if (listcount(old->paths) > 1) { struct listnode *anode, *anext, *nnode, *rnode, *rnext; @@ -810,7 +805,7 @@ void ospf6_abr_old_route_remove(struct ospf6_lsa *lsa, struct ospf6_route *old, : 0); if (table->hook_add) - (*table->hook_add)(old, ospf6); + (*table->hook_add)(old); if ((old->path.origin.id == lsa->header->id) && (old->path.origin.adv_router @@ -827,10 +822,10 @@ void ospf6_abr_old_route_remove(struct ospf6_lsa *lsa, struct ospf6_route *old, h_path->origin.adv_router; } } else - ospf6_route_remove(old, table, ospf6); + ospf6_route_remove(old, table); } } else - ospf6_route_remove(old, table, ospf6); + ospf6_route_remove(old, table); } /* RFC 2328 16.2. Calculating the inter-area routes */ @@ -945,7 +940,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, oa->ospf6); + ospf6_abr_old_route_remove(lsa, old, table); return; } if (OSPF6_LSA_IS_MAXAGE(lsa)) { @@ -953,7 +948,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, oa->ospf6); + ospf6_abr_old_route_remove(lsa, old, table); return; } @@ -963,7 +958,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, oa->ospf6); + ospf6_route_remove(old, table); return; } @@ -979,7 +974,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, oa->ospf6); + ospf6_route_remove(old, table); return; } @@ -990,7 +985,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, oa->ospf6); + ospf6_route_remove(old, table); return; } } @@ -1003,7 +998,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, oa->ospf6); + ospf6_route_remove(old, table); return; } @@ -1017,7 +1012,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, oa->ospf6); + ospf6_route_remove(old, table); return; } @@ -1045,7 +1040,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, oa->ospf6); + ospf6_route_remove(old, table); } } return; @@ -1064,8 +1059,7 @@ 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, - oa->ospf6); + ospf6_route_remove(old, table); return; } } @@ -1077,7 +1071,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, oa->ospf6); + ospf6_route_remove(old, table); return; } } @@ -1130,7 +1124,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, oa->ospf6); + table); continue; } @@ -1198,7 +1192,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, oa->ospf6); + (*table->hook_add)(old_route); /* Delete new route */ ospf6_route_delete(route); @@ -1218,7 +1212,7 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa) 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, oa->ospf6); + ospf6_route_add(route, table); } } diff --git a/ospf6d/ospf6_abr.h b/ospf6d/ospf6_abr.h index 8ad51a4f82..e261cd1090 100644 --- a/ospf6d/ospf6_abr.h +++ b/ospf6d/ospf6_abr.h @@ -81,12 +81,10 @@ extern void install_element_ospf6_debug_abr(void); extern int ospf6_abr_config_write(struct vty *vty); extern void ospf6_abr_old_route_remove(struct ospf6_lsa *lsa, struct ospf6_route *old, - struct ospf6_route_table *table, - struct ospf6 *ospf6); + struct ospf6_route_table *table); extern void ospf6_abr_old_path_update(struct ospf6_route *old_route, struct ospf6_route *route, - struct ospf6_route_table *table, - struct ospf6 *ospf6); + struct ospf6_route_table *table); extern void ospf6_abr_init(void); #endif /*OSPF6_ABR_H*/ diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c index 2ef61ae0cd..778bcb9a45 100644 --- a/ospf6d/ospf6_area.c +++ b/ospf6d/ospf6_area.c @@ -115,23 +115,25 @@ static void ospf6_area_lsdb_hook_remove(struct ospf6_lsa *lsa) } } -static void ospf6_area_route_hook_add(struct ospf6_route *route, - struct ospf6 *ospf6) +static void ospf6_area_route_hook_add(struct ospf6_route *route) { + struct ospf6_area *oa = route->table->scope; + struct ospf6 *ospf6 = oa->ospf6; struct ospf6_route *copy; copy = ospf6_route_copy(route); - ospf6_route_add(copy, ospf6->route_table, ospf6); + ospf6_route_add(copy, ospf6->route_table); } -static void ospf6_area_route_hook_remove(struct ospf6_route *route, - struct ospf6 *ospf6) +static void ospf6_area_route_hook_remove(struct ospf6_route *route) { + struct ospf6_area *oa = route->table->scope; + struct ospf6 *ospf6 = oa->ospf6; struct ospf6_route *copy; copy = ospf6_route_lookup_identical(route, ospf6->route_table); if (copy) - ospf6_route_remove(copy, ospf6->route_table, ospf6); + ospf6_route_remove(copy, ospf6->route_table); } static void ospf6_area_stub_update(struct ospf6_area *area) @@ -284,13 +286,13 @@ void ospf6_area_delete(struct ospf6_area *oa) ospf6_lsdb_delete(oa->lsdb_self); ospf6_lsdb_delete(oa->temp_router_lsa_lsdb); - ospf6_spf_table_finish(oa->spf_table, oa->ospf6); - ospf6_route_table_delete(oa->spf_table, oa->ospf6); - ospf6_route_table_delete(oa->route_table, oa->ospf6); + ospf6_spf_table_finish(oa->spf_table); + ospf6_route_table_delete(oa->spf_table); + ospf6_route_table_delete(oa->route_table); - ospf6_route_table_delete(oa->range_table, oa->ospf6); - ospf6_route_table_delete(oa->summary_prefix, oa->ospf6); - ospf6_route_table_delete(oa->summary_router, oa->ospf6); + ospf6_route_table_delete(oa->range_table); + ospf6_route_table_delete(oa->summary_prefix); + ospf6_route_table_delete(oa->summary_router); listnode_delete(oa->ospf6->area_list, oa); oa->ospf6 = NULL; @@ -351,8 +353,8 @@ void ospf6_area_disable(struct ospf6_area *oa) ospf6_lsdb_remove_all(oa->lsdb); ospf6_lsdb_remove_all(oa->lsdb_self); - ospf6_spf_table_finish(oa->spf_table, oa->ospf6); - ospf6_route_remove_all(oa->route_table, oa->ospf6); + ospf6_spf_table_finish(oa->spf_table); + ospf6_route_remove_all(oa->route_table); THREAD_OFF(oa->thread_router_lsa); THREAD_OFF(oa->thread_intra_prefix_lsa); @@ -508,7 +510,7 @@ DEFUN (area_range, zlog_debug("%s: for prefix %s, flag = %x", __func__, argv[idx_ipv6_prefixlen]->arg, range->flag); if (range->rnode == NULL) { - ospf6_route_add(range, oa->range_table, oa->ospf6); + ospf6_route_add(range, oa->range_table); } if (ospf6_is_router_abr(ospf6)) { @@ -569,7 +571,7 @@ DEFUN (no_area_range, /* purge the old aggregated summary LSA */ ospf6_abr_originate_summary(range, oa->ospf6); } - ospf6_route_remove(range, oa->range_table, oa->ospf6); + ospf6_route_remove(range, oa->range_table); return CMD_SUCCESS; } @@ -978,15 +980,15 @@ DEFUN (show_ipv6_ospf6_simulate_spf_tree_root, route = ospf6_route_lookup(&prefix, spf_table); if (route == NULL) { - ospf6_spf_table_finish(spf_table, ospf6); - ospf6_route_table_delete(spf_table, ospf6); + ospf6_spf_table_finish(spf_table); + ospf6_route_table_delete(spf_table); return CMD_SUCCESS; } root = (struct ospf6_vertex *)route->route_option; ospf6_spf_display_subtree(vty, "", 0, root); - ospf6_spf_table_finish(spf_table, ospf6); - ospf6_route_table_delete(spf_table, ospf6); + ospf6_spf_table_finish(spf_table); + ospf6_route_table_delete(spf_table); return CMD_SUCCESS; } diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c index 308732c4ee..175f87120f 100644 --- a/ospf6d/ospf6_asbr.c +++ b/ospf6d/ospf6_asbr.c @@ -287,7 +287,7 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old, */ if (ospf6->route_table->hook_add) (*ospf6->route_table->hook_add)( - old_route, ospf6); + old_route); if (old_route->path.origin.id == route->path.origin.id @@ -315,7 +315,7 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old, route->path.cost); } ospf6_route_remove(old_route, - ospf6->route_table, ospf6); + ospf6->route_table); } } if (route_updated) @@ -425,8 +425,7 @@ 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); + (*ospf6->route_table->hook_add)(old_route); /* Delete the new route its info added to existing * route. @@ -439,7 +438,7 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old, if (!route_found) { /* Add new route to existing node in ospf6 route table. */ - ospf6_route_add(route, ospf6->route_table, ospf6); + ospf6_route_add(route, ospf6->route_table); } } @@ -531,7 +530,7 @@ void ospf6_asbr_lsa_add(struct ospf6_lsa *lsa, struct ospf6 *ospf6) old = ospf6_route_lookup(&route->prefix, ospf6->route_table); if (!old) { /* Add the new route to ospf6 instance route table. */ - ospf6_route_add(route, ospf6->route_table, ospf6); + ospf6_route_add(route, ospf6->route_table); } else { /* RFC 2328 16.4 (6) * ECMP: Keep new equal preference path in current @@ -733,8 +732,7 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa, */ if (oa->ospf6->route_table->hook_add) (*oa->ospf6->route_table - ->hook_add)( - route, oa->ospf6); + ->hook_add)(route); /* route's primary path is similar * to LSA, replace route's primary @@ -758,8 +756,7 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa, } } else { ospf6_route_remove( - route, oa->ospf6->route_table, - oa->ospf6); + route, oa->ospf6->route_table); } } continue; @@ -799,7 +796,7 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa, &route->prefix, route->path.cost, route->path.u.cost_e2, listcount(route->nh_list)); } - ospf6_route_remove(route, oa->ospf6->route_table, oa->ospf6); + ospf6_route_remove(route, oa->ospf6->route_table); } if (route != NULL) ospf6_route_unlock(route); @@ -1191,7 +1188,7 @@ void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex, node = route_node_get(ospf6->external_id_table, &prefix_id); node->info = route; - route = ospf6_route_add(route, ospf6->external_table, ospf6); + route = ospf6_route_add(route, ospf6->external_table); route->route_option = info; if (IS_OSPF6_DEBUG_ASBR) { @@ -1257,7 +1254,7 @@ void ospf6_asbr_redistribute_remove(int type, ifindex_t ifindex, route_unlock_node(node); /* to free the lookup lock */ route_unlock_node(node); /* to free the original lock */ - ospf6_route_remove(match, ospf6->external_table, ospf6); + ospf6_route_remove(match, ospf6->external_table); XFREE(MTYPE_OSPF6_EXTERNAL_INFO, info); /* Router-Bit (ASBR Flag) may have to be updated */ diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c index 89b36d48a8..7045e427d3 100644 --- a/ospf6d/ospf6_interface.c +++ b/ospf6d/ospf6_interface.c @@ -261,7 +261,7 @@ void ospf6_interface_delete(struct ospf6_interface *oi) ospf6_lsdb_delete(oi->lsupdate_list); ospf6_lsdb_delete(oi->lsack_list); - ospf6_route_table_delete(oi->route_connected, oi->area->ospf6); + ospf6_route_table_delete(oi->route_connected); /* cut link */ oi->interface->info = NULL; @@ -417,7 +417,7 @@ void ospf6_interface_connected_route_update(struct interface *ifp) return; /* update "route to advertise" interface route table */ - ospf6_route_remove_all(oi->route_connected, oi->area->ospf6); + ospf6_route_remove_all(oi->route_connected); for (ALL_LIST_ELEMENTS(oi->interface->connected, node, nnode, c)) { if (c->address->family != AF_INET6) @@ -461,7 +461,7 @@ void ospf6_interface_connected_route_update(struct interface *ifp) inet_pton(AF_INET6, "::1", &nh_addr); ospf6_route_add_nexthop(route, oi->interface->ifindex, &nh_addr); - ospf6_route_add(route, oi->route_connected, oi->area->ospf6); + ospf6_route_add(route, oi->route_connected); } /* create new Link-LSA */ diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c index f84a7cfe9a..be5069c88d 100644 --- a/ospf6d/ospf6_intra.c +++ b/ospf6d/ospf6_intra.c @@ -987,7 +987,7 @@ int ospf6_intra_prefix_lsa_originate_stub(struct thread *thread) if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX)) zlog_debug(" include %pFX", &route->prefix); ospf6_route_add(ospf6_route_copy(route), - route_advertise, oa->ospf6); + route_advertise); } } @@ -1008,7 +1008,7 @@ int ospf6_intra_prefix_lsa_originate_stub(struct thread *thread) oa->lsdb); } } - ospf6_route_table_delete(route_advertise, oa->ospf6); + ospf6_route_table_delete(route_advertise); return 0; } @@ -1088,7 +1088,7 @@ int ospf6_intra_prefix_lsa_originate_stub(struct thread *thread) op = OSPF6_PREFIX_NEXT(op); } - ospf6_route_table_delete(route_advertise, oa->ospf6); + ospf6_route_table_delete(route_advertise); if (prefix_num == 0) { if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX)) @@ -1254,8 +1254,7 @@ int ospf6_intra_prefix_lsa_originate_transit(struct thread *thread) if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX)) zlog_debug(" include %pFX", &route->prefix); - ospf6_route_add(route, route_advertise, - oi->area->ospf6); + ospf6_route_add(route, route_advertise); prefix_num--; } if (current != end && IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX)) @@ -1277,7 +1276,7 @@ int ospf6_intra_prefix_lsa_originate_transit(struct thread *thread) prefix_num++; } - ospf6_route_table_delete(route_advertise, oi->area->ospf6); + ospf6_route_table_delete(route_advertise); if (prefix_num == 0) { if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX)) @@ -1438,7 +1437,7 @@ void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area *oa, */ if (oa->route_table->hook_add) (*oa->route_table->hook_add)( - old_route, oa->ospf6); + old_route); if (old_route->path.origin.id == route->path.origin.id && @@ -1459,8 +1458,7 @@ void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area *oa, } if (oa->route_table->hook_remove) ospf6_route_remove(old_route, - oa->route_table, - oa->ospf6); + oa->route_table); else SET_FLAG(old_route->flag, OSPF6_ROUTE_REMOVE); @@ -1601,8 +1599,7 @@ void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area *oa, SET_FLAG(old_route->flag, OSPF6_ROUTE_ADD); /* Update ospf6 route table and RIB/FIB */ if (oa->route_table->hook_add) - (*oa->route_table->hook_add)(old_route, - oa->ospf6); + (*oa->route_table->hook_add)(old_route); /* Delete the new route its info added to existing * route. */ @@ -1614,7 +1611,7 @@ void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area *oa, if (!route_found) { /* Add new route to existing node in ospf6 route table. */ - ospf6_route_add(route, oa->route_table, oa->ospf6); + ospf6_route_add(route, oa->route_table); } } @@ -1757,7 +1754,7 @@ void ospf6_intra_prefix_lsa_add(struct ospf6_lsa *lsa) listcount(route->paths), listcount(route->nh_list)); } - ospf6_route_add(route, oa->route_table, oa->ospf6); + ospf6_route_add(route, oa->route_table); } prefix_num--; } @@ -1839,7 +1836,7 @@ static void ospf6_intra_prefix_lsa_remove_update_route(struct ospf6_lsa *lsa, * nh_list */ if (oa->route_table->hook_add) - (*oa->route_table->hook_add)(route, oa->ospf6); + (*oa->route_table->hook_add)(route); /* route's primary path is similar * to LSA, replace route's primary @@ -1932,8 +1929,7 @@ void ospf6_intra_prefix_lsa_remove(struct ospf6_lsa *lsa) listcount(route->paths), listcount(route->nh_list)); } - ospf6_route_remove(route, oa->route_table, - oa->ospf6); + ospf6_route_remove(route, oa->route_table); } } if (route) @@ -1949,8 +1945,8 @@ void ospf6_intra_route_calculation(struct ospf6_area *oa) struct ospf6_route *route, *nroute; uint16_t type; struct ospf6_lsa *lsa; - void (*hook_add)(struct ospf6_route *, struct ospf6 *) = NULL; - void (*hook_remove)(struct ospf6_route *, struct ospf6 *) = NULL; + void (*hook_add)(struct ospf6_route *) = NULL; + void (*hook_remove)(struct ospf6_route *) = NULL; if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) zlog_debug("Re-examin intra-routes for area %s", oa->name); @@ -1980,11 +1976,11 @@ void ospf6_intra_route_calculation(struct ospf6_area *oa) } if (CHECK_FLAG(route->flag, OSPF6_ROUTE_REMOVE)) - ospf6_route_remove(route, oa->route_table, oa->ospf6); + ospf6_route_remove(route, oa->route_table); else if (CHECK_FLAG(route->flag, OSPF6_ROUTE_ADD) || CHECK_FLAG(route->flag, OSPF6_ROUTE_CHANGE)) { if (hook_add) - (*hook_add)(route, oa->ospf6); + (*hook_add)(route); route->flag = 0; } else { /* Redo the summaries as things might have changed */ @@ -2056,8 +2052,8 @@ static void ospf6_brouter_debug_print(struct ospf6_route *brouter) void ospf6_intra_brouter_calculation(struct ospf6_area *oa) { struct ospf6_route *brouter, *nbrouter, *copy; - void (*hook_add)(struct ospf6_route *, struct ospf6 *) = NULL; - void (*hook_remove)(struct ospf6_route *, struct ospf6 *) = NULL; + void (*hook_add)(struct ospf6_route *) = NULL; + void (*hook_remove)(struct ospf6_route *) = NULL; uint32_t brouter_id; char brouter_name[16]; @@ -2115,7 +2111,7 @@ void ospf6_intra_brouter_calculation(struct ospf6_area *oa) copy = ospf6_route_copy(brouter); copy->type = OSPF6_DEST_TYPE_ROUTER; copy->path.area_id = oa->area_id; - ospf6_route_add(copy, oa->ospf6->brouter_table, oa->ospf6); + ospf6_route_add(copy, oa->ospf6->brouter_table); if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID(brouter_id) || IS_OSPF6_DEBUG_ROUTE(MEMORY)) { @@ -2201,8 +2197,7 @@ void ospf6_intra_brouter_calculation(struct ospf6_area *oa) * removes brouters which are marked for remove. */ oa->intra_brouter_calc = 1; - ospf6_route_remove(brouter, oa->ospf6->brouter_table, - oa->ospf6); + ospf6_route_remove(brouter, oa->ospf6->brouter_table); brouter = NULL; } else if (CHECK_FLAG(brouter->flag, OSPF6_ROUTE_ADD) || CHECK_FLAG(brouter->flag, OSPF6_ROUTE_CHANGE)) { @@ -2216,7 +2211,7 @@ void ospf6_intra_brouter_calculation(struct ospf6_area *oa) /* newly added */ if (hook_add) - (*hook_add)(brouter, oa->ospf6); + (*hook_add)(brouter); } else { if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID( brouter_id) diff --git a/ospf6d/ospf6_route.c b/ospf6d/ospf6_route.c index 2602854f33..09b012e5aa 100644 --- a/ospf6d/ospf6_route.c +++ b/ospf6d/ospf6_route.c @@ -398,6 +398,7 @@ void ospf6_copy_paths(struct list *dst, struct list *src) struct ospf6_route *ospf6_route_create(void) { struct ospf6_route *route; + route = XCALLOC(MTYPE_OSPF6_ROUTE, sizeof(struct ospf6_route)); route->nh_list = list_new(); route->nh_list->cmp = (int (*)(void *, void *))ospf6_nexthop_cmp; @@ -590,8 +591,7 @@ static void route_table_assert(struct ospf6_route_table *table) #endif /*DEBUG*/ struct ospf6_route *ospf6_route_add(struct ospf6_route *route, - struct ospf6_route_table *table, - struct ospf6 *ospf6) + struct ospf6_route_table *table) { struct route_node *node, *nextnode, *prevnode; struct ospf6_route *current = NULL; @@ -700,7 +700,7 @@ struct ospf6_route *ospf6_route_add(struct ospf6_route *route, ospf6_route_table_assert(table); if (table->hook_add) - (*table->hook_add)(route, ospf6); + (*table->hook_add)(route); return route; } @@ -755,7 +755,7 @@ struct ospf6_route *ospf6_route_add(struct ospf6_route *route, SET_FLAG(route->flag, OSPF6_ROUTE_ADD); if (table->hook_add) - (*table->hook_add)(route, ospf6); + (*table->hook_add)(route); return route; } @@ -821,13 +821,13 @@ struct ospf6_route *ospf6_route_add(struct ospf6_route *route, SET_FLAG(route->flag, OSPF6_ROUTE_ADD); if (table->hook_add) - (*table->hook_add)(route, ospf6); + (*table->hook_add)(route); return route; } void ospf6_route_remove(struct ospf6_route *route, - struct ospf6_route_table *table, struct ospf6 *ospf6) + struct ospf6_route_table *table) { struct route_node *node; struct ospf6_route *current; @@ -882,7 +882,7 @@ void ospf6_route_remove(struct ospf6_route *route, /* Note hook_remove may call ospf6_route_remove */ if (table->hook_remove) - (*table->hook_remove)(route, ospf6); + (*table->hook_remove)(route); ospf6_route_unlock(route); } @@ -1002,13 +1002,12 @@ struct ospf6_route *ospf6_route_match_next(struct prefix *prefix, return next; } -void ospf6_route_remove_all(struct ospf6_route_table *table, - struct ospf6 *ospf6) +void ospf6_route_remove_all(struct ospf6_route_table *table) { struct ospf6_route *route; for (route = ospf6_route_head(table); route; route = ospf6_route_next(route)) - ospf6_route_remove(route, table, ospf6); + ospf6_route_remove(route, table); } struct ospf6_route_table *ospf6_route_table_create(int s, int t) @@ -1021,10 +1020,9 @@ struct ospf6_route_table *ospf6_route_table_create(int s, int t) return new; } -void ospf6_route_table_delete(struct ospf6_route_table *table, - struct ospf6 *ospf6) +void ospf6_route_table_delete(struct ospf6_route_table *table) { - ospf6_route_remove_all(table, ospf6); + ospf6_route_remove_all(table); bf_free(table->idspace); route_table_finish(table->table); XFREE(MTYPE_OSPF6_ROUTE, table); diff --git a/ospf6d/ospf6_route.h b/ospf6d/ospf6_route.h index 0b984400b5..8a219081cd 100644 --- a/ospf6d/ospf6_route.h +++ b/ospf6d/ospf6_route.h @@ -193,9 +193,9 @@ struct ospf6_route_table { bitfield_t idspace; /* hooks */ - void (*hook_add)(struct ospf6_route *, struct ospf6 *); + void (*hook_add)(struct ospf6_route *); void (*hook_change)(struct ospf6_route *); - void (*hook_remove)(struct ospf6_route *, struct ospf6 *); + void (*hook_remove)(struct ospf6_route *); }; #define OSPF6_SCOPE_TYPE_NONE 0 @@ -307,11 +307,9 @@ ospf6_route_lookup_bestmatch(struct prefix *prefix, struct ospf6_route_table *table); extern struct ospf6_route *ospf6_route_add(struct ospf6_route *route, - struct ospf6_route_table *table, - struct ospf6 *ospf6); + struct ospf6_route_table *table); extern void ospf6_route_remove(struct ospf6_route *route, - struct ospf6_route_table *table, - struct ospf6 *ospf6); + struct ospf6_route_table *table); extern struct ospf6_route *ospf6_route_head(struct ospf6_route_table *table); extern struct ospf6_route *ospf6_route_next(struct ospf6_route *route); @@ -322,10 +320,9 @@ ospf6_route_match_head(struct prefix *prefix, struct ospf6_route_table *table); extern struct ospf6_route *ospf6_route_match_next(struct prefix *prefix, struct ospf6_route *route); -extern void ospf6_route_remove_all(struct ospf6_route_table *, struct ospf6 *); +extern void ospf6_route_remove_all(struct ospf6_route_table *table); extern struct ospf6_route_table *ospf6_route_table_create(int s, int t); -extern void ospf6_route_table_delete(struct ospf6_route_table *, - struct ospf6 *); +extern void ospf6_route_table_delete(struct ospf6_route_table *table); extern void ospf6_route_dump(struct ospf6_route_table *table); diff --git a/ospf6d/ospf6_spf.c b/ospf6d/ospf6_spf.c index 4dd1d5a462..70771c6060 100644 --- a/ospf6d/ospf6_spf.c +++ b/ospf6d/ospf6_spf.c @@ -316,8 +316,7 @@ static void ospf6_nexthop_calc(struct ospf6_vertex *w, struct ospf6_vertex *v, } static int ospf6_spf_install(struct ospf6_vertex *v, - struct ospf6_route_table *result_table, - struct ospf6 *ospf6) + struct ospf6_route_table *result_table) { struct ospf6_route *route, *parent_route; struct ospf6_vertex *prev; @@ -417,12 +416,11 @@ static int ospf6_spf_install(struct ospf6_vertex *v, listnode_add_sort(v->parent->child_list, v); route->route_option = v; - ospf6_route_add(route, result_table, ospf6); + ospf6_route_add(route, result_table); return 0; } -void ospf6_spf_table_finish(struct ospf6_route_table *result_table, - struct ospf6 *ospf6) +void ospf6_spf_table_finish(struct ospf6_route_table *result_table) { struct ospf6_route *route, *nroute; struct ospf6_vertex *v; @@ -430,7 +428,7 @@ void ospf6_spf_table_finish(struct ospf6_route_table *result_table, nroute = ospf6_route_next(route); v = (struct ospf6_vertex *)route->route_option; ospf6_vertex_delete(v); - ospf6_route_remove(route, result_table, ospf6); + ospf6_route_remove(route, result_table); } } @@ -468,7 +466,7 @@ void ospf6_spf_calculation(uint32_t router_id, struct ospf6_lsa *lsa; struct in6_addr address; - ospf6_spf_table_finish(result_table, oa->ospf6); + ospf6_spf_table_finish(result_table); /* Install the calculating router itself as the root of the SPF tree */ /* construct root vertex */ @@ -497,7 +495,7 @@ void ospf6_spf_calculation(uint32_t router_id, while ((v = vertex_pqueue_pop(&candidate_list))) { /* installing may result in merging or rejecting of the vertex */ - if (ospf6_spf_install(v, result_table, oa->ospf6) < 0) + if (ospf6_spf_install(v, result_table) < 0) continue; /* Skip overloaded routers */ diff --git a/ospf6d/ospf6_spf.h b/ospf6d/ospf6_spf.h index f288f91f57..853ce4de07 100644 --- a/ospf6d/ospf6_spf.h +++ b/ospf6d/ospf6_spf.h @@ -139,8 +139,7 @@ static inline unsigned int ospf6_lsremove_to_spf_reason(struct ospf6_lsa *lsa) return (reason); } -extern void ospf6_spf_table_finish(struct ospf6_route_table *result_table, - struct ospf6 *ospf6); +extern void ospf6_spf_table_finish(struct ospf6_route_table *result_table); extern void ospf6_spf_calculation(uint32_t router_id, struct ospf6_route_table *result_table, struct ospf6_area *oa); diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index cbfa8ba3d5..6cd214f595 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -149,24 +149,27 @@ static void ospf6_top_lsdb_hook_remove(struct ospf6_lsa *lsa) } } -static void ospf6_top_route_hook_add(struct ospf6_route *route, - struct ospf6 *ospf6) +static void ospf6_top_route_hook_add(struct ospf6_route *route) { + struct ospf6 *ospf6 = route->table->scope; + ospf6_abr_originate_summary(route, ospf6); ospf6_zebra_route_update_add(route, ospf6); } -static void ospf6_top_route_hook_remove(struct ospf6_route *route, - struct ospf6 *ospf6) +static void ospf6_top_route_hook_remove(struct ospf6_route *route) { + struct ospf6 *ospf6 = route->table->scope; + route->flag |= OSPF6_ROUTE_REMOVE; ospf6_abr_originate_summary(route, ospf6); ospf6_zebra_route_update_remove(route, ospf6); } -static void ospf6_top_brouter_hook_add(struct ospf6_route *route, - struct ospf6 *ospf6) +static void ospf6_top_brouter_hook_add(struct ospf6_route *route) { + struct ospf6 *ospf6 = route->table->scope; + if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL) || IS_OSPF6_DEBUG_BROUTER) { uint32_t brouter_id; @@ -186,9 +189,10 @@ static void ospf6_top_brouter_hook_add(struct ospf6_route *route, ospf6_abr_originate_summary(route, ospf6); } -static void ospf6_top_brouter_hook_remove(struct ospf6_route *route, - struct ospf6 *ospf6) +static void ospf6_top_brouter_hook_remove(struct ospf6_route *route) { + struct ospf6 *ospf6 = route->table->scope; + if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL) || IS_OSPF6_DEBUG_BROUTER) { uint32_t brouter_id; @@ -310,10 +314,10 @@ void ospf6_delete(struct ospf6 *o) ospf6_lsdb_delete(o->lsdb); ospf6_lsdb_delete(o->lsdb_self); - ospf6_route_table_delete(o->route_table, o); - ospf6_route_table_delete(o->brouter_table, o); + ospf6_route_table_delete(o->route_table); + ospf6_route_table_delete(o->brouter_table); - ospf6_route_table_delete(o->external_table, o); + ospf6_route_table_delete(o->external_table); route_table_finish(o->external_id_table); ospf6_distance_reset(o); @@ -338,8 +342,8 @@ static void ospf6_disable(struct ospf6 *o) ospf6_asbr_redistribute_reset(o->vrf_id); ospf6_lsdb_remove_all(o->lsdb); - ospf6_route_remove_all(o->route_table, o); - ospf6_route_remove_all(o->brouter_table, o); + ospf6_route_remove_all(o->route_table); + ospf6_route_remove_all(o->brouter_table); THREAD_OFF(o->maxage_remover); THREAD_OFF(o->t_spf_calc);