1. All the changes are related to handle ospf6 with different vrf.
2. The dependancy of global ospf6 is removed.
Co-authored-by: Kaushik <kaushik@niralnetworks.com>
Signed-off-by: harios_niral <hari@niralnetworks.com>
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))
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 */
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) */
"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;
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;
}
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;
}
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;
}
buf, route_area->name);
}
ospf6_abr_delete_route(route, summary, summary_table,
- old);
+ old, area->ospf6);
return 0;
}
}
zlog_debug(
"This is the range with DoNotAdvertise set. ignore");
ospf6_abr_delete_route(route, summary, summary_table,
- old);
+ old, area->ospf6);
return 0;
}
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;
}
}
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);
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;
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
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) {
range = ospf6_route_lookup_bestmatch(&route->prefix,
oa->range_table);
if (range) {
- ospf6_abr_range_update(range);
+ ospf6_abr_range_update(range, ospf6);
}
}
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 */
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;
: 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 ==
}
}
-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;
}
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
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 */
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)) {
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;
}
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;
}
zlog_debug(
"Prefix is equal to address range, ignore");
if (old)
- ospf6_route_remove(old, table);
+ ospf6_route_remove(old, table, oa->ospf6);
return;
}
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;
}
}
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;
}
"Ignorning Inter-Router LSA for an ABR (%s)",
buf);
if (old)
- ospf6_route_remove(old, table);
+ ospf6_route_remove(old, table, oa->ospf6);
return;
}
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;
zlog_debug(
"Prefix was denied by import-list");
if (old)
- ospf6_route_remove(old, table);
+ ospf6_route_remove(old, table,
+ oa->ospf6);
return;
}
}
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;
}
}
*/
if (listcount(old_route->paths) > 1)
ospf6_abr_old_path_update(old_route, route,
- table);
+ table, oa->ospf6);
continue;
}
* 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);
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
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");
extern int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
struct ospf6_area *area);
-extern void ospf6_abr_originate_summary(struct ospf6_route *route);
+extern void ospf6_abr_originate_summary(struct ospf6_route *route,
+ struct ospf6 *ospf6);
extern void ospf6_abr_examin_summary(struct ospf6_lsa *lsa,
struct ospf6_area *oa);
extern void ospf6_abr_defaults_to_stub(struct ospf6 *);
-extern void ospf6_abr_examin_brouter(uint32_t router_id);
+extern void ospf6_abr_examin_brouter(uint32_t router_id,
+ struct ospf6_route *route,
+ struct ospf6 *ospf6);
extern void ospf6_abr_reimport(struct ospf6_area *oa);
extern void ospf6_abr_range_reset_cost(struct ospf6 *ospf6);
extern void ospf6_abr_prefix_resummarize(struct ospf6 *ospf6);
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_route_table *table,
+ struct ospf6 *ospf6);
extern 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);
extern void ospf6_abr_init(void);
#endif /*OSPF6_ABR_H*/
}
}
-static void ospf6_area_route_hook_add(struct ospf6_route *route)
+static void ospf6_area_route_hook_add(struct ospf6_route *route,
+ struct ospf6 *ospf6)
{
struct ospf6_route *copy;
copy = ospf6_route_copy(route);
- ospf6_route_add(copy, ospf6->route_table);
+ ospf6_route_add(copy, ospf6->route_table, ospf6);
}
-static void ospf6_area_route_hook_remove(struct ospf6_route *route)
+static void ospf6_area_route_hook_remove(struct ospf6_route *route,
+ struct ospf6 *ospf6)
{
struct ospf6_route *copy;
copy = ospf6_route_lookup_identical(route, ospf6->route_table);
if (copy)
- ospf6_route_remove(copy, ospf6->route_table);
+ ospf6_route_remove(copy, ospf6->route_table, ospf6);
}
static void ospf6_area_stub_update(struct ospf6_area *area)
ospf6_lsdb_delete(oa->lsdb_self);
ospf6_lsdb_delete(oa->temp_router_lsa_lsdb);
- ospf6_spf_table_finish(oa->spf_table);
- ospf6_route_table_delete(oa->spf_table);
- ospf6_route_table_delete(oa->route_table);
+ 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_route_table_delete(oa->range_table);
- ospf6_route_table_delete(oa->summary_prefix);
- ospf6_route_table_delete(oa->summary_router);
+ 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);
listnode_delete(oa->ospf6->area_list, oa);
oa->ospf6 = NULL;
XFREE(MTYPE_OSPF6_AREA, oa);
}
+struct ospf6_area *ospf6_area_lookup_by_area_id(uint32_t area_id)
+{
+ struct ospf6_area *oa;
+ struct listnode *n, *node, *nnode;
+ struct ospf6 *ospf6;
+
+ for (ALL_LIST_ELEMENTS(om6->ospf6, node, nnode, ospf6)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, n, oa))
+ if (oa->area_id == area_id)
+ return oa;
+ }
+ return (struct ospf6_area *)NULL;
+}
+
struct ospf6_area *ospf6_area_lookup(uint32_t area_id, struct ospf6 *ospf6)
{
struct ospf6_area *oa;
ospf6_lsdb_remove_all(oa->lsdb);
ospf6_lsdb_remove_all(oa->lsdb_self);
- ospf6_spf_table_finish(oa->spf_table);
- ospf6_route_remove_all(oa->route_table);
+ ospf6_spf_table_finish(oa->spf_table, oa->ospf6);
+ ospf6_route_remove_all(oa->route_table, oa->ospf6);
THREAD_OFF(oa->thread_router_lsa);
THREAD_OFF(oa->thread_intra_prefix_lsa);
struct ospf6_route *range;
uint32_t cost = OSPF_AREA_RANGE_COST_UNSPEC;
- OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, oa);
+ VTY_DECLVAR_CONTEXT(ospf6, ospf6);
+
+ OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, oa, ospf6);
ret = str2prefix(argv[idx_ipv6_prefixlen]->arg, &prefix);
if (ret != 1 || prefix.family != AF_INET6) {
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);
+ ospf6_route_add(range, oa->range_table, oa->ospf6);
}
if (ospf6_is_router_abr(ospf6)) {
struct prefix prefix;
struct ospf6_route *range, *route;
- OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, oa);
+ VTY_DECLVAR_CONTEXT(ospf6, ospf6);
+
+ OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, oa, ospf6);
ret = str2prefix(argv[idx_ipv6]->arg, &prefix);
if (ret != 1 || prefix.family != AF_INET6) {
SET_FLAG(range->flag, OSPF6_ROUTE_REMOVE);
/* Redo summaries if required */
- for (route = ospf6_route_head(ospf6->route_table); route;
+ for (route = ospf6_route_head(oa->ospf6->route_table); route;
route = ospf6_route_next(route))
- ospf6_abr_originate_summary(route);
+ ospf6_abr_originate_summary(route, oa->ospf6);
/* purge the old aggregated summary LSA */
- ospf6_abr_originate_summary(range);
+ ospf6_abr_originate_summary(range, oa->ospf6);
}
- ospf6_route_remove(range, oa->range_table);
+ ospf6_route_remove(range, oa->range_table, oa->ospf6);
return CMD_SUCCESS;
}
-void ospf6_area_config_write(struct vty *vty)
+void ospf6_area_config_write(struct vty *vty, struct ospf6 *ospf6)
{
struct listnode *node;
struct ospf6_area *oa;
struct ospf6_area *area;
struct prefix_list *plist;
- OSPF6_CMD_AREA_GET(areaid, area);
+ VTY_DECLVAR_CONTEXT(ospf6, ospf6);
+
+ OSPF6_CMD_AREA_GET(areaid, area, ospf6);
plist = prefix_list_lookup(AFI_IP6, plistname);
if (strmatch(inout, "in")) {
struct ospf6_area *area;
- OSPF6_CMD_AREA_GET(areaid, area);
+ VTY_DECLVAR_CONTEXT(ospf6, ospf6);
+ OSPF6_CMD_AREA_GET(areaid, area, ospf6);
if (strmatch(inout, "in")) {
if (PREFIX_NAME_IN(area))
void ospf6_area_plist_update(struct prefix_list *plist, int add)
{
+ struct listnode *node, *nnode;
struct ospf6_area *oa;
struct listnode *n;
const char *name = prefix_list_name(plist);
+ struct ospf6 *ospf6 = NULL;
+
- if (!ospf6)
+ if (!om6->ospf6)
return;
- for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, n, oa)) {
- if (PREFIX_NAME_IN(oa) && !strcmp(PREFIX_NAME_IN(oa), name))
- PREFIX_LIST_IN(oa) = add ? plist : NULL;
- if (PREFIX_NAME_OUT(oa) && !strcmp(PREFIX_NAME_OUT(oa), name))
- PREFIX_LIST_OUT(oa) = add ? plist : NULL;
+ for (ALL_LIST_ELEMENTS(om6->ospf6, node, nnode, ospf6)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, n, oa)) {
+ if (PREFIX_NAME_IN(oa)
+ && !strcmp(PREFIX_NAME_IN(oa), name))
+ PREFIX_LIST_IN(oa) = add ? plist : NULL;
+ if (PREFIX_NAME_OUT(oa)
+ && !strcmp(PREFIX_NAME_OUT(oa), name))
+ PREFIX_LIST_OUT(oa) = add ? plist : NULL;
+ }
}
}
struct ospf6_area *area;
struct access_list *list;
- OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, area);
+ VTY_DECLVAR_CONTEXT(ospf6, ospf6);
+
+ OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, area, ospf6);
list = access_list_lookup(AFI_IP6, argv[idx_name]->arg);
int idx_ipv4 = 2;
struct ospf6_area *area;
- OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, area);
+ VTY_DECLVAR_CONTEXT(ospf6, ospf6);
+
+ OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, area, ospf6);
IMPORT_LIST(area) = 0;
struct ospf6_area *area;
struct access_list *list;
- OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, area);
+ VTY_DECLVAR_CONTEXT(ospf6, ospf6);
+
+ OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, area, ospf6);
list = access_list_lookup(AFI_IP6, argv[idx_name]->arg);
int idx_ipv4 = 2;
struct ospf6_area *area;
- OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, area);
+ VTY_DECLVAR_CONTEXT(ospf6, ospf6);
+
+ OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, area, ospf6);
EXPORT_LIST(area) = 0;
struct ospf6_vertex *root;
struct ospf6_route *route;
struct prefix prefix;
+ struct ospf6 *ospf6;
- OSPF6_CMD_CHECK_RUNNING();
-
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
ospf6_linkstate_prefix(ospf6->router_id, htonl(0), &prefix);
for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, node, oa)) {
struct ospf6_vertex *root;
struct ospf6_route *route;
struct prefix prefix;
+ struct ospf6 *ospf6;
+
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
- OSPF6_CMD_CHECK_RUNNING();
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
ospf6_linkstate_prefix(ospf6->router_id, htonl(0), &prefix);
uint32_t router_id;
struct ospf6_route_table *spf_table;
unsigned char tmp_debug_ospf6_spf = 0;
+ struct ospf6 *ospf6;
- OSPF6_CMD_CHECK_RUNNING();
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
inet_pton(AF_INET, argv[idx_ipv4]->arg, &router_id);
ospf6_linkstate_prefix(router_id, htonl(0), &prefix);
route = ospf6_route_lookup(&prefix, spf_table);
if (route == NULL) {
- ospf6_spf_table_finish(spf_table);
- ospf6_route_table_delete(spf_table);
+ ospf6_spf_table_finish(spf_table, ospf6);
+ ospf6_route_table_delete(spf_table, ospf6);
return CMD_SUCCESS;
}
root = (struct ospf6_vertex *)route->route_option;
ospf6_spf_display_subtree(vty, "", 0, root);
- ospf6_spf_table_finish(spf_table);
- ospf6_route_table_delete(spf_table);
+ ospf6_spf_table_finish(spf_table, ospf6);
+ ospf6_route_table_delete(spf_table, ospf6);
return CMD_SUCCESS;
}
int idx_ipv4_number = 1;
struct ospf6_area *area;
- OSPF6_CMD_AREA_GET(argv[idx_ipv4_number]->arg, area);
+ VTY_DECLVAR_CONTEXT(ospf6, ospf6);
+
+ OSPF6_CMD_AREA_GET(argv[idx_ipv4_number]->arg, area, ospf6);
if (!ospf6_area_stub_set(ospf6, area)) {
vty_out(vty,
int idx_ipv4_number = 1;
struct ospf6_area *area;
- OSPF6_CMD_AREA_GET(argv[idx_ipv4_number]->arg, area);
+ VTY_DECLVAR_CONTEXT(ospf6, ospf6);
+
+ OSPF6_CMD_AREA_GET(argv[idx_ipv4_number]->arg, area, ospf6);
if (!ospf6_area_stub_set(ospf6, area)) {
vty_out(vty,
int idx_ipv4_number = 2;
struct ospf6_area *area;
- OSPF6_CMD_AREA_GET(argv[idx_ipv4_number]->arg, area);
+ VTY_DECLVAR_CONTEXT(ospf6, ospf6);
+
+ OSPF6_CMD_AREA_GET(argv[idx_ipv4_number]->arg, area, ospf6);
ospf6_area_stub_unset(ospf6, area);
ospf6_area_no_summary_unset(ospf6, area);
int idx_ipv4_number = 2;
struct ospf6_area *area;
- OSPF6_CMD_AREA_GET(argv[idx_ipv4_number]->arg, area);
+ VTY_DECLVAR_CONTEXT(ospf6, ospf6);
+
+ OSPF6_CMD_AREA_GET(argv[idx_ipv4_number]->arg, area, ospf6);
ospf6_area_stub_unset(ospf6, area);
ospf6_area_no_summary_unset(ospf6, area);
{
struct ospf6_area *oa;
struct listnode *node, *nnode;
+ struct ospf6 *ospf6;
- if (!ospf6)
+ if (!om6->ospf6)
return;
- for (ALL_LIST_ELEMENTS(ospf6->area_list, node, nnode, oa))
- if(listnode_lookup(oa->if_list, oi))
- listnode_delete(oa->if_list, oi);
-
+ for (ALL_LIST_ELEMENTS(om6->ospf6, node, nnode, ospf6))
+ for (ALL_LIST_ELEMENTS(ospf6->area_list, node, nnode, oa))
+ if (listnode_lookup(oa->if_list, oi))
+ listnode_delete(oa->if_list, oi);
}
#define IS_AREA_TRANSIT(oa) (CHECK_FLAG ((oa)->flag, OSPF6_AREA_TRANSIT))
#define IS_AREA_STUB(oa) (CHECK_FLAG ((oa)->flag, OSPF6_AREA_STUB))
-#define OSPF6_CMD_AREA_GET(str, oa) \
+#define OSPF6_CMD_AREA_GET(str, oa, ospf6) \
{ \
char *ep; \
uint32_t area_id = htonl(strtoul(str, &ep, 10)); \
extern struct ospf6_area *ospf6_area_create(uint32_t, struct ospf6 *, int);
extern void ospf6_area_delete(struct ospf6_area *);
extern struct ospf6_area *ospf6_area_lookup(uint32_t, struct ospf6 *);
+extern struct ospf6_area *ospf6_area_lookup_by_area_id(uint32_t area_id);
extern void ospf6_area_enable(struct ospf6_area *);
extern void ospf6_area_disable(struct ospf6_area *);
extern void ospf6_area_show(struct vty *, struct ospf6_area *);
extern void ospf6_area_plist_update(struct prefix_list *plist, int add);
-extern void ospf6_area_config_write(struct vty *vty);
+extern void ospf6_area_config_write(struct vty *vty, struct ospf6 *ospf6);
extern void ospf6_area_init(void);
struct ospf6_interface;
extern void ospf6_area_interface_delete(struct ospf6_interface *oi);
#include "ospf6_interface.h"
#include "ospf6_neighbor.h"
#include "ospf6_asbr.h"
+#include "ospf6_abr.h"
#include "ospf6_intra.h"
#include "ospf6_flood.h"
#include "ospf6d.h"
#define ZROUTE_NAME(x) zebra_route_string(x)
/* AS External LSA origination */
-static void ospf6_as_external_lsa_originate(struct ospf6_route *route)
+static void ospf6_as_external_lsa_originate(struct ospf6_route *route,
+ struct ospf6 *ospf6)
{
char buffer[OSPF6_MAX_LSASIZE];
struct ospf6_lsa_header *lsa_header;
type = htons(OSPF6_LSTYPE_AS_EXTERNAL);
adv_router = oi->area->ospf6->router_id;
- for (ALL_LSDB_TYPED_ADVRTR(ospf6->lsdb, type, adv_router, lsa)) {
+ for (ALL_LSDB_TYPED_ADVRTR(oi->area->ospf6->lsdb, type, adv_router,
+ lsa)) {
if (IS_OSPF6_DEBUG_ASBR)
zlog_debug(
"%s: Send update of AS-External LSA %s seq 0x%x",
}
void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,
- struct ospf6_route *route)
+ struct ospf6_route *route,
+ struct ospf6 *ospf6)
{
struct ospf6_route *old_route;
struct ospf6_path *ecmp_path, *o_path = NULL;
* nh_list
*/
if (ospf6->route_table->hook_add)
- (*ospf6->route_table->hook_add)
- (old_route);
+ (*ospf6->route_table->hook_add)(
+ old_route, ospf6);
if (old_route->path.origin.id
== route->path.origin.id
route->path.cost);
}
ospf6_route_remove(old_route,
- ospf6->route_table);
+ ospf6->route_table, ospf6);
}
}
if (route_updated)
/* Update RIB/FIB */
if (ospf6->route_table->hook_add)
- (*ospf6->route_table->hook_add)(old_route);
+ (*ospf6->route_table->hook_add)(old_route,
+ ospf6);
/* Delete the new route its info added to existing
* route.
if (!route_found) {
/* Add new route to existing node in ospf6 route table. */
- ospf6_route_add(route, ospf6->route_table);
+ ospf6_route_add(route, ospf6->route_table, ospf6);
}
}
-void ospf6_asbr_lsa_add(struct ospf6_lsa *lsa)
+void ospf6_asbr_lsa_add(struct ospf6_lsa *lsa, struct ospf6 *ospf6)
{
struct ospf6_as_external_lsa *external;
struct prefix asbr_id;
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_route_add(route, ospf6->route_table, ospf6);
} else {
/* RFC 2328 16.4 (6)
* ECMP: Keep new equal preference path in current
* route's path list, update zebra with new effective
* list along with addition of ECMP path.
*/
- ospf6_asbr_update_route_ecmp_path(old, route);
+ ospf6_asbr_update_route_ecmp_path(old, route, ospf6);
}
}
struct ospf6_as_external_lsa *external;
struct prefix prefix;
struct ospf6_route *route, *nroute, *route_to_del;
+ struct ospf6_area *oa = NULL;
+ struct ospf6 *ospf6;
external = (struct ospf6_as_external_lsa *)OSPF6_LSA_HEADER_END(
lsa->header);
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL))
zlog_debug("Withdraw AS-External route for %s", lsa->name);
- if (lsa->header->adv_router == ospf6->router_id) {
+ ospf6 = ospf6_get_by_lsdb(lsa);
+ if (ospf6_is_router_abr(ospf6))
+ oa = ospf6->backbone;
+ else
+ oa = listgetdata(listhead(ospf6->area_list));
+
+ if (oa == NULL)
+ return;
+
+ if (lsa->header->adv_router == oa->ospf6->router_id) {
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL))
zlog_debug("Ignore self-originated AS-External-LSA");
return;
prefix.prefixlen = external->prefix.prefix_length;
ospf6_prefix_in6_addr(&prefix.u.prefix6, external, &external->prefix);
- route = ospf6_route_lookup(&prefix, ospf6->route_table);
+ route = ospf6_route_lookup(&prefix, oa->ospf6->route_table);
if (route == NULL) {
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) {
zlog_debug("AS-External route %pFX not found", &prefix);
/* Update RIB/FIB with effective
* nh_list
*/
- if (ospf6->route_table->hook_add)
- (*ospf6->route_table->hook_add)
- (route);
+ if (oa->ospf6->route_table->hook_add)
+ (*oa->ospf6->route_table
+ ->hook_add)(
+ route, oa->ospf6);
/* route's primary path is similar
* to LSA, replace route's primary
h_path->origin.adv_router;
}
} else {
- ospf6_route_remove(route,
- ospf6->route_table);
+ ospf6_route_remove(
+ route, oa->ospf6->route_table,
+ oa->ospf6);
}
}
continue;
&route->prefix, route->path.cost, route->path.u.cost_e2,
listcount(route->nh_list));
}
- ospf6_route_remove(route, ospf6->route_table);
+ ospf6_route_remove(route, oa->ospf6->route_table, oa->ospf6);
}
if (route != NULL)
ospf6_route_unlock(route);
ospf6_route_delete(route_to_del);
}
-void ospf6_asbr_lsentry_add(struct ospf6_route *asbr_entry)
+void ospf6_asbr_lsentry_add(struct ospf6_route *asbr_entry, struct ospf6 *ospf6)
{
struct ospf6_lsa *lsa;
uint16_t type;
router = ospf6_linkstate_prefix_adv_router(&asbr_entry->prefix);
for (ALL_LSDB_TYPED_ADVRTR(ospf6->lsdb, type, router, lsa)) {
if (!OSPF6_LSA_IS_MAXAGE(lsa))
- ospf6_asbr_lsa_add(lsa);
+ ospf6_asbr_lsa_add(lsa, ospf6);
}
}
-void ospf6_asbr_lsentry_remove(struct ospf6_route *asbr_entry)
+void ospf6_asbr_lsentry_remove(struct ospf6_route *asbr_entry,
+ struct ospf6 *ospf6)
{
struct ospf6_lsa *lsa;
uint16_t type;
/* redistribute function */
-static void ospf6_asbr_routemap_set(int type, const char *mapname)
+static void ospf6_asbr_routemap_set(int type, const char *mapname,
+ uint32_t vrf_id)
{
+ struct ospf6 *ospf6 = NULL;
+
+ ospf6 = ospf6_lookup_by_vrf_id(vrf_id);
+
+ if (ospf6 == NULL)
+ return;
+
if (ospf6->rmap[type].name) {
route_map_counter_decrement(ospf6->rmap[type].map);
free(ospf6->rmap[type].name);
route_map_counter_increment(ospf6->rmap[type].map);
}
-static void ospf6_asbr_routemap_unset(int type)
+static void ospf6_asbr_routemap_unset(int type, struct ospf6 *ospf6)
{
if (ospf6->rmap[type].name)
free(ospf6->rmap[type].name);
{
void **arg;
int arg_type;
+ struct ospf6 *ospf6;
arg = THREAD_ARG(thread);
+ ospf6 = (struct ospf6 *)arg[0];
arg_type = (int)(intptr_t)arg[1];
ospf6->t_distribute_update = NULL;
return 0;
}
-void ospf6_asbr_distribute_list_update(int type)
+void ospf6_asbr_distribute_list_update(int type, struct ospf6 *ospf6)
{
void **args = NULL;
static void ospf6_asbr_routemap_update(const char *mapname)
{
int type;
+ struct listnode *node, *nnode;
+ struct ospf6 *ospf6 = NULL;
- if (ospf6 == NULL)
+ if (om6 == NULL)
return;
- for (type = 0; type < ZEBRA_ROUTE_MAX; type++) {
- if (ospf6->rmap[type].name) {
- ospf6->rmap[type].map = route_map_lookup_by_name(
- ospf6->rmap[type].name);
-
- if (mapname
- && (strcmp(ospf6->rmap[type].name, mapname) == 0)) {
- if (ospf6->rmap[type].map) {
- if (IS_OSPF6_DEBUG_ASBR)
- zlog_debug(
- "%s: route-map %s update, reset redist %s",
- __func__, mapname,
- ZROUTE_NAME(type));
-
- route_map_counter_increment(
- ospf6->rmap[type].map);
-
- ospf6_asbr_distribute_list_update(type);
- } else {
- /*
- * if the mapname matches a route-map on
- * ospf6 but the map doesn't exist, it
- * is being deleted. flush and then
- * readvertise
- */
- if (IS_OSPF6_DEBUG_ASBR)
- zlog_debug(
- "%s: route-map %s deleted, reset redist %s",
- __func__, mapname,
- ZROUTE_NAME(type));
- ospf6_asbr_redistribute_unset(
- type, ospf6->vrf_id);
- ospf6_asbr_routemap_set(type, mapname);
- ospf6_asbr_redistribute_set(
- type, ospf6->vrf_id);
+ for (ALL_LIST_ELEMENTS(om6->ospf6, node, nnode, ospf6)) {
+ for (type = 0; type < ZEBRA_ROUTE_MAX; type++) {
+ if (ospf6->rmap[type].name) {
+ ospf6->rmap[type].map =
+ route_map_lookup_by_name(
+ ospf6->rmap[type].name);
+
+ if (mapname
+ && (strcmp(ospf6->rmap[type].name, mapname)
+ == 0)) {
+ if (ospf6->rmap[type].map) {
+ if (IS_OSPF6_DEBUG_ASBR)
+ zlog_debug(
+ "%s: route-map %s update, reset redist %s",
+ __func__,
+ mapname,
+ ZROUTE_NAME(
+ type));
+
+ route_map_counter_increment(
+ ospf6->rmap[type].map);
+
+ ospf6_asbr_distribute_list_update(
+ type, ospf6);
+ } else {
+ /*
+ * if the mapname matches a
+ * route-map on ospf6 but the
+ * map doesn't exist, it is
+ * being deleted. flush and then
+ * readvertise
+ */
+ if (IS_OSPF6_DEBUG_ASBR)
+ zlog_debug(
+ "%s: route-map %s deleted, reset redist %s",
+ __func__,
+ mapname,
+ ZROUTE_NAME(
+ type));
+ ospf6_asbr_redistribute_unset(
+ type, ospf6->vrf_id);
+ ospf6_asbr_routemap_set(
+ type, mapname,
+ ospf6->vrf_id);
+ ospf6_asbr_redistribute_set(
+ type, ospf6->vrf_id);
+ }
}
- }
- } else
- ospf6->rmap[type].map = NULL;
+ } else
+ ospf6->rmap[type].map = NULL;
+ }
}
}
static void ospf6_asbr_routemap_event(const char *name)
{
int type;
+ struct listnode *node, *nnode;
+ struct ospf6 *ospf6;
- if (ospf6 == NULL)
+ if (om6 == NULL)
return;
- for (type = 0; type < ZEBRA_ROUTE_MAX; type++) {
- if ((ospf6->rmap[type].name)
- && (strcmp(ospf6->rmap[type].name, name) == 0)) {
- ospf6_asbr_distribute_list_update(type);
+ for (ALL_LIST_ELEMENTS(om6->ospf6, node, nnode, ospf6)) {
+ for (type = 0; type < ZEBRA_ROUTE_MAX; type++) {
+ if ((ospf6->rmap[type].name)
+ && (strcmp(ospf6->rmap[type].name, name) == 0))
+ ospf6_asbr_distribute_list_update(type, ospf6);
}
}
}
{
struct ospf6_route *route;
struct ospf6_external_info *info;
+ struct ospf6 *ospf6 = NULL;
+
+ ospf6 = ospf6_lookup_by_vrf_id(vrf_id);
+
+ if (ospf6 == NULL)
+ return;
ospf6_zebra_no_redistribute(type, vrf_id);
if (info->type != type)
continue;
- ospf6_asbr_redistribute_remove(info->type, 0, &route->prefix);
+ ospf6_asbr_redistribute_remove(info->type, 0, &route->prefix,
+ ospf6);
}
- ospf6_asbr_routemap_unset(type);
+ ospf6_asbr_routemap_unset(type, ospf6);
}
/* When an area is unstubified, flood all the external LSAs in the area */
void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex,
struct prefix *prefix,
unsigned int nexthop_num,
- struct in6_addr *nexthop, route_tag_t tag)
+ struct in6_addr *nexthop, route_tag_t tag,
+ struct ospf6 *ospf6)
{
route_map_result_t ret;
struct ospf6_route troute;
if (IS_OSPF6_DEBUG_ASBR)
zlog_debug("Denied by route-map \"%s\"",
ospf6->rmap[type].name);
- ospf6_asbr_redistribute_remove(type, ifindex, prefix);
+ ospf6_asbr_redistribute_remove(type, ifindex, prefix,
+ ospf6);
return;
}
}
}
match->path.origin.id = htonl(info->id);
- ospf6_as_external_lsa_originate(match);
+ ospf6_as_external_lsa_originate(match, ospf6);
return;
}
node = route_node_get(ospf6->external_id_table, &prefix_id);
node->info = route;
- route = ospf6_route_add(route, ospf6->external_table);
+ route = ospf6_route_add(route, ospf6->external_table, ospf6);
route->route_option = info;
if (IS_OSPF6_DEBUG_ASBR) {
}
route->path.origin.id = htonl(info->id);
- ospf6_as_external_lsa_originate(route);
+ ospf6_as_external_lsa_originate(route, ospf6);
/* Router-Bit (ASBR Flag) may have to be updated */
for (ALL_LIST_ELEMENTS(ospf6->area_list, lnode, lnnode, oa))
}
void ospf6_asbr_redistribute_remove(int type, ifindex_t ifindex,
- struct prefix *prefix)
+ struct prefix *prefix, struct ospf6 *ospf6)
{
struct ospf6_route *match;
struct ospf6_external_info *info = NULL;
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_route_remove(match, ospf6->external_table, ospf6);
XFREE(MTYPE_OSPF6_EXTERNAL_INFO, info);
/* Router-Bit (ASBR Flag) may have to be updated */
{
int type;
- OSPF6_CMD_CHECK_RUNNING();
-
+ VTY_DECLVAR_CONTEXT(ospf6, ospf6);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
char *proto = argv[argc - 1]->text;
type = proto_redistnum(AFI_IP6, proto);
if (type < 0)
int idx_word = 3;
int type;
- OSPF6_CMD_CHECK_RUNNING();
+ VTY_DECLVAR_CONTEXT(ospf6, ospf6);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
char *proto = argv[idx_protocol]->text;
type = proto_redistnum(AFI_IP6, proto);
return CMD_WARNING_CONFIG_FAILED;
ospf6_asbr_redistribute_unset(type, ospf6->vrf_id);
- ospf6_asbr_routemap_set(type, argv[idx_word]->arg);
+ ospf6_asbr_routemap_set(type, argv[idx_word]->arg, ospf6->vrf_id);
ospf6_asbr_redistribute_set(type, ospf6->vrf_id);
return CMD_SUCCESS;
}
int idx_protocol = 2;
int type;
- OSPF6_CMD_CHECK_RUNNING();
+ VTY_DECLVAR_CONTEXT(ospf6, ospf6);
+
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
char *proto = argv[idx_protocol]->text;
type = proto_redistnum(AFI_IP6, proto);
return CMD_SUCCESS;
}
-int ospf6_redistribute_config_write(struct vty *vty)
+int ospf6_redistribute_config_write(struct vty *vty, struct ospf6 *ospf6)
{
int type;
return 0;
}
-static void ospf6_redistribute_show_config(struct vty *vty)
+static void ospf6_redistribute_show_config(struct vty *vty, struct ospf6 *ospf6)
{
int type;
int nroute[ZEBRA_ROUTE_MAX];
)
{
struct ospf6_route *route;
+ struct ospf6 *ospf6 = NULL;
- OSPF6_CMD_CHECK_RUNNING();
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
- ospf6_redistribute_show_config(vty);
+ ospf6_redistribute_show_config(vty, ospf6);
for (route = ospf6_route_head(ospf6->external_table); route;
route = ospf6_route_next(route))
(E)->bits_metric |= htonl(0x00ffffff) & htonl(C); \
}
-extern void ospf6_asbr_lsa_add(struct ospf6_lsa *lsa);
+extern void ospf6_asbr_lsa_add(struct ospf6_lsa *lsa, struct ospf6 *ospf6);
extern void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,
struct ospf6_route *asbr_entry);
-extern void ospf6_asbr_lsentry_add(struct ospf6_route *asbr_entry);
-extern void ospf6_asbr_lsentry_remove(struct ospf6_route *asbr_entry);
+extern void ospf6_asbr_lsentry_add(struct ospf6_route *asbr_entry,
+ struct ospf6 *ospf6);
+extern void ospf6_asbr_lsentry_remove(struct ospf6_route *asbr_entry,
+ struct ospf6 *ospf6);
extern int ospf6_asbr_is_asbr(struct ospf6 *o);
extern void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex,
struct prefix *prefix,
unsigned int nexthop_num,
struct in6_addr *nexthop,
- route_tag_t tag);
+ route_tag_t tag, struct ospf6 *ospf6);
extern void ospf6_asbr_redistribute_remove(int type, ifindex_t ifindex,
- struct prefix *prefix);
+ struct prefix *prefix,
+ struct ospf6 *ospf6);
-extern int ospf6_redistribute_config_write(struct vty *vty);
+extern int ospf6_redistribute_config_write(struct vty *vty,
+ struct ospf6 *ospf6);
extern void ospf6_asbr_init(void);
extern void ospf6_asbr_redistribute_reset(vrf_id_t vrf_id);
extern int config_write_ospf6_debug_asbr(struct vty *vty);
extern void install_element_ospf6_debug_asbr(void);
extern void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,
- struct ospf6_route *route);
-extern void ospf6_asbr_distribute_list_update(int type);
+ struct ospf6_route *route,
+ struct ospf6 *ospf6);
+extern void ospf6_asbr_distribute_list_update(int type, struct ospf6 *ospf6);
#endif /* OSPF6_ASBR_H */
continue;
}
- if (ospf6->inst_shutdown) {
+ if (oi->area->ospf6->inst_shutdown) {
if (is_debug)
zlog_debug(
"%s: Send LSA %s (age %d) update now",
void ospf6_flood(struct ospf6_neighbor *from, struct ospf6_lsa *lsa)
{
+ struct ospf6 *ospf6;
+
+ ospf6 = ospf6_get_by_lsdb(lsa);
+ if (ospf6 == NULL)
+ return;
+
ospf6_flood_process(from, lsa, ospf6);
}
void ospf6_flood_clear(struct ospf6_lsa *lsa)
{
+ struct ospf6 *ospf6;
+
+ ospf6 = ospf6_get_by_lsdb(lsa);
ospf6_flood_clear_process(lsa, ospf6);
}
/* If all else fails, use default OSPF cost */
uint32_t cost;
uint32_t bw, refbw;
-
+ struct ospf6 *ospf6;
/* interface speed and bw can be 0 in some platforms,
* use ospf default bw. If bw is configured then it would
* be used.
: OSPF6_INTERFACE_BANDWIDTH;
}
+ ospf6 = ospf6_lookup_by_vrf_id(oi->interface->vrf_id);
refbw = ospf6 ? ospf6->ref_bandwidth : OSPF6_REFERENCE_BANDWIDTH;
/* A specifed ip ospf cost overrides a calculated one. */
ospf6_lsdb_delete(oi->lsupdate_list);
ospf6_lsdb_delete(oi->lsack_list);
- ospf6_route_table_delete(oi->route_connected);
+ ospf6_route_table_delete(oi->route_connected, oi->area->ospf6);
/* cut link */
oi->interface->info = NULL;
return;
/* update "route to advertise" interface route table */
- ospf6_route_remove_all(oi->route_connected);
+ ospf6_route_remove_all(oi->route_connected, oi->area->ospf6);
for (ALL_LIST_ELEMENTS(oi->interface->connected, node, nnode, c)) {
if (c->address->family != AF_INET6)
inet_pton(AF_INET6, "::1", &nh_addr);
ospf6_route_add_nexthop(route, oi->interface->ifindex,
&nh_addr);
- ospf6_route_add(route, oi->route_connected);
+ ospf6_route_add(route, oi->route_connected, oi->area->ospf6);
}
/* create new Link-LSA */
struct ospf6_interface *oi)
{
uint8_t prev_state;
+ struct ospf6 *ospf6;
prev_state = oi->state;
oi->state = next_state;
ospf6_interface_state_str[next_state]);
}
oi->state_change++;
+ ospf6 = ospf6_lookup_by_vrf_id(oi->interface->vrf_id);
if ((prev_state == OSPF6_INTERFACE_DR
|| prev_state == OSPF6_INTERFACE_BDR)
&& (next_state != OSPF6_INTERFACE_DR
&& next_state != OSPF6_INTERFACE_BDR))
ospf6_sso(oi->interface->ifindex, &alldrouters6,
- IPV6_LEAVE_GROUP);
+ IPV6_LEAVE_GROUP, ospf6->fd);
if ((prev_state != OSPF6_INTERFACE_DR
&& prev_state != OSPF6_INTERFACE_BDR)
&& (next_state == OSPF6_INTERFACE_DR
|| next_state == OSPF6_INTERFACE_BDR))
ospf6_sso(oi->interface->ifindex, &alldrouters6,
- IPV6_JOIN_GROUP);
+ IPV6_JOIN_GROUP, ospf6->fd);
OSPF6_ROUTER_LSA_SCHEDULE(oi->area);
if (next_state == OSPF6_INTERFACE_DOWN) {
int interface_up(struct thread *thread)
{
struct ospf6_interface *oi;
+ struct ospf6 *ospf6;
oi = (struct ospf6_interface *)THREAD_ARG(thread);
assert(oi && oi->interface);
return 0;
}
#endif /* __FreeBSD__ */
+ if (oi->area->ospf6)
+ ospf6 = oi->area->ospf6;
+ else
+ ospf6 = ospf6_lookup_by_vrf_id(oi->interface->vrf_id);
/* Join AllSPFRouters */
- if (ospf6_sso(oi->interface->ifindex, &allspfrouters6, IPV6_JOIN_GROUP)
+ if (ospf6_sso(oi->interface->ifindex, &allspfrouters6, IPV6_JOIN_GROUP,
+ ospf6->fd)
< 0) {
if (oi->sso_try_cnt++ < OSPF6_INTERFACE_SSO_RETRY_MAX) {
zlog_info(
struct ospf6_interface *oi;
struct listnode *node, *nnode;
struct ospf6_neighbor *on;
+ struct ospf6 *ospf6;
oi = (struct ospf6_interface *)THREAD_ARG(thread);
assert(oi && oi->interface);
/* Stop trying to set socket options. */
THREAD_OFF(oi->thread_sso);
-
+ ospf6 = ospf6_lookup_by_vrf_id(oi->interface->vrf_id);
/* Leave AllSPFRouters */
if (oi->state > OSPF6_INTERFACE_DOWN)
ospf6_sso(oi->interface->ifindex, &allspfrouters6,
- IPV6_LEAVE_GROUP);
+ IPV6_LEAVE_GROUP, ospf6->fd);
ospf6_interface_state_change(OSPF6_INTERFACE_DOWN, oi);
OSPF6_OPT_CLEAR_ALL(router_lsa->options);
memcpy(router_lsa->options, oa->options, 3);
- if (ospf6_is_router_abr(ospf6))
+ if (ospf6_is_router_abr(oa->ospf6))
SET_FLAG(router_lsa->bits, OSPF6_ROUTER_BIT_B);
else
UNSET_FLAG(router_lsa->bits, OSPF6_ROUTER_BIT_B);
zlog_debug(" include %s", buf);
}
ospf6_route_add(ospf6_route_copy(route),
- route_advertise);
+ route_advertise, oa->ospf6);
}
}
oa->lsdb);
}
}
- ospf6_route_table_delete(route_advertise);
+ ospf6_route_table_delete(route_advertise, oa->ospf6);
return 0;
}
op = OSPF6_PREFIX_NEXT(op);
}
- ospf6_route_table_delete(route_advertise);
+ ospf6_route_table_delete(route_advertise, oa->ospf6);
if (prefix_num == 0) {
if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX))
zlog_debug(" include %s", buf);
}
- ospf6_route_add(route, route_advertise);
+ ospf6_route_add(route, route_advertise,
+ oi->area->ospf6);
prefix_num--;
}
if (current != end && IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX))
prefix_num++;
}
- ospf6_route_table_delete(route_advertise);
+ ospf6_route_table_delete(route_advertise, oi->area->ospf6);
if (prefix_num == 0) {
if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX))
return 0;
}
-static void ospf6_intra_prefix_update_route_origin(struct ospf6_route *oa_route)
+static void ospf6_intra_prefix_update_route_origin(struct ospf6_route *oa_route,
+ struct ospf6 *ospf6)
{
struct ospf6_path *h_path;
struct ospf6_route *g_route, *nroute;
/* Update Global ospf6 route path */
- g_route = ospf6_route_lookup(&oa_route->prefix,
- ospf6->route_table);
+ g_route = ospf6_route_lookup(&oa_route->prefix, ospf6->route_table);
assert(g_route);
* nh_list
*/
if (oa->route_table->hook_add)
- (*oa->route_table->hook_add)
- (old_route);
+ (*oa->route_table->hook_add)(
+ old_route, oa->ospf6);
if (old_route->path.origin.id ==
route->path.origin.id &&
old_route->path.origin.adv_router ==
route->path.origin.adv_router) {
ospf6_intra_prefix_update_route_origin(
- old_route);
+ old_route, oa->ospf6);
}
break;
}
}
if (oa->route_table->hook_remove)
ospf6_route_remove(old_route,
- oa->route_table);
+ oa->route_table,
+ oa->ospf6);
else
SET_FLAG(old_route->flag,
OSPF6_ROUTE_REMOVE);
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->route_table->hook_add)(old_route,
+ oa->ospf6);
/* Delete the new route its info added to existing
* route.
*/
if (!route_found) {
/* Add new route to existing node in ospf6 route table. */
- ospf6_route_add(route, oa->route_table);
+ ospf6_route_add(route, oa->route_table, oa->ospf6);
}
}
listcount(route->paths),
listcount(route->nh_list));
}
- ospf6_route_add(route, oa->route_table);
+ ospf6_route_add(route, oa->route_table, oa->ospf6);
}
prefix_num--;
}
* nh_list
*/
if (oa->route_table->hook_add)
- (*oa->route_table->hook_add)(route);
+ (*oa->route_table->hook_add)(route, oa->ospf6);
/* route's primary path is similar
* to LSA, replace route's primary
if ((route->path.origin.id == lsa->header->id) &&
(route->path.origin.adv_router ==
lsa->header->adv_router)) {
- ospf6_intra_prefix_update_route_origin(route);
+ ospf6_intra_prefix_update_route_origin(route,
+ oa->ospf6);
}
}
listcount(route->paths),
listcount(route->nh_list));
}
- ospf6_route_remove(route, oa->route_table);
+ ospf6_route_remove(route, oa->route_table,
+ oa->ospf6);
}
}
if (route)
struct ospf6_route *route, *nroute;
uint16_t type;
struct ospf6_lsa *lsa;
- void (*hook_add)(struct ospf6_route *) = NULL;
- void (*hook_remove)(struct ospf6_route *) = NULL;
+ void (*hook_add)(struct ospf6_route *, struct ospf6 *) = NULL;
+ void (*hook_remove)(struct ospf6_route *, struct ospf6 *) = NULL;
if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX))
zlog_debug("Re-examin intra-routes for area %s", oa->name);
}
if (CHECK_FLAG(route->flag, OSPF6_ROUTE_REMOVE))
- ospf6_route_remove(route, oa->route_table);
+ ospf6_route_remove(route, oa->route_table, oa->ospf6);
else if (CHECK_FLAG(route->flag, OSPF6_ROUTE_ADD)
|| CHECK_FLAG(route->flag, OSPF6_ROUTE_CHANGE)) {
if (hook_add)
- (*hook_add)(route);
+ (*hook_add)(route, oa->ospf6);
route->flag = 0;
} else {
/* Redo the summaries as things might have changed */
- ospf6_abr_originate_summary(route);
+ ospf6_abr_originate_summary(route, oa->ospf6);
route->flag = 0;
}
}
void ospf6_intra_brouter_calculation(struct ospf6_area *oa)
{
struct ospf6_route *brouter, *nbrouter, *copy;
- void (*hook_add)(struct ospf6_route *) = NULL;
- void (*hook_remove)(struct ospf6_route *) = NULL;
+ void (*hook_add)(struct ospf6_route *, struct ospf6 *) = NULL;
+ void (*hook_remove)(struct ospf6_route *, struct ospf6 *) = NULL;
uint32_t brouter_id;
char brouter_name[16];
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);
+ ospf6_route_add(copy, oa->ospf6->brouter_table, oa->ospf6);
if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID(brouter_id)
|| IS_OSPF6_DEBUG_ROUTE(MEMORY)) {
* removes brouters which are marked for remove.
*/
oa->intra_brouter_calc = 1;
- ospf6_route_remove(brouter, oa->ospf6->brouter_table);
+ ospf6_route_remove(brouter, oa->ospf6->brouter_table,
+ oa->ospf6);
brouter = NULL;
} else if (CHECK_FLAG(brouter->flag, OSPF6_ROUTE_ADD)
|| CHECK_FLAG(brouter->flag, OSPF6_ROUTE_CHANGE)) {
/* newly added */
if (hook_add)
- (*hook_add)(brouter);
+ (*hook_add)(brouter, oa->ospf6);
} else {
if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID(
brouter_id)
zlog_info("brouter %s still exists via area %s",
brouter_name, oa->name);
/* But re-originate summaries */
- ospf6_abr_originate_summary(brouter);
+ ospf6_abr_originate_summary(brouter, oa->ospf6);
}
if (brouter) {
vector ospf6_lsa_handler_vector;
+struct ospf6 *ospf6_get_by_lsdb(struct ospf6_lsa *lsa)
+{
+ struct ospf6 *ospf6 = NULL;
+
+ switch (OSPF6_LSA_SCOPE(lsa->header->type)) {
+ case OSPF6_SCOPE_LINKLOCAL:
+ ospf6 = OSPF6_INTERFACE(lsa->lsdb->data)->area->ospf6;
+ break;
+ case OSPF6_SCOPE_AREA:
+ ospf6 = OSPF6_AREA(lsa->lsdb->data)->ospf6;
+ break;
+ case OSPF6_SCOPE_AS:
+ ospf6 = OSPF6_PROCESS(lsa->lsdb->data);
+ break;
+ default:
+ assert(0);
+ break;
+ }
+ return ospf6;
+}
+
static int ospf6_unknown_lsa_show(struct vty *vty, struct ospf6_lsa *lsa)
{
uint8_t *start, *end, *current;
int ospf6_lsa_expire(struct thread *thread)
{
struct ospf6_lsa *lsa;
+ struct ospf6 *ospf6;
lsa = (struct ospf6_lsa *)THREAD_ARG(thread);
if (CHECK_FLAG(lsa->flag, OSPF6_LSA_HEADERONLY))
return 0; /* dbexchange will do something ... */
-
+ ospf6 = ospf6_get_by_lsdb(lsa);
/* reinstall lsa */
ospf6_install_lsa(lsa);
return 0;
}
-void ospf6_flush_self_originated_lsas_now(void)
+void ospf6_flush_self_originated_lsas_now(struct ospf6 *ospf6)
{
struct listnode *node;
struct ospf6_area *oa;
#ifndef OSPF6_LSA_H
#define OSPF6_LSA_H
+#include "ospf6_top.h"
/* Debug option */
#define OSPF6_LSA_DEBUG 0x01
extern int config_write_ospf6_debug_lsa(struct vty *vty);
extern void install_element_ospf6_debug_lsa(void);
extern void ospf6_lsa_age_set(struct ospf6_lsa *lsa);
-extern void ospf6_flush_self_originated_lsas_now(void);
-
+extern void ospf6_flush_self_originated_lsas_now(struct ospf6 *ospf6);
+extern struct ospf6 *ospf6_get_by_lsdb(struct ospf6_lsa *lsa);
#endif /* OSPF6_LSA_H */
{
struct vrf *vrf;
struct interface *ifp;
+ struct ospf6 *ospf6;
+ struct listnode *node, *nnode;
frr_early_fini();
- if (ospf6) {
+ for (ALL_LIST_ELEMENTS(om6->ospf6, node, nnode, ospf6)) {
vrf = vrf_lookup_by_id(ospf6->vrf_id);
ospf6_serv_close(&ospf6->fd);
+ FOR_ALL_INTERFACES (vrf, ifp)
+ if (ifp->info != NULL)
+ ospf6_interface_delete(ifp->info);
ospf6_delete(ospf6);
ospf6 = NULL;
- } else
- vrf = vrf_lookup_by_id(VRF_DEFAULT);
+ }
bfd_gbl_exit();
- FOR_ALL_INTERFACES (vrf, ifp)
- if (ifp->info != NULL)
- ospf6_interface_delete(ifp->info);
ospf6_message_terminate();
ospf6_asbr_terminate();
}
/* OSPF6 master init. */
- ospf6_master_init();
+ ospf6_master_init(frr_init());
/* thread master */
- master = frr_init();
+ master = om6->master;
vrf_init(NULL, NULL, NULL, NULL, NULL);
access_list_init();
prefix_list_init();
/* initialize ospf6 */
- ospf6_init();
+ ospf6_init(master);
frr_config_fork();
frr_run(master);
oi->db_desc_in++;
- if (ntohl(oh->router_id) < ntohl(ospf6->router_id))
+ if (ntohl(oh->router_id) < ntohl(oi->area->ospf6->router_id))
ospf6_dbdesc_recv_master(oh, on);
- else if (ntohl(ospf6->router_id) < ntohl(oh->router_id))
+ else if (ntohl(oi->area->ospf6->router_id) < ntohl(oh->router_id))
ospf6_dbdesc_recv_slave(oh, on);
else {
if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV))
struct ospf6_area *oa;
struct listnode *i, *j, *k;
void (*showfunc)(struct vty *, struct ospf6_neighbor *);
+ struct ospf6 *ospf6;
- OSPF6_CMD_CHECK_RUNNING();
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
showfunc = ospf6_neighbor_show;
if (argc == 5) {
struct listnode *i, *j, *k;
void (*showfunc)(struct vty *, struct ospf6_neighbor *);
uint32_t router_id;
+ struct ospf6 *ospf6;
- OSPF6_CMD_CHECK_RUNNING();
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
showfunc = ospf6_neighbor_show_detail;
if ((inet_pton(AF_INET, argv[idx_ipv4]->arg, &router_id)) != 1) {
}
/* ospf6 set socket option */
-int ospf6_sso(ifindex_t ifindex, struct in6_addr *group, int option)
+int ospf6_sso(ifindex_t ifindex, struct in6_addr *group, int option, int sockfd)
{
struct ipv6_mreq mreq6;
int ret;
int bufsize = (8 * 1024 * 1024);
- if (ospf6->fd == -1)
+ if (sockfd == -1)
return -1;
assert(ifindex);
mreq6.ipv6mr_interface = ifindex;
memcpy(&mreq6.ipv6mr_multiaddr, group, sizeof(struct in6_addr));
- ret = setsockopt(ospf6->fd, IPPROTO_IPV6, option, &mreq6,
- sizeof(mreq6));
+ ret = setsockopt(sockfd, IPPROTO_IPV6, option, &mreq6, sizeof(mreq6));
if (ret < 0) {
flog_err_sys(
EC_LIB_SOCKET,
return ret;
}
- setsockopt_so_sendbuf(ospf6->fd, bufsize);
- setsockopt_so_recvbuf(ospf6->fd, bufsize);
+ setsockopt_so_sendbuf(sockfd, bufsize);
+ setsockopt_so_recvbuf(sockfd, bufsize);
return 0;
}
extern int ospf6_serv_sock(struct ospf6 *ospf6);
extern void ospf6_serv_close(int *ospf6_sock);
-extern int ospf6_sso(ifindex_t ifindex, struct in6_addr *group, int option);
+extern int ospf6_sso(ifindex_t ifindex, struct in6_addr *group, int option,
+ int sockfd);
extern int ospf6_sendmsg(struct in6_addr *, struct in6_addr *, ifindex_t *,
struct iovec *, int ospf6_sock);
{
struct ospf6_nexthop *nh;
struct listnode *node;
+ struct interface *ifp;
char buf[64];
int i;
if (route) {
i = 0;
for (ALL_LIST_ELEMENTS_RO(route->nh_list, node, nh)) {
+ ifp = if_lookup_by_index_all_vrf(nh->ifindex);
if (IS_OSPF6_DEBUG_ZEBRA(SEND)) {
- const char *ifname;
inet_ntop(AF_INET6, &nh->address, buf,
sizeof(buf));
- ifname = ifindex2ifname(nh->ifindex,
- ospf6->vrf_id);
zlog_debug(" nexthop: %s%%%.*s(%d)", buf,
- IFNAMSIZ, ifname, nh->ifindex);
+ IFNAMSIZ, ifp->name, nh->ifindex);
}
if (i >= entries)
return;
- nexthops[i].vrf_id = ospf6->vrf_id;
+ nexthops[i].vrf_id = ifp->vrf_id;
nexthops[i].ifindex = nh->ifindex;
if (!IN6_IS_ADDR_UNSPECIFIED(&nh->address)) {
nexthops[i].gate.ipv6 = nh->address;
#endif /*DEBUG*/
struct ospf6_route *ospf6_route_add(struct ospf6_route *route,
- struct ospf6_route_table *table)
+ struct ospf6_route_table *table,
+ struct ospf6 *ospf6)
{
struct route_node *node, *nextnode, *prevnode;
struct ospf6_route *current = NULL;
ospf6_route_table_assert(table);
if (table->hook_add)
- (*table->hook_add)(route);
+ (*table->hook_add)(route, ospf6);
return route;
}
SET_FLAG(route->flag, OSPF6_ROUTE_ADD);
if (table->hook_add)
- (*table->hook_add)(route);
+ (*table->hook_add)(route, ospf6);
return route;
}
SET_FLAG(route->flag, OSPF6_ROUTE_ADD);
if (table->hook_add)
- (*table->hook_add)(route);
+ (*table->hook_add)(route, ospf6);
return route;
}
void ospf6_route_remove(struct ospf6_route *route,
- struct ospf6_route_table *table)
+ struct ospf6_route_table *table, struct ospf6 *ospf6)
{
struct route_node *node;
struct ospf6_route *current;
/* Note hook_remove may call ospf6_route_remove */
if (table->hook_remove)
- (*table->hook_remove)(route);
+ (*table->hook_remove)(route, ospf6);
ospf6_route_unlock(route);
}
return next;
}
-void ospf6_route_remove_all(struct ospf6_route_table *table)
+void ospf6_route_remove_all(struct ospf6_route_table *table,
+ struct ospf6 *ospf6)
{
struct ospf6_route *route;
for (route = ospf6_route_head(table); route;
route = ospf6_route_next(route))
- ospf6_route_remove(route, table);
+ ospf6_route_remove(route, table, ospf6);
}
struct ospf6_route_table *ospf6_route_table_create(int s, int t)
return new;
}
-void ospf6_route_table_delete(struct ospf6_route_table *table)
+void ospf6_route_table_delete(struct ospf6_route_table *table,
+ struct ospf6 *ospf6)
{
- ospf6_route_remove_all(table);
+ ospf6_route_remove_all(table, ospf6);
bf_free(table->idspace);
route_table_finish(table->table);
XFREE(MTYPE_OSPF6_ROUTE, table);
int i;
char destination[PREFIX2STR_BUFFER], nexthop[64];
char duration[64];
- const char *ifname;
struct timeval now, res;
struct listnode *node;
struct ospf6_nexthop *nh;
- if (ospf6 == NULL) {
+ if (om6->ospf6 == NULL) {
vty_out(vty, "OSPFv3 is not running\n");
return;
}
i = 0;
for (ALL_LIST_ELEMENTS_RO(route->nh_list, node, nh)) {
+ struct interface *ifp;
/* nexthop */
inet_ntop(AF_INET6, &nh->address, nexthop, sizeof(nexthop));
- ifname = ifindex2ifname(nh->ifindex, ospf6->vrf_id);
-
+ ifp = if_lookup_by_index_all_vrf(nh->ifindex);
if (!i) {
vty_out(vty, "%c%1s %2s %-30s %-25s %6.*s %s\n",
(ospf6_route_is_best(route) ? '*' : ' '),
OSPF6_DEST_TYPE_SUBSTR(route->type),
OSPF6_PATH_TYPE_SUBSTR(route->path.type),
- destination, nexthop, IFNAMSIZ, ifname,
+ destination, nexthop, IFNAMSIZ, ifp->name,
duration);
i++;
} else
vty_out(vty, "%c%1s %2s %-30s %-25s %6.*s %s\n", ' ',
- "", "", "", nexthop, IFNAMSIZ, ifname, "");
+ "", "", "", nexthop, IFNAMSIZ, ifp->name, "");
}
}
void ospf6_route_show_detail(struct vty *vty, struct ospf6_route *route)
{
- const char *ifname;
char destination[PREFIX2STR_BUFFER], nexthop[64];
char area_id[16], id[16], adv_router[16], capa[16], options[16];
struct timeval now, res;
struct listnode *node;
struct ospf6_nexthop *nh;
- if (ospf6 == NULL) {
+ if (om6->ospf6 == NULL) {
vty_out(vty, "OSPFv3 is not running\n");
return;
}
/* Nexthops */
vty_out(vty, "Nexthop:\n");
for (ALL_LIST_ELEMENTS_RO(route->nh_list, node, nh)) {
+ struct interface *ifp;
/* nexthop */
inet_ntop(AF_INET6, &nh->address, nexthop, sizeof(nexthop));
- ifname = ifindex2ifname(nh->ifindex, ospf6->vrf_id);
- vty_out(vty, " %s %.*s\n", nexthop, IFNAMSIZ, ifname);
+
+ ifp = if_lookup_by_index_all_vrf(nh->ifindex);
+ vty_out(vty, " %s %.*s\n", nexthop, IFNAMSIZ, ifp->name);
}
vty_out(vty, "\n");
}
#define OSPF6_ROUTE_DO_NOT_ADVERTISE 0x20
#define OSPF6_ROUTE_WAS_REMOVED 0x40
#define OSPF6_ROUTE_BLACKHOLE_ADDED 0x80
+struct ospf6;
struct ospf6_route_table {
int scope_type;
bitfield_t idspace;
/* hooks */
- void (*hook_add)(struct ospf6_route *);
+ void (*hook_add)(struct ospf6_route *, struct ospf6 *);
void (*hook_change)(struct ospf6_route *);
- void (*hook_remove)(struct ospf6_route *);
+ void (*hook_remove)(struct ospf6_route *, struct ospf6 *);
};
#define OSPF6_SCOPE_TYPE_NONE 0
extern void ospf6_route_lock(struct ospf6_route *route);
extern void ospf6_route_unlock(struct ospf6_route *route);
-
extern struct ospf6_route *ospf6_route_lookup(struct prefix *prefix,
struct ospf6_route_table *table);
extern struct ospf6_route *
struct ospf6_route_table *table);
extern struct ospf6_route *ospf6_route_add(struct ospf6_route *route,
- struct ospf6_route_table *table);
+ struct ospf6_route_table *table,
+ struct ospf6 *ospf6);
extern void ospf6_route_remove(struct ospf6_route *route,
- struct ospf6_route_table *table);
+ struct ospf6_route_table *table,
+ struct ospf6 *ospf6);
extern struct ospf6_route *ospf6_route_head(struct ospf6_route_table *table);
extern struct ospf6_route *ospf6_route_next(struct ospf6_route *route);
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 *);
+extern void ospf6_route_remove_all(struct ospf6_route_table *, struct ospf6 *);
extern struct ospf6_route_table *ospf6_route_table_create(int s, int t);
-extern void ospf6_route_table_delete(struct ospf6_route_table *);
+extern void ospf6_route_table_delete(struct ospf6_route_table *,
+ struct ospf6 *);
extern void ospf6_route_dump(struct ospf6_route_table *table);
extern int config_write_ospf6_debug_route(struct vty *vty);
extern void install_element_ospf6_debug_route(void);
extern void ospf6_route_init(void);
-extern void ospf6_clean(void);
extern void ospf6_path_free(struct ospf6_path *op);
extern struct ospf6_path *ospf6_path_dup(struct ospf6_path *path);
extern void ospf6_copy_paths(struct list *dst, struct list *src);
uint16_t sum;
uint32_t count;
struct ospf6_lsa *lsa = NULL, *lsanext;
+ struct ospf6 *ospf6;
+ ospf6 = ospf6_lookup_by_vrf_id(VRF_DEFAULT);
/* Check whether the instance identifier is valid */
if (smux_header_generic(v, name, length, exact, var_len, write_method)
== MATCH_FAILED)
unsigned int len;
char a[16];
struct ospf6_route *ro;
+ struct ospf6 *ospf6;
+
+ ospf6 = ospf6_lookup_by_vrf_id(VRF_DEFAULT);
if (ospf6 == NULL)
return NULL;
struct interface *iif;
struct ospf6_interface *oi = NULL;
struct list *ifslist;
+ struct ospf6 *ospf6;
+
+ ospf6 = ospf6_lookup_by_vrf_id(VRF_DEFAULT);
if (smux_header_table(v, name, length, exact, var_len, write_method)
== MATCH_FAILED)
oid *offset;
int offsetlen, len;
uint32_t sum;
+ struct ospf6 *ospf6;
+
+ ospf6 = ospf6_lookup_by_vrf_id(VRF_DEFAULT);
if (smux_header_table(v, name, length, exact, var_len, write_method)
== MATCH_FAILED)
struct list *ifslist;
oid *offset;
int offsetlen, len;
+ struct ospf6 *ospf6;
+
+ ospf6 = ospf6_lookup_by_vrf_id(VRF_DEFAULT);
if (smux_header_table(v, name, length, exact, var_len, write_method)
== MATCH_FAILED)
}
static void ospf6_nexthop_calc(struct ospf6_vertex *w, struct ospf6_vertex *v,
- caddr_t lsdesc)
+ caddr_t lsdesc, struct ospf6 *ospf6)
{
int i;
ifindex_t ifindex;
}
static int ospf6_spf_install(struct ospf6_vertex *v,
- struct ospf6_route_table *result_table)
+ struct ospf6_route_table *result_table,
+ struct ospf6 *ospf6)
{
struct ospf6_route *route, *parent_route;
struct ospf6_vertex *prev;
listnode_add_sort(v->parent->child_list, v);
route->route_option = v;
- ospf6_route_add(route, result_table);
+ ospf6_route_add(route, result_table, ospf6);
return 0;
}
-void ospf6_spf_table_finish(struct ospf6_route_table *result_table)
+void ospf6_spf_table_finish(struct ospf6_route_table *result_table,
+ struct ospf6 *ospf6)
{
struct ospf6_route *route, *nroute;
struct ospf6_vertex *v;
nroute = ospf6_route_next(route);
v = (struct ospf6_vertex *)route->route_option;
ospf6_vertex_delete(v);
- ospf6_route_remove(route, result_table);
+ ospf6_route_remove(route, result_table, ospf6);
}
}
struct ospf6_lsa *lsa;
struct in6_addr address;
- ospf6_spf_table_finish(result_table);
+ ospf6_spf_table_finish(result_table, oa->ospf6);
/* Install the calculating router itself as the root of the SPF tree */
/* construct root vertex */
while ((v = vertex_pqueue_pop(&candidate_list))) {
/* installing may result in merging or rejecting of the vertex
*/
- if (ospf6_spf_install(v, result_table) < 0)
+ if (ospf6_spf_install(v, result_table, oa->ospf6) < 0)
continue;
/* Skip overloaded routers */
w->nh_list,
ROUTER_LSDESC_GET_IFID(lsdesc), NULL);
else if (w->hops == 1 && v->hops == 0)
- ospf6_nexthop_calc(w, v, lsdesc);
+ ospf6_nexthop_calc(w, v, lsdesc, oa->ospf6);
else
ospf6_copy_nexthops(w->nh_list, v->nh_list);
return 0;
}
-void ospf6_spf_config_write(struct vty *vty)
+void ospf6_spf_config_write(struct vty *vty, struct ospf6 *ospf6)
{
if (ospf6->spf_delay != OSPF_SPF_DELAY_DEFAULT
return (reason);
}
-extern void ospf6_spf_table_finish(struct ospf6_route_table *result_table);
+extern void ospf6_spf_table_finish(struct ospf6_route_table *result_table,
+ struct ospf6 *ospf6);
extern void ospf6_spf_calculation(uint32_t router_id,
struct ospf6_route_table *result_table,
struct ospf6_area *oa);
extern void ospf6_spf_display_subtree(struct vty *vty, const char *prefix,
int rest, struct ospf6_vertex *v);
-extern void ospf6_spf_config_write(struct vty *vty);
+extern void ospf6_spf_config_write(struct vty *vty, struct ospf6 *ospf6);
extern int config_write_ospf6_debug_spf(struct vty *vty);
extern void install_element_ospf6_debug_spf(void);
extern void ospf6_spf_init(void);
)
/* global ospf6d variable */
-struct ospf6 *ospf6;
static struct ospf6_master ospf6_master;
struct ospf6_master *om6;
static void ospf6_disable(struct ospf6 *o);
+static void ospf6_add(struct ospf6 *ospf6)
+{
+ listnode_add(om6->ospf6, ospf6);
+}
+
+static void ospf6_del(struct ospf6 *ospf6)
+{
+ listnode_delete(om6->ospf6, ospf6);
+}
+
+const char *ospf6_vrf_id_to_name(vrf_id_t vrf_id)
+{
+ struct vrf *vrf = vrf_lookup_by_id(vrf_id);
+
+ return vrf ? vrf->name : "NIL";
+}
+
+/* Link OSPF instance to VRF. */
+void ospf6_vrf_link(struct ospf6 *ospf6, struct vrf *vrf)
+{
+ ospf6->vrf_id = vrf->vrf_id;
+ if (vrf->info != (void *)ospf6)
+ vrf->info = (void *)ospf6;
+}
+
+/* Unlink OSPF instance from VRF. */
+void ospf6_vrf_unlink(struct ospf6 *ospf6, struct vrf *vrf)
+{
+ if (vrf->info == (void *)ospf6)
+ vrf->info = NULL;
+ ospf6->vrf_id = VRF_UNKNOWN;
+}
+
+struct ospf6 *ospf6_lookup_by_vrf_id(vrf_id_t vrf_id)
+{
+ struct vrf *vrf = NULL;
+
+ vrf = vrf_lookup_by_id(vrf_id);
+ if (!vrf)
+ return NULL;
+ return (vrf->info) ? (struct ospf6 *)vrf->info : NULL;
+}
+
+struct ospf6 *ospf6_lookup_by_vrf_name(const char *name)
+{
+ struct ospf6 *o = NULL;
+ struct listnode *node, *nnode;
+
+ for (ALL_LIST_ELEMENTS(om6->ospf6, node, nnode, o)) {
+ if (((o->name == NULL && name == NULL)
+ || (o->name && name && strcmp(o->name, name) == 0)))
+ return o;
+ }
+ return NULL;
+}
+
+
static void ospf6_top_lsdb_hook_add(struct ospf6_lsa *lsa)
{
+ struct ospf6 *ospf6 = NULL;
+
switch (ntohs(lsa->header->type)) {
case OSPF6_LSTYPE_AS_EXTERNAL:
- ospf6_asbr_lsa_add(lsa);
+ ospf6 = ospf6_get_by_lsdb(lsa);
+ ospf6_asbr_lsa_add(lsa, ospf6);
break;
default:
}
}
-static void ospf6_top_route_hook_add(struct ospf6_route *route)
+static void ospf6_top_route_hook_add(struct ospf6_route *route,
+ struct ospf6 *ospf6)
{
- ospf6_abr_originate_summary(route);
- ospf6_zebra_route_update_add(route);
+ ospf6_abr_originate_summary(route, ospf6);
+ ospf6_zebra_route_update_add(route, ospf6);
}
-static void ospf6_top_route_hook_remove(struct ospf6_route *route)
+static void ospf6_top_route_hook_remove(struct ospf6_route *route,
+ struct ospf6 *ospf6)
{
route->flag |= OSPF6_ROUTE_REMOVE;
- ospf6_abr_originate_summary(route);
- ospf6_zebra_route_update_remove(route);
+ ospf6_abr_originate_summary(route, ospf6);
+ ospf6_zebra_route_update_remove(route, ospf6);
}
-static void ospf6_top_brouter_hook_add(struct ospf6_route *route)
+static void ospf6_top_brouter_hook_add(struct ospf6_route *route,
+ struct ospf6 *ospf6)
{
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL) ||
IS_OSPF6_DEBUG_BROUTER) {
route->path.origin.adv_router,
listcount(route->nh_list));
}
- ospf6_abr_examin_brouter(ADV_ROUTER_IN_PREFIX(&route->prefix));
- ospf6_asbr_lsentry_add(route);
- ospf6_abr_originate_summary(route);
+ ospf6_abr_examin_brouter(ADV_ROUTER_IN_PREFIX(&route->prefix), route,
+ ospf6);
+ ospf6_asbr_lsentry_add(route, ospf6);
+ ospf6_abr_originate_summary(route, ospf6);
}
-static void ospf6_top_brouter_hook_remove(struct ospf6_route *route)
+static void ospf6_top_brouter_hook_remove(struct ospf6_route *route,
+ struct ospf6 *ospf6)
{
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL) ||
IS_OSPF6_DEBUG_BROUTER) {
listcount(route->nh_list));
}
route->flag |= OSPF6_ROUTE_REMOVE;
- ospf6_abr_examin_brouter(ADV_ROUTER_IN_PREFIX(&route->prefix));
- ospf6_asbr_lsentry_remove(route);
- ospf6_abr_originate_summary(route);
+ ospf6_abr_examin_brouter(ADV_ROUTER_IN_PREFIX(&route->prefix), route,
+ ospf6);
+ ospf6_asbr_lsentry_remove(route, ospf6);
+ ospf6_abr_originate_summary(route, ospf6);
}
static struct ospf6 *ospf6_create(const char *name)
vrf = vrf_lookup_by_name(name);
if (vrf) {
o->vrf_id = vrf->vrf_id;
- /* Freed in ospf6_delete */
- o->name = XSTRDUP(MTYPE_OSPF6_TOP, name);
- }
+ } else
+ o->vrf_id = VRF_UNKNOWN;
+
+ /* Freed in ospf6_delete */
+ o->name = XSTRDUP(MTYPE_OSPF6_TOP, name);
+ if (vrf)
+ ospf6_vrf_link(o, vrf);
+
+ ospf6_zebra_vrf_register(o);
+
/* initialize */
monotime(&o->starttime);
o->area_list = list_new();
return o;
}
-void ospf6_instance_create(const char *name)
+struct ospf6 *ospf6_instance_create(const char *name)
{
+ struct ospf6 *ospf6;
+
ospf6 = ospf6_create(name);
if (DFLT_OSPF6_LOG_ADJACENCY_CHANGES)
SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES);
if (ospf6->router_id == 0)
- ospf6_router_id_update();
-
+ ospf6_router_id_update(ospf6);
+ ospf6_add(ospf6);
thread_add_read(master, ospf6_receive, ospf6, ospf6->fd,
&ospf6->t_ospf6_receive);
+
+ return ospf6;
}
void ospf6_delete(struct ospf6 *o)
QOBJ_UNREG(o);
- ospf6_flush_self_originated_lsas_now();
- ospf6_disable(ospf6);
+ ospf6_flush_self_originated_lsas_now(o);
+ ospf6_disable(o);
+ ospf6_del(o);
for (ALL_LIST_ELEMENTS(o->area_list, node, nnode, oa))
ospf6_area_delete(oa);
ospf6_lsdb_delete(o->lsdb);
ospf6_lsdb_delete(o->lsdb_self);
- ospf6_route_table_delete(o->route_table);
- ospf6_route_table_delete(o->brouter_table);
+ ospf6_route_table_delete(o->route_table, o);
+ ospf6_route_table_delete(o->brouter_table, o);
- ospf6_route_table_delete(o->external_table);
+ ospf6_route_table_delete(o->external_table, o);
route_table_finish(o->external_id_table);
ospf6_distance_reset(o);
ospf6_asbr_redistribute_reset(o->vrf_id);
ospf6_lsdb_remove_all(o->lsdb);
- ospf6_route_remove_all(o->route_table);
- ospf6_route_remove_all(o->brouter_table);
+ ospf6_route_remove_all(o->route_table, o);
+ ospf6_route_remove_all(o->brouter_table, o);
THREAD_OFF(o->maxage_remover);
THREAD_OFF(o->t_spf_calc);
}
}
-void ospf6_master_init(void)
+void ospf6_master_init(struct thread_master *master)
{
memset(&ospf6_master, 0, sizeof(struct ospf6_master));
om6 = &ospf6_master;
+ om6->ospf6 = list_new();
+ om6->master = master;
}
static int ospf6_maxage_remover(struct thread *thread)
&o->maxage_remover);
}
-void ospf6_router_id_update(void)
+void ospf6_router_id_update(struct ospf6 *ospf6)
{
if (!ospf6)
return;
ROUTER_STR
OSPF6_STR)
{
+ struct ospf6 *ospf6;
+
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
if (ospf6 == NULL)
- ospf6_instance_create(VRF_DEFAULT_NAME);
+ ospf6 = ospf6_instance_create(VRF_DEFAULT_NAME);
/* set current ospf point. */
VTY_PUSH_CONTEXT(OSPF6_NODE, ospf6);
ROUTER_STR
OSPF6_STR)
{
+ struct ospf6 *ospf6;
+
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
if (ospf6 == NULL)
vty_out(vty, "OSPFv3 is not configured\n");
else {
"OSPF6 area ID in decimal notation\n"
)
{
- VTY_DECLVAR_CONTEXT(ospf6, o);
int idx_ifname = 1;
int idx_ipv4 = 3;
struct ospf6_area *oa;
struct ospf6_interface *oi;
struct interface *ifp;
+ VTY_DECLVAR_CONTEXT(ospf6, ospf6);
+
/* find/create ospf6 interface */
ifp = if_get_by_name(argv[idx_ifname]->arg, VRF_DEFAULT);
oi = (struct ospf6_interface *)ifp->info;
}
/* parse Area-ID */
- OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, oa);
+ OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, oa, ospf6);
/* attach interface to area */
listnode_add(oa->if_list, oi); /* sort ?? */
SET_FLAG(oa->flag, OSPF6_AREA_ENABLE);
/* ospf6 process is currently disabled, not much more to do */
- if (CHECK_FLAG(o->flag, OSPF6_DISABLED))
+ if (CHECK_FLAG(ospf6->flag, OSPF6_DISABLED))
return CMD_SUCCESS;
/* start up */
ospf6_interface_enable(oi);
/* If the router is ABR, originate summary routes */
- if (ospf6_is_router_abr(o))
+ if (ospf6_is_router_abr(ospf6))
ospf6_abr_enable_area(oa);
return CMD_SUCCESS;
struct listnode *node;
struct ospf6_area *oa;
+ VTY_DECLVAR_CONTEXT(ospf6, ospf6);
+
if (!CHECK_FLAG(ospf6->flag, OSPF6_STUB_ROUTER)) {
for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, node, oa)) {
OSPF6_OPT_CLEAR(oa->options, OSPF6_OPT_V6);
struct listnode *node;
struct ospf6_area *oa;
+ VTY_DECLVAR_CONTEXT(ospf6, ospf6);
if (CHECK_FLAG(ospf6->flag, OSPF6_STUB_ROUTER)) {
for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, node, oa)) {
OSPF6_OPT_SET(oa->options, OSPF6_OPT_V6);
IP6_STR
OSPF6_STR)
{
- OSPF6_CMD_CHECK_RUNNING();
+ struct ospf6 *ospf6;
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
ospf6_show(vty, ospf6);
return CMD_SUCCESS;
}
"Detailed information\n"
"Summary of route table\n")
{
- OSPF6_CMD_CHECK_RUNNING();
+ struct ospf6 *ospf6;
+
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
ospf6_route_table_show(vty, 4, argc, argv, ospf6->route_table);
return CMD_SUCCESS;
"Display routes which match the specified route\n"
"Display routes longer than the specified route\n")
{
- OSPF6_CMD_CHECK_RUNNING();
+ struct ospf6 *ospf6;
+
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
ospf6_route_table_show(vty, 4, argc, argv, ospf6->route_table);
+
return CMD_SUCCESS;
}
"Detailed information\n"
)
{
- OSPF6_CMD_CHECK_RUNNING();
+ struct ospf6 *ospf6;
+
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
ospf6_route_table_show(vty, 4, argc, argv, ospf6->route_table);
return CMD_SUCCESS;
"Detailed information\n"
)
{
- OSPF6_CMD_CHECK_RUNNING();
+ struct ospf6 *ospf6;
+
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
ospf6_route_table_show(vty, 4, argc, argv, ospf6->route_table);
return CMD_SUCCESS;
}
-static void ospf6_stub_router_config_write(struct vty *vty)
+static void ospf6_stub_router_config_write(struct vty *vty, struct ospf6 *ospf6)
{
if (CHECK_FLAG(ospf6->flag, OSPF6_STUB_ROUTER)) {
vty_out(vty, " stub-router administrative\n");
return;
}
-static int ospf6_distance_config_write(struct vty *vty)
+static int ospf6_distance_config_write(struct vty *vty, struct ospf6 *ospf6)
{
struct route_node *rn;
struct ospf6_distance *odistance;
/* OSPF configuration write function. */
static int config_write_ospf6(struct vty *vty)
{
- char router_id[16];
struct listnode *j, *k;
struct ospf6_area *oa;
struct ospf6_interface *oi;
+ struct ospf6 *ospf6;
+ struct listnode *node, *nnode;
/* OSPFv3 configuration. */
- if (ospf6 == NULL)
+ if (om6 == NULL)
return CMD_SUCCESS;
- inet_ntop(AF_INET, &ospf6->router_id_static, router_id,
- sizeof(router_id));
- vty_out(vty, "router ospf6\n");
- if (ospf6->router_id_static != 0)
- vty_out(vty, " ospf6 router-id %s\n", router_id);
-
- /* log-adjacency-changes flag print. */
- if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES)) {
- if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL))
- vty_out(vty, " log-adjacency-changes detail\n");
- else if (!SAVE_OSPF6_LOG_ADJACENCY_CHANGES)
- vty_out(vty, " log-adjacency-changes\n");
- } else if (SAVE_OSPF6_LOG_ADJACENCY_CHANGES) {
- vty_out(vty, " no log-adjacency-changes\n");
- }
+ for (ALL_LIST_ELEMENTS(om6->ospf6, node, nnode, ospf6)) {
+ vty_out(vty, "router ospf6\n");
+ if (ospf6->router_id_static != 0)
+ vty_out(vty, " ospf6 router-id %pI4\n",
+ &ospf6->router_id_static);
+
+ /* log-adjacency-changes flag print. */
+ if (CHECK_FLAG(ospf6->config_flags,
+ OSPF6_LOG_ADJACENCY_CHANGES)) {
+ if (CHECK_FLAG(ospf6->config_flags,
+ OSPF6_LOG_ADJACENCY_DETAIL))
+ vty_out(vty, " log-adjacency-changes detail\n");
+ else if (!SAVE_OSPF6_LOG_ADJACENCY_CHANGES)
+ vty_out(vty, " log-adjacency-changes\n");
+ } else if (SAVE_OSPF6_LOG_ADJACENCY_CHANGES) {
+ vty_out(vty, " no log-adjacency-changes\n");
+ }
- if (ospf6->ref_bandwidth != OSPF6_REFERENCE_BANDWIDTH)
- vty_out(vty, " auto-cost reference-bandwidth %d\n",
- ospf6->ref_bandwidth);
-
- /* LSA timers print. */
- if (ospf6->lsa_minarrival != OSPF_MIN_LS_ARRIVAL)
- vty_out(vty, " timers lsa min-arrival %d\n",
- ospf6->lsa_minarrival);
-
- ospf6_stub_router_config_write(vty);
- ospf6_redistribute_config_write(vty);
- ospf6_area_config_write(vty);
- ospf6_spf_config_write(vty);
- ospf6_distance_config_write(vty);
-
- for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, j, oa)) {
- for (ALL_LIST_ELEMENTS_RO(oa->if_list, k, oi))
- vty_out(vty, " interface %s area %s\n",
- oi->interface->name, oa->name);
+ if (ospf6->ref_bandwidth != OSPF6_REFERENCE_BANDWIDTH)
+ vty_out(vty, " auto-cost reference-bandwidth %d\n",
+ ospf6->ref_bandwidth);
+
+ /* LSA timers print. */
+ if (ospf6->lsa_minarrival != OSPF_MIN_LS_ARRIVAL)
+ vty_out(vty, " timers lsa min-arrival %d\n",
+ ospf6->lsa_minarrival);
+
+ ospf6_stub_router_config_write(vty, ospf6);
+ ospf6_redistribute_config_write(vty, ospf6);
+ ospf6_area_config_write(vty, ospf6);
+ ospf6_spf_config_write(vty, ospf6);
+ ospf6_distance_config_write(vty, ospf6);
+
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, j, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(oa->if_list, k, oi))
+ vty_out(vty, " interface %s area %s\n",
+ oi->interface->name, oa->name);
+ }
+ vty_out(vty, "!\n");
}
- vty_out(vty, "!\n");
return 0;
}
#include "qobj.h"
#include "routemap.h"
-
struct ospf6_master {
+ /* OSPFv3 instance. */
+ struct list *ospf6;
+ /* OSPFv3 thread master. */
+ struct thread_master *master;
in_addr_t zebra_router_id;
};
extern struct ospf6_master *om6;
/* prototypes */
-extern void ospf6_master_init(void);
+extern void ospf6_master_init(struct thread_master *master);
extern void ospf6_top_init(void);
extern void ospf6_delete(struct ospf6 *o);
-extern void ospf6_router_id_update(void);
+extern void ospf6_router_id_update(struct ospf6 *ospf6);
extern void ospf6_maxage_remove(struct ospf6 *o);
-extern void ospf6_instance_create(const char *name);
+extern struct ospf6 *ospf6_instance_create(const char *name);
+void ospf6_vrf_link(struct ospf6 *ospf6, struct vrf *vrf);
+void ospf6_vrf_unlink(struct ospf6 *ospf6, struct vrf *vrf);
+struct ospf6 *ospf6_lookup_by_vrf_id(vrf_id_t vrf_id);
+struct ospf6 *ospf6_lookup_by_vrf_name(const char *name);
+const char *ospf6_vrf_id_to_name(vrf_id_t vrf_id);
#endif /* OSPF6_TOP_H */
#include "ospf6_asbr.h"
#include "ospf6_zebra.h"
#include "ospf6d.h"
+#include "ospf6_area.h"
DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_DISTANCE, "OSPF6 distance")
/* information about zebra. */
struct zclient *zclient = NULL;
+void ospf6_zebra_vrf_register(struct ospf6 *ospf6)
+{
+ if (!zclient || zclient->sock < 0 || !ospf6)
+ return;
+
+ if (ospf6->vrf_id != VRF_UNKNOWN) {
+ if (IS_OSPF6_DEBUG_ZEBRA(RECV)) {
+ zlog_debug("%s: Register VRF %s id %u", __func__,
+ ospf6_vrf_id_to_name(ospf6->vrf_id),
+ ospf6->vrf_id);
+ }
+ zclient_send_reg_requests(zclient, ospf6->vrf_id);
+ }
+}
+
+void ospf6_zebra_vrf_deregister(struct ospf6 *ospf6)
+{
+ if (!zclient || zclient->sock < 0 || !ospf6)
+ return;
+
+ if (ospf6->vrf_id != VRF_DEFAULT && ospf6->vrf_id != VRF_UNKNOWN) {
+ if (IS_OSPF6_DEBUG_ZEBRA(RECV)) {
+ zlog_debug("%s: De-Register VRF %s id %u to Zebra.",
+ __func__,
+ ospf6_vrf_id_to_name(ospf6->vrf_id),
+ ospf6->vrf_id);
+ }
+ /* Deregister for router-id, interfaces,
+ * redistributed routes. */
+ zclient_send_dereg_requests(zclient, ospf6->vrf_id);
+ }
+}
+
/* Router-id update message from zebra. */
static int ospf6_router_id_update_zebra(ZAPI_CALLBACK_ARGS)
{
struct prefix router_id;
- struct ospf6 *o = ospf6;
+ struct ospf6 *o;
zebra_router_id_update_read(zclient->ibuf, &router_id);
om6->zebra_router_id = router_id.u.prefix4.s_addr;
-
+ o = ospf6_lookup_by_vrf_id(vrf_id);
if (o == NULL)
return 0;
INET_ADDRSTRLEN));
}
- ospf6_router_id_update();
+ ospf6_router_id_update(o);
return 0;
}
struct zapi_route api;
unsigned long ifindex;
struct in6_addr *nexthop;
+ struct ospf6 *ospf6;
+
+ ospf6 = ospf6_lookup_by_vrf_id(vrf_id);
if (ospf6 == NULL)
return 0;
if (cmd == ZEBRA_REDISTRIBUTE_ROUTE_ADD)
ospf6_asbr_redistribute_add(api.type, ifindex, &api.prefix,
- api.nexthop_num, nexthop, api.tag);
+ api.nexthop_num, nexthop, api.tag,
+ ospf6);
else
- ospf6_asbr_redistribute_remove(api.type, ifindex, &api.prefix);
+ ospf6_asbr_redistribute_remove(api.type, ifindex, &api.prefix,
+ ospf6);
return 0;
}
#define ADD 0
#define REM 1
-static void ospf6_zebra_route_update(int type, struct ospf6_route *request)
+static void ospf6_zebra_route_update(int type, struct ospf6_route *request,
+ struct ospf6 *ospf6)
{
struct zapi_route api;
char buf[PREFIX2STR_BUFFER];
}
SET_FLAG(api.message, ZAPI_MESSAGE_DISTANCE);
- api.distance =
- ospf6_distance_apply((struct prefix_ipv6 *)dest, request);
+ api.distance = ospf6_distance_apply((struct prefix_ipv6 *)dest, request,
+ ospf6);
if (type == REM)
ret = zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api);
return;
}
-void ospf6_zebra_route_update_add(struct ospf6_route *request)
+void ospf6_zebra_route_update_add(struct ospf6_route *request,
+ struct ospf6 *ospf6)
{
- ospf6_zebra_route_update(ADD, request);
+ ospf6_zebra_route_update(ADD, request, ospf6);
}
-void ospf6_zebra_route_update_remove(struct ospf6_route *request)
+void ospf6_zebra_route_update_remove(struct ospf6_route *request,
+ struct ospf6 *ospf6)
{
- ospf6_zebra_route_update(REM, request);
+ ospf6_zebra_route_update(REM, request, ospf6);
}
-void ospf6_zebra_add_discard(struct ospf6_route *request)
+void ospf6_zebra_add_discard(struct ospf6_route *request, struct ospf6 *ospf6)
{
struct zapi_route api;
char buf[INET6_ADDRSTRLEN];
}
}
-void ospf6_zebra_delete_discard(struct ospf6_route *request)
+void ospf6_zebra_delete_discard(struct ospf6_route *request,
+ struct ospf6 *ospf6)
{
struct zapi_route api;
char buf[INET6_ADDRSTRLEN];
}
}
-uint8_t ospf6_distance_apply(struct prefix_ipv6 *p, struct ospf6_route * or)
+uint8_t ospf6_distance_apply(struct prefix_ipv6 *p, struct ospf6_route * or,
+ struct ospf6 *ospf6)
{
struct ospf6 *o;
};
extern struct zclient *zclient;
+struct ospf6;
-extern void ospf6_zebra_route_update_add(struct ospf6_route *request);
-extern void ospf6_zebra_route_update_remove(struct ospf6_route *request);
+extern void ospf6_zebra_route_update_add(struct ospf6_route *request,
+ struct ospf6 *ospf6);
+extern void ospf6_zebra_route_update_remove(struct ospf6_route *request,
+ struct ospf6 *ospf6);
extern void ospf6_zebra_redistribute(int, vrf_id_t vrf_id);
extern void ospf6_zebra_no_redistribute(int, vrf_id_t vrf_id);
#define ospf6_zebra_is_redistribute(type, vrf_id) \
vrf_bitmap_check(zclient->redist[AFI_IP6][type], vrf_id)
extern void ospf6_zebra_init(struct thread_master *);
-extern void ospf6_zebra_add_discard(struct ospf6_route *request);
-extern void ospf6_zebra_delete_discard(struct ospf6_route *request);
+extern void ospf6_zebra_add_discard(struct ospf6_route *request,
+ struct ospf6 *ospf6);
+extern void ospf6_zebra_delete_discard(struct ospf6_route *request,
+ struct ospf6 *ospf6);
-struct ospf6;
extern void ospf6_distance_reset(struct ospf6 *);
-extern uint8_t ospf6_distance_apply(struct prefix_ipv6 *, struct ospf6_route *);
+extern uint8_t ospf6_distance_apply(struct prefix_ipv6 *, struct ospf6_route *,
+ struct ospf6 *);
extern int ospf6_distance_set(struct vty *, struct ospf6 *, const char *,
const char *, const char *);
extern int config_write_ospf6_debug_zebra(struct vty *vty);
extern void install_element_ospf6_debug_zebra(void);
-
+extern void ospf6_zebra_vrf_register(struct ospf6 *ospf6);
+extern void ospf6_zebra_vrf_deregister(struct ospf6 *ospf6);
#endif /*OSPF6_ZEBRA_H*/
int idx_level = 4;
int level;
struct listnode *i, *j;
- struct ospf6 *o = ospf6;
+ struct ospf6 *ospf6;
struct ospf6_area *oa;
struct ospf6_interface *oi;
- OSPF6_CMD_CHECK_RUNNING();
+
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
level = parse_show_level(idx_level, argc, argv);
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
vty_out(vty, AREA_LSDB_TITLE_FORMAT, oa->name);
ospf6_lsdb_show(vty, level, NULL, NULL, NULL, oa->lsdb);
}
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi)) {
vty_out(vty, IF_LSDB_TITLE_FORMAT, oi->interface->name,
oa->name);
}
vty_out(vty, AS_LSDB_TITLE_FORMAT);
- ospf6_lsdb_show(vty, level, NULL, NULL, NULL, o->lsdb);
+ ospf6_lsdb_show(vty, level, NULL, NULL, NULL, ospf6->lsdb);
vty_out(vty, "\n");
return CMD_SUCCESS;
int idx_level = 5;
int level;
struct listnode *i, *j;
- struct ospf6 *o = ospf6;
+ struct ospf6 *ospf6;
struct ospf6_area *oa;
struct ospf6_interface *oi;
uint16_t type = 0;
- OSPF6_CMD_CHECK_RUNNING();
+
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
type = parse_type_spec(idx_lsa, argc, argv);
level = parse_show_level(idx_level, argc, argv);
switch (OSPF6_LSA_SCOPE(type)) {
case OSPF6_SCOPE_AREA:
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
vty_out(vty, AREA_LSDB_TITLE_FORMAT, oa->name);
ospf6_lsdb_show(vty, level, &type, NULL, NULL,
oa->lsdb);
break;
case OSPF6_SCOPE_LINKLOCAL:
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi)) {
vty_out(vty, IF_LSDB_TITLE_FORMAT,
oi->interface->name, oa->name);
case OSPF6_SCOPE_AS:
vty_out(vty, AS_LSDB_TITLE_FORMAT);
- ospf6_lsdb_show(vty, level, &type, NULL, NULL, o->lsdb);
+ ospf6_lsdb_show(vty, level, &type, NULL, NULL, ospf6->lsdb);
break;
default:
int idx_level = 6;
int level;
struct listnode *i, *j;
- struct ospf6 *o = ospf6;
+ struct ospf6 *ospf6;
struct ospf6_area *oa;
struct ospf6_interface *oi;
uint32_t id = 0;
- OSPF6_CMD_CHECK_RUNNING();
+
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
if (argv[idx_ipv4]->type == IPV4_TKN)
inet_pton(AF_INET, argv[idx_ipv4]->arg, &id);
level = parse_show_level(idx_level, argc, argv);
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
vty_out(vty, AREA_LSDB_TITLE_FORMAT, oa->name);
ospf6_lsdb_show(vty, level, NULL, &id, NULL, oa->lsdb);
}
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi)) {
vty_out(vty, IF_LSDB_TITLE_FORMAT, oi->interface->name,
oa->name);
}
vty_out(vty, AS_LSDB_TITLE_FORMAT);
- ospf6_lsdb_show(vty, level, NULL, &id, NULL, o->lsdb);
+ ospf6_lsdb_show(vty, level, NULL, &id, NULL, ospf6->lsdb);
vty_out(vty, "\n");
return CMD_SUCCESS;
int idx_level = 7;
int level;
struct listnode *i, *j;
- struct ospf6 *o = ospf6;
+ struct ospf6 *ospf6;
struct ospf6_area *oa;
struct ospf6_interface *oi;
uint32_t adv_router = 0;
- OSPF6_CMD_CHECK_RUNNING();
+
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
inet_pton(AF_INET, argv[idx_ipv4]->arg, &adv_router);
level = parse_show_level(idx_level, argc, argv);
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
vty_out(vty, AREA_LSDB_TITLE_FORMAT, oa->name);
ospf6_lsdb_show(vty, level, NULL, NULL, &adv_router, oa->lsdb);
}
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi)) {
vty_out(vty, IF_LSDB_TITLE_FORMAT, oi->interface->name,
oa->name);
}
vty_out(vty, AS_LSDB_TITLE_FORMAT);
- ospf6_lsdb_show(vty, level, NULL, NULL, &adv_router, o->lsdb);
+ ospf6_lsdb_show(vty, level, NULL, NULL, &adv_router, ospf6->lsdb);
vty_out(vty, "\n");
return CMD_SUCCESS;
uint16_t type = htons(OSPF6_LSTYPE_ROUTER);
int idx_ipv4 = 6;
struct listnode *i;
- struct ospf6 *o = ospf6;
+ struct ospf6 *ospf6;
struct ospf6_area *oa;
struct ospf6_lsdb *lsdb;
uint32_t adv_router = 0;
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
+
inet_pton(AF_INET, argv[idx_ipv4]->arg, &adv_router);
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
- if (adv_router == o->router_id)
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
+ if (adv_router == ospf6->router_id)
lsdb = oa->lsdb_self;
else
lsdb = oa->lsdb;
int idx_level = 7;
int level;
struct listnode *i, *j;
- struct ospf6 *o = ospf6;
+ struct ospf6 *ospf6;
struct ospf6_area *oa;
struct ospf6_interface *oi;
uint16_t type = 0;
uint32_t id = 0;
- OSPF6_CMD_CHECK_RUNNING();
+
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
type = parse_type_spec(idx_lsa, argc, argv);
inet_pton(AF_INET, argv[idx_ipv4]->arg, &id);
switch (OSPF6_LSA_SCOPE(type)) {
case OSPF6_SCOPE_AREA:
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
vty_out(vty, AREA_LSDB_TITLE_FORMAT, oa->name);
ospf6_lsdb_show(vty, level, &type, &id, NULL, oa->lsdb);
}
break;
case OSPF6_SCOPE_LINKLOCAL:
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi)) {
vty_out(vty, IF_LSDB_TITLE_FORMAT,
oi->interface->name, oa->name);
case OSPF6_SCOPE_AS:
vty_out(vty, AS_LSDB_TITLE_FORMAT);
- ospf6_lsdb_show(vty, level, &type, &id, NULL, o->lsdb);
+ ospf6_lsdb_show(vty, level, &type, &id, NULL, ospf6->lsdb);
break;
default:
int idx_level = 7;
int level;
struct listnode *i, *j;
- struct ospf6 *o = ospf6;
+ struct ospf6 *ospf6;
struct ospf6_area *oa;
struct ospf6_interface *oi;
uint16_t type = 0;
uint32_t adv_router = 0;
- OSPF6_CMD_CHECK_RUNNING();
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
type = parse_type_spec(idx_lsa, argc, argv);
inet_pton(AF_INET, argv[idx_ipv4]->arg, &adv_router);
level = parse_show_level(idx_level, argc, argv);
switch (OSPF6_LSA_SCOPE(type)) {
case OSPF6_SCOPE_AREA:
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
vty_out(vty, AREA_LSDB_TITLE_FORMAT, oa->name);
ospf6_lsdb_show(vty, level, &type, NULL, &adv_router,
oa->lsdb);
break;
case OSPF6_SCOPE_LINKLOCAL:
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi)) {
vty_out(vty, IF_LSDB_TITLE_FORMAT,
oi->interface->name, oa->name);
case OSPF6_SCOPE_AS:
vty_out(vty, AS_LSDB_TITLE_FORMAT);
- ospf6_lsdb_show(vty, level, &type, NULL, &adv_router, o->lsdb);
+ ospf6_lsdb_show(vty, level, &type, NULL, &adv_router,
+ ospf6->lsdb);
break;
default:
int idx_level = 7;
int level;
struct listnode *i, *j;
- struct ospf6 *o = ospf6;
+ struct ospf6 *ospf6;
struct ospf6_area *oa;
struct ospf6_interface *oi;
uint32_t id = 0;
uint32_t adv_router = 0;
- OSPF6_CMD_CHECK_RUNNING();
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
inet_pton(AF_INET, argv[idx_ls_id]->arg, &id);
inet_pton(AF_INET, argv[idx_adv_rtr]->arg, &adv_router);
level = parse_show_level(idx_level, argc, argv);
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
vty_out(vty, AREA_LSDB_TITLE_FORMAT, oa->name);
ospf6_lsdb_show(vty, level, NULL, &id, &adv_router, oa->lsdb);
}
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi)) {
vty_out(vty, IF_LSDB_TITLE_FORMAT, oi->interface->name,
oa->name);
}
vty_out(vty, AS_LSDB_TITLE_FORMAT);
- ospf6_lsdb_show(vty, level, NULL, &id, &adv_router, o->lsdb);
+ ospf6_lsdb_show(vty, level, NULL, &id, &adv_router, ospf6->lsdb);
vty_out(vty, "\n");
return CMD_SUCCESS;
int idx_level = 8;
int level;
struct listnode *i, *j;
- struct ospf6 *o = ospf6;
+ struct ospf6 *ospf6;
struct ospf6_area *oa;
struct ospf6_interface *oi;
uint32_t id = 0;
uint32_t adv_router = 0;
- OSPF6_CMD_CHECK_RUNNING();
+
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
inet_pton(AF_INET, argv[idx_adv_rtr]->arg, &adv_router);
inet_pton(AF_INET, argv[idx_ls_id]->arg, &id);
level = parse_show_level(idx_level, argc, argv);
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
vty_out(vty, AREA_LSDB_TITLE_FORMAT, oa->name);
ospf6_lsdb_show(vty, level, NULL, &id, &adv_router, oa->lsdb);
}
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi)) {
vty_out(vty, IF_LSDB_TITLE_FORMAT, oi->interface->name,
oa->name);
}
vty_out(vty, AS_LSDB_TITLE_FORMAT);
- ospf6_lsdb_show(vty, level, NULL, &id, &adv_router, o->lsdb);
+ ospf6_lsdb_show(vty, level, NULL, &id, &adv_router, ospf6->lsdb);
vty_out(vty, "\n");
return CMD_SUCCESS;
int idx_level = 7;
int level;
struct listnode *i, *j;
- struct ospf6 *o = ospf6;
+ struct ospf6 *ospf6;
struct ospf6_area *oa;
struct ospf6_interface *oi;
uint16_t type = 0;
uint32_t id = 0;
uint32_t adv_router = 0;
- OSPF6_CMD_CHECK_RUNNING();
+
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
type = parse_type_spec(idx_lsa, argc, argv);
inet_pton(AF_INET, argv[idx_ls_id]->arg, &id);
switch (OSPF6_LSA_SCOPE(type)) {
case OSPF6_SCOPE_AREA:
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
vty_out(vty, AREA_LSDB_TITLE_FORMAT, oa->name);
ospf6_lsdb_show(vty, level, &type, &id, &adv_router,
oa->lsdb);
break;
case OSPF6_SCOPE_LINKLOCAL:
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi)) {
vty_out(vty, IF_LSDB_TITLE_FORMAT,
oi->interface->name, oa->name);
case OSPF6_SCOPE_AS:
vty_out(vty, AS_LSDB_TITLE_FORMAT);
- ospf6_lsdb_show(vty, level, &type, &id, &adv_router, o->lsdb);
+ ospf6_lsdb_show(vty, level, &type, &id, &adv_router,
+ ospf6->lsdb);
break;
default:
int idx_level = 9;
int level;
struct listnode *i, *j;
- struct ospf6 *o = ospf6;
+ struct ospf6 *ospf6;
struct ospf6_area *oa;
struct ospf6_interface *oi;
uint16_t type = 0;
uint32_t id = 0;
uint32_t adv_router = 0;
- OSPF6_CMD_CHECK_RUNNING();
+
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
type = parse_type_spec(idx_lsa, argc, argv);
inet_pton(AF_INET, argv[idx_adv_rtr]->arg, &adv_router);
switch (OSPF6_LSA_SCOPE(type)) {
case OSPF6_SCOPE_AREA:
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
vty_out(vty, AREA_LSDB_TITLE_FORMAT, oa->name);
ospf6_lsdb_show(vty, level, &type, &id, &adv_router,
oa->lsdb);
break;
case OSPF6_SCOPE_LINKLOCAL:
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi)) {
vty_out(vty, IF_LSDB_TITLE_FORMAT,
oi->interface->name, oa->name);
case OSPF6_SCOPE_AS:
vty_out(vty, AS_LSDB_TITLE_FORMAT);
- ospf6_lsdb_show(vty, level, &type, &id, &adv_router, o->lsdb);
+ ospf6_lsdb_show(vty, level, &type, &id, &adv_router,
+ ospf6->lsdb);
break;
default:
int idx_level = 5;
int level;
struct listnode *i, *j;
- struct ospf6 *o = ospf6;
+ struct ospf6 *ospf6;
struct ospf6_area *oa;
struct ospf6_interface *oi;
uint32_t adv_router = 0;
- OSPF6_CMD_CHECK_RUNNING();
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
level = parse_show_level(idx_level, argc, argv);
- adv_router = o->router_id;
+ adv_router = ospf6->router_id;
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
vty_out(vty, AREA_LSDB_TITLE_FORMAT, oa->name);
ospf6_lsdb_show(vty, level, NULL, NULL, &adv_router, oa->lsdb);
}
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi)) {
vty_out(vty, IF_LSDB_TITLE_FORMAT, oi->interface->name,
oa->name);
}
vty_out(vty, AS_LSDB_TITLE_FORMAT);
- ospf6_lsdb_show(vty, level, NULL, NULL, &adv_router, o->lsdb);
+ ospf6_lsdb_show(vty, level, NULL, NULL, &adv_router, ospf6->lsdb);
vty_out(vty, "\n");
return CMD_SUCCESS;
int idx_level = 6;
int level;
struct listnode *i, *j;
- struct ospf6 *o = ospf6;
+ struct ospf6 *ospf6;
struct ospf6_area *oa;
struct ospf6_interface *oi;
uint16_t type = 0;
uint32_t adv_router = 0;
- OSPF6_CMD_CHECK_RUNNING();
-
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
type = parse_type_spec(idx_lsa, argc, argv);
level = parse_show_level(idx_level, argc, argv);
- adv_router = o->router_id;
+ adv_router = ospf6->router_id;
switch (OSPF6_LSA_SCOPE(type)) {
case OSPF6_SCOPE_AREA:
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
vty_out(vty, AREA_LSDB_TITLE_FORMAT, oa->name);
ospf6_lsdb_show(vty, level, &type, NULL, &adv_router,
oa->lsdb);
break;
case OSPF6_SCOPE_LINKLOCAL:
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi)) {
vty_out(vty, IF_LSDB_TITLE_FORMAT,
oi->interface->name, oa->name);
case OSPF6_SCOPE_AS:
vty_out(vty, AS_LSDB_TITLE_FORMAT);
- ospf6_lsdb_show(vty, level, &type, NULL, &adv_router, o->lsdb);
+ ospf6_lsdb_show(vty, level, &type, NULL, &adv_router,
+ ospf6->lsdb);
break;
default:
int idx_level = 8;
int level;
struct listnode *i, *j;
- struct ospf6 *o = ospf6;
+ struct ospf6 *ospf6;
struct ospf6_area *oa;
struct ospf6_interface *oi;
uint16_t type = 0;
uint32_t adv_router = 0;
uint32_t id = 0;
- OSPF6_CMD_CHECK_RUNNING();
-
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
type = parse_type_spec(idx_lsa, argc, argv);
inet_pton(AF_INET, argv[idx_ls_id]->arg, &id);
level = parse_show_level(idx_level, argc, argv);
- adv_router = o->router_id;
+ adv_router = ospf6->router_id;
switch (OSPF6_LSA_SCOPE(type)) {
case OSPF6_SCOPE_AREA:
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
vty_out(vty, AREA_LSDB_TITLE_FORMAT, oa->name);
ospf6_lsdb_show(vty, level, &type, &id, &adv_router,
oa->lsdb);
break;
case OSPF6_SCOPE_LINKLOCAL:
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi)) {
vty_out(vty, IF_LSDB_TITLE_FORMAT,
oi->interface->name, oa->name);
case OSPF6_SCOPE_AS:
vty_out(vty, AS_LSDB_TITLE_FORMAT);
- ospf6_lsdb_show(vty, level, &type, &id, &adv_router, o->lsdb);
+ ospf6_lsdb_show(vty, level, &type, &id, &adv_router,
+ ospf6->lsdb);
break;
default:
int idx_level = 7;
int level;
struct listnode *i, *j;
- struct ospf6 *o = ospf6;
+ struct ospf6 *ospf6;
struct ospf6_area *oa;
struct ospf6_interface *oi;
uint16_t type = 0;
uint32_t adv_router = 0;
uint32_t id = 0;
- OSPF6_CMD_CHECK_RUNNING();
-
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
type = parse_type_spec(idx_lsa, argc, argv);
inet_pton(AF_INET, argv[idx_ls_id]->arg, &id);
level = parse_show_level(idx_level, argc, argv);
- adv_router = o->router_id;
+ adv_router = ospf6->router_id;
switch (OSPF6_LSA_SCOPE(type)) {
case OSPF6_SCOPE_AREA:
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
vty_out(vty, AREA_LSDB_TITLE_FORMAT, oa->name);
ospf6_lsdb_show(vty, level, &type, &id, &adv_router,
oa->lsdb);
break;
case OSPF6_SCOPE_LINKLOCAL:
- for (ALL_LIST_ELEMENTS_RO(o->area_list, i, oa)) {
+ for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa)) {
for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi)) {
vty_out(vty, IF_LSDB_TITLE_FORMAT,
oi->interface->name, oa->name);
case OSPF6_SCOPE_AS:
vty_out(vty, AS_LSDB_TITLE_FORMAT);
- ospf6_lsdb_show(vty, level, &type, &id, &adv_router, o->lsdb);
+ ospf6_lsdb_show(vty, level, &type, &id, &adv_router,
+ ospf6->lsdb);
break;
default:
uint32_t adv_router;
struct ospf6_route *ro;
struct prefix prefix;
+ struct ospf6 *ospf6 = NULL;
- OSPF6_CMD_CHECK_RUNNING();
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
if (argc == 5) {
if (strmatch(argv[idx_ipv4]->text, "detail")) {
for (ro = ospf6_route_head(ospf6->brouter_table); ro;
int idx_ipv4 = 5;
struct listnode *node;
struct ospf6_area *oa;
+ struct ospf6 *ospf6 = NULL;
- OSPF6_CMD_CHECK_RUNNING();
-
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, node, oa)) {
vty_out(vty, "\n SPF Result in Area %s\n\n", oa->name);
ospf6_linkstate_table_show(vty, idx_ipv4, argc, argv,
int idx_detail = 4;
struct listnode *node;
struct ospf6_area *oa;
+ struct ospf6 *ospf6 = NULL;
- OSPF6_CMD_CHECK_RUNNING();
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
+ OSPF6_CMD_CHECK_RUNNING(ospf6);
for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, node, oa)) {
vty_out(vty, "\n SPF Result in Area %s\n\n", oa->name);
}
/* Install ospf related commands. */
-void ospf6_init(void)
+void ospf6_init(struct thread_master *master)
{
+ struct ospf6 *ospf6;
+
ospf6_top_init();
ospf6_area_init();
ospf6_interface_init();
&show_ipv6_ospf6_database_type_self_originated_linkstate_id_cmd);
install_element(VIEW_NODE, &show_ipv6_ospf6_database_aggr_router_cmd);
+ ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
if (ospf6 == NULL)
ospf6_instance_create(VRF_DEFAULT_NAME);
}
-
-void ospf6_clean(void)
-{
- if (!ospf6)
- return;
- if (ospf6->route_table)
- ospf6_route_remove_all(ospf6->route_table);
- if (ospf6->brouter_table)
- ospf6_route_remove_all(ospf6->brouter_table);
-}
#define OSPF6_ROUTER_ID_STR "Specify Router-ID\n"
#define OSPF6_LS_ID_STR "Specify Link State ID\n"
-#define OSPF6_CMD_CHECK_RUNNING() \
+#define OSPF6_CMD_CHECK_RUNNING(ospf6) \
if (ospf6 == NULL) { \
vty_out(vty, "OSPFv3 is not running\n"); \
return CMD_SUCCESS; \
extern struct route_node *route_prev(struct route_node *node);
extern void ospf6_debug(void);
-extern void ospf6_init(void);
+extern void ospf6_init(struct thread_master *master);
#endif /* OSPF6D_H */