diff options
-rw-r--r-- | pimd/pim_assert.c | 2 | ||||
-rw-r--r-- | pimd/pim_ifchannel.c | 31 | ||||
-rw-r--r-- | pimd/pim_igmp.c | 14 | ||||
-rw-r--r-- | pimd/pim_igmpv3.c | 7 | ||||
-rw-r--r-- | pimd/pim_instance.c | 2 | ||||
-rw-r--r-- | pimd/pim_instance.h | 4 | ||||
-rw-r--r-- | pimd/pim_main.c | 4 | ||||
-rw-r--r-- | pimd/pim_mroute.c | 2 | ||||
-rw-r--r-- | pimd/pim_msdp_socket.c | 2 | ||||
-rw-r--r-- | pimd/pim_neighbor.c | 12 | ||||
-rw-r--r-- | pimd/pim_pim.c | 10 | ||||
-rw-r--r-- | pimd/pim_ssmpingd.c | 2 | ||||
-rw-r--r-- | pimd/pim_upstream.c | 18 | ||||
-rw-r--r-- | pimd/pim_zebra.c | 4 | ||||
-rw-r--r-- | pimd/pim_zlookup.c | 6 | ||||
-rw-r--r-- | pimd/pimd.c | 20 | ||||
-rw-r--r-- | pimd/pimd.h | 5 |
17 files changed, 87 insertions, 58 deletions
diff --git a/pimd/pim_assert.c b/pimd/pim_assert.c index 3f863ebec..0a450834e 100644 --- a/pimd/pim_assert.c +++ b/pimd/pim_assert.c @@ -569,7 +569,7 @@ static void pim_assert_timer_set(struct pim_ifchannel *ch, int interval) ch->interface->name); } - thread_add_timer(master, on_assert_timer, ch, interval, + thread_add_timer(router->master, on_assert_timer, ch, interval, &ch->t_ifassert_timer); } diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c index 8f6a9ece5..a96404c8d 100644 --- a/pimd/pim_ifchannel.c +++ b/pimd/pim_ifchannel.c @@ -889,8 +889,8 @@ void pim_ifchannel_join_add(struct interface *ifp, struct in_addr neigh_addr, } if (holdtime != 0xFFFF) { - thread_add_timer(master, on_ifjoin_expiry_timer, ch, holdtime, - &ch->t_ifjoin_expiry_timer); + thread_add_timer(router->master, on_ifjoin_expiry_timer, ch, + holdtime, &ch->t_ifjoin_expiry_timer); } } @@ -945,11 +945,12 @@ void pim_ifchannel_prune(struct interface *ifp, struct in_addr upstream, THREAD_OFF(ch->t_ifjoin_prune_pending_timer); THREAD_OFF(ch->t_ifjoin_expiry_timer); thread_add_timer_msec( - master, on_ifjoin_prune_pending_timer, ch, - jp_override_interval_msec, + router->master, on_ifjoin_prune_pending_timer, + ch, jp_override_interval_msec, &ch->t_ifjoin_prune_pending_timer); - thread_add_timer(master, on_ifjoin_expiry_timer, ch, - holdtime, &ch->t_ifjoin_expiry_timer); + thread_add_timer(router->master, on_ifjoin_expiry_timer, + ch, holdtime, + &ch->t_ifjoin_expiry_timer); pim_upstream_update_join_desired(pim_ifp->pim, ch->upstream); } @@ -973,31 +974,35 @@ void pim_ifchannel_prune(struct interface *ifp, struct in_addr upstream, be taken not to use "ch" afterwards since it would be deleted. */ THREAD_OFF(ch->t_ifjoin_prune_pending_timer); - thread_add_timer_msec(master, on_ifjoin_prune_pending_timer, ch, + thread_add_timer_msec(router->master, + on_ifjoin_prune_pending_timer, ch, jp_override_interval_msec, &ch->t_ifjoin_prune_pending_timer); break; case PIM_IFJOIN_PRUNE: if (source_flags & PIM_ENCODE_RPT_BIT) { THREAD_OFF(ch->t_ifjoin_prune_pending_timer); - thread_add_timer(master, on_ifjoin_expiry_timer, ch, - holdtime, &ch->t_ifjoin_expiry_timer); + thread_add_timer(router->master, on_ifjoin_expiry_timer, + ch, holdtime, + &ch->t_ifjoin_expiry_timer); } break; case PIM_IFJOIN_PRUNE_TMP: if (source_flags & PIM_ENCODE_RPT_BIT) { ch->ifjoin_state = PIM_IFJOIN_PRUNE; THREAD_OFF(ch->t_ifjoin_expiry_timer); - thread_add_timer(master, on_ifjoin_expiry_timer, ch, - holdtime, &ch->t_ifjoin_expiry_timer); + thread_add_timer(router->master, on_ifjoin_expiry_timer, + ch, holdtime, + &ch->t_ifjoin_expiry_timer); } break; case PIM_IFJOIN_PRUNE_PENDING_TMP: if (source_flags & PIM_ENCODE_RPT_BIT) { ch->ifjoin_state = PIM_IFJOIN_PRUNE_PENDING; THREAD_OFF(ch->t_ifjoin_expiry_timer); - thread_add_timer(master, on_ifjoin_expiry_timer, ch, - holdtime, &ch->t_ifjoin_expiry_timer); + thread_add_timer(router->master, on_ifjoin_expiry_timer, + ch, holdtime, + &ch->t_ifjoin_expiry_timer); } break; } diff --git a/pimd/pim_igmp.c b/pimd/pim_igmp.c index 7a19d25a7..cdd156b96 100644 --- a/pimd/pim_igmp.c +++ b/pimd/pim_igmp.c @@ -250,8 +250,8 @@ void pim_igmp_other_querier_timer_on(struct igmp_sock *igmp) other_querier_present_interval_msec % 1000); } - thread_add_timer_msec(master, pim_igmp_other_querier_expire, igmp, - other_querier_present_interval_msec, + thread_add_timer_msec(router->master, pim_igmp_other_querier_expire, + igmp, other_querier_present_interval_msec, &igmp->t_other_querier_timer); } @@ -603,8 +603,8 @@ void pim_igmp_general_query_on(struct igmp_sock *igmp) startup_mode ? "startup" : "non-startup", igmp->fd); } igmp->t_igmp_query_timer = NULL; - thread_add_timer(master, pim_igmp_general_query, igmp, query_interval, - &igmp->t_igmp_query_timer); + thread_add_timer(router->master, pim_igmp_general_query, igmp, + query_interval, &igmp->t_igmp_query_timer); } void pim_igmp_general_query_off(struct igmp_sock *igmp) @@ -940,7 +940,7 @@ static void igmp_read_on(struct igmp_sock *igmp) igmp->fd); } igmp->t_igmp_read = NULL; - thread_add_read(master, pim_igmp_read, igmp, igmp->fd, + thread_add_read(router->master, pim_igmp_read, igmp, igmp->fd, &igmp->t_igmp_read); } @@ -1067,8 +1067,8 @@ void igmp_group_timer_on(struct igmp_group *group, long interval_msec, */ zassert(group->group_filtermode_isexcl); - thread_add_timer_msec(master, igmp_group_timer, group, interval_msec, - &group->t_group_timer); + thread_add_timer_msec(router->master, igmp_group_timer, group, + interval_msec, &group->t_group_timer); } struct igmp_group *find_group_by_addr(struct igmp_sock *igmp, diff --git a/pimd/pim_igmpv3.c b/pimd/pim_igmpv3.c index 430cba76b..b845f54f0 100644 --- a/pimd/pim_igmpv3.c +++ b/pimd/pim_igmpv3.c @@ -214,8 +214,8 @@ static void igmp_source_timer_on(struct igmp_group *group, source_str, group->group_igmp_sock->interface->name); } - thread_add_timer_msec(master, igmp_source_timer, source, interval_msec, - &source->t_source_timer); + thread_add_timer_msec(router->master, igmp_source_timer, source, + interval_msec, &source->t_source_timer); /* RFC 3376: 6.3. IGMPv3 Source-Specific Forwarding Rules @@ -1294,7 +1294,8 @@ static void group_retransmit_timer_on(struct igmp_group *group) igmp->interface->name); } - thread_add_timer_msec(master, igmp_group_retransmit, group, lmqi_msec, + thread_add_timer_msec(router->master, igmp_group_retransmit, group, + lmqi_msec, &group->t_group_query_retransmit_timer); } diff --git a/pimd/pim_instance.c b/pimd/pim_instance.c index b0d7a7b2d..e817bfa55 100644 --- a/pimd/pim_instance.c +++ b/pimd/pim_instance.c @@ -85,7 +85,7 @@ static struct pim_instance *pim_instance_init(struct vrf *vrf) pim->spt.switchover = PIM_SPT_IMMEDIATE; pim->spt.plist = NULL; - pim_msdp_init(pim, master); + pim_msdp_init(pim, router->master); snprintf(hash_name, 64, "PIM %s RPF Hash", vrf->name); pim->rpf_hash = hash_create_size(256, pim_rpf_hash_key, pim_rpf_equal, diff --git a/pimd/pim_instance.h b/pimd/pim_instance.h index b447075e9..3b4acb207 100644 --- a/pimd/pim_instance.h +++ b/pimd/pim_instance.h @@ -42,6 +42,10 @@ enum pim_spt_switchover { PIM_SPT_INFINITY, }; +struct pim_router { + struct thread_master *master; +}; + /* Per VRF PIM DB */ struct pim_instance { vrf_id_t vrf_id; diff --git a/pimd/pim_main.c b/pimd/pim_main.c index 50ebc4003..dc42899c7 100644 --- a/pimd/pim_main.c +++ b/pimd/pim_main.c @@ -109,7 +109,7 @@ int main(int argc, char **argv, char **envp) } } - master = frr_init(); + pim_router_init(); /* * Initializations @@ -157,7 +157,7 @@ int main(int argc, char **argv, char **envp) "PIM_UNEXPECTED_KERNEL_UPCALL: report unexpected kernel upcall"); #endif - frr_run(master); + frr_run(router->master); /* never reached */ return 0; diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c index dc4c4402a..d94e5c48b 100644 --- a/pimd/pim_mroute.c +++ b/pimd/pim_mroute.c @@ -720,7 +720,7 @@ done: static void mroute_read_on(struct pim_instance *pim) { - thread_add_read(master, mroute_read, pim, pim->mroute_socket, + thread_add_read(router->master, mroute_read, pim, pim->mroute_socket, &pim->thread); } diff --git a/pimd/pim_msdp_socket.c b/pimd/pim_msdp_socket.c index 7997d3138..b1f7cfd2c 100644 --- a/pimd/pim_msdp_socket.c +++ b/pimd/pim_msdp_socket.c @@ -79,7 +79,7 @@ static int pim_msdp_sock_accept(struct thread *thread) return -1; } pim->msdp.listener.thread = NULL; - thread_add_read(master, pim_msdp_sock_accept, pim, accept_sock, + thread_add_read(router->master, pim_msdp_sock_accept, pim, accept_sock, &pim->msdp.listener.thread); /* accept client connection. */ diff --git a/pimd/pim_neighbor.c b/pimd/pim_neighbor.c index f40262965..4f06daf31 100644 --- a/pimd/pim_neighbor.c +++ b/pimd/pim_neighbor.c @@ -255,8 +255,8 @@ void pim_neighbor_timer_reset(struct pim_neighbor *neigh, uint16_t holdtime) neigh->interface->name); } - thread_add_timer(master, on_neighbor_timer, neigh, neigh->holdtime, - &neigh->t_expire_timer); + thread_add_timer(router->master, on_neighbor_timer, neigh, + neigh->holdtime, &neigh->t_expire_timer); } static int on_neighbor_jp_timer(struct thread *t) @@ -277,8 +277,8 @@ static int on_neighbor_jp_timer(struct thread *t) rpf.rpf_addr.u.prefix4 = neigh->source_addr; pim_joinprune_send(&rpf, neigh->upstream_jp_agg); - thread_add_timer(master, on_neighbor_jp_timer, neigh, qpim_t_periodic, - &neigh->jp_timer); + thread_add_timer(router->master, on_neighbor_jp_timer, neigh, + qpim_t_periodic, &neigh->jp_timer); return 0; } @@ -286,8 +286,8 @@ static int on_neighbor_jp_timer(struct thread *t) static void pim_neighbor_start_jp_timer(struct pim_neighbor *neigh) { THREAD_TIMER_OFF(neigh->jp_timer); - thread_add_timer(master, on_neighbor_jp_timer, neigh, qpim_t_periodic, - &neigh->jp_timer); + thread_add_timer(router->master, on_neighbor_jp_timer, neigh, + qpim_t_periodic, &neigh->jp_timer); } static struct pim_neighbor * diff --git a/pimd/pim_pim.c b/pimd/pim_pim.c index 0696a680e..bfd98e63f 100644 --- a/pimd/pim_pim.c +++ b/pimd/pim_pim.c @@ -376,8 +376,8 @@ static void pim_sock_read_on(struct interface *ifp) pim_ifp->pim_sock_fd); } pim_ifp->t_pim_sock_read = NULL; - thread_add_read(master, pim_sock_read, ifp, pim_ifp->pim_sock_fd, - &pim_ifp->t_pim_sock_read); + thread_add_read(router->master, pim_sock_read, ifp, + pim_ifp->pim_sock_fd, &pim_ifp->t_pim_sock_read); } static int pim_sock_open(struct interface *ifp) @@ -683,7 +683,7 @@ static void hello_resched(struct interface *ifp) pim_ifp->pim_hello_period, ifp->name); } THREAD_OFF(pim_ifp->t_pim_hello_timer); - thread_add_timer(master, on_pim_hello_send, ifp, + thread_add_timer(router->master, on_pim_hello_send, ifp, pim_ifp->pim_hello_period, &pim_ifp->t_pim_hello_timer); } @@ -796,8 +796,8 @@ void pim_hello_restart_triggered(struct interface *ifp) random_msec, ifp->name); } - thread_add_timer_msec(master, on_pim_hello_send, ifp, random_msec, - &pim_ifp->t_pim_hello_timer); + thread_add_timer_msec(router->master, on_pim_hello_send, ifp, + random_msec, &pim_ifp->t_pim_hello_timer); } int pim_sock_add(struct interface *ifp) diff --git a/pimd/pim_ssmpingd.c b/pimd/pim_ssmpingd.c index c3d958428..17bc375c1 100644 --- a/pimd/pim_ssmpingd.c +++ b/pimd/pim_ssmpingd.c @@ -339,7 +339,7 @@ static int ssmpingd_sock_read(struct thread *t) static void ssmpingd_read_on(struct ssmpingd_sock *ss) { - thread_add_read(master, ssmpingd_sock_read, ss, ss->sock_fd, + thread_add_read(router->master, ssmpingd_sock_read, ss, ss->sock_fd, &ss->t_sock_read); } diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c index cd5b632de..59a7e27cf 100644 --- a/pimd/pim_upstream.c +++ b/pimd/pim_upstream.c @@ -317,8 +317,8 @@ void join_timer_start(struct pim_upstream *up) pim_jp_agg_add_group(nbr->upstream_jp_agg, up, 1); else { THREAD_OFF(up->t_join_timer); - thread_add_timer(master, on_join_timer, up, qpim_t_periodic, - &up->t_join_timer); + thread_add_timer(router->master, on_join_timer, up, + qpim_t_periodic, &up->t_join_timer); } pim_jp_agg_upstream_verification(up, true); } @@ -346,7 +346,7 @@ static void pim_upstream_join_timer_restart_msec(struct pim_upstream *up, } THREAD_OFF(up->t_join_timer); - thread_add_timer_msec(master, on_join_timer, up, interval_msec, + thread_add_timer_msec(router->master, on_join_timer, up, interval_msec, &up->t_join_timer); } @@ -1124,8 +1124,8 @@ void pim_upstream_keep_alive_timer_start(struct pim_upstream *up, uint32_t time) up->sg_str); } THREAD_OFF(up->t_ka_timer); - thread_add_timer(master, pim_upstream_keep_alive_timer, up, time, - &up->t_ka_timer); + thread_add_timer(router->master, pim_upstream_keep_alive_timer, up, + time, &up->t_ka_timer); /* any time keepalive is started against a SG we will have to * re-evaluate our active source database */ @@ -1145,7 +1145,7 @@ static int pim_upstream_msdp_reg_timer(struct thread *t) void pim_upstream_msdp_reg_timer_start(struct pim_upstream *up) { THREAD_OFF(up->t_msdp_reg_timer); - thread_add_timer(master, pim_upstream_msdp_reg_timer, up, + thread_add_timer(router->master, pim_upstream_msdp_reg_timer, up, PIM_MSDP_REG_RXED_PERIOD, &up->t_msdp_reg_timer); pim_msdp_sa_local_update(up); @@ -1406,8 +1406,8 @@ void pim_upstream_start_register_stop_timer(struct pim_upstream *up, "%s: (S,G)=%s Starting upstream register stop timer %d", __PRETTY_FUNCTION__, up->sg_str, time); } - thread_add_timer(master, pim_upstream_register_stop_timer, up, time, - &up->t_rs_timer); + thread_add_timer(router->master, pim_upstream_register_stop_timer, up, + time, &up->t_rs_timer); } int pim_upstream_inherited_olist_decide(struct pim_instance *pim, @@ -1768,7 +1768,7 @@ void pim_upstream_init(struct pim_instance *pim) snprintf(name, 64, "PIM %s Timer Wheel", pim->vrf->name); pim->upstream_sg_wheel = - wheel_init(master, 31000, 100, pim_upstream_hash_key, + wheel_init(router->master, 31000, 100, pim_upstream_hash_key, pim_upstream_sg_running, name); snprintf(name, 64, "PIM %s Upstream Hash", diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c index b205de11e..0524f74e3 100644 --- a/pimd/pim_zebra.c +++ b/pimd/pim_zebra.c @@ -730,7 +730,7 @@ void sched_rpf_cache_refresh(struct pim_instance *pim) qpim_rpf_cache_refresh_delay_msec); } - thread_add_timer_msec(master, on_rpf_cache_refresh, pim, + thread_add_timer_msec(router->master, on_rpf_cache_refresh, pim, qpim_rpf_cache_refresh_delay_msec, &pim->rpf_cache_refresher); } @@ -753,7 +753,7 @@ static void pim_zebra_capabilities(struct zclient_capabilities *cap) void pim_zebra_init(void) { /* Socket for receiving updates from Zebra daemon */ - zclient = zclient_new(master, &zclient_options_default); + zclient = zclient_new(router->master, &zclient_options_default); zclient->zebra_capabilities = pim_zebra_capabilities; zclient->zebra_connected = pim_zebra_connected; diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c index 6b4531308..0ffe313c1 100644 --- a/pimd/pim_zlookup.c +++ b/pimd/pim_zlookup.c @@ -71,7 +71,7 @@ static int zclient_lookup_connect(struct thread *t) /* Schedule connection with delay. */ static void zclient_lookup_sched(struct zclient *zlookup, int delay) { - thread_add_timer(master, zclient_lookup_connect, zlookup, delay, + thread_add_timer(router->master, zclient_lookup_connect, zlookup, delay, &zlookup->t_connect); zlog_notice("%s: zclient lookup connection scheduled for %d seconds", @@ -81,7 +81,7 @@ static void zclient_lookup_sched(struct zclient *zlookup, int delay) /* Schedule connection for now. */ static void zclient_lookup_sched_now(struct zclient *zlookup) { - thread_add_event(master, zclient_lookup_connect, zlookup, 0, + thread_add_event(router->master, zclient_lookup_connect, zlookup, 0, &zlookup->t_connect); zlog_notice("%s: zclient lookup immediate connection scheduled", @@ -120,7 +120,7 @@ void zclient_lookup_free(void) void zclient_lookup_new(void) { - zlookup = zclient_new(master, &zclient_options_default); + zlookup = zclient_new(router->master, &zclient_options_default); if (!zlookup) { flog_err(EC_LIB_ZAPI_SOCKET, "%s: zclient_new() failure", __PRETTY_FUNCTION__); diff --git a/pimd/pimd.c b/pimd/pimd.c index 5d3018b2f..27a7d4973 100644 --- a/pimd/pimd.c +++ b/pimd/pimd.c @@ -47,7 +47,10 @@ const char *const PIM_ALL_ROUTERS = MCAST_ALL_ROUTERS; const char *const PIM_ALL_PIM_ROUTERS = MCAST_ALL_PIM_ROUTERS; const char *const PIM_ALL_IGMP_ROUTERS = MCAST_ALL_IGMP_ROUTERS; -struct thread_master *master = NULL; +DEFINE_MTYPE_STATIC(PIMD, ROUTER, "PIM Router information"); + +struct pim_router *router = NULL; + uint32_t qpim_debugs = 0; int qpim_t_periodic = PIM_DEFAULT_T_PERIODIC; /* Period between Join/Prune Messages */ @@ -82,7 +85,19 @@ static void pim_free() zclient_lookup_free(); } -void pim_init() +void pim_router_init(void) +{ + router = XCALLOC(MTYPE_ROUTER, sizeof(*router)); + + router->master = frr_init(); +} + +void pim_router_terminate(void) +{ + XFREE(MTYPE_ROUTER, router); +} + +void pim_init(void) { if (!inet_aton(PIM_ALL_PIM_ROUTERS, &qpim_all_pim_routers_addr)) { flog_err( @@ -130,5 +145,6 @@ void pim_terminate() zclient_free(zclient); } + pim_router_terminate(); frr_fini(); } diff --git a/pimd/pimd.h b/pimd/pimd.h index 1b11dc3f7..1dd363d2e 100644 --- a/pimd/pimd.h +++ b/pimd/pimd.h @@ -132,7 +132,7 @@ const char *const PIM_ALL_ROUTERS; const char *const PIM_ALL_PIM_ROUTERS; const char *const PIM_ALL_IGMP_ROUTERS; -extern struct thread_master *master; +extern struct pim_router *router; extern struct zebra_privs_t pimd_privs; uint32_t qpim_debugs; struct in_addr qpim_all_pim_routers_addr; @@ -237,6 +237,9 @@ extern int32_t qpim_register_probe_time; #define PIM_DONT_DEBUG_PIM_NHT_RP (qpim_debugs &= ~PIM_MASK_PIM_NHT_RP) #define PIM_DONT_DEBUG_MTRACE (qpim_debugs &= ~PIM_MASK_MTRACE) +void pim_router_init(void); +void pim_router_terminate(void); + void pim_init(void); void pim_terminate(void); |