diff options
Diffstat (limited to 'ospfd/ospf_zebra.c')
| -rw-r--r-- | ospfd/ospf_zebra.c | 423 |
1 files changed, 266 insertions, 157 deletions
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index 9bba2c9806..16f87735be 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -53,6 +53,7 @@ DEFINE_MTYPE_STATIC(OSPFD, OSPF_EXTERNAL, "OSPF External route table") DEFINE_MTYPE_STATIC(OSPFD, OSPF_REDISTRIBUTE, "OSPF Redistriute") +DEFINE_MTYPE_STATIC(OSPFD, OSPF_DIST_ARGS, "OSPF Distribute arguments") DEFINE_HOOK(ospf_if_update, (struct interface * ifp), (ifp)) DEFINE_HOOK(ospf_if_delete, (struct interface * ifp), (ifp)) @@ -68,23 +69,33 @@ struct in_addr router_id_zebra; static int ospf_router_id_update_zebra(int command, struct zclient *zclient, zebra_size_t length, vrf_id_t vrf_id) { - struct ospf *ospf; + struct ospf *ospf = NULL; struct prefix router_id; zebra_router_id_update_read(zclient->ibuf, &router_id); if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE)) { char buf[PREFIX2STR_BUFFER]; prefix2str(&router_id, buf, sizeof(buf)); - zlog_debug("Zebra rcvd: router id update %s", buf); + zlog_debug("Zebra rcvd: router id update %s vrf %s id %u", + buf, ospf_vrf_id_to_name(vrf_id), vrf_id); } router_id_zebra = router_id.u.prefix4; - ospf = ospf_lookup(); + ospf = ospf_lookup_by_vrf_id(vrf_id); if (ospf != NULL) ospf_router_id_update(ospf); - + else { + if (IS_DEBUG_OSPF_EVENT) { + char buf[PREFIX2STR_BUFFER]; + + prefix2str(&router_id, buf, sizeof(buf)); + zlog_debug("%s: ospf instance not found for vrf %s id %u router_id %s", + __PRETTY_FUNCTION__, + ospf_vrf_id_to_name(vrf_id), vrf_id, buf); + } + } return 0; } @@ -92,14 +103,18 @@ static int ospf_router_id_update_zebra(int command, struct zclient *zclient, static int ospf_interface_add(int command, struct zclient *zclient, zebra_size_t length, vrf_id_t vrf_id) { - struct interface *ifp; + struct interface *ifp = NULL; + struct ospf *ospf = NULL; ifp = zebra_interface_add_read(zclient->ibuf, vrf_id); + if (ifp == NULL) + return 0; if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE)) zlog_debug( - "Zebra: interface add %s[%u] index %d flags %llx metric %d mtu %d", - ifp->name, ifp->vrf_id, ifp->ifindex, + "Zebra: interface add %s vrf %s[%u] index %d flags %llx metric %d mtu %d", + ifp->name, ospf_vrf_id_to_name(ifp->vrf_id), + ifp->vrf_id, ifp->ifindex, (unsigned long long)ifp->flags, ifp->metric, ifp->mtu); assert(ifp->info); @@ -109,7 +124,11 @@ static int ospf_interface_add(int command, struct zclient *zclient, IF_DEF_PARAMS(ifp)->type = ospf_default_iftype(ifp); } - ospf_if_update(NULL, ifp); + ospf = ospf_lookup_by_vrf_id(vrf_id); + if (!ospf) + return 0; + + ospf_if_update(ospf, ifp); hook_call(ospf_if_update, ifp); @@ -136,8 +155,9 @@ static int ospf_interface_delete(int command, struct zclient *zclient, if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE)) zlog_debug( - "Zebra: interface delete %s[%u] index %d flags %llx metric %d mtu %d", - ifp->name, ifp->vrf_id, ifp->ifindex, + "Zebra: interface delete %s vrf %s[%u] index %d flags %llx metric %d mtu %d", + ifp->name, ospf_vrf_id_to_name(ifp->vrf_id), + ifp->vrf_id, ifp->ifindex, (unsigned long long)ifp->flags, ifp->metric, ifp->mtu); hook_call(ospf_if_delete, ifp); @@ -160,7 +180,7 @@ static struct interface *zebra_interface_if_lookup(struct stream *s, /* And look it up. */ return if_lookup_by_name_len( - ifname_tmp, strnlen(ifname_tmp, INTERFACE_NAMSIZ), VRF_DEFAULT); + ifname_tmp, strnlen(ifname_tmp, INTERFACE_NAMSIZ), vrf_id); } static int ospf_interface_state_up(int command, struct zclient *zclient, @@ -249,6 +269,8 @@ static int ospf_interface_address_add(int command, struct zclient *zclient, zebra_size_t length, vrf_id_t vrf_id) { struct connected *c; + struct ospf *ospf = NULL; + c = zebra_interface_address_read(command, zclient->ibuf, vrf_id); @@ -258,11 +280,16 @@ static int ospf_interface_address_add(int command, struct zclient *zclient, if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE)) { char buf[PREFIX2STR_BUFFER]; prefix2str(c->address, buf, sizeof(buf)); - zlog_debug("Zebra: interface %s address add %s", c->ifp->name, - buf); + zlog_debug("Zebra: interface %s address add %s vrf %s id %u", + c->ifp->name, buf, ospf_vrf_id_to_name(vrf_id), + vrf_id); } - ospf_if_update(NULL, c->ifp); + ospf = ospf_lookup_by_vrf_id(vrf_id); + if (!ospf) + return 0; + + ospf_if_update(ospf, c->ifp); hook_call(ospf_if_update, c->ifp); @@ -330,19 +357,41 @@ static int ospf_interface_link_params(int command, struct zclient *zclient, return 0; } +/* VRF update for an interface. */ +static int ospf_interface_vrf_update(int command, struct zclient *zclient, + zebra_size_t length, vrf_id_t vrf_id) +{ + struct interface *ifp = NULL; + vrf_id_t new_vrf_id; + + ifp = zebra_interface_vrf_update_read(zclient->ibuf, vrf_id, + &new_vrf_id); + if (!ifp) + return 0; + + if (IS_DEBUG_OSPF_EVENT) + zlog_debug("%s: Rx Interface %s VRF change vrf_id %u New vrf %s id %u", + __PRETTY_FUNCTION__, ifp->name, vrf_id, + ospf_vrf_id_to_name(new_vrf_id), new_vrf_id); + + /*if_update(ifp, ifp->name, strlen(ifp->name), new_vrf_id);*/ + if_update_to_new_vrf(ifp, new_vrf_id); + + return 0; +} -void ospf_zebra_add(struct prefix_ipv4 *p, struct ospf_route * or) +void ospf_zebra_add(struct ospf *ospf, struct prefix_ipv4 *p, + struct ospf_route *or) { struct zapi_route api; struct zapi_nexthop *api_nh; u_char distance; struct ospf_path *path; struct listnode *node; - struct ospf *ospf = ospf_lookup(); int count = 0; memset(&api, 0, sizeof(api)); - api.vrf_id = VRF_DEFAULT; + api.vrf_id = ospf->vrf_id; api.type = ZEBRA_ROUTE_OSPF; api.instance = ospf->instance; api.safi = SAFI_UNICAST; @@ -368,7 +417,7 @@ void ospf_zebra_add(struct prefix_ipv4 *p, struct ospf_route * or) } /* Distance value. */ - distance = ospf_distance_apply(p, or); + distance = ospf_distance_apply(ospf, p, or); if (distance) { SET_FLAG(api.message, ZAPI_MESSAGE_DISTANCE); api.distance = distance; @@ -413,13 +462,13 @@ void ospf_zebra_add(struct prefix_ipv4 *p, struct ospf_route * or) zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api); } -void ospf_zebra_delete(struct prefix_ipv4 *p, struct ospf_route * or) +void ospf_zebra_delete(struct ospf *ospf, struct prefix_ipv4 *p, + struct ospf_route *or) { struct zapi_route api; - struct ospf *ospf = ospf_lookup(); memset(&api, 0, sizeof(api)); - api.vrf_id = VRF_DEFAULT; + api.vrf_id = ospf->vrf_id; api.type = ZEBRA_ROUTE_OSPF; api.instance = ospf->instance; api.safi = SAFI_UNICAST; @@ -435,13 +484,12 @@ void ospf_zebra_delete(struct prefix_ipv4 *p, struct ospf_route * or) zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api); } -void ospf_zebra_add_discard(struct prefix_ipv4 *p) +void ospf_zebra_add_discard(struct ospf *ospf, struct prefix_ipv4 *p) { struct zapi_route api; - struct ospf *ospf = ospf_lookup(); memset(&api, 0, sizeof(api)); - api.vrf_id = VRF_DEFAULT; + api.vrf_id = ospf->vrf_id; api.type = ZEBRA_ROUTE_OSPF; api.instance = ospf->instance; api.safi = SAFI_UNICAST; @@ -455,13 +503,12 @@ void ospf_zebra_add_discard(struct prefix_ipv4 *p) inet_ntoa(p->prefix), p->prefixlen); } -void ospf_zebra_delete_discard(struct prefix_ipv4 *p) +void ospf_zebra_delete_discard(struct ospf *ospf, struct prefix_ipv4 *p) { struct zapi_route api; - struct ospf *ospf = ospf_lookup(); memset(&api, 0, sizeof(api)); - api.vrf_id = VRF_DEFAULT; + api.vrf_id = ospf->vrf_id; api.type = ZEBRA_ROUTE_OSPF; api.instance = ospf->instance; api.safi = SAFI_UNICAST; @@ -527,8 +574,7 @@ void ospf_external_del(u_char type, u_short instance) listnode_delete(om->external[type], ext); if (!om->external[type]->count) { - list_free(om->external[type]); - om->external[type] = NULL; + list_delete_and_null(&om->external[type]); } XFREE(MTYPE_OSPF_EXTERNAL, ext); } @@ -586,8 +632,7 @@ void ospf_redist_del(struct ospf *ospf, u_char type, u_short instance) if (red) { listnode_delete(ospf->redist[type], red); if (!ospf->redist[type]->count) { - list_free(ospf->redist[type]); - ospf->redist[type] = NULL; + list_delete_and_null(&ospf->redist[type]); } ospf_routemap_unset(red); XFREE(MTYPE_OSPF_REDISTRIBUTE, red); @@ -595,11 +640,11 @@ void ospf_redist_del(struct ospf *ospf, u_char type, u_short instance) } -int ospf_is_type_redistributed(int type, u_short instance) +int ospf_is_type_redistributed(struct ospf *ospf, int type, u_short instance) { return (DEFAULT_ROUTE_TYPE(type) ? vrf_bitmap_check(zclient->default_information, - VRF_DEFAULT) + ospf->vrf_id) : ((instance && redist_check_instance( &zclient->mi_redist[AFI_IP][type], @@ -607,7 +652,7 @@ int ospf_is_type_redistributed(int type, u_short instance) || (!instance && vrf_bitmap_check( zclient->redist[AFI_IP][type], - VRF_DEFAULT)))); + ospf->vrf_id)))); } int ospf_redistribute_set(struct ospf *ospf, int type, u_short instance, @@ -617,7 +662,7 @@ int ospf_redistribute_set(struct ospf *ospf, int type, u_short instance, struct ospf_redist *red; red = ospf_redist_lookup(ospf, type, instance); - if (ospf_is_type_redistributed(type, instance)) { + if (ospf_is_type_redistributed(ospf, type, instance)) { if (mtype != red->dmetric.type) { red->dmetric.type = mtype; force = LSA_REFRESH_FORCE; @@ -645,11 +690,11 @@ int ospf_redistribute_set(struct ospf *ospf, int type, u_short instance, ospf_external_add(type, instance); zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, type, - instance, VRF_DEFAULT); + instance, ospf->vrf_id); if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) - zlog_debug("Redistribute[%s][%d]: Start Type[%d], Metric[%d]", - ospf_redist_string(type), instance, + zlog_debug("Redistribute[%s][%d] vrf id %u: Start Type[%d], Metric[%d]", + ospf_redist_string(type), instance, ospf->vrf_id, metric_type(ospf, type, instance), metric_value(ospf, type, instance)); @@ -663,15 +708,15 @@ int ospf_redistribute_unset(struct ospf *ospf, int type, u_short instance) if (type == zclient->redist_default && instance == zclient->instance) return CMD_SUCCESS; - if (!ospf_is_type_redistributed(type, instance)) + if (!ospf_is_type_redistributed(ospf, type, instance)) return CMD_SUCCESS; zclient_redistribute(ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP, type, - instance, VRF_DEFAULT); + instance, ospf->vrf_id); if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) - zlog_debug("Redistribute[%s][%d]: Stop", - ospf_redist_string(type), instance); + zlog_debug("Redistribute[%s][%d] vrf id %u: Stop", + ospf_redist_string(type), instance, ospf->vrf_id); ospf_redist_del(ospf, type, instance); @@ -698,7 +743,7 @@ int ospf_redistribute_default_set(struct ospf *ospf, int originate, int mtype, ospf_external_add(DEFAULT_ROUTE, 0); - if (ospf_is_type_redistributed(DEFAULT_ROUTE, 0)) { + if (ospf_is_type_redistributed(ospf, DEFAULT_ROUTE, 0)) { /* if ospf->default_originate changes value, is calling ospf_external_lsa_refresh_default sufficient to implement the change? */ @@ -714,7 +759,7 @@ int ospf_redistribute_default_set(struct ospf *ospf, int originate, int mtype, } zclient_redistribute_default(ZEBRA_REDISTRIBUTE_DEFAULT_ADD, zclient, - VRF_DEFAULT); + ospf->vrf_id); if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) zlog_debug("Redistribute[DEFAULT]: Start Type[%d], Metric[%d]", @@ -734,14 +779,14 @@ int ospf_redistribute_default_set(struct ospf *ospf, int originate, int mtype, int ospf_redistribute_default_unset(struct ospf *ospf) { - if (!ospf_is_type_redistributed(DEFAULT_ROUTE, 0)) + if (!ospf_is_type_redistributed(ospf, DEFAULT_ROUTE, 0)) return CMD_SUCCESS; ospf->default_originate = DEFAULT_ORIGINATE_NONE; ospf_redist_del(ospf, DEFAULT_ROUTE, 0); zclient_redistribute_default(ZEBRA_REDISTRIBUTE_DEFAULT_DELETE, zclient, - VRF_DEFAULT); + ospf->vrf_id); if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) zlog_debug("Redistribute[DEFAULT]: Stop"); @@ -886,7 +931,7 @@ static int ospf_zebra_read_route(int command, struct zclient *zclient, struct ospf *ospf; int i; - ospf = ospf_lookup(); + ospf = ospf_lookup_by_vrf_id(vrf_id); if (ospf == NULL) return 0; @@ -1019,10 +1064,13 @@ static int ospf_distribute_list_update_timer(struct thread *thread) struct external_info *ei; struct route_table *rt; struct ospf_lsa *lsa; - int type, default_refresh = 0; - struct ospf *ospf; + int type, default_refresh = 0, arg_type; + struct ospf *ospf = NULL; + void **arg = THREAD_ARG (thread); + + ospf = (struct ospf *)arg[0]; + arg_type = (int)(intptr_t)arg[1]; - ospf = ospf_lookup(); if (ospf == NULL) return 0; @@ -1030,6 +1078,12 @@ static int ospf_distribute_list_update_timer(struct thread *thread) zlog_info("Zebra[Redistribute]: distribute-list update timer fired!"); + if (IS_DEBUG_OSPF_EVENT) { + zlog_debug("%s: ospf distribute-list update arg_type %d vrf %s id %d", + __PRETTY_FUNCTION__, arg_type, + ospf_vrf_id_to_name(ospf->vrf_id), ospf->vrf_id); + } + /* foreach all external info. */ for (type = 0; type <= ZEBRA_ROUTE_MAX; type++) { struct list *ext_list; @@ -1062,29 +1116,39 @@ static int ospf_distribute_list_update_timer(struct thread *thread) } if (default_refresh) ospf_external_lsa_refresh_default(ospf); + + XFREE(MTYPE_OSPF_DIST_ARGS, arg); return 0; } /* Update distribute-list and set timer to apply access-list. */ -void ospf_distribute_list_update(struct ospf *ospf, uintptr_t type, +void ospf_distribute_list_update(struct ospf *ospf, int type, u_short instance) { struct route_table *rt; struct ospf_external *ext; + void **args = XCALLOC(MTYPE_OSPF_DIST_ARGS, sizeof(void *)*2); + + args[0] = ospf; + args[1] = (void *)((ptrdiff_t) type); /* External info does not exist. */ ext = ospf_external_lookup(type, instance); - if (!ext || !(rt = EXTERNAL_INFO(ext))) + if (!ext || !(rt = EXTERNAL_INFO(ext))) { + XFREE(MTYPE_OSPF_DIST_ARGS, args); return; + } /* If exists previously invoked thread, then let it continue. */ - if (ospf->t_distribute_update) + if (ospf->t_distribute_update) { + XFREE(MTYPE_OSPF_DIST_ARGS, args); return; + } /* Set timer. */ ospf->t_distribute_update = NULL; thread_add_timer_msec(master, ospf_distribute_list_update_timer, - (void *)type, ospf->min_ls_interval, + (void **)args, ospf->min_ls_interval, &ospf->t_distribute_update); } @@ -1095,134 +1159,148 @@ static void ospf_filter_update(struct access_list *access) int type; int abr_inv = 0; struct ospf_area *area; - struct listnode *node; + struct listnode *node, *n1; /* If OSPF instance does not exist, return right now. */ - ospf = ospf_lookup(); - if (ospf == NULL) + if (listcount(om->ospf) == 0) return; - /* Update distribute-list, and apply filter. */ - for (type = 0; type <= ZEBRA_ROUTE_MAX; type++) { - struct list *red_list; - struct listnode *node; - struct ospf_redist *red; - - red_list = ospf->redist[type]; - if (red_list) - for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { - if (ROUTEMAP(red)) { - /* if route-map is not NULL it may be - * using this access list */ - ospf_distribute_list_update( - ospf, type, red->instance); + /* Iterate all ospf [VRF] instances */ + for (ALL_LIST_ELEMENTS_RO(om->ospf, n1, ospf)) { + /* Update distribute-list, and apply filter. */ + for (type = 0; type <= ZEBRA_ROUTE_MAX; type++) { + struct list *red_list; + struct listnode *node; + struct ospf_redist *red; + + red_list = ospf->redist[type]; + if (red_list) + for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { + if (ROUTEMAP(red)) { + /* if route-map is not NULL it may be + * using this access list */ + ospf_distribute_list_update( + ospf, + type, red->instance); + } } - } - - /* There is place for route-map for default-information - * (ZEBRA_ROUTE_MAX), - * but no distribute list. */ - if (type == ZEBRA_ROUTE_MAX) - break; - - if (DISTRIBUTE_NAME(ospf, type)) { - /* Keep old access-list for distribute-list. */ - struct access_list *old = DISTRIBUTE_LIST(ospf, type); - - /* Update access-list for distribute-list. */ - DISTRIBUTE_LIST(ospf, type) = access_list_lookup( - AFI_IP, DISTRIBUTE_NAME(ospf, type)); - - /* No update for this distribute type. */ - if (old == NULL && DISTRIBUTE_LIST(ospf, type) == NULL) - continue; - /* Schedule distribute-list update timer. */ - if (DISTRIBUTE_LIST(ospf, type) == NULL - || strcmp(DISTRIBUTE_NAME(ospf, type), access->name) - == 0) - ospf_distribute_list_update(ospf, type, 0); + /* There is place for route-map for default-information + * (ZEBRA_ROUTE_MAX), + * but no distribute list. */ + if (type == ZEBRA_ROUTE_MAX) + break; + + if (DISTRIBUTE_NAME(ospf, type)) { + /* Keep old access-list for distribute-list. */ + struct access_list *old = DISTRIBUTE_LIST(ospf, + type); + + /* Update access-list for distribute-list. */ + DISTRIBUTE_LIST(ospf, type) = access_list_lookup( + AFI_IP, DISTRIBUTE_NAME(ospf, type)); + + /* No update for this distribute type. */ + if (old == NULL && DISTRIBUTE_LIST(ospf, type) == NULL) + continue; + + /* Schedule distribute-list update timer. */ + if (DISTRIBUTE_LIST(ospf, type) == NULL + || strcmp(DISTRIBUTE_NAME(ospf, type), access->name) + == 0) + ospf_distribute_list_update(ospf, type, 0); + } } - } - /* Update Area access-list. */ - for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) { - if (EXPORT_NAME(area)) { - EXPORT_LIST(area) = NULL; - abr_inv++; - } + /* Update Area access-list. */ + for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) { + if (EXPORT_NAME(area)) { + EXPORT_LIST(area) = NULL; + abr_inv++; + } - if (IMPORT_NAME(area)) { - IMPORT_LIST(area) = NULL; - abr_inv++; + if (IMPORT_NAME(area)) { + IMPORT_LIST(area) = NULL; + abr_inv++; + } } - } - /* Schedule ABR tasks -- this will be changed -- takada. */ - if (IS_OSPF_ABR(ospf) && abr_inv) - ospf_schedule_abr_task(ospf); + /* Schedule ABR tasks -- this will be changed -- takada. */ + if (IS_OSPF_ABR(ospf) && abr_inv) + ospf_schedule_abr_task(ospf); + } } /* If prefix-list is updated, do some updates. */ void ospf_prefix_list_update(struct prefix_list *plist) { - struct ospf *ospf; + struct ospf *ospf = NULL; int type; int abr_inv = 0; struct ospf_area *area; - struct listnode *node; + struct listnode *node, *n1; /* If OSPF instatnce does not exist, return right now. */ - ospf = ospf_lookup(); - if (ospf == NULL) + if (listcount(om->ospf) == 0) return; - /* Update all route-maps which are used as redistribution filters. - * They might use prefix-list. - */ - for (type = 0; type <= ZEBRA_ROUTE_MAX; type++) { - struct list *red_list; - struct listnode *node; - struct ospf_redist *red; - - red_list = ospf->redist[type]; - if (red_list) - for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { - if (ROUTEMAP(red)) { - /* if route-map is not NULL it may be - * using this prefix list */ - ospf_distribute_list_update( - ospf, type, red->instance); + /* Iterate all ospf [VRF] instances */ + for (ALL_LIST_ELEMENTS_RO(om->ospf, n1, ospf)) { + + /* Update all route-maps which are used + * as redistribution filters. + * They might use prefix-list. + */ + for (type = 0; type <= ZEBRA_ROUTE_MAX; type++) { + struct list *red_list; + struct listnode *node; + struct ospf_redist *red; + + red_list = ospf->redist[type]; + if (red_list) { + for (ALL_LIST_ELEMENTS_RO(red_list, + node, red)) { + if (ROUTEMAP(red)) { + /* if route-map is not NULL + * it may be using + * this prefix list */ + ospf_distribute_list_update( + ospf, type, + red->instance); + } } } - } + } - /* Update area filter-lists. */ - for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) { - /* Update filter-list in. */ - if (PREFIX_NAME_IN(area)) - if (strcmp(PREFIX_NAME_IN(area), - prefix_list_name(plist)) - == 0) { - PREFIX_LIST_IN(area) = prefix_list_lookup( - AFI_IP, PREFIX_NAME_IN(area)); - abr_inv++; - } + /* Update area filter-lists. */ + for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) { + /* Update filter-list in. */ + if (PREFIX_NAME_IN(area)) + if (strcmp(PREFIX_NAME_IN(area), + prefix_list_name(plist)) == 0) { + PREFIX_LIST_IN(area) = + prefix_list_lookup( + AFI_IP, + PREFIX_NAME_IN(area)); + abr_inv++; + } - /* Update filter-list out. */ - if (PREFIX_NAME_OUT(area)) - if (strcmp(PREFIX_NAME_OUT(area), - prefix_list_name(plist)) - == 0) { - PREFIX_LIST_IN(area) = prefix_list_lookup( - AFI_IP, PREFIX_NAME_OUT(area)); - abr_inv++; - } - } + /* Update filter-list out. */ + if (PREFIX_NAME_OUT(area)) + if (strcmp(PREFIX_NAME_OUT(area), + prefix_list_name(plist)) == 0) { + PREFIX_LIST_IN(area) = + prefix_list_lookup( + AFI_IP, + PREFIX_NAME_OUT(area)); + abr_inv++; + } + } - /* Schedule ABR task. */ - if (IS_OSPF_ABR(ospf) && abr_inv) - ospf_schedule_abr_task(ospf); + /* Schedule ABR task. */ + if (IS_OSPF_ABR(ospf) && abr_inv) + ospf_schedule_abr_task(ospf); + } } static struct ospf_distance *ospf_distance_new(void) @@ -1326,11 +1404,10 @@ void ospf_distance_reset(struct ospf *ospf) } } -u_char ospf_distance_apply(struct prefix_ipv4 *p, struct ospf_route * or) +u_char ospf_distance_apply(struct ospf *ospf, struct prefix_ipv4 *p, + struct ospf_route *or) { - struct ospf *ospf; - ospf = ospf_lookup(); if (ospf == NULL) return 0; @@ -1353,6 +1430,37 @@ u_char ospf_distance_apply(struct prefix_ipv4 *p, struct ospf_route * or) return 0; } +void ospf_zebra_vrf_register(struct ospf *ospf) +{ + if (!zclient || zclient->sock < 0 || !ospf) + return; + + if (ospf->vrf_id != VRF_DEFAULT && ospf->vrf_id != VRF_UNKNOWN) { + if (IS_DEBUG_OSPF_EVENT) + zlog_debug("%s: Register VRF %s id %u", + __PRETTY_FUNCTION__, + ospf_vrf_id_to_name(ospf->vrf_id), + ospf->vrf_id); + zclient_send_reg_requests(zclient, ospf->vrf_id); + } +} + +void ospf_zebra_vrf_deregister(struct ospf *ospf) +{ + if (!zclient || zclient->sock < 0 || !ospf) + return; + + if (ospf->vrf_id != VRF_DEFAULT && ospf->vrf_id != VRF_UNKNOWN) { + if (IS_DEBUG_OSPF_EVENT) + zlog_debug("%s: De-Register VRF %s id %u", + __PRETTY_FUNCTION__, + ospf_vrf_id_to_name(ospf->vrf_id), + ospf->vrf_id); + /* Deregister for router-id, interfaces, + * redistributed routes. */ + zclient_send_dereg_requests(zclient, ospf->vrf_id); + } +} static void ospf_zebra_connected(struct zclient *zclient) { /* Send the client registration */ @@ -1375,6 +1483,7 @@ void ospf_zebra_init(struct thread_master *master, u_short instance) zclient->interface_address_add = ospf_interface_address_add; zclient->interface_address_delete = ospf_interface_address_delete; zclient->interface_link_params = ospf_interface_link_params; + zclient->interface_vrf_update = ospf_interface_vrf_update; zclient->redistribute_route_add = ospf_zebra_read_route; zclient->redistribute_route_del = ospf_zebra_read_route; |
