diff options
Diffstat (limited to 'nhrpd')
-rw-r--r-- | nhrpd/netlink_arp.c | 11 | ||||
-rw-r--r-- | nhrpd/nhrp_cache.c | 13 | ||||
-rw-r--r-- | nhrpd/nhrp_event.c | 20 | ||||
-rw-r--r-- | nhrpd/nhrp_nhs.c | 27 | ||||
-rw-r--r-- | nhrpd/nhrp_packet.c | 4 | ||||
-rw-r--r-- | nhrpd/nhrp_peer.c | 13 | ||||
-rw-r--r-- | nhrpd/nhrp_shortcut.c | 17 | ||||
-rw-r--r-- | nhrpd/resolver.c | 15 | ||||
-rw-r--r-- | nhrpd/vici.c | 17 |
9 files changed, 86 insertions, 51 deletions
diff --git a/nhrpd/netlink_arp.c b/nhrpd/netlink_arp.c index 76419a7ff..2b222e3c5 100644 --- a/nhrpd/netlink_arp.c +++ b/nhrpd/netlink_arp.c @@ -124,7 +124,7 @@ static int netlink_route_recv(struct thread *t) } } - thread_add_read(master, netlink_route_recv, 0, fd); + thread_add_read(master, netlink_route_recv, 0, fd, NULL); return 0; } @@ -214,7 +214,8 @@ static int netlink_log_recv(struct thread *t) } } - THREAD_READ_ON(master, netlink_log_thread, netlink_log_recv, 0, netlink_log_fd); + thread_add_read(master, netlink_log_recv, 0, netlink_log_fd, + &netlink_log_thread); return 0; } @@ -230,7 +231,8 @@ void netlink_set_nflog_group(int nlgroup) if (nlgroup) { netlink_log_fd = znl_open(NETLINK_NETFILTER, 0); netlink_log_register(netlink_log_fd, nlgroup); - THREAD_READ_ON(master, netlink_log_thread, netlink_log_recv, 0, netlink_log_fd); + thread_add_read(master, netlink_log_recv, 0, netlink_log_fd, + &netlink_log_thread); } } @@ -238,7 +240,8 @@ int netlink_init(void) { netlink_req_fd = znl_open(NETLINK_ROUTE, 0); netlink_listen_fd = znl_open(NETLINK_ROUTE, RTMGRP_NEIGH); - thread_add_read(master, netlink_route_recv, 0, netlink_listen_fd); + thread_add_read(master, netlink_route_recv, 0, netlink_listen_fd, + NULL); return 0; } diff --git a/nhrpd/nhrp_cache.c b/nhrpd/nhrp_cache.c index d9094ec33..2d92842b5 100644 --- a/nhrpd/nhrp_cache.c +++ b/nhrpd/nhrp_cache.c @@ -181,11 +181,14 @@ static void nhrp_cache_update_timers(struct nhrp_cache *c) switch (c->cur.type) { case NHRP_CACHE_INVALID: if (!c->t_auth) - THREAD_TIMER_MSEC_ON(master, c->t_timeout, nhrp_cache_do_free, c, 10); + thread_add_timer_msec(master, nhrp_cache_do_free, c, + 10, &c->t_timeout); break; default: if (c->cur.expires) - THREAD_TIMER_ON(master, c->t_timeout, nhrp_cache_do_timeout, c, c->cur.expires - monotime(NULL)); + thread_add_timer(master, nhrp_cache_do_timeout, c, + c->cur.expires - monotime(NULL), + &c->t_timeout); break; } } @@ -239,7 +242,8 @@ static void nhrp_cache_newpeer_notifier(struct notifier_block *n, unsigned long case NOTIFY_PEER_UP: if (nhrp_peer_check(c->new.peer, 1)) { evmgr_notify("authorize-binding", c, nhrp_cache_authorize_binding); - THREAD_TIMER_ON(master, c->t_auth, nhrp_cache_do_auth_timeout, c, 10); + thread_add_timer(master, nhrp_cache_do_auth_timeout, + c, 10, &c->t_auth); } break; case NOTIFY_PEER_DOWN: @@ -294,7 +298,8 @@ int nhrp_cache_update_binding(struct nhrp_cache *c, enum nhrp_cache_type type, i } else { nhrp_peer_notify_add(c->new.peer, &c->newpeer_notifier, nhrp_cache_newpeer_notifier); nhrp_cache_newpeer_notifier(&c->newpeer_notifier, NOTIFY_PEER_UP); - THREAD_TIMER_ON(master, c->t_auth, nhrp_cache_do_auth_timeout, c, 60); + thread_add_timer(master, nhrp_cache_do_auth_timeout, + c, 60, &c->t_auth); } } nhrp_cache_update_timers(c); diff --git a/nhrpd/nhrp_event.c b/nhrpd/nhrp_event.c index aab9ec642..da86c585a 100644 --- a/nhrpd/nhrp_event.c +++ b/nhrpd/nhrp_event.c @@ -40,8 +40,8 @@ static void evmgr_connection_error(struct event_manager *evmgr) close(evmgr->fd); evmgr->fd = -1; if (nhrp_event_socket_path) - THREAD_TIMER_MSEC_ON(master, evmgr->t_reconnect, evmgr_reconnect, - evmgr, 10); + thread_add_timer_msec(master, evmgr_reconnect, evmgr, 10, + &evmgr->t_reconnect); } static void evmgr_recv_message(struct event_manager *evmgr, struct zbuf *zb) @@ -85,7 +85,7 @@ static int evmgr_read(struct thread *t) while (zbuf_may_pull_until(ibuf, "\n\n", &msg)) evmgr_recv_message(evmgr, &msg); - THREAD_READ_ON(master, evmgr->t_read, evmgr_read, evmgr, evmgr->fd); + thread_add_read(master, evmgr_read, evmgr, evmgr->fd, &evmgr->t_read); return 0; } @@ -97,7 +97,8 @@ static int evmgr_write(struct thread *t) evmgr->t_write = NULL; r = zbufq_write(&evmgr->obuf, evmgr->fd); if (r > 0) { - THREAD_WRITE_ON(master, evmgr->t_write, evmgr_write, evmgr, evmgr->fd); + thread_add_write(master, evmgr_write, evmgr, evmgr->fd, + &evmgr->t_write); } else if (r < 0) { evmgr_connection_error(evmgr); } @@ -170,7 +171,8 @@ static void evmgr_submit(struct event_manager *evmgr, struct zbuf *obuf) zbuf_put(obuf, "\n", 1); zbufq_queue(&evmgr->obuf, obuf); if (evmgr->fd >= 0) - THREAD_WRITE_ON(master, evmgr->t_write, evmgr_write, evmgr, evmgr->fd); + thread_add_write(master, evmgr_write, evmgr, evmgr->fd, + &evmgr->t_write); } static int evmgr_reconnect(struct thread *t) @@ -186,13 +188,14 @@ static int evmgr_reconnect(struct thread *t) zlog_warn("%s: failure connecting nhrp-event socket: %s", __PRETTY_FUNCTION__, strerror(errno)); zbufq_reset(&evmgr->obuf); - THREAD_TIMER_ON(master, evmgr->t_reconnect, evmgr_reconnect, evmgr, 10); + thread_add_timer(master, evmgr_reconnect, evmgr, 10, + &evmgr->t_reconnect); return 0; } zlog_info("Connected to Event Manager"); evmgr->fd = fd; - THREAD_READ_ON(master, evmgr->t_read, evmgr_read, evmgr, evmgr->fd); + thread_add_read(master, evmgr_read, evmgr, evmgr->fd, &evmgr->t_read); return 0; } @@ -206,7 +209,8 @@ void evmgr_init(void) evmgr->fd = -1; zbuf_init(&evmgr->ibuf, evmgr->ibuf_data, sizeof(evmgr->ibuf_data), 0); zbufq_init(&evmgr->obuf); - THREAD_TIMER_MSEC_ON(master, evmgr->t_reconnect, evmgr_reconnect, evmgr, 10); + thread_add_timer_msec(master, evmgr_reconnect, evmgr, 10, + &evmgr->t_reconnect); } void evmgr_set_socket(const char *socket) diff --git a/nhrpd/nhrp_nhs.c b/nhrpd/nhrp_nhs.c index 555c0d1de..b926a8d7b 100644 --- a/nhrpd/nhrp_nhs.c +++ b/nhrpd/nhrp_nhs.c @@ -81,7 +81,8 @@ static void nhrp_reg_reply(struct nhrp_reqid *reqid, void *arg) /* RFC 2332 5.2.3 - Registration is recommend to be renewed * every one third of holdtime */ - THREAD_TIMER_ON(master, r->t_register, nhrp_reg_send_req, r, holdtime / 3); + thread_add_timer(master, nhrp_reg_send_req, r, holdtime / 3, + &r->t_register); r->proto_addr = p->dst_proto; c = nhrp_cache_get(ifp, &p->dst_proto, 1); @@ -104,7 +105,8 @@ static int nhrp_reg_timeout(struct thread *t) r->timeout <<= 1; if (r->timeout > 64) r->timeout = 2; - THREAD_TIMER_MSEC_ON(master, r->t_register, nhrp_reg_send_req, r, 10); + thread_add_timer_msec(master, nhrp_reg_send_req, r, 10, + &r->t_register); return 0; } @@ -122,7 +124,8 @@ static void nhrp_reg_peer_notify(struct notifier_block *n, unsigned long cmd) debugf(NHRP_DEBUG_COMMON, "NHS: Flush timer for %s", sockunion2str(&r->peer->vc->remote.nbma, buf, sizeof buf)); THREAD_TIMER_OFF(r->t_register); - THREAD_TIMER_MSEC_ON(master, r->t_register, nhrp_reg_send_req, r, 10); + thread_add_timer_msec(master, nhrp_reg_send_req, r, 10, + &r->t_register); break; } } @@ -145,11 +148,13 @@ static int nhrp_reg_send_req(struct thread *t) if (!nhrp_peer_check(r->peer, 2)) { debugf(NHRP_DEBUG_COMMON, "NHS: Waiting link for %s", sockunion2str(&r->peer->vc->remote.nbma, buf1, sizeof buf1)); - THREAD_TIMER_ON(master, r->t_register, nhrp_reg_send_req, r, 120); + thread_add_timer(master, nhrp_reg_send_req, r, 120, + &r->t_register); return 0; } - THREAD_TIMER_ON(master, r->t_register, nhrp_reg_timeout, r, r->timeout); + thread_add_timer(master, nhrp_reg_timeout, r, r->timeout, + &r->t_register); /* RFC2332 5.2.3 NHC uses it's own address as dst if NHS is unknown */ dst_proto = &nhs->proto_addr; @@ -223,11 +228,13 @@ static void nhrp_nhs_resolve_cb(struct resolver_query *q, int n, union sockunion nhs->t_resolve = NULL; if (n < 0) { /* Failed, retry in a moment */ - THREAD_TIMER_ON(master, nhs->t_resolve, nhrp_nhs_resolve, nhs, 5); + thread_add_timer(master, nhrp_nhs_resolve, nhs, 5, + &nhs->t_resolve); return; } - THREAD_TIMER_ON(master, nhs->t_resolve, nhrp_nhs_resolve, nhs, 2*60*60); + thread_add_timer(master, nhrp_nhs_resolve, nhs, 2 * 60 * 60, + &nhs->t_resolve); list_for_each_entry(reg, &nhs->reglist_head, reglist_entry) reg->mark = 1; @@ -252,7 +259,8 @@ static void nhrp_nhs_resolve_cb(struct resolver_query *q, int n, union sockunion list_init(®->reglist_entry); list_add_tail(®->reglist_entry, &nhs->reglist_head); nhrp_peer_notify_add(reg->peer, ®->peer_notifier, nhrp_reg_peer_notify); - THREAD_TIMER_MSEC_ON(master, reg->t_register, nhrp_reg_send_req, reg, 50); + thread_add_timer_msec(master, nhrp_reg_send_req, reg, 50, + ®->t_register); } list_for_each_entry_safe(reg, regn, &nhs->reglist_head, reglist_entry) { @@ -300,7 +308,8 @@ int nhrp_nhs_add(struct interface *ifp, afi_t afi, union sockunion *proto_addr, .reglist_head = LIST_INITIALIZER(nhs->reglist_head), }; list_add_tail(&nhs->nhslist_entry, &nifp->afi[afi].nhslist_head); - THREAD_TIMER_MSEC_ON(master, nhs->t_resolve, nhrp_nhs_resolve, nhs, 1000); + thread_add_timer_msec(master, nhrp_nhs_resolve, nhs, 1000, + &nhs->t_resolve); return NHRP_OK; } diff --git a/nhrpd/nhrp_packet.c b/nhrpd/nhrp_packet.c index 36dbdfd77..76c5f1517 100644 --- a/nhrpd/nhrp_packet.c +++ b/nhrpd/nhrp_packet.c @@ -269,7 +269,7 @@ static int nhrp_packet_recvraw(struct thread *t) uint8_t addr[64]; size_t len, addrlen; - thread_add_read(master, nhrp_packet_recvraw, 0, fd); + thread_add_read(master, nhrp_packet_recvraw, 0, fd, NULL); zb = zbuf_alloc(1500); if (!zb) return 0; @@ -307,6 +307,6 @@ err: int nhrp_packet_init(void) { - thread_add_read(master, nhrp_packet_recvraw, 0, os_socket()); + thread_add_read(master, nhrp_packet_recvraw, 0, os_socket(), NULL); return 0; } diff --git a/nhrpd/nhrp_peer.c b/nhrpd/nhrp_peer.c index 3cc91a908..5f1e43a60 100644 --- a/nhrpd/nhrp_peer.c +++ b/nhrpd/nhrp_peer.c @@ -79,9 +79,8 @@ static void __nhrp_peer_check(struct nhrp_peer *p) * the up notification a bit to allow things * settle down. This allows IKE to install * SPDs and SAs. */ - THREAD_TIMER_MSEC_ON( - master, p->t_fallback, - nhrp_peer_notify_up, p, 50); + thread_add_timer_msec(master, nhrp_peer_notify_up, p, + 50, &p->t_fallback); } else { nhrp_peer_ref(p); p->online = online; @@ -230,7 +229,8 @@ static int nhrp_peer_request_timeout(struct thread *t) p->fallback_requested = 1; vici_request_vc(nifp->ipsec_fallback_profile, &vc->local.nbma, &vc->remote.nbma, p->prio); - THREAD_TIMER_ON(master, p->t_fallback, nhrp_peer_request_timeout, p, 30); + thread_add_timer(master, nhrp_peer_request_timeout, p, 30, + &p->t_fallback); } else { p->requested = p->fallback_requested = 0; } @@ -258,8 +258,9 @@ int nhrp_peer_check(struct nhrp_peer *p, int establish) p->prio = establish > 1; p->requested = 1; vici_request_vc(nifp->ipsec_profile, &vc->local.nbma, &vc->remote.nbma, p->prio); - THREAD_TIMER_ON(master, p->t_fallback, nhrp_peer_request_timeout, p, - (nifp->ipsec_fallback_profile && !p->prio) ? 15 : 30); + thread_add_timer(master, nhrp_peer_request_timeout, p, + (nifp->ipsec_fallback_profile && !p->prio) ? 15 : 30, + &p->t_fallback); return 0; } diff --git a/nhrpd/nhrp_shortcut.c b/nhrpd/nhrp_shortcut.c index cd33ff028..4a6cbce31 100644 --- a/nhrpd/nhrp_shortcut.c +++ b/nhrpd/nhrp_shortcut.c @@ -38,7 +38,8 @@ static int nhrp_shortcut_do_expire(struct thread *t) struct nhrp_shortcut *s = THREAD_ARG(t); s->t_timer = NULL; - THREAD_TIMER_ON(master, s->t_timer, nhrp_shortcut_do_purge, s, s->holding_time/3); + thread_add_timer(master, nhrp_shortcut_do_purge, s, + s->holding_time / 3, &s->t_timer); s->expiring = 1; nhrp_shortcut_check_use(s); @@ -103,7 +104,8 @@ static void nhrp_shortcut_update_binding(struct nhrp_shortcut *s, enum nhrp_cach if (holding_time) { s->expiring = 0; s->holding_time = holding_time; - THREAD_TIMER_ON(master, s->t_timer, nhrp_shortcut_do_expire, s, 2*holding_time/3); + thread_add_timer(master, nhrp_shortcut_do_expire, s, + 2 * holding_time / 3, &s->t_timer); } } @@ -180,7 +182,7 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid, void *ar nhrp_reqid_free(&nhrp_packet_reqid, &s->reqid); THREAD_OFF(s->t_timer); - THREAD_TIMER_ON(master, s->t_timer, nhrp_shortcut_do_purge, s, 1); + thread_add_timer(master, nhrp_shortcut_do_purge, s, 1, &s->t_timer); if (pp->hdr->type != NHRP_PACKET_RESOLUTION_REPLY) { if (pp->hdr->type == NHRP_PACKET_ERROR_INDICATION && @@ -326,7 +328,8 @@ void nhrp_shortcut_initiate(union sockunion *addr) if (s && s->type != NHRP_CACHE_INCOMPLETE) { s->addr = *addr; THREAD_OFF(s->t_timer); - THREAD_TIMER_ON(master, s->t_timer, nhrp_shortcut_do_purge, s, 30); + thread_add_timer(master, nhrp_shortcut_do_purge, s, 30, + &s->t_timer); nhrp_shortcut_send_resolution_req(s); } } @@ -370,7 +373,8 @@ void nhrp_shortcut_purge(struct nhrp_shortcut *s, int force) if (force) { /* Immediate purge on route with draw or pending shortcut */ - THREAD_TIMER_MSEC_ON(master, s->t_timer, nhrp_shortcut_do_purge, s, 5); + thread_add_timer_msec(master, nhrp_shortcut_do_purge, s, 5, + &s->t_timer); } else { /* Soft expire - force immediate renewal, but purge * in few seconds to make sure stale route is not @@ -379,7 +383,8 @@ void nhrp_shortcut_purge(struct nhrp_shortcut *s, int force) * This allows to keep nhrp route up, and to not * cause temporary rerouting via hubs causing latency * jitter. */ - THREAD_TIMER_MSEC_ON(master, s->t_timer, nhrp_shortcut_do_purge, s, 3000); + thread_add_timer_msec(master, nhrp_shortcut_do_purge, s, 3000, + &s->t_timer); s->expiring = 1; nhrp_shortcut_check_use(s); } diff --git a/nhrpd/resolver.c b/nhrpd/resolver.c index 07bdb735a..c29be3cbf 100644 --- a/nhrpd/resolver.c +++ b/nhrpd/resolver.c @@ -47,7 +47,8 @@ static int resolver_cb_socket_readable(struct thread *t) ares_process_fd(r->channel, fd, ARES_SOCKET_BAD); if (vector_lookup(r->read_threads, fd) == THREAD_RUNNING) { t = NULL; - THREAD_READ_ON(master, t, resolver_cb_socket_readable, r, fd); + thread_add_read(master, resolver_cb_socket_readable, r, fd, + &t); vector_set_index(r->read_threads, fd, t); } resolver_update_timeouts(r); @@ -64,7 +65,8 @@ static int resolver_cb_socket_writable(struct thread *t) ares_process_fd(r->channel, ARES_SOCKET_BAD, fd); if (vector_lookup(r->write_threads, fd) == THREAD_RUNNING) { t = NULL; - THREAD_WRITE_ON(master, t, resolver_cb_socket_writable, r, fd); + thread_add_write(master, resolver_cb_socket_writable, r, fd, + &t); vector_set_index(r->write_threads, fd, t); } resolver_update_timeouts(r); @@ -82,7 +84,8 @@ static void resolver_update_timeouts(struct resolver_state *r) tv = ares_timeout(r->channel, NULL, &tvbuf); if (tv) { unsigned int timeoutms = tv->tv_sec * 1000 + tv->tv_usec / 1000; - THREAD_TIMER_MSEC_ON(master, r->timeout, resolver_cb_timeout, r, timeoutms); + thread_add_timer_msec(master, resolver_cb_timeout, r, + timeoutms, &r->timeout); } } @@ -94,7 +97,8 @@ static void ares_socket_cb(void *data, ares_socket_t fd, int readable, int writa if (readable) { t = vector_lookup_ensure(r->read_threads, fd); if (!t) { - THREAD_READ_ON(master, t, resolver_cb_socket_readable, r, fd); + thread_add_read(master, resolver_cb_socket_readable, + r, fd, &t); vector_set_index(r->read_threads, fd, t); } } else { @@ -110,7 +114,8 @@ static void ares_socket_cb(void *data, ares_socket_t fd, int readable, int writa if (writable) { t = vector_lookup_ensure(r->write_threads, fd); if (!t) { - THREAD_READ_ON(master, t, resolver_cb_socket_writable, r, fd); + thread_add_read(master, resolver_cb_socket_writable, + r, fd, &t); vector_set_index(r->write_threads, fd, t); } } else { diff --git a/nhrpd/vici.c b/nhrpd/vici.c index 5491bacf7..244562d54 100644 --- a/nhrpd/vici.c +++ b/nhrpd/vici.c @@ -73,7 +73,7 @@ static void vici_connection_error(struct vici_conn *vici) close(vici->fd); vici->fd = -1; - THREAD_TIMER_ON(master, vici->t_reconnect, vici_reconnect, vici, 2); + thread_add_timer(master, vici_reconnect, vici, 2, &vici->t_reconnect); } static void vici_parse_message( @@ -324,7 +324,7 @@ static int vici_read(struct thread *t) vici_recv_message(vici, &pktbuf); } while (1); - THREAD_READ_ON(master, vici->t_read, vici_read, vici, vici->fd); + thread_add_read(master, vici_read, vici, vici->fd, &vici->t_read); return 0; } @@ -336,7 +336,8 @@ static int vici_write(struct thread *t) vici->t_write = NULL; r = zbufq_write(&vici->obuf, vici->fd); if (r > 0) { - THREAD_WRITE_ON(master, vici->t_write, vici_write, vici, vici->fd); + thread_add_write(master, vici_write, vici, vici->fd, + &vici->t_write); } else if (r < 0) { vici_connection_error(vici); } @@ -352,7 +353,7 @@ static void vici_submit(struct vici_conn *vici, struct zbuf *obuf) } zbufq_queue(&vici->obuf, obuf); - THREAD_WRITE_ON(master, vici->t_write, vici_write, vici, vici->fd); + thread_add_write(master, vici_write, vici, vici->fd, &vici->t_write); } static void vici_submit_request(struct vici_conn *vici, const char *name, ...) @@ -422,13 +423,14 @@ static int vici_reconnect(struct thread *t) if (fd < 0) { zlog_warn("%s: failure connecting VICI socket: %s", __PRETTY_FUNCTION__, strerror(errno)); - THREAD_TIMER_ON(master, vici->t_reconnect, vici_reconnect, vici, 2); + thread_add_timer(master, vici_reconnect, vici, 2, + &vici->t_reconnect); return 0; } debugf(NHRP_DEBUG_COMMON, "VICI: Connected"); vici->fd = fd; - THREAD_READ_ON(master, vici->t_read, vici_read, vici, vici->fd); + thread_add_read(master, vici_read, vici, vici->fd, &vici->t_read); /* Send event subscribtions */ //vici_register_event(vici, "child-updown"); @@ -451,7 +453,8 @@ void vici_init(void) vici->fd = -1; zbuf_init(&vici->ibuf, vici->ibuf_data, sizeof(vici->ibuf_data), 0); zbufq_init(&vici->obuf); - THREAD_TIMER_MSEC_ON(master, vici->t_reconnect, vici_reconnect, vici, 10); + thread_add_timer_msec(master, vici_reconnect, vici, 10, + &vici->t_reconnect); } void vici_terminate(void) |