diff options
Diffstat (limited to 'ospfd/ospf_zebra.c')
| -rw-r--r-- | ospfd/ospf_zebra.c | 68 |
1 files changed, 26 insertions, 42 deletions
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index 1298a17f55..b0ed66da5f 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -55,7 +55,6 @@ 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"); /* Zebra structure to hold current status. */ @@ -1493,12 +1492,8 @@ 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, arg_type; - struct ospf *ospf = NULL; - void **arg = THREAD_ARG(thread); - - ospf = (struct ospf *)arg[0]; - arg_type = (int)(intptr_t)arg[1]; + int type, default_refresh = 0; + struct ospf *ospf = THREAD_ARG(thread); if (ospf == NULL) return 0; @@ -1508,10 +1503,9 @@ 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", - __func__, arg_type, ospf_vrf_id_to_name(ospf->vrf_id), - ospf->vrf_id); + zlog_debug("%s: ospf distribute-list update vrf %s id %d", + __func__, ospf_vrf_id_to_name(ospf->vrf_id), + ospf->vrf_id); } /* foreach all external info. */ @@ -1610,7 +1604,6 @@ 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; } @@ -1619,27 +1612,14 @@ void ospf_distribute_list_update(struct ospf *ospf, int type, unsigned short instance) { 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(ospf, type, instance); - if (!ext || !EXTERNAL_INFO(ext)) { - XFREE(MTYPE_OSPF_DIST_ARGS, args); + if (!ext || !EXTERNAL_INFO(ext)) return; - } - - /* If exists previously invoked thread, then let it continue. */ - 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, args, + /* Set timer. If timer is already started, this call does nothing. */ + thread_add_timer_msec(master, ospf_distribute_list_update_timer, ospf, ospf->min_ls_interval, &ospf->t_distribute_update); } @@ -2122,25 +2102,33 @@ static int ospf_zebra_client_close_notify(ZAPI_CALLBACK_ARGS) return ret; } +static zclient_handler *const ospf_handlers[] = { + [ZEBRA_ROUTER_ID_UPDATE] = ospf_router_id_update_zebra, + [ZEBRA_INTERFACE_ADDRESS_ADD] = ospf_interface_address_add, + [ZEBRA_INTERFACE_ADDRESS_DELETE] = ospf_interface_address_delete, + [ZEBRA_INTERFACE_LINK_PARAMS] = ospf_interface_link_params, + [ZEBRA_INTERFACE_VRF_UPDATE] = ospf_interface_vrf_update, + + [ZEBRA_REDISTRIBUTE_ROUTE_ADD] = ospf_zebra_read_route, + [ZEBRA_REDISTRIBUTE_ROUTE_DEL] = ospf_zebra_read_route, + + [ZEBRA_OPAQUE_MESSAGE] = ospf_opaque_msg_handler, + + [ZEBRA_CLIENT_CLOSE_NOTIFY] = ospf_zebra_client_close_notify, +}; + void ospf_zebra_init(struct thread_master *master, unsigned short instance) { /* Allocate zebra structure. */ - zclient = zclient_new(master, &zclient_options_default); + zclient = zclient_new(master, &zclient_options_default, ospf_handlers, + array_size(ospf_handlers)); zclient_init(zclient, ZEBRA_ROUTE_OSPF, instance, &ospfd_privs); zclient->zebra_connected = ospf_zebra_connected; - zclient->router_id_update = ospf_router_id_update_zebra; - 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; /* Initialize special zclient for synchronous message exchanges. */ struct zclient_options options = zclient_options_default; options.synchronous = true; - zclient_sync = zclient_new(master, &options); + zclient_sync = zclient_new(master, &options, NULL, 0); zclient_sync->sock = -1; zclient_sync->redist_default = ZEBRA_ROUTE_OSPF; zclient_sync->instance = instance; @@ -2155,10 +2143,6 @@ void ospf_zebra_init(struct thread_master *master, unsigned short instance) access_list_delete_hook(ospf_filter_update); prefix_list_add_hook(ospf_prefix_list_update); prefix_list_delete_hook(ospf_prefix_list_update); - - zclient->opaque_msg_handler = ospf_opaque_msg_handler; - - zclient->zebra_client_close_notify = ospf_zebra_client_close_notify; } void ospf_zebra_send_arp(const struct interface *ifp, const struct prefix *p) |
