summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--COMMUNITY.md6
-rw-r--r--bgpd/bgp_attr.c28
-rw-r--r--bgpd/bgp_btoa.c2
-rw-r--r--bgpd/bgp_damp.c9
-rw-r--r--bgpd/bgp_dump.c10
-rw-r--r--bgpd/bgp_fsm.c13
-rw-r--r--bgpd/bgp_fsm.h72
-rw-r--r--bgpd/bgp_network.c7
-rw-r--r--bgpd/bgp_open.c52
-rw-r--r--bgpd/bgp_route.c26
-rw-r--r--bgpd/bgp_routemap.c6
-rw-r--r--bgpd/bgp_updgrp.c7
-rw-r--r--bgpd/bgp_updgrp_adv.c4
-rw-r--r--bgpd/bgp_updgrp_packet.c18
-rw-r--r--bgpd/bgpd.c6
-rw-r--r--bgpd/bgpd.h10
-rw-r--r--bgpd/rfapi/rfapi_import.c13
-rw-r--r--bgpd/rfapi/rfapi_monitor.c10
-rw-r--r--bgpd/rfapi/rfapi_rib.c6
-rw-r--r--bgpd/rfapi/vnc_export_bgp.c6
-rwxr-xr-xconfigure.ac5
-rw-r--r--eigrpd/eigrp_filter.c8
-rw-r--r--eigrpd/eigrp_hello.c17
-rw-r--r--eigrpd/eigrp_interface.c2
-rw-r--r--eigrpd/eigrp_neighbor.c8
-rw-r--r--eigrpd/eigrp_packet.c38
-rw-r--r--eigrpd/eigrp_update.c13
-rw-r--r--eigrpd/eigrp_vty.c4
-rw-r--r--eigrpd/eigrpd.c3
-rw-r--r--isisd/isis_circuit.c35
-rw-r--r--isisd/isis_dr.c58
-rw-r--r--isisd/isis_dynhn.c4
-rw-r--r--isisd/isis_events.c34
-rw-r--r--isisd/isis_lsp.c57
-rw-r--r--isisd/isis_pdu.c53
-rw-r--r--isisd/isis_spf.c12
-rw-r--r--isisd/isisd.c2
-rw-r--r--ldpd/accept.c15
-rw-r--r--ldpd/adjacency.c10
-rw-r--r--ldpd/control.c5
-rw-r--r--ldpd/interface.c5
-rw-r--r--ldpd/lde.c10
-rw-r--r--ldpd/lde_lib.c5
-rw-r--r--ldpd/ldpd.c32
-rw-r--r--ldpd/ldpe.c33
-rw-r--r--ldpd/neighbor.c19
-rw-r--r--ldpd/packet.c14
-rw-r--r--lib/agentx.c10
-rw-r--r--lib/command.c5
-rw-r--r--lib/sigevent.c11
-rw-r--r--lib/smux.c11
-rw-r--r--lib/spf_backoff.c16
-rw-r--r--lib/systemd.c4
-rw-r--r--lib/thread.c126
-rw-r--r--lib/thread.h117
-rw-r--r--lib/vty.c28
-rw-r--r--lib/wheel.c15
-rw-r--r--lib/workqueue.c5
-rw-r--r--lib/zclient.c25
-rw-r--r--nhrpd/netlink_arp.c11
-rw-r--r--nhrpd/nhrp_cache.c13
-rw-r--r--nhrpd/nhrp_event.c20
-rw-r--r--nhrpd/nhrp_nhs.c27
-rw-r--r--nhrpd/nhrp_packet.c4
-rw-r--r--nhrpd/nhrp_peer.c13
-rw-r--r--nhrpd/nhrp_shortcut.c17
-rw-r--r--nhrpd/resolver.c15
-rw-r--r--nhrpd/vici.c17
-rw-r--r--ospf6d/ospf6_bfd.c2
-rw-r--r--ospf6d/ospf6_flood.c69
-rw-r--r--ospf6d/ospf6_interface.c40
-rw-r--r--ospf6d/ospf6_intra.h34
-rw-r--r--ospf6d/ospf6_lsa.c6
-rw-r--r--ospf6d/ospf6_message.c129
-rw-r--r--ospf6d/ospf6_neighbor.c40
-rw-r--r--ospf6d/ospf6_spf.c5
-rw-r--r--ospf6d/ospf6_top.c6
-rw-r--r--ospf6d/ospf6d.c2
-rw-r--r--ospfclient/ospfclient.c10
-rw-r--r--ospfd/ospf_abr.c5
-rw-r--r--ospfd/ospf_apiserver.c26
-rw-r--r--ospfd/ospf_ase.c5
-rw-r--r--ospfd/ospf_flood.c1
-rw-r--r--ospfd/ospf_ism.h35
-rw-r--r--ospfd/ospf_lsa.c9
-rw-r--r--ospfd/ospf_nsm.h8
-rw-r--r--ospfd/ospf_opaque.c21
-rw-r--r--ospfd/ospf_packet.c28
-rw-r--r--ospfd/ospf_spf.c5
-rw-r--r--ospfd/ospf_te.c4
-rw-r--r--ospfd/ospf_zebra.c8
-rw-r--r--ospfd/ospfd.c37
-rw-r--r--ospfd/ospfd.h24
-rw-r--r--pimd/pim_assert.c5
-rw-r--r--pimd/pim_ifchannel.c37
-rw-r--r--pimd/pim_igmp.c18
-rw-r--r--pimd/pim_igmpv3.c10
-rw-r--r--pimd/pim_mroute.c4
-rw-r--r--pimd/pim_msdp.c20
-rw-r--r--pimd/pim_msdp.h7
-rw-r--r--pimd/pim_msdp_socket.c9
-rw-r--r--pimd/pim_neighbor.c15
-rw-r--r--pimd/pim_pim.c14
-rw-r--r--pimd/pim_ssmpingd.c4
-rw-r--r--pimd/pim_upstream.c25
-rw-r--r--pimd/pim_zebra.c6
-rw-r--r--pimd/pim_zlookup.c10
-rw-r--r--ripd/rip_interface.c5
-rw-r--r--ripd/rip_peer.c5
-rw-r--r--ripd/ripd.c21
-rw-r--r--ripd/ripd.h6
-rw-r--r--ripngd/ripng_interface.c5
-rw-r--r--ripngd/ripng_peer.c5
-rw-r--r--ripngd/ripngd.c31
-rw-r--r--ripngd/ripngd.h6
-rw-r--r--tests/helpers/c/main.c4
-rw-r--r--tests/lib/test_heavy_thread.c4
-rw-r--r--tests/lib/test_timer_correctness.c4
-rw-r--r--tests/lib/test_timer_performance.c11
-rw-r--r--tools/.gitignore3
-rw-r--r--tools/permutations.c5
-rw-r--r--vtysh/vtysh.c2
-rw-r--r--watchfrr/watchfrr.c71
-rw-r--r--zebra/debug.c10
-rw-r--r--zebra/irdp_interface.c7
-rw-r--r--zebra/irdp_main.c14
-rw-r--r--zebra/irdp_packet.c3
-rw-r--r--zebra/kernel_netlink.c14
-rw-r--r--zebra/kernel_socket.c4
-rw-r--r--zebra/label_manager.c6
-rw-r--r--zebra/rtadv.c19
-rw-r--r--zebra/zebra_fpm.c44
-rw-r--r--zebra/zebra_mpls.c50
-rw-r--r--zebra/zebra_mpls.h2
-rw-r--r--zebra/zebra_mpls_null.c2
-rw-r--r--zebra/zebra_ptm.c59
-rw-r--r--zebra/zebra_routemap.c9
-rw-r--r--zebra/zebra_vty.c166
-rw-r--r--zebra/zserv.c23
139 files changed, 1454 insertions, 1231 deletions
diff --git a/COMMUNITY.md b/COMMUNITY.md
index 704c47a95e..0eeb93403e 100644
--- a/COMMUNITY.md
+++ b/COMMUNITY.md
@@ -132,6 +132,12 @@ Linux Foundation
website](http://www.linuxfoundation.org/content/how-participate-linux-community-0)
to be a helpful resource.
+### Code submission - What do I submit my changes against?
+
+We've documented where we would like to have the different fixes applied at
+https://github.com/FRRouting/frr/wiki/Where-Do-I-create-a-Pull-Request-against%3F
+If you are unsure where your submission goes, look at that document or ask
+the question of a maintainer.
### Code submission - Github Pull Request (Strongly Preferred)
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index b2789cd47d..b97ba61c95 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -2847,8 +2847,9 @@ bgp_packet_mpattr_start (struct stream *s, afi_t afi, safi_t safi, afi_t nh_afi,
stream_putw (s, pkt_afi); /* AFI */
stream_putc (s, pkt_safi); /* SAFI */
-
- if (nh_afi == AFI_MAX)
+ if (afi == AFI_L2VPN)
+ nh_afi = AFI_L2VPN;
+ else if (nh_afi == AFI_MAX)
nh_afi = BGP_NEXTHOP_AFI_FROM_NHLEN(attr->extra->mp_nexthop_len);
/* Nexthop */
@@ -2890,10 +2891,15 @@ bgp_packet_mpattr_start (struct stream *s, afi_t afi, safi_t safi, afi_t nh_afi,
assert (attr->extra);
bpacket_attr_vec_arr_set_vec (vecarr, BGP_ATTR_VEC_NH, s, attr);
- stream_putc (s, attre->mp_nexthop_len);
- stream_put (s, &attre->mp_nexthop_global, IPV6_MAX_BYTELEN);
- if (attre->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
+
+ if (attre->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) {
+ stream_putc (s, BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL);
+ stream_put (s, &attre->mp_nexthop_global, IPV6_MAX_BYTELEN);
stream_put (s, &attre->mp_nexthop_local, IPV6_MAX_BYTELEN);
+ } else {
+ stream_putc (s, IPV6_MAX_BYTELEN);
+ stream_put (s, &attre->mp_nexthop_global, IPV6_MAX_BYTELEN);
+ }
}
break;
case SAFI_MPLS_VPN:
@@ -3137,14 +3143,14 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer,
cp = stream_get_endp (s);
if (p && !((afi == AFI_IP && safi == SAFI_UNICAST) &&
- !peer_cap_enhe(peer)))
+ !peer_cap_enhe(peer, afi, safi)))
{
size_t mpattrlen_pos = 0;
mpattrlen_pos = bgp_packet_mpattr_start(s, afi, safi,
- (peer_cap_enhe(peer) ? AFI_IP6 :
- AFI_MAX), /* get from NH */
- vecarr, attr);
+ (peer_cap_enhe(peer, afi, safi) ? AFI_IP6 :
+ AFI_MAX), /* get from NH */
+ vecarr, attr);
bgp_packet_mpattr_prefix(s, afi, safi, p, prd, tag,
addpath_encode, addpath_tx_id, attr);
bgp_packet_mpattr_end(s, mpattrlen_pos);
@@ -3220,7 +3226,7 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer,
send_as4_path = 1; /* we'll do this later, at the correct place */
/* Nexthop attribute. */
- if (afi == AFI_IP && safi == SAFI_UNICAST && !peer_cap_enhe(peer))
+ if (afi == AFI_IP && safi == SAFI_UNICAST && !peer_cap_enhe(peer, afi, safi))
{
if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP))
{
@@ -3230,7 +3236,7 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer,
stream_putc (s, 4);
stream_put_ipv4 (s, attr->nexthop.s_addr);
}
- else if (peer_cap_enhe(from))
+ else if (peer_cap_enhe(from, afi, safi))
{
/*
* Likely this is the case when an IPv4 prefix was received with
diff --git a/bgpd/bgp_btoa.c b/bgpd/bgp_btoa.c
index 37bef9b85d..d3162a4ea5 100644
--- a/bgpd/bgp_btoa.c
+++ b/bgpd/bgp_btoa.c
@@ -238,7 +238,7 @@ main (int argc, char **argv)
printf ("len: %zd\n", len);
- ret = fread (s->data + 12, len, 1, fp);
+ fread (s->data + 12, len, 1, fp);
if (feof (fp))
{
printf ("ENDOF FILE 2\n");
diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c
index 168dbd0122..114e641ebd 100644
--- a/bgpd/bgp_damp.c
+++ b/bgpd/bgp_damp.c
@@ -116,8 +116,8 @@ bgp_reuse_timer (struct thread *t)
time_t t_now, t_diff;
damp->t_reuse = NULL;
- damp->t_reuse =
- thread_add_timer (bm->master, bgp_reuse_timer, NULL, DELTA_REUSE);
+ thread_add_timer(bm->master, bgp_reuse_timer, NULL, DELTA_REUSE,
+ &damp->t_reuse);
t_now = bgp_clock ();
@@ -447,9 +447,8 @@ bgp_damp_enable (struct bgp *bgp, afi_t afi, safi_t safi, time_t half,
bgp_damp_parameter_set (half, reuse, suppress, max);
/* Register reuse timer. */
- if (! damp->t_reuse)
- damp->t_reuse =
- thread_add_timer (bm->master, bgp_reuse_timer, NULL, DELTA_REUSE);
+ thread_add_timer(bm->master, bgp_reuse_timer, NULL, DELTA_REUSE,
+ &damp->t_reuse);
return 0;
}
diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c
index 84ece48850..10ddf1660c 100644
--- a/bgpd/bgp_dump.c
+++ b/bgpd/bgp_dump.c
@@ -171,14 +171,16 @@ bgp_dump_interval_add (struct bgp_dump *bgp_dump, int interval)
secs_into_day = tm->tm_sec + 60*tm->tm_min + 60*60*tm->tm_hour;
interval = interval - secs_into_day % interval; /* always > 0 */
}
- bgp_dump->t_interval = thread_add_timer (bm->master, bgp_dump_interval_func,
- bgp_dump, interval);
+ bgp_dump->t_interval = NULL;
+ thread_add_timer(bm->master, bgp_dump_interval_func, bgp_dump, interval,
+ &bgp_dump->t_interval);
}
else
{
/* One-off dump: execute immediately, don't affect any scheduled dumps */
- bgp_dump->t_interval = thread_add_event (bm->master, bgp_dump_interval_func,
- bgp_dump, 0);
+ bgp_dump->t_interval = NULL;
+ thread_add_event(bm->master, bgp_dump_interval_func, bgp_dump, 0,
+ &bgp_dump->t_interval);
}
return 0;
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index b178884824..2d0349b6a4 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -808,9 +808,8 @@ bgp_maxmed_onstartup_begin (struct bgp *bgp)
zlog_info ("Begin maxmed onstartup mode - timer %d seconds",
bgp->v_maxmed_onstartup);
- THREAD_TIMER_ON (bm->master, bgp->t_maxmed_onstartup,
- bgp_maxmed_onstartup_timer,
- bgp, bgp->v_maxmed_onstartup);
+ thread_add_timer(bm->master, bgp_maxmed_onstartup_timer, bgp,
+ bgp->v_maxmed_onstartup, &bgp->t_maxmed_onstartup);
if (!bgp->v_maxmed_admin)
{
@@ -877,12 +876,12 @@ bgp_update_delay_begin (struct bgp *bgp)
peer->update_delay_over = 0;
/* Start the update-delay timer */
- THREAD_TIMER_ON (bm->master, bgp->t_update_delay, bgp_update_delay_timer,
- bgp, bgp->v_update_delay);
+ thread_add_timer(bm->master, bgp_update_delay_timer, bgp,
+ bgp->v_update_delay, &bgp->t_update_delay);
if (bgp->v_establish_wait != bgp->v_update_delay)
- THREAD_TIMER_ON (bm->master, bgp->t_establish_wait, bgp_establish_wait_timer,
- bgp, bgp->v_establish_wait);
+ thread_add_timer(bm->master, bgp_establish_wait_timer, bgp,
+ bgp->v_establish_wait, &bgp->t_establish_wait);
quagga_timestamp(3, bgp->update_delay_begin_time,
sizeof(bgp->update_delay_begin_time));
diff --git a/bgpd/bgp_fsm.h b/bgpd/bgp_fsm.h
index 4d0b48f529..67ba387eb9 100644
--- a/bgpd/bgp_fsm.h
+++ b/bgpd/bgp_fsm.h
@@ -23,58 +23,58 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#define _QUAGGA_BGP_FSM_H
/* Macro for BGP read, write and timer thread. */
-#define BGP_READ_ON(T,F,V) \
- do { \
- if (!(T) && (peer->status != Deleted)) \
- THREAD_READ_ON(bm->master,T,F,peer,V); \
+#define BGP_READ_ON(T,F,V) \
+ do { \
+ if ((peer->status != Deleted)) \
+ thread_add_read (bm->master,(F),peer,(V),&(T)); \
} while (0)
-#define BGP_READ_OFF(T) \
- do { \
- if (T) \
- THREAD_READ_OFF(T); \
+#define BGP_READ_OFF(T) \
+ do { \
+ if (T) \
+ THREAD_READ_OFF(T); \
} while (0)
-#define BGP_WRITE_ON(T,F,V) \
- do { \
- if (!(T) && (peer->status != Deleted)) \
- THREAD_WRITE_ON(bm->master,(T),(F),peer,(V)); \
+#define BGP_WRITE_ON(T,F,V) \
+ do { \
+ if ((peer)->status != Deleted) \
+ thread_add_write (bm->master,(F),(peer),(V),&(T)); \
} while (0)
-#define BGP_PEER_WRITE_ON(T,F,V, peer) \
- do { \
- if (!(T) && ((peer)->status != Deleted)) \
- THREAD_WRITE_ON(bm->master,(T),(F),(peer),(V)); \
+#define BGP_PEER_WRITE_ON(T,F,V, peer) \
+ do { \
+ if ((peer)->status != Deleted) \
+ thread_add_write (bm->master,(F),(peer),(V),&(T)); \
} while (0)
-#define BGP_WRITE_OFF(T) \
- do { \
- if (T) \
- THREAD_WRITE_OFF(T); \
+#define BGP_WRITE_OFF(T) \
+ do { \
+ if (T) \
+ THREAD_WRITE_OFF(T); \
} while (0)
-#define BGP_TIMER_ON(T,F,V) \
- do { \
- if (!(T) && (peer->status != Deleted)) \
- THREAD_TIMER_ON(bm->master,(T),(F),peer,(V)); \
+#define BGP_TIMER_ON(T,F,V) \
+ do { \
+ if ((peer->status != Deleted)) \
+ thread_add_timer (bm->master,(F),peer,(V),&(T)); \
} while (0)
-#define BGP_TIMER_OFF(T) \
- do { \
- if (T) \
- THREAD_TIMER_OFF(T); \
+#define BGP_TIMER_OFF(T) \
+ do { \
+ if (T) \
+ THREAD_TIMER_OFF(T); \
} while (0)
-#define BGP_EVENT_ADD(P,E) \
- do { \
- if ((P)->status != Deleted) \
- thread_add_event (bm->master, bgp_event, (P), (E)); \
+#define BGP_EVENT_ADD(P,E) \
+ do { \
+ if ((P)->status != Deleted) \
+ thread_add_event (bm->master, bgp_event, (P), (E), NULL); \
} while (0)
-#define BGP_EVENT_FLUSH(P) \
- do { \
- assert (peer); \
- thread_cancel_event (bm->master, (P)); \
+#define BGP_EVENT_FLUSH(P) \
+ do { \
+ assert (peer); \
+ thread_cancel_event (bm->master, (P)); \
} while (0)
#define BGP_MSEC_JITTER 10
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index 46ae882b2e..b64d902d88 100644
--- a/bgpd/bgp_network.c
+++ b/bgpd/bgp_network.c
@@ -297,7 +297,9 @@ bgp_accept (struct thread *thread)
zlog_err ("accept_sock is nevative value %d", accept_sock);
return -1;
}
- listener->thread = thread_add_read (bm->master, bgp_accept, listener, accept_sock);
+ listener->thread = NULL;
+ thread_add_read(bm->master, bgp_accept, listener, accept_sock,
+ &listener->thread);
/* Accept client connection. */
bgp_sock = sockunion_accept (accept_sock, &su);
@@ -704,7 +706,8 @@ bgp_listener (int sock, struct sockaddr *sa, socklen_t salen)
listener = XMALLOC (MTYPE_BGP_LISTENER, sizeof(*listener));
listener->fd = sock;
memcpy(&listener->su, sa, salen);
- listener->thread = thread_add_read (bm->master, bgp_accept, listener, sock);
+ listener->thread = NULL;
+ thread_add_read(bm->master, bgp_accept, listener, sock, &listener->thread);
listnode_add (bm->listen_sockets, listener);
return 0;
diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c
index 83fc3fe977..3ad6be1a3f 100644
--- a/bgpd/bgp_open.c
+++ b/bgpd/bgp_open.c
@@ -594,11 +594,11 @@ bgp_capability_enhe (struct peer *peer, struct capability_header *hdr)
/* RFC 5549 specifies use of this capability only for IPv4 AFI, with
* the Nexthop AFI being IPv6. A future spec may introduce other
* possibilities, so we ignore other values with a log. Also, only
- * Unicast SAFI is currently supported (and expected).
+ * SAFI_UNICAST and SAFI_LABELED_UNICAST are currently supported (and expected).
*/
nh_afi = afi_iana2int (pkt_nh_afi);
- if (afi != AFI_IP || safi != SAFI_UNICAST || nh_afi != AFI_IP6)
+ if (afi != AFI_IP || nh_afi != AFI_IP6 || !(safi == SAFI_UNICAST || safi == SAFI_LABELED_UNICAST))
{
zlog_warn ("%s Unexpected afi/safi/next-hop afi: %u/%u/%u "
"in Extended Next-hop capability, ignoring",
@@ -1288,32 +1288,34 @@ bgp_open_capability (struct stream *s, struct peer *peer)
stream_putw (s, pkt_afi);
stream_putc (s, 0);
stream_putc (s, pkt_safi);
+
+ /* Extended nexthop capability - currently supporting RFC-5549 for
+ * Link-Local peering only
+ */
+ if (CHECK_FLAG (peer->flags, PEER_FLAG_CAPABILITY_ENHE) &&
+ peer->su.sa.sa_family == AF_INET6 &&
+ IN6_IS_ADDR_LINKLOCAL(&peer->su.sin6.sin6_addr) &&
+ afi == AFI_IP &&
+ (safi == SAFI_UNICAST || safi == SAFI_LABELED_UNICAST))
+ {
+ /* RFC 5549 Extended Next Hop Encoding */
+ SET_FLAG (peer->cap, PEER_CAP_ENHE_ADV);
+ stream_putc (s, BGP_OPEN_OPT_CAP);
+ stream_putc (s, CAPABILITY_CODE_ENHE_LEN + 2);
+ stream_putc (s, CAPABILITY_CODE_ENHE);
+ stream_putc (s, CAPABILITY_CODE_ENHE_LEN);
+
+ SET_FLAG (peer->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_ADV);
+ stream_putw (s, pkt_afi);
+ stream_putw (s, pkt_safi);
+ stream_putw (s, afi_int2iana(AFI_IP6));
+
+ if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ENHE_AF_RCV))
+ SET_FLAG (peer->af_cap[afi][safi], PEER_CAP_ENHE_AF_NEGO);
+ }
}
}
- /* Extended nexthop capability - currently supporting RFC-5549 for
- * Link-Local peering only
- */
- if (CHECK_FLAG (peer->flags, PEER_FLAG_CAPABILITY_ENHE) &&
- peer->su.sa.sa_family == AF_INET6 &&
- IN6_IS_ADDR_LINKLOCAL(&peer->su.sin6.sin6_addr))
- {
- /* RFC 5549 Extended Next Hop Encoding */
- SET_FLAG (peer->cap, PEER_CAP_ENHE_ADV);
- stream_putc (s, BGP_OPEN_OPT_CAP);
- stream_putc (s, CAPABILITY_CODE_ENHE_LEN + 2);
- stream_putc (s, CAPABILITY_CODE_ENHE);
- stream_putc (s, CAPABILITY_CODE_ENHE_LEN);
- /* Currently supporting for SAFI_UNICAST only */
- SET_FLAG (peer->af_cap[AFI_IP][SAFI_UNICAST], PEER_CAP_ENHE_AF_ADV);
- stream_putw (s, AFI_IP);
- stream_putw (s, SAFI_UNICAST);
- stream_putw (s, AFI_IP6);
-
- if (CHECK_FLAG (peer->af_cap[AFI_IP][SAFI_UNICAST], PEER_CAP_ENHE_AF_RCV))
- SET_FLAG (peer->af_cap[AFI_IP][SAFI_UNICAST], PEER_CAP_ENHE_AF_NEGO);
- }
-
/* Route refresh. */
SET_FLAG (peer->cap, PEER_CAP_REFRESH_ADV);
stream_putc (s, BGP_OPEN_OPT_CAP);
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index f327e34f2a..24a68778dc 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -1456,7 +1456,7 @@ subgroup_announce_check (struct bgp_node *rn, struct bgp_info *ri,
#define NEXTHOP_IS_V6 (\
(safi != SAFI_ENCAP && safi != SAFI_MPLS_VPN &&\
- (p->family == AF_INET6 || peer_cap_enhe(peer))) || \
+ (p->family == AF_INET6 || peer_cap_enhe(peer, AFI_IP6, safi))) || \
((safi == SAFI_ENCAP || safi == SAFI_MPLS_VPN) &&\
attr->extra->mp_nexthop_len >= IPV6_MAX_BYTELEN))
@@ -1558,7 +1558,7 @@ subgroup_announce_check (struct bgp_node *rn, struct bgp_info *ri,
if (!reflect ||
CHECK_FLAG (peer->af_flags[afi][safi],
PEER_FLAG_FORCE_NEXTHOP_SELF))
- subgroup_announce_reset_nhop ((peer_cap_enhe(peer) ?
+ subgroup_announce_reset_nhop ((peer_cap_enhe(peer, afi, safi) ?
AF_INET6 : p->family), attr);
}
else if (peer->sort == BGP_PEER_EBGP)
@@ -1573,14 +1573,14 @@ subgroup_announce_check (struct bgp_node *rn, struct bgp_info *ri,
break;
}
if (!paf)
- subgroup_announce_reset_nhop ((peer_cap_enhe(peer) ? AF_INET6 : p->family), attr);
+ subgroup_announce_reset_nhop ((peer_cap_enhe(peer, afi, safi) ? AF_INET6 : p->family), attr);
}
/* If IPv6/MP and nexthop does not have any override and happens to
* be a link-local address, reset it so that we don't pass along the
* source's link-local IPv6 address to recipients who may not be on
* the same interface.
*/
- if (p->family == AF_INET6 || peer_cap_enhe(peer))
+ if (p->family == AF_INET6 || peer_cap_enhe(peer, afi, safi))
{
if (IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_global))
subgroup_announce_reset_nhop (AF_INET6, attr);
@@ -2017,9 +2017,10 @@ bgp_process_main (struct work_queue *wq, void *data)
if (!bgp->t_rmap_def_originate_eval)
{
bgp_lock (bgp);
- THREAD_TIMER_ON(bm->master, bgp->t_rmap_def_originate_eval,
- update_group_refresh_default_originate_route_map,
- bgp, RMAP_DEFAULT_ORIGINATE_EVAL_TIMER);
+ thread_add_timer(bm->master,
+ update_group_refresh_default_originate_route_map,
+ bgp, RMAP_DEFAULT_ORIGINATE_EVAL_TIMER,
+ &bgp->t_rmap_def_originate_eval);
}
}
@@ -3088,9 +3089,6 @@ bgp_announce_route_timer_expired (struct thread *t)
paf = THREAD_ARG (t);
peer = paf->peer;
- assert (paf->t_announce_route);
- paf->t_announce_route = NULL;
-
if (peer->status != Established)
return 0;
@@ -3130,11 +3128,9 @@ bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi)
* multiple peers and the announcement doesn't happen in the
* vty context.
*/
- THREAD_TIMER_MSEC_ON (bm->master, paf->t_announce_route,
- bgp_announce_route_timer_expired, paf,
- (subgrp->peer_count == 1) ?
- BGP_ANNOUNCE_ROUTE_SHORT_DELAY_MS :
- BGP_ANNOUNCE_ROUTE_DELAY_MS);
+ thread_add_timer_msec(bm->master, bgp_announce_route_timer_expired, paf,
+ (subgrp->peer_count == 1) ? BGP_ANNOUNCE_ROUTE_SHORT_DELAY_MS : BGP_ANNOUNCE_ROUTE_DELAY_MS,
+ &paf->t_announce_route);
}
/*
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index 9b3a6a513a..4563ec85f6 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -3176,9 +3176,9 @@ bgp_route_map_mark_update (const char *rmap_name)
/* rmap_update_timer of 0 means don't do route updates */
if (bm->rmap_update_timer)
{
- bm->t_rmap_update =
- thread_add_timer(bm->master, bgp_route_map_update_timer, NULL,
- bm->rmap_update_timer);
+ bm->t_rmap_update = NULL;
+ thread_add_timer(bm->master, bgp_route_map_update_timer, NULL, bm->rmap_update_timer,
+ &bm->t_rmap_update);
/* Signal the groups that a route-map update event has started */
for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c
index 9e5ec4b26d..09089a3b3f 100644
--- a/bgpd/bgp_updgrp.c
+++ b/bgpd/bgp_updgrp.c
@@ -1169,10 +1169,9 @@ update_subgroup_trigger_merge_check (struct update_subgroup *subgrp,
if (!force && !update_subgroup_ready_for_merge (subgrp))
return 0;
- subgrp->t_merge_check =
- thread_add_background (bm->master,
- update_subgroup_merge_check_thread_cb,
- subgrp, 0);
+ subgrp->t_merge_check = NULL;
+ thread_add_background(bm->master, update_subgroup_merge_check_thread_cb, subgrp, 0,
+ &subgrp->t_merge_check);
SUBGRP_INCR_STAT (subgrp, merge_checks_triggered);
diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c
index ac5f77474c..3ed2958254 100644
--- a/bgpd/bgp_updgrp_adv.c
+++ b/bgpd/bgp_updgrp_adv.c
@@ -828,8 +828,8 @@ subgroup_announce_all (struct update_subgroup *subgrp)
*/
if (!subgrp->t_coalesce)
{
- THREAD_TIMER_MSEC_ON (bm->master, subgrp->t_coalesce, subgroup_coalesce_timer,
- subgrp, subgrp->v_coalesce);
+ thread_add_timer_msec(bm->master, subgroup_coalesce_timer, subgrp,
+ subgrp->v_coalesce, &subgrp->t_coalesce);
}
}
diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c
index 9be1a50db7..459cf707d0 100644
--- a/bgpd/bgp_updgrp_packet.c
+++ b/bgpd/bgp_updgrp_packet.c
@@ -427,7 +427,7 @@ bpacket_reformat_for_peer (struct bpacket *pkt, struct peer_af *paf)
if (paf->afi == AFI_IP || paf->afi == AFI_IP6)
{
nhafi = BGP_NEXTHOP_AFI_FROM_NHLEN(nhlen);
- if (peer_cap_enhe(peer))
+ if (peer_cap_enhe(peer, paf->afi, paf->safi))
nhafi = AFI_IP6;
if (paf->safi == SAFI_MPLS_VPN && /* if VPN && not global */
nhlen != BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL)
@@ -754,7 +754,7 @@ subgroup_update_packet (struct update_subgroup *subgrp)
}
if ((afi == AFI_IP && safi == SAFI_UNICAST) &&
- !peer_cap_enhe(peer))
+ !peer_cap_enhe(peer, afi, safi))
stream_put_prefix_addpath (s, &rn->p, addpath_encode, addpath_tx_id);
else
{
@@ -769,9 +769,9 @@ subgroup_update_packet (struct update_subgroup *subgrp)
if (stream_empty (snlri))
mpattrlen_pos = bgp_packet_mpattr_start (snlri, afi, safi,
- (peer_cap_enhe(peer) ? AFI_IP6 :
- AFI_MAX), /* get from NH */
- &vecarr, adv->baa->attr);
+ (peer_cap_enhe(peer, afi, safi) ? AFI_IP6 :
+ AFI_MAX), /* get from NH */
+ &vecarr, adv->baa->attr);
bgp_packet_mpattr_prefix (snlri, afi, safi, &rn->p, prd,
tag, addpath_encode, addpath_tx_id, adv->baa->attr);
@@ -923,7 +923,7 @@ subgroup_withdraw_packet (struct update_subgroup *subgrp)
first_time = 0;
if (afi == AFI_IP && safi == SAFI_UNICAST &&
- !peer_cap_enhe(peer))
+ !peer_cap_enhe(peer, afi, safi))
stream_put_prefix_addpath (s, &rn->p, addpath_encode, addpath_tx_id);
else
{
@@ -975,7 +975,7 @@ subgroup_withdraw_packet (struct update_subgroup *subgrp)
if (!stream_empty (s))
{
if (afi == AFI_IP && safi == SAFI_UNICAST &&
- !peer_cap_enhe(peer))
+ !peer_cap_enhe(peer, afi, safi))
{
unfeasible_len
= stream_get_endp (s) - BGP_HEADER_SIZE - BGP_UNFEASIBLE_LEN;
@@ -1072,7 +1072,7 @@ subgroup_default_update_packet (struct update_subgroup *subgrp,
/* NLRI set. */
if (p.family == AF_INET && safi == SAFI_UNICAST &&
- !peer_cap_enhe(peer))
+ !peer_cap_enhe(peer, afi, safi))
stream_put_prefix_addpath (s, &p, addpath_encode, BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE);
/* Set size. */
@@ -1133,7 +1133,7 @@ subgroup_default_withdraw_packet (struct update_subgroup *subgrp)
/* Withdrawn Routes. */
if (p.family == AF_INET && safi == SAFI_UNICAST &&
- !peer_cap_enhe(peer))
+ !peer_cap_enhe(peer, afi, safi))
{
stream_put_prefix_addpath (s, &p, addpath_encode,
BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE);
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 955ed2ab5e..2c04f79478 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -2970,8 +2970,8 @@ bgp_create (as_t *as, const char *name, enum bgp_instance_type inst_type)
else
{
/* TODO - The startup timer needs to be run for the whole of BGP */
- THREAD_TIMER_ON (bm->master, bgp->t_startup, bgp_startup_timer_expire,
- bgp, bgp->restart_time);
+ thread_add_timer(bm->master, bgp_startup_timer_expire, bgp,
+ bgp->restart_time, &bgp->t_startup);
}
bgp->wpkt_quanta = BGP_WRITE_PACKET_MAX;
@@ -6129,7 +6129,7 @@ peer_ttl_security_hops_set (struct peer *peer, int gtsm_hops)
* min & max ttls on the socket. The return value is
* irrelevant.
*/
- ret = peer_ebgp_multihop_set (peer, MAXTTL);
+ peer_ebgp_multihop_set (peer, MAXTTL);
}
}
}
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index ac09b97580..66ec8ccc84 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -1514,16 +1514,10 @@ peer_dynamic_neighbor (struct peer *peer)
return (CHECK_FLAG(peer->flags, PEER_FLAG_DYNAMIC_NEIGHBOR)) ? 1 : 0;
}
-/*
- * Currently supporting RFC 5549 for AFI_IP/SAFI_UNICAST only.
- *
- * Note: When other RFC-5549 applicable SAFIs to be supported, that should
- * come as an argument to this routine.
- */
static inline int
-peer_cap_enhe (struct peer *peer)
+peer_cap_enhe (struct peer *peer, afi_t afi, safi_t safi)
{
- return (CHECK_FLAG(peer->af_cap[AFI_IP][SAFI_UNICAST], PEER_CAP_ENHE_AF_NEGO));
+ return (CHECK_FLAG(peer->af_cap[afi][safi], PEER_CAP_ENHE_AF_NEGO));
}
/* Lookup VRF for BGP instance based on its type. */
diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c
index 4a05018d23..bef4b64d27 100644
--- a/bgpd/rfapi/rfapi_import.c
+++ b/bgpd/rfapi/rfapi_import.c
@@ -3033,9 +3033,9 @@ rfapiBiStartWithdrawTimer (
if (lifetime > UINT32_MAX / 1001)
{
/* sub-optimal case, but will probably never happen */
- bi->extra->vnc.import.timer = thread_add_timer (bm->master,
- timer_service_func,
- wcb, lifetime);
+ bi->extra->vnc.import.timer = NULL;
+ thread_add_timer(bm->master, timer_service_func, wcb, lifetime,
+ &bi->extra->vnc.import.timer);
}
else
{
@@ -3051,10 +3051,9 @@ rfapiBiStartWithdrawTimer (
lifetime_msec = (lifetime * 1000) + jitter;
- bi->extra->vnc.import.timer = thread_add_background (bm->master,
- timer_service_func,
- wcb,
- lifetime_msec);
+ bi->extra->vnc.import.timer = NULL;
+ thread_add_background(bm->master, timer_service_func, wcb, lifetime_msec,
+ &bi->extra->vnc.import.timer);
}
/* re-sort route list (BGP_INFO_REMOVED routes are last) */
diff --git a/bgpd/rfapi/rfapi_monitor.c b/bgpd/rfapi/rfapi_monitor.c
index a9e6e4f934..8eeed0216c 100644
--- a/bgpd/rfapi/rfapi_monitor.c
+++ b/bgpd/rfapi/rfapi_monitor.c
@@ -852,8 +852,9 @@ rfapiMonitorTimerRestart (struct rfapi_monitor_vpn *m)
rfapi_ntop (m->p.family, m->p.u.val, buf, BUFSIZ),
m->rfd->response_lifetime);
}
- m->timer = thread_add_timer (bm->master, rfapiMonitorTimerExpire, m,
- m->rfd->response_lifetime);
+ m->timer = NULL;
+ thread_add_timer(bm->master, rfapiMonitorTimerExpire, m, m->rfd->response_lifetime,
+ &m->timer);
}
/*
@@ -1183,8 +1184,9 @@ rfapiMonitorEthTimerRestart (struct rfapi_monitor_eth *m)
rfapiEthAddr2Str (&m->macaddr, buf, BUFSIZ),
m->rfd->response_lifetime);
}
- m->timer = thread_add_timer (bm->master, rfapiMonitorEthTimerExpire, m,
- m->rfd->response_lifetime);
+ m->timer = NULL;
+ thread_add_timer(bm->master, rfapiMonitorEthTimerExpire, m, m->rfd->response_lifetime,
+ &m->timer);
}
static int
diff --git a/bgpd/rfapi/rfapi_rib.c b/bgpd/rfapi/rfapi_rib.c
index d633023dcf..85ac936818 100644
--- a/bgpd/rfapi/rfapi_rib.c
+++ b/bgpd/rfapi/rfapi_rib.c
@@ -400,8 +400,9 @@ rfapiRibStartTimer (
prefix2str (&rn->p, buf_prefix, BUFSIZ);
vnc_zlog_debug_verbose ("%s: rfd %p pfx %s life %u", __func__, rfd, buf_prefix,
ri->lifetime);
- ri->timer = thread_add_timer (bm->master, rfapiRibExpireTimer,
- tcb, ri->lifetime);
+ ri->timer = NULL;
+ thread_add_timer(bm->master, rfapiRibExpireTimer, tcb, ri->lifetime,
+ &ri->timer);
assert (ri->timer);
}
@@ -1306,7 +1307,6 @@ callback:
if (!printedprefix)
{
vnc_zlog_debug_verbose ("%s: For prefix %s (d)", __func__, buf_prefix);
- printedprefix = 1;
}
vnc_zlog_debug_verbose ("%s: delete_list has %d elements",
__func__, delete_list->count);
diff --git a/bgpd/rfapi/vnc_export_bgp.c b/bgpd/rfapi/vnc_export_bgp.c
index 9b2dc25823..55eda907c8 100644
--- a/bgpd/rfapi/vnc_export_bgp.c
+++ b/bgpd/rfapi/vnc_export_bgp.c
@@ -1856,9 +1856,9 @@ vnc_direct_bgp_rh_del_route (
if (!eti->timer && eti->lifetime <= INT32_MAX)
{
- eti->timer = thread_add_timer (bm->master,
- vncExportWithdrawTimer,
- eti, eti->lifetime);
+ eti->timer = NULL;
+ thread_add_timer(bm->master, vncExportWithdrawTimer, eti, eti->lifetime,
+ &eti->timer);
vnc_zlog_debug_verbose ("%s: set expiration timer for %u seconds",
__func__, eti->lifetime);
}
diff --git a/configure.ac b/configure.ac
index 340b0a953b..fa10baf8fa 100755
--- a/configure.ac
+++ b/configure.ac
@@ -228,6 +228,9 @@ AC_ARG_WITH(pkg-extra-version,
AC_ARG_WITH(pkg-git-version,
AS_HELP_STRING([--with-pkg-git-version], [add git information to MOTD and build version string]),
[ test "x$withval" != "xno" && with_pkg_git_version="yes" ])
+AC_ARG_WITH(vtysh_pager,
+ AS_HELP_STRING([--with-vtysh-pager=PAGER], [control what pager is compiled in as default]),
+ VTYSH_PAGER=$withval, VTYSH_PAGER="more")
AC_ARG_ENABLE(vtysh,
AS_HELP_STRING([--disable-vtysh], [do not build integrated vty shell for Quagga]))
AC_ARG_ENABLE(doc,
@@ -532,6 +535,8 @@ esac
AC_DEFINE_UNQUOTED(MULTIPATH_NUM, $MPATH_NUM, Maximum number of paths for a route)
+AC_DEFINE_UNQUOTED(VTYSH_PAGER, "$VTYSH_PAGER", [What pager to use])
+
dnl -----------------------------------
dnl Add extra version string to package
dnl name, string and version fields.
diff --git a/eigrpd/eigrp_filter.c b/eigrpd/eigrp_filter.c
index 236c53acfc..bfe51ae88d 100644
--- a/eigrpd/eigrp_filter.c
+++ b/eigrpd/eigrp_filter.c
@@ -181,7 +181,9 @@ eigrp_distribute_update (struct distribute *dist)
thread_cancel(e->t_distribute);
}
/* schedule Graceful restart for whole process in 10sec */
- e->t_distribute = thread_add_timer(master, eigrp_distribute_timer_process, e,(10));
+ e->t_distribute = NULL;
+ thread_add_timer(master, eigrp_distribute_timer_process, e, (10),
+ &e->t_distribute);
return;
}
@@ -305,7 +307,9 @@ eigrp_distribute_update (struct distribute *dist)
thread_cancel(ei->t_distribute);
}
/* schedule Graceful restart for interface in 10sec */
- e->t_distribute = thread_add_timer(master, eigrp_distribute_timer_interface, ei, 10);
+ e->t_distribute = NULL;
+ thread_add_timer(master, eigrp_distribute_timer_interface, ei, 10,
+ &e->t_distribute);
}
/*
diff --git a/eigrpd/eigrp_hello.c b/eigrpd/eigrp_hello.c
index 240aa36789..051836d7e8 100644
--- a/eigrpd/eigrp_hello.c
+++ b/eigrpd/eigrp_hello.c
@@ -101,8 +101,9 @@ eigrp_hello_timer (struct thread *thread)
eigrp_hello_send(ei, EIGRP_HELLO_NORMAL, NULL);
/* Hello timer set. */
- ei->t_hello = thread_add_timer(master, eigrp_hello_timer, ei,
- EIGRP_IF_PARAM(ei, v_hello));
+ ei->t_hello = NULL;
+ thread_add_timer(master, eigrp_hello_timer, ei, EIGRP_IF_PARAM(ei, v_hello),
+ &ei->t_hello);
return 0;
}
@@ -713,9 +714,8 @@ eigrp_hello_send_ack (struct eigrp_neighbor *nbr)
listnode_add(nbr->ei->eigrp->oi_write_q, nbr->ei);
nbr->ei->on_write_q = 1;
}
- if (nbr->ei->eigrp->t_write == NULL)
- nbr->ei->eigrp->t_write =
- thread_add_write(master, eigrp_write, nbr->ei->eigrp, nbr->ei->eigrp->fd);
+ thread_add_write(master, eigrp_write, nbr->ei->eigrp, nbr->ei->eigrp->fd,
+ &nbr->ei->eigrp->t_write);
}
}
@@ -766,13 +766,12 @@ eigrp_hello_send (struct eigrp_interface *ei, u_char flags, struct in_addr *nbr_
{
if(flags & EIGRP_HELLO_GRACEFUL_SHUTDOWN)
{
- ei->eigrp->t_write =
- thread_execute(master, eigrp_write, ei->eigrp, ei->eigrp->fd);
+ thread_execute(master, eigrp_write, ei->eigrp, ei->eigrp->fd);
}
else
{
- ei->eigrp->t_write =
- thread_add_write(master, eigrp_write, ei->eigrp, ei->eigrp->fd);
+ thread_add_write(master, eigrp_write, ei->eigrp, ei->eigrp->fd,
+ &ei->eigrp->t_write);
}
}
}
diff --git a/eigrpd/eigrp_interface.c b/eigrpd/eigrp_interface.c
index 7fa135d968..1ad5e88c22 100644
--- a/eigrpd/eigrp_interface.c
+++ b/eigrpd/eigrp_interface.c
@@ -276,7 +276,7 @@ eigrp_if_up (struct eigrp_interface *ei)
/* Set multicast memberships appropriately for new state. */
eigrp_if_set_multicast (ei);
- thread_add_event (master, eigrp_hello_timer, ei, (1));
+ thread_add_event(master, eigrp_hello_timer, ei, (1), NULL);
/*Prepare metrics*/
metric.bandwith = eigrp_bandwidth_to_scaled (EIGRP_IF_PARAM (ei,bandwidth));
diff --git a/eigrpd/eigrp_neighbor.c b/eigrpd/eigrp_neighbor.c
index 01b2e68a02..f200351c10 100644
--- a/eigrpd/eigrp_neighbor.c
+++ b/eigrpd/eigrp_neighbor.c
@@ -298,16 +298,16 @@ eigrp_nbr_state_update (struct eigrp_neighbor *nbr)
{
/*Reset Hold Down Timer for neighbor*/
THREAD_OFF(nbr->t_holddown);
- THREAD_TIMER_ON(master, nbr->t_holddown, holddown_timer_expired, nbr,
- nbr->v_holddown);
+ thread_add_timer(master, holddown_timer_expired, nbr,
+ nbr->v_holddown, &nbr->t_holddown);
break;
}
case EIGRP_NEIGHBOR_UP:
{
/*Reset Hold Down Timer for neighbor*/
THREAD_OFF(nbr->t_holddown);
- THREAD_TIMER_ON(master, nbr->t_holddown, holddown_timer_expired, nbr,
- nbr->v_holddown);
+ thread_add_timer(master, holddown_timer_expired, nbr,
+ nbr->v_holddown, &nbr->t_holddown);
break;
}
}
diff --git a/eigrpd/eigrp_packet.c b/eigrpd/eigrp_packet.c
index 5b62e98abc..635c1cf66b 100644
--- a/eigrpd/eigrp_packet.c
+++ b/eigrpd/eigrp_packet.c
@@ -448,8 +448,10 @@ eigrp_write (struct thread *thread)
}
/* If packets still remain in queue, call write thread. */
- if (!list_isempty(eigrp->oi_write_q))
- eigrp->t_write = thread_add_write(master, eigrp_write, eigrp, eigrp->fd);
+ if (!list_isempty(eigrp->oi_write_q)) {
+ eigrp->t_write = NULL;
+ thread_add_write(master, eigrp_write, eigrp, eigrp->fd, &eigrp->t_write);
+ }
return 0;
}
@@ -474,7 +476,8 @@ eigrp_read (struct thread *thread)
eigrp = THREAD_ARG(thread);
/* prepare for next packet. */
- eigrp->t_read = thread_add_read(master, eigrp_read, eigrp, eigrp->fd);
+ eigrp->t_read = NULL;
+ thread_add_read(master, eigrp_read, eigrp, eigrp->fd, &eigrp->t_read);
stream_reset(eigrp->ibuf);
if (!(ibuf = eigrp_recv_packet(eigrp->fd, &ifp, eigrp->ibuf)))
@@ -846,8 +849,8 @@ eigrp_send_packet_reliably (struct eigrp_neighbor *nbr)
eigrp_fifo_push_head(nbr->ei->obuf, duplicate);
/*Start retransmission timer*/
- THREAD_TIMER_ON(master, ep->t_retrans_timer, eigrp_unack_packet_retrans,
- nbr, EIGRP_PACKET_RETRANS_TIME);
+ thread_add_timer(master, eigrp_unack_packet_retrans, nbr,
+ EIGRP_PACKET_RETRANS_TIME, &ep->t_retrans_timer);
/*Increment sequence number counter*/
nbr->ei->eigrp->sequence_number++;
@@ -858,9 +861,8 @@ eigrp_send_packet_reliably (struct eigrp_neighbor *nbr)
listnode_add(nbr->ei->eigrp->oi_write_q, nbr->ei);
nbr->ei->on_write_q = 1;
}
- if (nbr->ei->eigrp->t_write == NULL)
- nbr->ei->eigrp->t_write =
- thread_add_write(master, eigrp_write, nbr->ei->eigrp, nbr->ei->eigrp->fd);
+ thread_add_write(master, eigrp_write, nbr->ei->eigrp, nbr->ei->eigrp->fd,
+ &nbr->ei->eigrp->t_write);
}
}
@@ -1048,8 +1050,9 @@ eigrp_unack_packet_retrans (struct thread *thread)
return eigrp_retrans_count_exceeded(ep, nbr);
/*Start retransmission timer*/
- ep->t_retrans_timer =
- thread_add_timer(master, eigrp_unack_packet_retrans, nbr,EIGRP_PACKET_RETRANS_TIME);
+ ep->t_retrans_timer = NULL;
+ thread_add_timer(master, eigrp_unack_packet_retrans, nbr, EIGRP_PACKET_RETRANS_TIME,
+ &ep->t_retrans_timer);
/* Hook thread to write packet. */
if (nbr->ei->on_write_q == 0)
@@ -1057,9 +1060,8 @@ eigrp_unack_packet_retrans (struct thread *thread)
listnode_add(nbr->ei->eigrp->oi_write_q, nbr->ei);
nbr->ei->on_write_q = 1;
}
- if (nbr->ei->eigrp->t_write == NULL)
- nbr->ei->eigrp->t_write =
- thread_add_write(master, eigrp_write, nbr->ei->eigrp, nbr->ei->eigrp->fd);
+ thread_add_write(master, eigrp_write, nbr->ei->eigrp, nbr->ei->eigrp->fd,
+ &nbr->ei->eigrp->t_write);
}
return 0;
@@ -1086,8 +1088,9 @@ eigrp_unack_multicast_packet_retrans (struct thread *thread)
return eigrp_retrans_count_exceeded(ep, nbr);
/*Start retransmission timer*/
- ep->t_retrans_timer =
- thread_add_timer(master, eigrp_unack_multicast_packet_retrans, nbr,EIGRP_PACKET_RETRANS_TIME);
+ ep->t_retrans_timer = NULL;
+ thread_add_timer(master, eigrp_unack_multicast_packet_retrans, nbr, EIGRP_PACKET_RETRANS_TIME,
+ &ep->t_retrans_timer);
/* Hook thread to write packet. */
if (nbr->ei->on_write_q == 0)
@@ -1095,9 +1098,8 @@ eigrp_unack_multicast_packet_retrans (struct thread *thread)
listnode_add(nbr->ei->eigrp->oi_write_q, nbr->ei);
nbr->ei->on_write_q = 1;
}
- if (nbr->ei->eigrp->t_write == NULL)
- nbr->ei->eigrp->t_write =
- thread_add_write(master, eigrp_write, nbr->ei->eigrp, nbr->ei->eigrp->fd);
+ thread_add_write(master, eigrp_write, nbr->ei->eigrp, nbr->ei->eigrp->fd,
+ &nbr->ei->eigrp->t_write);
}
return 0;
diff --git a/eigrpd/eigrp_update.c b/eigrpd/eigrp_update.c
index ee873bb07b..5c942bd4d5 100644
--- a/eigrpd/eigrp_update.c
+++ b/eigrpd/eigrp_update.c
@@ -1046,7 +1046,9 @@ eigrp_update_send_GR_thread(struct thread *thread)
* schedule this thread again with small delay */
if(nbr->retrans_queue->count > 0)
{
- nbr->t_nbr_send_gr = thread_add_timer_msec(master, eigrp_update_send_GR_thread, nbr, 10);
+ nbr->t_nbr_send_gr = NULL;
+ thread_add_timer_msec(master, eigrp_update_send_GR_thread, nbr, 10,
+ &nbr->t_nbr_send_gr);
return 0;
}
@@ -1054,8 +1056,10 @@ eigrp_update_send_GR_thread(struct thread *thread)
eigrp_update_send_GR_part(nbr);
/* if it wasn't last chunk, schedule this thread again */
- if(nbr->nbr_gr_packet_type != EIGRP_PACKET_PART_LAST)
- nbr->t_nbr_send_gr = thread_execute(master, eigrp_update_send_GR_thread, nbr, 0);
+ if(nbr->nbr_gr_packet_type != EIGRP_PACKET_PART_LAST) {
+ thread_execute(master, eigrp_update_send_GR_thread, nbr, 0);
+ nbr->t_nbr_send_gr = NULL;
+ }
return 0;
}
@@ -1115,7 +1119,8 @@ eigrp_update_send_GR (struct eigrp_neighbor *nbr, enum GR_type gr_type, struct v
/* indicate, that this is first GR Update packet chunk */
nbr->nbr_gr_packet_type = EIGRP_PACKET_PART_FIRST;
/* execute packet sending in thread */
- nbr->t_nbr_send_gr = thread_execute(master, eigrp_update_send_GR_thread, nbr, 0);
+ thread_execute(master, eigrp_update_send_GR_thread, nbr, 0);
+ nbr->t_nbr_send_gr = NULL;
}
/**
diff --git a/eigrpd/eigrp_vty.c b/eigrpd/eigrp_vty.c
index 1fc8c54594..cc346405a5 100644
--- a/eigrpd/eigrp_vty.c
+++ b/eigrpd/eigrp_vty.c
@@ -791,7 +791,7 @@ DEFUN (eigrp_ip_summary_address,
"AS number\n"
"Summary <network>/<length>, e.g. 192.168.0.0/16\n")
{
- VTY_DECLVAR_CONTEXT(interface, ifp);
+ //VTY_DECLVAR_CONTEXT(interface, ifp);
//u_int32_t AS;
struct eigrp *eigrp;
@@ -819,7 +819,7 @@ DEFUN (no_eigrp_ip_summary_address,
"AS number\n"
"Summary <network>/<length>, e.g. 192.168.0.0/16\n")
{
- VTY_DECLVAR_CONTEXT(interface, ifp);
+ //VTY_DECLVAR_CONTEXT(interface, ifp);
//u_int32_t AS;
struct eigrp *eigrp;
diff --git a/eigrpd/eigrpd.c b/eigrpd/eigrpd.c
index 8d7aa028a3..40885c8a46 100644
--- a/eigrpd/eigrpd.c
+++ b/eigrpd/eigrpd.c
@@ -181,7 +181,8 @@ eigrp_new (const char *AS)
exit(1);
}
- eigrp->t_read = thread_add_read(master, eigrp_read, eigrp, eigrp->fd);
+ eigrp->t_read = NULL;
+ thread_add_read(master, eigrp_read, eigrp, eigrp->fd, &eigrp->t_read);
eigrp->oi_write_q = list_new();
eigrp->topology_table = eigrp_topology_new();
diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c
index 6caf8200ee..190811bac4 100644
--- a/isisd/isis_circuit.c
+++ b/isisd/isis_circuit.c
@@ -607,11 +607,12 @@ void
isis_circuit_prepare (struct isis_circuit *circuit)
{
#ifdef GNU_LINUX
- THREAD_READ_ON (master, circuit->t_read, isis_receive, circuit,
- circuit->fd);
+ thread_add_read(master, isis_receive, circuit, circuit->fd,
+ &circuit->t_read);
#else
- THREAD_TIMER_MSEC_ON (master, circuit->t_read, isis_receive, circuit,
- listcount (circuit->area->circuit_list) * 100);
+ thread_add_timer_msec(master, isis_receive, circuit,
+ listcount(circuit->area->circuit_list) * 100,
+ &circuit->t_read);
#endif
}
@@ -672,13 +673,13 @@ isis_circuit_up (struct isis_circuit *circuit)
if (circuit->is_type & IS_LEVEL_1)
{
- thread_add_event (master, send_lan_l1_hello, circuit, 0);
+ thread_add_event(master, send_lan_l1_hello, circuit, 0, NULL);
circuit->u.bc.lan_neighs[0] = list_new ();
}
if (circuit->is_type & IS_LEVEL_2)
{
- thread_add_event (master, send_lan_l2_hello, circuit, 0);
+ thread_add_event(master, send_lan_l2_hello, circuit, 0, NULL);
circuit->u.bc.lan_neighs[1] = list_new ();
}
@@ -688,11 +689,13 @@ isis_circuit_up (struct isis_circuit *circuit)
/* 8.4.1 d) */
/* dr election will commence in... */
if (circuit->is_type & IS_LEVEL_1)
- THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
- circuit, 2 * circuit->hello_interval[0]);
+ thread_add_timer(master, isis_run_dr_l1, circuit,
+ 2 * circuit->hello_interval[0],
+ &circuit->u.bc.t_run_dr[0]);
if (circuit->is_type & IS_LEVEL_2)
- THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
- circuit, 2 * circuit->hello_interval[1]);
+ thread_add_timer(master, isis_run_dr_l2, circuit,
+ 2 * circuit->hello_interval[1],
+ &circuit->u.bc.t_run_dr[1]);
}
else
{
@@ -700,17 +703,19 @@ isis_circuit_up (struct isis_circuit *circuit)
* for a ptp IF
*/
circuit->u.p2p.neighbor = NULL;
- thread_add_event (master, send_p2p_hello, circuit, 0);
+ thread_add_event(master, send_p2p_hello, circuit, 0, NULL);
}
/* initializing PSNP timers */
if (circuit->is_type & IS_LEVEL_1)
- THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
- isis_jitter (circuit->psnp_interval[0], PSNP_JITTER));
+ thread_add_timer(master, send_l1_psnp, circuit,
+ isis_jitter(circuit->psnp_interval[0], PSNP_JITTER),
+ &circuit->t_send_psnp[0]);
if (circuit->is_type & IS_LEVEL_2)
- THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
- isis_jitter (circuit->psnp_interval[1], PSNP_JITTER));
+ thread_add_timer(master, send_l2_psnp, circuit,
+ isis_jitter(circuit->psnp_interval[1], PSNP_JITTER),
+ &circuit->t_send_psnp[1]);
/* unified init for circuits; ignore warnings below this level */
retv = isis_sock_init (circuit);
diff --git a/isisd/isis_dr.c b/isisd/isis_dr.c
index bc6ec11962..def6e3860e 100644
--- a/isisd/isis_dr.c
+++ b/isisd/isis_dr.c
@@ -259,12 +259,13 @@ isis_dr_resign (struct isis_circuit *circuit, int level)
THREAD_TIMER_OFF (circuit->t_send_csnp[0]);
- THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
- circuit, 2 * circuit->hello_interval[0]);
+ thread_add_timer(master, isis_run_dr_l1, circuit,
+ 2 * circuit->hello_interval[0],
+ &circuit->u.bc.t_run_dr[0]);
- THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
- isis_jitter (circuit->psnp_interval[level - 1],
- PSNP_JITTER));
+ thread_add_timer(master, send_l1_psnp, circuit,
+ isis_jitter(circuit->psnp_interval[level - 1], PSNP_JITTER),
+ &circuit->t_send_psnp[0]);
}
else
{
@@ -272,15 +273,16 @@ isis_dr_resign (struct isis_circuit *circuit, int level)
THREAD_TIMER_OFF (circuit->t_send_csnp[1]);
- THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
- circuit, 2 * circuit->hello_interval[1]);
+ thread_add_timer(master, isis_run_dr_l2, circuit,
+ 2 * circuit->hello_interval[1],
+ &circuit->u.bc.t_run_dr[1]);
- THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
- isis_jitter (circuit->psnp_interval[level - 1],
- PSNP_JITTER));
+ thread_add_timer(master, send_l2_psnp, circuit,
+ isis_jitter(circuit->psnp_interval[level - 1], PSNP_JITTER),
+ &circuit->t_send_psnp[1]);
}
- thread_add_event (master, isis_event_dis_status_change, circuit, 0);
+ thread_add_event(master, isis_event_dis_status_change, circuit, 0, NULL);
return ISIS_OK;
}
@@ -296,11 +298,13 @@ isis_dr_commence (struct isis_circuit *circuit, int level)
/* Lets keep a pause in DR election */
circuit->u.bc.run_dr_elect[level - 1] = 0;
if (level == 1)
- THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
- circuit, 2 * circuit->hello_interval[0]);
+ thread_add_timer(master, isis_run_dr_l1, circuit,
+ 2 * circuit->hello_interval[0],
+ &circuit->u.bc.t_run_dr[0]);
else
- THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
- circuit, 2 * circuit->hello_interval[1]);
+ thread_add_timer(master, isis_run_dr_l2, circuit,
+ 2 * circuit->hello_interval[1],
+ &circuit->u.bc.t_run_dr[1]);
circuit->u.bc.is_dr[level - 1] = 1;
if (level == 1)
@@ -321,12 +325,13 @@ isis_dr_commence (struct isis_circuit *circuit, int level)
lsp_generate_pseudo (circuit, 1);
THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[0]);
- THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
- circuit, 2 * circuit->hello_interval[0]);
+ thread_add_timer(master, isis_run_dr_l1, circuit,
+ 2 * circuit->hello_interval[0],
+ &circuit->u.bc.t_run_dr[0]);
- THREAD_TIMER_ON (master, circuit->t_send_csnp[0], send_l1_csnp, circuit,
- isis_jitter (circuit->csnp_interval[level - 1],
- CSNP_JITTER));
+ thread_add_timer(master, send_l1_csnp, circuit,
+ isis_jitter(circuit->csnp_interval[level - 1], CSNP_JITTER),
+ &circuit->t_send_csnp[0]);
}
else
@@ -347,15 +352,16 @@ isis_dr_commence (struct isis_circuit *circuit, int level)
lsp_generate_pseudo (circuit, 2);
THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[1]);
- THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
- circuit, 2 * circuit->hello_interval[1]);
+ thread_add_timer(master, isis_run_dr_l2, circuit,
+ 2 * circuit->hello_interval[1],
+ &circuit->u.bc.t_run_dr[1]);
- THREAD_TIMER_ON (master, circuit->t_send_csnp[1], send_l2_csnp, circuit,
- isis_jitter (circuit->csnp_interval[level - 1],
- CSNP_JITTER));
+ thread_add_timer(master, send_l2_csnp, circuit,
+ isis_jitter(circuit->csnp_interval[level - 1], CSNP_JITTER),
+ &circuit->t_send_csnp[1]);
}
- thread_add_event (master, isis_event_dis_status_change, circuit, 0);
+ thread_add_event(master, isis_event_dis_status_change, circuit, 0, NULL);
return ISIS_OK;
}
diff --git a/isisd/isis_dynhn.c b/isisd/isis_dynhn.c
index 412f098a1b..541bfe4a5c 100644
--- a/isisd/isis_dynhn.c
+++ b/isisd/isis_dynhn.c
@@ -51,7 +51,7 @@ dyn_cache_init (void)
{
if (dyn_cache == NULL)
dyn_cache = list_new ();
- THREAD_TIMER_ON (master, isis->t_dync_clean, dyn_cache_cleanup, NULL, 120);
+ thread_add_timer(master, dyn_cache_cleanup, NULL, 120, &isis->t_dync_clean);
return;
}
@@ -73,7 +73,7 @@ dyn_cache_cleanup (struct thread *thread)
XFREE (MTYPE_ISIS_DYNHN, dyn);
}
- THREAD_TIMER_ON (master, isis->t_dync_clean, dyn_cache_cleanup, NULL, 120);
+ thread_add_timer(master, dyn_cache_cleanup, NULL, 120, &isis->t_dync_clean);
return ISIS_OK;
}
diff --git a/isisd/isis_events.c b/isisd/isis_events.c
index ab42a1e367..32415092a4 100644
--- a/isisd/isis_events.c
+++ b/isisd/isis_events.c
@@ -82,18 +82,19 @@ circuit_commence_level (struct isis_circuit *circuit, int level)
if (level == 1)
{
if (! circuit->is_passive)
- THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
- isis_jitter (circuit->psnp_interval[0], PSNP_JITTER));
+ thread_add_timer(master, send_l1_psnp, circuit,
+ isis_jitter(circuit->psnp_interval[0], PSNP_JITTER),
+ &circuit->t_send_psnp[0]);
if (circuit->circ_type == CIRCUIT_T_BROADCAST)
{
- THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
- circuit, 2 * circuit->hello_interval[0]);
+ thread_add_timer(master, isis_run_dr_l1, circuit,
+ 2 * circuit->hello_interval[0],
+ &circuit->u.bc.t_run_dr[0]);
- THREAD_TIMER_ON (master, circuit->u.bc.t_send_lan_hello[0],
- send_lan_l1_hello, circuit,
- isis_jitter (circuit->hello_interval[0],
- IIH_JITTER));
+ thread_add_timer(master, send_lan_l1_hello, circuit,
+ isis_jitter(circuit->hello_interval[0], IIH_JITTER),
+ &circuit->u.bc.t_send_lan_hello[0]);
circuit->u.bc.lan_neighs[0] = list_new ();
}
@@ -101,18 +102,19 @@ circuit_commence_level (struct isis_circuit *circuit, int level)
else
{
if (! circuit->is_passive)
- THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
- isis_jitter (circuit->psnp_interval[1], PSNP_JITTER));
+ thread_add_timer(master, send_l2_psnp, circuit,
+ isis_jitter(circuit->psnp_interval[1], PSNP_JITTER),
+ &circuit->t_send_psnp[1]);
if (circuit->circ_type == CIRCUIT_T_BROADCAST)
{
- THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
- circuit, 2 * circuit->hello_interval[1]);
+ thread_add_timer(master, isis_run_dr_l2, circuit,
+ 2 * circuit->hello_interval[1],
+ &circuit->u.bc.t_run_dr[1]);
- THREAD_TIMER_ON (master, circuit->u.bc.t_send_lan_hello[1],
- send_lan_l2_hello, circuit,
- isis_jitter (circuit->hello_interval[1],
- IIH_JITTER));
+ thread_add_timer(master, send_lan_l2_hello, circuit,
+ isis_jitter(circuit->hello_interval[1], IIH_JITTER),
+ &circuit->u.bc.t_send_lan_hello[1]);
circuit->u.bc.lan_neighs[1] = list_new ();
}
diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c
index 955a73ef61..b7e66d13a1 100644
--- a/isisd/isis_lsp.c
+++ b/isisd/isis_lsp.c
@@ -2034,11 +2034,11 @@ lsp_generate (struct isis_area *area, int level)
THREAD_TIMER_OFF (area->t_lsp_refresh[level - 1]);
area->lsp_regenerate_pending[level - 1] = 0;
if (level == IS_LEVEL_1)
- THREAD_TIMER_ON (master, area->t_lsp_refresh[level - 1],
- lsp_l1_refresh, area, refresh_time);
+ thread_add_timer(master, lsp_l1_refresh, area, refresh_time,
+ &area->t_lsp_refresh[level - 1]);
else if (level == IS_LEVEL_2)
- THREAD_TIMER_ON (master, area->t_lsp_refresh[level - 1],
- lsp_l2_refresh, area, refresh_time);
+ thread_add_timer(master, lsp_l2_refresh, area, refresh_time,
+ &area->t_lsp_refresh[level - 1]);
if (isis->debugs & DEBUG_UPDATE_PACKETS)
{
@@ -2111,11 +2111,11 @@ lsp_regenerate (struct isis_area *area, int level)
refresh_time = lsp_refresh_time (lsp, rem_lifetime);
if (level == IS_LEVEL_1)
- THREAD_TIMER_ON (master, area->t_lsp_refresh[level - 1],
- lsp_l1_refresh, area, refresh_time);
+ thread_add_timer(master, lsp_l1_refresh, area, refresh_time,
+ &area->t_lsp_refresh[level - 1]);
else if (level == IS_LEVEL_2)
- THREAD_TIMER_ON (master, area->t_lsp_refresh[level - 1],
- lsp_l2_refresh, area, refresh_time);
+ thread_add_timer(master, lsp_l2_refresh, area, refresh_time,
+ &area->t_lsp_refresh[level - 1]);
area->lsp_regenerate_pending[level - 1] = 0;
if (isis->debugs & DEBUG_UPDATE_PACKETS)
@@ -2249,13 +2249,13 @@ lsp_regenerate_schedule (struct isis_area *area, int level, int all_pseudo)
area->lsp_regenerate_pending[lvl - 1] = 1;
if (lvl == IS_LEVEL_1)
{
- THREAD_TIMER_MSEC_ON(master, area->t_lsp_refresh[lvl - 1],
- lsp_l1_refresh, area, timeout);
+ thread_add_timer_msec(master, lsp_l1_refresh, area, timeout,
+ &area->t_lsp_refresh[lvl - 1]);
}
else if (lvl == IS_LEVEL_2)
{
- THREAD_TIMER_MSEC_ON(master, area->t_lsp_refresh[lvl - 1],
- lsp_l2_refresh, area, timeout);
+ thread_add_timer_msec(master, lsp_l2_refresh, area, timeout,
+ &area->t_lsp_refresh[lvl - 1]);
}
}
@@ -2465,11 +2465,11 @@ lsp_generate_pseudo (struct isis_circuit *circuit, int level)
THREAD_TIMER_OFF (circuit->u.bc.t_refresh_pseudo_lsp[level - 1]);
circuit->lsp_regenerate_pending[level - 1] = 0;
if (level == IS_LEVEL_1)
- THREAD_TIMER_ON (master, circuit->u.bc.t_refresh_pseudo_lsp[level - 1],
- lsp_l1_refresh_pseudo, circuit, refresh_time);
+ thread_add_timer(master, lsp_l1_refresh_pseudo, circuit, refresh_time,
+ &circuit->u.bc.t_refresh_pseudo_lsp[level - 1]);
else if (level == IS_LEVEL_2)
- THREAD_TIMER_ON (master, circuit->u.bc.t_refresh_pseudo_lsp[level - 1],
- lsp_l2_refresh_pseudo, circuit, refresh_time);
+ thread_add_timer(master, lsp_l2_refresh_pseudo, circuit, refresh_time,
+ &circuit->u.bc.t_refresh_pseudo_lsp[level - 1]);
if (isis->debugs & DEBUG_UPDATE_PACKETS)
{
@@ -2528,11 +2528,11 @@ lsp_regenerate_pseudo (struct isis_circuit *circuit, int level)
refresh_time = lsp_refresh_time (lsp, rem_lifetime);
if (level == IS_LEVEL_1)
- THREAD_TIMER_ON (master, circuit->u.bc.t_refresh_pseudo_lsp[level - 1],
- lsp_l1_refresh_pseudo, circuit, refresh_time);
+ thread_add_timer(master, lsp_l1_refresh_pseudo, circuit, refresh_time,
+ &circuit->u.bc.t_refresh_pseudo_lsp[level - 1]);
else if (level == IS_LEVEL_2)
- THREAD_TIMER_ON (master, circuit->u.bc.t_refresh_pseudo_lsp[level - 1],
- lsp_l2_refresh_pseudo, circuit, refresh_time);
+ thread_add_timer(master, lsp_l2_refresh_pseudo, circuit, refresh_time,
+ &circuit->u.bc.t_refresh_pseudo_lsp[level - 1]);
if (isis->debugs & DEBUG_UPDATE_PACKETS)
{
@@ -2684,15 +2684,15 @@ lsp_regenerate_schedule_pseudo (struct isis_circuit *circuit, int level)
if (lvl == IS_LEVEL_1)
{
- THREAD_TIMER_MSEC_ON(master,
- circuit->u.bc.t_refresh_pseudo_lsp[lvl - 1],
- lsp_l1_refresh_pseudo, circuit, timeout);
+ thread_add_timer_msec(master, lsp_l1_refresh_pseudo, circuit,
+ timeout,
+ &circuit->u.bc.t_refresh_pseudo_lsp[lvl - 1]);
}
else if (lvl == IS_LEVEL_2)
{
- THREAD_TIMER_MSEC_ON(master,
- circuit->u.bc.t_refresh_pseudo_lsp[lvl - 1],
- lsp_l2_refresh_pseudo, circuit, timeout);
+ thread_add_timer_msec(master, lsp_l2_refresh_pseudo, circuit,
+ timeout,
+ &circuit->u.bc.t_refresh_pseudo_lsp[lvl - 1]);
}
}
@@ -2721,7 +2721,7 @@ lsp_tick (struct thread *thread)
area = THREAD_ARG (thread);
assert (area);
area->t_tick = NULL;
- THREAD_TIMER_ON (master, area->t_tick, lsp_tick, area, 1);
+ thread_add_timer(master, lsp_tick, area, 1, &area->t_tick);
/*
* Build a list of LSPs with (any) SRMflag set
@@ -2799,7 +2799,8 @@ lsp_tick (struct thread *thread)
if (! listnode_lookup (circuit->lsp_queue, lsp))
{
listnode_add (circuit->lsp_queue, lsp);
- thread_add_event (master, send_lsp, circuit, 0);
+ thread_add_event(master, send_lsp, circuit, 0,
+ NULL);
}
}
}
diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c
index 5232666bda..bca3f91d4e 100644
--- a/isisd/isis_pdu.c
+++ b/isisd/isis_pdu.c
@@ -569,8 +569,8 @@ process_p2p_hello (struct isis_circuit *circuit)
/* lets take care of the expiry */
THREAD_TIMER_OFF (adj->t_expire);
- THREAD_TIMER_ON (master, adj->t_expire, isis_adj_expire, adj,
- (long) adj->hold_time);
+ thread_add_timer(master, isis_adj_expire, adj, (long)adj->hold_time,
+ &adj->t_expire);
/* 8.2.5.2 a) a match was detected */
if (area_match (circuit->area->area_addrs, tlvs.area_addrs))
@@ -1124,7 +1124,8 @@ process_lan_hello (int level, struct isis_circuit *circuit, const u_char *ssnpa)
case 1:
if (memcmp (circuit->u.bc.l1_desig_is, hdr.lan_id, ISIS_SYS_ID_LEN + 1))
{
- thread_add_event (master, isis_event_dis_status_change, circuit, 0);
+ thread_add_event(master, isis_event_dis_status_change, circuit, 0,
+ NULL);
memcpy (&circuit->u.bc.l1_desig_is, hdr.lan_id,
ISIS_SYS_ID_LEN + 1);
}
@@ -1132,7 +1133,8 @@ process_lan_hello (int level, struct isis_circuit *circuit, const u_char *ssnpa)
case 2:
if (memcmp (circuit->u.bc.l2_desig_is, hdr.lan_id, ISIS_SYS_ID_LEN + 1))
{
- thread_add_event (master, isis_event_dis_status_change, circuit, 0);
+ thread_add_event(master, isis_event_dis_status_change, circuit, 0,
+ NULL);
memcpy (&circuit->u.bc.l2_desig_is, hdr.lan_id,
ISIS_SYS_ID_LEN + 1);
}
@@ -1167,8 +1169,8 @@ process_lan_hello (int level, struct isis_circuit *circuit, const u_char *ssnpa)
/* lets take care of the expiry */
THREAD_TIMER_OFF (adj->t_expire);
- THREAD_TIMER_ON (master, adj->t_expire, isis_adj_expire, adj,
- (long) adj->hold_time);
+ thread_add_timer(master, isis_adj_expire, adj, (long)adj->hold_time,
+ &adj->t_expire);
/*
* If the snpa for this circuit is found from LAN Neighbours TLV
@@ -1403,7 +1405,6 @@ process_lsp (int level, struct isis_circuit *circuit, const u_char *ssnpa)
((level == IS_LEVEL_2) &&
(circuit->u.p2p.neighbor->adj_usage == ISIS_ADJ_LEVEL1)))
return ISIS_WARNING; /* Silently discard */
- adj = circuit->u.p2p.neighbor;
}
}
@@ -2389,9 +2390,9 @@ send_lan_l1_hello (struct thread *thread)
retval = send_hello (circuit, 1);
/* set next timer thread */
- THREAD_TIMER_ON (master, circuit->u.bc.t_send_lan_hello[0],
- send_lan_l1_hello, circuit,
- isis_jitter (circuit->hello_interval[0], IIH_JITTER));
+ thread_add_timer(master, send_lan_l1_hello, circuit,
+ isis_jitter(circuit->hello_interval[0], IIH_JITTER),
+ &circuit->u.bc.t_send_lan_hello[0]);
return retval;
}
@@ -2419,9 +2420,9 @@ send_lan_l2_hello (struct thread *thread)
retval = send_hello (circuit, 2);
/* set next timer thread */
- THREAD_TIMER_ON (master, circuit->u.bc.t_send_lan_hello[1],
- send_lan_l2_hello, circuit,
- isis_jitter (circuit->hello_interval[1], IIH_JITTER));
+ thread_add_timer(master, send_lan_l2_hello, circuit,
+ isis_jitter(circuit->hello_interval[1], IIH_JITTER),
+ &circuit->u.bc.t_send_lan_hello[1]);
return retval;
}
@@ -2438,9 +2439,9 @@ send_p2p_hello (struct thread *thread)
send_hello (circuit, 1);
/* set next timer thread */
- THREAD_TIMER_ON (master, circuit->u.p2p.t_send_p2p_hello, send_p2p_hello,
- circuit, isis_jitter (circuit->hello_interval[1],
- IIH_JITTER));
+ thread_add_timer(master, send_p2p_hello, circuit,
+ isis_jitter(circuit->hello_interval[1], IIH_JITTER),
+ &circuit->u.p2p.t_send_p2p_hello);
return ISIS_OK;
}
@@ -2740,8 +2741,9 @@ send_l1_csnp (struct thread *thread)
send_csnp (circuit, 1);
}
/* set next timer thread */
- THREAD_TIMER_ON (master, circuit->t_send_csnp[0], send_l1_csnp, circuit,
- isis_jitter (circuit->csnp_interval[0], CSNP_JITTER));
+ thread_add_timer(master, send_l1_csnp, circuit,
+ isis_jitter(circuit->csnp_interval[0], CSNP_JITTER),
+ &circuit->t_send_csnp[0]);
return retval;
}
@@ -2762,8 +2764,9 @@ send_l2_csnp (struct thread *thread)
send_csnp (circuit, 2);
}
/* set next timer thread */
- THREAD_TIMER_ON (master, circuit->t_send_csnp[1], send_l2_csnp, circuit,
- isis_jitter (circuit->csnp_interval[1], CSNP_JITTER));
+ thread_add_timer(master, send_l2_csnp, circuit,
+ isis_jitter(circuit->csnp_interval[1], CSNP_JITTER),
+ &circuit->t_send_csnp[1]);
return retval;
}
@@ -2965,8 +2968,9 @@ send_l1_psnp (struct thread *thread)
send_psnp (1, circuit);
/* set next timer thread */
- THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
- isis_jitter (circuit->psnp_interval[0], PSNP_JITTER));
+ thread_add_timer(master, send_l1_psnp, circuit,
+ isis_jitter(circuit->psnp_interval[0], PSNP_JITTER),
+ &circuit->t_send_psnp[0]);
return retval;
}
@@ -2989,8 +2993,9 @@ send_l2_psnp (struct thread *thread)
send_psnp (2, circuit);
/* set next timer thread */
- THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
- isis_jitter (circuit->psnp_interval[1], PSNP_JITTER));
+ thread_add_timer(master, send_l2_psnp, circuit,
+ isis_jitter(circuit->psnp_interval[1], PSNP_JITTER),
+ &circuit->t_send_psnp[1]);
return retval;
}
diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c
index 43dffdc863..1eb2586147 100644
--- a/isisd/isis_spf.c
+++ b/isisd/isis_spf.c
@@ -1279,9 +1279,9 @@ isis_spf_schedule (struct isis_area *area, int level)
if (area->spf_timer[level - 1])
return ISIS_OK;
- THREAD_TIMER_MSEC_ON(master, area->spf_timer[level-1],
- isis_run_spf_cb, isis_run_spf_arg(area, level),
- delay);
+ thread_add_timer_msec (master, isis_run_spf_cb,
+ isis_run_spf_arg(area, level),
+ delay, &area->spf_timer[level-1]);
return ISIS_OK;
}
@@ -1301,9 +1301,9 @@ isis_spf_schedule (struct isis_area *area, int level)
return retval;
}
- THREAD_TIMER_ON (master, area->spf_timer[level-1],
- isis_run_spf_cb, isis_run_spf_arg(area, level),
- area->min_spf_interval[level-1] - diff);
+ thread_add_timer (master, isis_run_spf_cb, isis_run_spf_arg(area, level),
+ area->min_spf_interval[level-1] - diff,
+ &area->spf_timer[level-1]);
if (isis->debugs & DEBUG_SPF_EVENTS)
zlog_debug ("ISIS-Spf (%s) L%d SPF scheduled %d sec from now",
diff --git a/isisd/isisd.c b/isisd/isisd.c
index d11044377f..fedac084e3 100644
--- a/isisd/isisd.c
+++ b/isisd/isisd.c
@@ -137,7 +137,7 @@ isis_area_create (const char *area_tag)
area->circuit_list = list_new ();
area->area_addrs = list_new ();
- THREAD_TIMER_ON (master, area->t_tick, lsp_tick, area, 1);
+ thread_add_timer(master, lsp_tick, area, 1, &area->t_tick);
flags_initialize (&area->flags);
/*
diff --git a/ldpd/accept.c b/ldpd/accept.c
index 4cb461b908..323558d7fd 100644
--- a/ldpd/accept.c
+++ b/ldpd/accept.c
@@ -58,7 +58,8 @@ accept_add(int fd, int (*cb)(struct thread *), void *arg)
av->arg = arg;
LIST_INSERT_HEAD(&accept_queue.queue, av, entry);
- av->ev = thread_add_read(master, accept_cb, av, av->fd);
+ av->ev = NULL;
+ thread_add_read(master, accept_cb, av, av->fd, &av->ev);
log_debug("%s: accepting on fd %d", __func__, fd);
@@ -85,7 +86,8 @@ accept_pause(void)
{
log_debug(__func__);
accept_unarm();
- accept_queue.evt = thread_add_timer(master, accept_timeout, NULL, 1);
+ accept_queue.evt = NULL;
+ thread_add_timer(master, accept_timeout, NULL, 1, &accept_queue.evt);
}
void
@@ -102,8 +104,10 @@ static void
accept_arm(void)
{
struct accept_ev *av;
- LIST_FOREACH(av, &accept_queue.queue, entry)
- av->ev = thread_add_read(master, accept_cb, av, av->fd);
+ LIST_FOREACH(av, &accept_queue.queue, entry) {
+ av->ev = NULL;
+ thread_add_read(master, accept_cb, av, av->fd, &av->ev);
+ }
}
static void
@@ -118,7 +122,8 @@ static int
accept_cb(struct thread *thread)
{
struct accept_ev *av = THREAD_ARG(thread);
- av->ev = thread_add_read(master, accept_cb, av, av->fd);
+ av->ev = NULL;
+ thread_add_read(master, accept_cb, av, av->fd, &av->ev);
av->accept_cb(thread);
return (0);
diff --git a/ldpd/adjacency.c b/ldpd/adjacency.c
index 3ec57f1589..52e2776654 100644
--- a/ldpd/adjacency.c
+++ b/ldpd/adjacency.c
@@ -206,8 +206,9 @@ void
adj_start_itimer(struct adj *adj)
{
THREAD_TIMER_OFF(adj->inactivity_timer);
- adj->inactivity_timer = thread_add_timer(master, adj_itimer, adj,
- adj->holdtime);
+ adj->inactivity_timer = NULL;
+ thread_add_timer(master, adj_itimer, adj, adj->holdtime,
+ &adj->inactivity_timer);
}
void
@@ -366,8 +367,9 @@ static void
tnbr_start_hello_timer(struct tnbr *tnbr)
{
THREAD_TIMER_OFF(tnbr->hello_timer);
- tnbr->hello_timer = thread_add_timer(master, tnbr_hello_timer, tnbr,
- tnbr_get_hello_interval(tnbr));
+ tnbr->hello_timer = NULL;
+ thread_add_timer(master, tnbr_hello_timer, tnbr, tnbr_get_hello_interval(tnbr),
+ &tnbr->hello_timer);
}
static void
diff --git a/ldpd/control.c b/ldpd/control.c
index d40e0342c1..cde99dc8a9 100644
--- a/ldpd/control.c
+++ b/ldpd/control.c
@@ -133,8 +133,9 @@ control_accept(struct thread *thread)
imsg_init(&c->iev.ibuf, connfd);
c->iev.handler_read = control_dispatch_imsg;
- c->iev.ev_read = thread_add_read(master, c->iev.handler_read,
- &c->iev, c->iev.ibuf.fd);
+ c->iev.ev_read = NULL;
+ thread_add_read(master, c->iev.handler_read, &c->iev, c->iev.ibuf.fd,
+ &c->iev.ev_read);
c->iev.handler_write = ldp_write_handler;
c->iev.ev_write = NULL;
diff --git a/ldpd/interface.c b/ldpd/interface.c
index 440bb2dca0..a064a58b2e 100644
--- a/ldpd/interface.c
+++ b/ldpd/interface.c
@@ -440,8 +440,9 @@ static void
if_start_hello_timer(struct iface_af *ia)
{
THREAD_TIMER_OFF(ia->hello_timer);
- ia->hello_timer = thread_add_timer(master, if_hello_timer, ia,
- if_get_hello_interval(ia));
+ ia->hello_timer = NULL;
+ thread_add_timer(master, if_hello_timer, ia, if_get_hello_interval(ia),
+ &ia->hello_timer);
}
static void
diff --git a/ldpd/lde.c b/ldpd/lde.c
index 859d47431b..bef35f3194 100644
--- a/ldpd/lde.c
+++ b/ldpd/lde.c
@@ -140,8 +140,9 @@ lde(void)
fatal(NULL);
imsg_init(&iev_main->ibuf, LDPD_FD_ASYNC);
iev_main->handler_read = lde_dispatch_parent;
- iev_main->ev_read = thread_add_read(master, iev_main->handler_read,
- iev_main, iev_main->ibuf.fd);
+ iev_main->ev_read = NULL;
+ thread_add_read(master, iev_main->handler_read, iev_main, iev_main->ibuf.fd,
+ &iev_main->ev_read);
iev_main->handler_write = ldp_write_handler;
if ((iev_main_sync = calloc(1, sizeof(struct imsgev))) == NULL)
@@ -526,8 +527,9 @@ lde_dispatch_parent(struct thread *thread)
fatal(NULL);
imsg_init(&iev_ldpe->ibuf, fd);
iev_ldpe->handler_read = lde_dispatch_imsg;
- iev_ldpe->ev_read = thread_add_read(master,
- iev_ldpe->handler_read, iev_ldpe, iev_ldpe->ibuf.fd);
+ iev_ldpe->ev_read = NULL;
+ thread_add_read(master, iev_ldpe->handler_read, iev_ldpe, iev_ldpe->ibuf.fd,
+ &iev_ldpe->ev_read);
iev_ldpe->handler_write = ldp_write_handler;
iev_ldpe->ev_write = NULL;
break;
diff --git a/ldpd/lde_lib.c b/ldpd/lde_lib.c
index 37a670bc8c..89aa6d4201 100644
--- a/ldpd/lde_lib.c
+++ b/ldpd/lde_lib.c
@@ -932,8 +932,9 @@ void
lde_gc_start_timer(void)
{
THREAD_TIMER_OFF(gc_timer);
- gc_timer = thread_add_timer(master, lde_gc_timer, NULL,
- LDE_GC_INTERVAL);
+ gc_timer = NULL;
+ thread_add_timer(master, lde_gc_timer, NULL, LDE_GC_INTERVAL,
+ &gc_timer);
}
void
diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c
index bdf7097323..a0b021dfd9 100644
--- a/ldpd/ldpd.c
+++ b/ldpd/ldpd.c
@@ -358,26 +358,30 @@ main(int argc, char *argv[])
fatal(NULL);
imsg_init(&iev_ldpe->ibuf, pipe_parent2ldpe[0]);
iev_ldpe->handler_read = main_dispatch_ldpe;
- iev_ldpe->ev_read = thread_add_read(master, iev_ldpe->handler_read,
- iev_ldpe, iev_ldpe->ibuf.fd);
+ iev_ldpe->ev_read = NULL;
+ thread_add_read(master, iev_ldpe->handler_read, iev_ldpe, iev_ldpe->ibuf.fd,
+ &iev_ldpe->ev_read);
iev_ldpe->handler_write = ldp_write_handler;
imsg_init(&iev_ldpe_sync->ibuf, pipe_parent2ldpe_sync[0]);
iev_ldpe_sync->handler_read = main_dispatch_ldpe;
- iev_ldpe_sync->ev_read = thread_add_read(master,
- iev_ldpe_sync->handler_read, iev_ldpe_sync, iev_ldpe_sync->ibuf.fd);
+ iev_ldpe_sync->ev_read = NULL;
+ thread_add_read(master, iev_ldpe_sync->handler_read, iev_ldpe_sync, iev_ldpe_sync->ibuf.fd,
+ &iev_ldpe_sync->ev_read);
iev_ldpe_sync->handler_write = ldp_write_handler;
imsg_init(&iev_lde->ibuf, pipe_parent2lde[0]);
iev_lde->handler_read = main_dispatch_lde;
- iev_lde->ev_read = thread_add_read(master, iev_lde->handler_read,
- iev_lde, iev_lde->ibuf.fd);
+ iev_lde->ev_read = NULL;
+ thread_add_read(master, iev_lde->handler_read, iev_lde, iev_lde->ibuf.fd,
+ &iev_lde->ev_read);
iev_lde->handler_write = ldp_write_handler;
imsg_init(&iev_lde_sync->ibuf, pipe_parent2lde_sync[0]);
iev_lde_sync->handler_read = main_dispatch_lde;
- iev_lde_sync->ev_read = thread_add_read(master,
- iev_lde_sync->handler_read, iev_lde_sync, iev_lde_sync->ibuf.fd);
+ iev_lde_sync->ev_read = NULL;
+ thread_add_read(master, iev_lde_sync->handler_read, iev_lde_sync, iev_lde_sync->ibuf.fd,
+ &iev_lde_sync->ev_read);
iev_lde_sync->handler_write = ldp_write_handler;
if (main_imsg_send_ipc_sockets(&iev_ldpe->ibuf, &iev_lde->ibuf))
@@ -690,12 +694,12 @@ void
imsg_event_add(struct imsgev *iev)
{
if (iev->handler_read)
- THREAD_READ_ON(master, iev->ev_read, iev->handler_read, iev,
- iev->ibuf.fd);
+ thread_add_read(master, iev->handler_read, iev, iev->ibuf.fd,
+ &iev->ev_read);
if (iev->handler_write && iev->ibuf.w.queued)
- THREAD_WRITE_ON(master, iev->ev_write, iev->handler_write, iev,
- iev->ibuf.fd);
+ thread_add_write(master, iev->handler_write, iev,
+ iev->ibuf.fd, &iev->ev_write);
}
int
@@ -721,8 +725,8 @@ void
evbuf_event_add(struct evbuf *eb)
{
if (eb->wbuf.queued)
- THREAD_WRITE_ON(master, eb->ev, eb->handler, eb->arg,
- eb->wbuf.fd);
+ thread_add_write(master, eb->handler, eb->arg, eb->wbuf.fd,
+ &eb->ev);
}
void
diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c
index 017eec2502..ce2441ca2f 100644
--- a/ldpd/ldpe.c
+++ b/ldpd/ldpe.c
@@ -119,8 +119,9 @@ ldpe(void)
fatal(NULL);
imsg_init(&iev_main->ibuf, LDPD_FD_ASYNC);
iev_main->handler_read = ldpe_dispatch_main;
- iev_main->ev_read = thread_add_read(master, iev_main->handler_read,
- iev_main, iev_main->ibuf.fd);
+ iev_main->ev_read = NULL;
+ thread_add_read(master, iev_main->handler_read, iev_main, iev_main->ibuf.fd,
+ &iev_main->ev_read);
iev_main->handler_write = ldp_write_handler;
if ((iev_main_sync = calloc(1, sizeof(struct imsgev))) == NULL)
@@ -164,9 +165,11 @@ ldpe_init(struct ldpd_init *init)
fatal("inet_pton");
#ifdef __OpenBSD__
global.pfkeysock = pfkey_init();
- if (sysdep.no_pfkey == 0)
- pfkey_ev = thread_add_read(master, ldpe_dispatch_pfkey,
- NULL, global.pfkeysock);
+ if (sysdep.no_pfkey == 0) {
+ pfkey_ev = NULL;
+ thread_add_read(master, ldpe_dispatch_pfkey, NULL, global.pfkeysock,
+ &pfkey_ev);
+ }
#endif
/* mark sockets as closed */
@@ -353,8 +356,9 @@ ldpe_dispatch_main(struct thread *thread)
fatal(NULL);
imsg_init(&iev_lde->ibuf, fd);
iev_lde->handler_read = ldpe_dispatch_lde;
- iev_lde->ev_read = thread_add_read(master,
- iev_lde->handler_read, iev_lde, iev_lde->ibuf.fd);
+ iev_lde->ev_read = NULL;
+ thread_add_read(master, iev_lde->handler_read, iev_lde, iev_lde->ibuf.fd,
+ &iev_lde->ev_read);
iev_lde->handler_write = ldp_write_handler;
iev_lde->ev_write = NULL;
break;
@@ -694,8 +698,9 @@ ldpe_dispatch_pfkey(struct thread *thread)
{
int fd = THREAD_FD(thread);
- pfkey_ev = thread_add_read(master, ldpe_dispatch_pfkey,
- NULL, global.pfkeysock);
+ pfkey_ev = NULL;
+ thread_add_read(master, ldpe_dispatch_pfkey, NULL, global.pfkeysock,
+ &pfkey_ev);
if (pfkey_read(fd, NULL) == -1)
fatal("pfkey_read failed, exiting...");
@@ -714,13 +719,15 @@ ldpe_setup_sockets(int af, int disc_socket, int edisc_socket,
/* discovery socket */
af_global->ldp_disc_socket = disc_socket;
- af_global->disc_ev = thread_add_read(master, disc_recv_packet,
- &af_global->disc_ev, af_global->ldp_disc_socket);
+ af_global->disc_ev = NULL;
+ thread_add_read(master, disc_recv_packet, &af_global->disc_ev, af_global->ldp_disc_socket,
+ &af_global->disc_ev);
/* extended discovery socket */
af_global->ldp_edisc_socket = edisc_socket;
- af_global->edisc_ev = thread_add_read(master, disc_recv_packet,
- &af_global->edisc_ev, af_global->ldp_edisc_socket);
+ af_global->edisc_ev = NULL;
+ thread_add_read(master, disc_recv_packet, &af_global->edisc_ev, af_global->ldp_edisc_socket,
+ &af_global->edisc_ev);
/* session socket */
af_global->ldp_session_socket = session_socket;
diff --git a/ldpd/neighbor.c b/ldpd/neighbor.c
index 9a92a00d32..f867db228d 100644
--- a/ldpd/neighbor.c
+++ b/ldpd/neighbor.c
@@ -408,7 +408,8 @@ nbr_start_ktimer(struct nbr *nbr)
/* send three keepalives per period */
secs = nbr->keepalive / KEEPALIVE_PER_PERIOD;
THREAD_TIMER_OFF(nbr->keepalive_timer);
- nbr->keepalive_timer = thread_add_timer(master, nbr_ktimer, nbr, secs);
+ nbr->keepalive_timer = NULL;
+ thread_add_timer(master, nbr_ktimer, nbr, secs, &nbr->keepalive_timer);
}
void
@@ -437,8 +438,9 @@ static void
nbr_start_ktimeout(struct nbr *nbr)
{
THREAD_TIMER_OFF(nbr->keepalive_timeout);
- nbr->keepalive_timeout = thread_add_timer(master, nbr_ktimeout, nbr,
- nbr->keepalive);
+ nbr->keepalive_timeout = NULL;
+ thread_add_timer(master, nbr_ktimeout, nbr, nbr->keepalive,
+ &nbr->keepalive_timeout);
}
void
@@ -468,7 +470,8 @@ nbr_start_itimeout(struct nbr *nbr)
secs = INIT_FSM_TIMEOUT;
THREAD_TIMER_OFF(nbr->init_timeout);
- nbr->init_timeout = thread_add_timer(master, nbr_itimeout, nbr, secs);
+ nbr->init_timeout = NULL;
+ thread_add_timer(master, nbr_itimeout, nbr, secs, &nbr->init_timeout);
}
void
@@ -516,7 +519,9 @@ nbr_start_idtimer(struct nbr *nbr)
}
THREAD_TIMER_OFF(nbr->initdelay_timer);
- nbr->initdelay_timer = thread_add_timer(master, nbr_idtimer, nbr, secs);
+ nbr->initdelay_timer = NULL;
+ thread_add_timer(master, nbr_idtimer, nbr, secs,
+ &nbr->initdelay_timer);
}
void
@@ -633,8 +638,8 @@ nbr_establish_connection(struct nbr *nbr)
if (connect(nbr->fd, (struct sockaddr *)&remote_sa,
sockaddr_len((struct sockaddr *)&remote_sa)) == -1) {
if (errno == EINPROGRESS) {
- THREAD_WRITE_ON(master, nbr->ev_connect, nbr_connect_cb,
- nbr, nbr->fd);
+ thread_add_write(master, nbr_connect_cb, nbr, nbr->fd,
+ &nbr->ev_connect);
return (0);
}
log_warn("%s: error while connecting to %s", __func__,
diff --git a/ldpd/packet.c b/ldpd/packet.c
index df6bd8e57a..be7f2ba649 100644
--- a/ldpd/packet.c
+++ b/ldpd/packet.c
@@ -143,7 +143,8 @@ disc_recv_packet(struct thread *thread)
struct in_addr lsr_id;
/* reschedule read */
- *threadp = thread_add_read(master, disc_recv_packet, threadp, fd);
+ *threadp = NULL;
+ thread_add_read(master, disc_recv_packet, threadp, fd, &*threadp);
/* setup buffer */
memset(&m, 0, sizeof(m));
@@ -427,7 +428,8 @@ session_read(struct thread *thread)
uint16_t pdu_len, msg_len, msg_size, max_pdu_len;
int ret;
- tcp->rev = thread_add_read(master, session_read, nbr, fd);
+ tcp->rev = NULL;
+ thread_add_read(master, session_read, nbr, fd, &tcp->rev);
if ((n = read(fd, tcp->rbuf->buf + tcp->rbuf->wpos,
sizeof(tcp->rbuf->buf) - tcp->rbuf->wpos)) == -1) {
@@ -731,7 +733,8 @@ tcp_new(int fd, struct nbr *nbr)
if ((tcp->rbuf = calloc(1, sizeof(struct ibuf_read))) == NULL)
fatal(__func__);
- tcp->rev = thread_add_read(master, session_read, nbr, tcp->fd);
+ tcp->rev = NULL;
+ thread_add_read(master, session_read, nbr, tcp->fd, &tcp->rev);
tcp->nbr = nbr;
}
@@ -777,8 +780,9 @@ pending_conn_new(int fd, int af, union ldpd_addr *addr)
pconn->af = af;
pconn->addr = *addr;
TAILQ_INSERT_TAIL(&global.pending_conns, pconn, entry);
- pconn->ev_timeout = thread_add_timer(master, pending_conn_timeout,
- pconn, PENDING_CONN_TIMEOUT);
+ pconn->ev_timeout = NULL;
+ thread_add_timer(master, pending_conn_timeout, pconn, PENDING_CONN_TIMEOUT,
+ &pconn->ev_timeout);
return (pconn);
}
diff --git a/lib/agentx.c b/lib/agentx.c
index e1d8b54043..5deb8f1e06 100644
--- a/lib/agentx.c
+++ b/lib/agentx.c
@@ -85,8 +85,11 @@ agentx_events_update(void)
FD_ZERO (&fds);
snmp_select_info (&maxfd, &fds, &timeout, &block);
- if (!block)
- timeout_thr = thread_add_timer_tv (agentx_tm, agentx_timeout, NULL, &timeout);
+ if (!block) {
+ timeout_thr = NULL;
+ thread_add_timer_tv(agentx_tm, agentx_timeout, NULL, &timeout,
+ &timeout_thr);
+ }
ln = listhead (events);
thr = ln ? listgetdata (ln) : NULL;
@@ -114,7 +117,8 @@ agentx_events_update(void)
else if (FD_ISSET (fd, &fds))
{
struct listnode *newln;
- thr = thread_add_read (agentx_tm, agentx_read, NULL, fd);
+ thr = NULL;
+ thread_add_read(agentx_tm, agentx_read, NULL, fd, &thr);
newln = listnode_add_before (events, ln, thr);
thr->arg = newln;
}
diff --git a/lib/command.c b/lib/command.c
index 11c9a0968b..03092ed184 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -1623,8 +1623,11 @@ permute (struct graph_node *start, struct vty *vty)
bool skip = false;
if (stok->type == FORK_TKN && tok->type != FORK_TKN)
for (ALL_LIST_ELEMENTS_RO (position, ln, gnn))
- if (gnn == gn && (skip = true))
+ if (gnn == gn)
+ {
+ skip = true;
break;
+ }
if (!skip)
permute (gn, vty);
}
diff --git a/lib/sigevent.c b/lib/sigevent.c
index b2059a17bf..a34fd4946e 100644
--- a/lib/sigevent.c
+++ b/lib/sigevent.c
@@ -132,8 +132,9 @@ quagga_signal_timer (struct thread *t)
int i;
sigm = THREAD_ARG (t);
- sigm->t = thread_add_timer (sigm->t->master, quagga_signal_timer, &sigmaster,
- QUAGGA_SIGNAL_TIMER_INTERVAL);
+ sigm->t = NULL;
+ thread_add_timer(sigm->t->master, quagga_signal_timer, &sigmaster, QUAGGA_SIGNAL_TIMER_INTERVAL,
+ &sigm->t);
return quagga_sigevent_process ();
}
#endif /* SIGEVENT_SCHEDULE_THREAD */
@@ -378,8 +379,8 @@ signal_init (struct thread_master *m, int sigc,
sigmaster.signals = signals;
#ifdef SIGEVENT_SCHEDULE_THREAD
- sigmaster.t =
- thread_add_timer (m, quagga_signal_timer, &sigmaster,
- QUAGGA_SIGNAL_TIMER_INTERVAL);
+ sigmaster.t = NULL;
+ thread_add_timer(m, quagga_signal_timer, &sigmaster, QUAGGA_SIGNAL_TIMER_INTERVAL,
+ &sigmaster.t);
#endif /* SIGEVENT_SCHEDULE_THREAD */
}
diff --git a/lib/smux.c b/lib/smux.c
index 370b8f138e..6e53061d45 100644
--- a/lib/smux.c
+++ b/lib/smux.c
@@ -1197,13 +1197,18 @@ smux_event (enum smux_event event, int sock)
switch (event)
{
case SMUX_SCHEDULE:
- smux_connect_thread = thread_add_event (smux_master, smux_connect, NULL, 0);
+ smux_connect_thread = NULL;
+ thread_add_event(smux_master, smux_connect, NULL, 0,
+ &smux_connect_thread);
break;
case SMUX_CONNECT:
- smux_connect_thread = thread_add_timer (smux_master, smux_connect, NULL, 10);
+ smux_connect_thread = NULL;
+ thread_add_timer(smux_master, smux_connect, NULL, 10,
+ &smux_connect_thread);
break;
case SMUX_READ:
- smux_read_thread = thread_add_read (smux_master, smux_read, NULL, sock);
+ smux_read_thread = NULL;
+ thread_add_read(smux_master, smux_read, NULL, sock, &smux_read_thread);
break;
default:
break;
diff --git a/lib/spf_backoff.c b/lib/spf_backoff.c
index e923f232b8..9a9af8db20 100644
--- a/lib/spf_backoff.c
+++ b/lib/spf_backoff.c
@@ -169,21 +169,19 @@ long spf_backoff_schedule(struct spf_backoff *backoff)
{
case SPF_BACKOFF_QUIET:
backoff->state = SPF_BACKOFF_SHORT_WAIT;
- THREAD_TIMER_MSEC_ON(backoff->m, backoff->t_timetolearn,
- spf_backoff_timetolearn_elapsed, backoff,
- backoff->timetolearn);
- THREAD_TIMER_MSEC_ON(backoff->m, backoff->t_holddown,
- spf_backoff_holddown_elapsed, backoff,
- backoff->holddown);
+ thread_add_timer_msec(backoff->m, spf_backoff_timetolearn_elapsed,
+ backoff, backoff->timetolearn,
+ &backoff->t_timetolearn);
+ thread_add_timer_msec(backoff->m, spf_backoff_holddown_elapsed, backoff,
+ backoff->holddown, &backoff->t_holddown);
backoff->first_event_time = now;
rv = backoff->init_delay;
break;
case SPF_BACKOFF_SHORT_WAIT:
case SPF_BACKOFF_LONG_WAIT:
THREAD_TIMER_OFF(backoff->t_holddown);
- THREAD_TIMER_MSEC_ON(backoff->m, backoff->t_holddown,
- spf_backoff_holddown_elapsed, backoff,
- backoff->holddown);
+ thread_add_timer_msec(backoff->m, spf_backoff_holddown_elapsed, backoff,
+ backoff->holddown, &backoff->t_holddown);
if (backoff->state == SPF_BACKOFF_SHORT_WAIT)
rv = backoff->short_delay;
else
diff --git a/lib/systemd.c b/lib/systemd.c
index 4c78cf328c..e2329af93a 100644
--- a/lib/systemd.c
+++ b/lib/systemd.c
@@ -104,7 +104,7 @@ systemd_send_watchdog (struct thread *t)
{
systemd_send_information ("WATCHDOG=1");
- thread_add_timer (systemd_master, systemd_send_watchdog, NULL, wsecs);
+ thread_add_timer(systemd_master, systemd_send_watchdog, NULL, wsecs, NULL);
return 1;
}
@@ -119,5 +119,5 @@ systemd_send_started (struct thread_master *m, int the_process)
systemd_send_information ("READY=1");
if (wsecs != 0)
- thread_add_timer (m, systemd_send_watchdog, m, wsecs);
+ thread_add_timer(m, systemd_send_watchdog, m, wsecs, NULL);
}
diff --git a/lib/thread.c b/lib/thread.c
index 3fb28bce26..e4dbebe1c4 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -454,6 +454,7 @@ thread_add_unuse (struct thread_master *m, struct thread *thread)
assert (m != NULL && thread != NULL);
assert (thread->next == NULL);
assert (thread->prev == NULL);
+ thread->ref = NULL;
thread->type = THREAD_UNUSED;
thread->hist->total_active--;
@@ -725,6 +726,7 @@ fd_select (struct thread_master *m, int size, thread_fd_set *read, thread_fd_set
num = poll (m->handler.pfds, m->handler.pfdcount + m->handler.pfdcountsnmp, timeout);
#else
struct timeval timeout;
+
if (m->selectpoll_timeout > 0) // use the user's timeout
{
timeout.tv_sec = m->selectpoll_timeout / 1000;
@@ -774,15 +776,21 @@ fd_clear_read_write (struct thread *thread)
}
/* Add new read thread. */
-struct thread *
+void
funcname_thread_add_read_write (int dir, struct thread_master *m,
- int (*func) (struct thread *), void *arg, int fd,
- debugargdef)
+ int (*func) (struct thread *), void *arg, int fd, struct thread **t_ptr,
+ debugargdef)
{
struct thread *thread = NULL;
pthread_mutex_lock (&m->mtx);
{
+ if (t_ptr && *t_ptr) // thread is already scheduled; don't reschedule
+ {
+ pthread_mutex_unlock (&m->mtx);
+ return;
+ }
+
#if defined (HAVE_POLL_CALL)
thread = generic_thread_add(m, func, arg, fd, dir, debugargpass);
#else
@@ -822,19 +830,20 @@ funcname_thread_add_read_write (int dir, struct thread_master *m,
}
pthread_mutex_unlock (&thread->mtx);
}
+
+ if (t_ptr)
+ {
+ *t_ptr = thread;
+ thread->ref = t_ptr;
+ }
}
pthread_mutex_unlock (&m->mtx);
-
- return thread;
}
-static struct thread *
+static void
funcname_thread_add_timer_timeval (struct thread_master *m,
- int (*func) (struct thread *),
- int type,
- void *arg,
- struct timeval *time_relative,
- debugargdef)
+ int (*func) (struct thread *), int type, void *arg,
+ struct timeval *time_relative, struct thread **t_ptr, debugargdef)
{
struct thread *thread;
struct pqueue *queue;
@@ -846,6 +855,12 @@ funcname_thread_add_timer_timeval (struct thread_master *m,
pthread_mutex_lock (&m->mtx);
{
+ if (t_ptr && *t_ptr) // thread is already scheduled; don't reschedule
+ {
+ pthread_mutex_unlock (&m->mtx);
+ return;
+ }
+
queue = ((type == THREAD_TIMER) ? m->timer : m->background);
thread = thread_get (m, type, func, arg, debugargpass);
@@ -856,19 +871,22 @@ funcname_thread_add_timer_timeval (struct thread_master *m,
pqueue_enqueue(thread, queue);
}
pthread_mutex_unlock (&thread->mtx);
+
+ if (t_ptr)
+ {
+ *t_ptr = thread;
+ thread->ref = t_ptr;
+ }
}
pthread_mutex_unlock (&m->mtx);
-
- return thread;
}
/* Add timer event thread. */
-struct thread *
+void
funcname_thread_add_timer (struct thread_master *m,
- int (*func) (struct thread *),
- void *arg, long timer,
- debugargdef)
+ int (*func) (struct thread *), void *arg, long timer,
+ struct thread **t_ptr, debugargdef)
{
struct timeval trel;
@@ -877,16 +895,15 @@ funcname_thread_add_timer (struct thread_master *m,
trel.tv_sec = timer;
trel.tv_usec = 0;
- return funcname_thread_add_timer_timeval (m, func, THREAD_TIMER, arg,
- &trel, debugargpass);
+ return funcname_thread_add_timer_timeval (m, func, THREAD_TIMER, arg, &trel,
+ t_ptr, debugargpass);
}
/* Add timer event thread with "millisecond" resolution */
-struct thread *
+void
funcname_thread_add_timer_msec (struct thread_master *m,
- int (*func) (struct thread *),
- void *arg, long timer,
- debugargdef)
+ int (*func) (struct thread *), void *arg, long timer,
+ struct thread **t_ptr, debugargdef)
{
struct timeval trel;
@@ -895,27 +912,25 @@ funcname_thread_add_timer_msec (struct thread_master *m,
trel.tv_sec = timer / 1000;
trel.tv_usec = 1000*(timer % 1000);
- return funcname_thread_add_timer_timeval (m, func, THREAD_TIMER,
- arg, &trel, debugargpass);
+ funcname_thread_add_timer_timeval (m, func, THREAD_TIMER, arg, &trel,
+ t_ptr, debugargpass);
}
/* Add timer event thread with "millisecond" resolution */
-struct thread *
+void
funcname_thread_add_timer_tv (struct thread_master *m,
- int (*func) (struct thread *),
- void *arg, struct timeval *tv,
- debugargdef)
+ int (*func) (struct thread *), void *arg, struct timeval *tv,
+ struct thread **t_ptr, debugargdef)
{
- return funcname_thread_add_timer_timeval (m, func, THREAD_TIMER,
- arg, tv, debugargpass);
+ funcname_thread_add_timer_timeval (m, func, THREAD_TIMER, arg, tv, t_ptr,
+ debugargpass);
}
/* Add a background thread, with an optional millisec delay */
-struct thread *
+void
funcname_thread_add_background (struct thread_master *m,
- int (*func) (struct thread *),
- void *arg, long delay,
- debugargdef)
+ int (*func) (struct thread *), void *arg, long delay,
+ struct thread **t_ptr, debugargdef)
{
struct timeval trel;
@@ -932,15 +947,15 @@ funcname_thread_add_background (struct thread_master *m,
trel.tv_usec = 0;
}
- return funcname_thread_add_timer_timeval (m, func, THREAD_BACKGROUND,
- arg, &trel, debugargpass);
+ funcname_thread_add_timer_timeval (m, func, THREAD_BACKGROUND, arg, &trel,
+ t_ptr, debugargpass);
}
/* Add simple event thread. */
-struct thread *
+void
funcname_thread_add_event (struct thread_master *m,
- int (*func) (struct thread *), void *arg, int val,
- debugargdef)
+ int (*func) (struct thread *), void *arg, int val,
+ struct thread **t_ptr, debugargdef)
{
struct thread *thread;
@@ -948,6 +963,12 @@ funcname_thread_add_event (struct thread_master *m,
pthread_mutex_lock (&m->mtx);
{
+ if (t_ptr && *t_ptr) // thread is already scheduled; don't reschedule
+ {
+ pthread_mutex_unlock (&m->mtx);
+ return;
+ }
+
thread = thread_get (m, THREAD_EVENT, func, arg, debugargpass);
pthread_mutex_lock (&thread->mtx);
{
@@ -955,10 +976,14 @@ funcname_thread_add_event (struct thread_master *m,
thread_list_add (&m->event, thread);
}
pthread_mutex_unlock (&thread->mtx);
+
+ if (t_ptr)
+ {
+ *t_ptr = thread;
+ thread->ref = t_ptr;
+ }
}
pthread_mutex_unlock (&m->mtx);
-
- return thread;
}
static void
@@ -1056,6 +1081,9 @@ thread_cancel (struct thread *thread)
assert(!"Thread should be either in queue or list or array!");
}
+ if (thread->ref)
+ *thread->ref = NULL;
+
thread_add_unuse (thread->master, thread);
done:
@@ -1085,6 +1113,8 @@ thread_cancel_event (struct thread_master *m, void *arg)
{
ret++;
thread_list_delete (&m->event, t);
+ if (t->ref)
+ *t->ref = NULL;
thread_add_unuse (m, t);
}
}
@@ -1104,6 +1134,8 @@ thread_cancel_event (struct thread_master *m, void *arg)
{
ret++;
thread_list_delete (&m->ready, t);
+ if (t->ref)
+ *t->ref = NULL;
thread_add_unuse (m, t);
}
}
@@ -1285,6 +1317,8 @@ thread_fetch (struct thread_master *m, struct thread *fetch)
if ((thread = thread_trim_head (&m->ready)) != NULL)
{
fetch = thread_run (m, thread, fetch);
+ if (fetch->ref)
+ *fetch->ref = NULL;
pthread_mutex_unlock (&m->mtx);
return fetch;
}
@@ -1354,6 +1388,8 @@ thread_fetch (struct thread_master *m, struct thread *fetch)
if ((thread = thread_trim_head (&m->ready)) != NULL)
{
fetch = thread_run (m, thread, fetch);
+ if (fetch->ref)
+ *fetch->ref = NULL;
pthread_mutex_unlock (&m->mtx);
return fetch;
}
@@ -1365,6 +1401,8 @@ thread_fetch (struct thread_master *m, struct thread *fetch)
if ((thread = thread_trim_head (&m->ready)) != NULL)
{
fetch = thread_run (m, thread, fetch);
+ if (fetch->ref)
+ *fetch->ref = NULL;
pthread_mutex_unlock (&m->mtx);
return fetch;
}
@@ -1472,7 +1510,7 @@ thread_call (struct thread *thread)
}
/* Execute thread */
-struct thread *
+void
funcname_thread_execute (struct thread_master *m,
int (*func)(struct thread *),
void *arg,
@@ -1504,6 +1542,4 @@ funcname_thread_execute (struct thread_master *m,
dummy.schedfrom_line = fromln;
thread_call (&dummy);
-
- return NULL;
}
diff --git a/lib/thread.h b/lib/thread.h
index 6fb6ad7c9d..3eaae8883b 100644
--- a/lib/thread.h
+++ b/lib/thread.h
@@ -96,26 +96,27 @@ typedef unsigned char thread_type;
/* Thread itself. */
struct thread
{
- thread_type type; /* thread type */
- thread_type add_type; /* thread type */
- struct thread *next; /* next pointer of the thread */
- struct thread *prev; /* previous pointer of the thread */
- struct thread_master *master; /* pointer to the struct thread_master. */
- int (*func) (struct thread *); /* event function */
- void *arg; /* event argument */
+ thread_type type; /* thread type */
+ thread_type add_type; /* thread type */
+ struct thread *next; /* next pointer of the thread */
+ struct thread *prev; /* previous pointer of the thread */
+ struct thread **ref; /* external reference (if given) */
+ struct thread_master *master; /* pointer to the struct thread_master */
+ int (*func) (struct thread *); /* event function */
+ void *arg; /* event argument */
union {
- int val; /* second argument of the event. */
- int fd; /* file descriptor in case of read/write. */
- struct timeval sands; /* rest of time sands value. */
+ int val; /* second argument of the event. */
+ int fd; /* file descriptor in case of r/w */
+ struct timeval sands; /* rest of time sands value. */
} u;
- int index; /* used for timers to store position in queue */
+ int index; /* queue position for timers */
struct timeval real;
- struct cpu_thread_history *hist; /* cache pointer to cpu_history */
- unsigned long yield; /* yield time in us */
- const char *funcname;
- const char *schedfrom;
- int schedfrom_line;
- pthread_mutex_t mtx;
+ struct cpu_thread_history *hist; /* cache pointer to cpu_history */
+ unsigned long yield; /* yield time in microseconds */
+ const char *funcname; /* name of thread function */
+ const char *schedfrom; /* source file thread was scheduled from */
+ int schedfrom_line; /* line number of source file */
+ pthread_mutex_t mtx; /* mutex for thread.c functions */
};
struct cpu_thread_history
@@ -153,30 +154,6 @@ struct cpu_thread_history
#define THREAD_FD(X) ((X)->u.fd)
#define THREAD_VAL(X) ((X)->u.val)
-#define THREAD_READ_ON(master,thread,func,arg,sock) \
- do { \
- if (! thread) \
- thread = thread_add_read (master, func, arg, sock); \
- } while (0)
-
-#define THREAD_WRITE_ON(master,thread,func,arg,sock) \
- do { \
- if (! thread) \
- thread = thread_add_write (master, func, arg, sock); \
- } while (0)
-
-#define THREAD_TIMER_ON(master,thread,func,arg,time) \
- do { \
- if (! thread) \
- thread = thread_add_timer (master, func, arg, time); \
- } while (0)
-
-#define THREAD_TIMER_MSEC_ON(master,thread,func,arg,time) \
- do { \
- if (! thread) \
- thread = thread_add_timer_msec (master, func, arg, time); \
- } while (0)
-
#define THREAD_OFF(thread) \
do { \
if (thread) \
@@ -192,46 +169,42 @@ struct cpu_thread_history
#define debugargdef const char *funcname, const char *schedfrom, int fromln
-#define thread_add_read(m,f,a,v) funcname_thread_add_read_write(THREAD_READ,m,f,a,v,#f,__FILE__,__LINE__)
-#define thread_add_write(m,f,a,v) funcname_thread_add_read_write(THREAD_WRITE,m,f,a,v,#f,__FILE__,__LINE__)
-#define thread_add_timer(m,f,a,v) funcname_thread_add_timer(m,f,a,v,#f,__FILE__,__LINE__)
-#define thread_add_timer_msec(m,f,a,v) funcname_thread_add_timer_msec(m,f,a,v,#f,__FILE__,__LINE__)
-#define thread_add_timer_tv(m,f,a,v) funcname_thread_add_timer_tv(m,f,a,v,#f,__FILE__,__LINE__)
-#define thread_add_event(m,f,a,v) funcname_thread_add_event(m,f,a,v,#f,__FILE__,__LINE__)
+#define thread_add_read(m,f,a,v,t) funcname_thread_add_read_write(THREAD_READ,m,f,a,v,t,#f,__FILE__,__LINE__)
+#define thread_add_write(m,f,a,v,t) funcname_thread_add_read_write(THREAD_WRITE,m,f,a,v,t,#f,__FILE__,__LINE__)
+#define thread_add_timer(m,f,a,v,t) funcname_thread_add_timer(m,f,a,v,t,#f,__FILE__,__LINE__)
+#define thread_add_timer_msec(m,f,a,v,t) funcname_thread_add_timer_msec(m,f,a,v,t,#f,__FILE__,__LINE__)
+#define thread_add_timer_tv(m,f,a,v,t) funcname_thread_add_timer_tv(m,f,a,v,t,#f,__FILE__,__LINE__)
+#define thread_add_event(m,f,a,v,t) funcname_thread_add_event(m,f,a,v,t,#f,__FILE__,__LINE__)
#define thread_execute(m,f,a,v) funcname_thread_execute(m,f,a,v,#f,__FILE__,__LINE__)
/* The 4th arg to thread_add_background is the # of milliseconds to delay. */
-#define thread_add_background(m,f,a,v) funcname_thread_add_background(m,f,a,v,#f,__FILE__,__LINE__)
+#define thread_add_background(m,f,a,v,t) funcname_thread_add_background(m,f,a,v,t,#f,__FILE__,__LINE__)
/* Prototypes. */
extern struct thread_master *thread_master_create (void);
extern void thread_master_free (struct thread_master *);
extern void thread_master_free_unused(struct thread_master *);
-extern struct thread *funcname_thread_add_read_write (int dir, struct thread_master *,
- int (*)(struct thread *),
- void *, int, debugargdef);
-extern struct thread *funcname_thread_add_timer (struct thread_master *,
- int (*)(struct thread *),
- void *, long, debugargdef);
-extern struct thread *funcname_thread_add_timer_msec (struct thread_master *,
- int (*)(struct thread *),
- void *, long, debugargdef);
-extern struct thread *funcname_thread_add_timer_tv (struct thread_master *,
- int (*)(struct thread *),
- void *, struct timeval *,
- debugargdef);
-extern struct thread *funcname_thread_add_event (struct thread_master *,
- int (*)(struct thread *),
- void *, int, debugargdef);
-extern struct thread *funcname_thread_add_background (struct thread_master *,
- int (*func)(struct thread *),
- void *arg,
- long milliseconds_to_delay,
- debugargdef);
-extern struct thread *funcname_thread_execute (struct thread_master *,
- int (*)(struct thread *),
- void *, int, debugargdef);
+extern void funcname_thread_add_read_write (int dir, struct thread_master *,
+ int (*)(struct thread *), void *, int, struct thread **, debugargdef);
+
+extern void funcname_thread_add_timer (struct thread_master *,
+ int (*)(struct thread *), void *, long, struct thread **, debugargdef);
+
+extern void funcname_thread_add_timer_msec (struct thread_master *,
+ int (*)(struct thread *), void *, long, struct thread **, debugargdef);
+
+extern void funcname_thread_add_timer_tv (struct thread_master *,
+ int (*)(struct thread *), void *, struct timeval *, struct thread **, debugargdef);
+
+extern void funcname_thread_add_event (struct thread_master *,
+ int (*)(struct thread *), void *, int, struct thread **, debugargdef);
+
+extern void funcname_thread_add_background (struct thread_master *,
+ int (*)(struct thread *), void *, long, struct thread **, debugargdef);
+
+extern void funcname_thread_execute (struct thread_master *,
+ int (*)(struct thread *), void *, int, debugargdef);
#undef debugargdef
extern void thread_cancel (struct thread *);
diff --git a/lib/vty.c b/lib/vty.c
index 225a82c2db..a8e54a57de 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -2618,36 +2618,41 @@ vty_event (enum event event, int sock, struct vty *vty)
switch (event)
{
case VTY_SERV:
- vty_serv_thread = thread_add_read (vty_master, vty_accept, vty, sock);
+ vty_serv_thread = NULL;
+ thread_add_read(vty_master, vty_accept, vty, sock, &vty_serv_thread);
vector_set_index (Vvty_serv_thread, sock, vty_serv_thread);
break;
#ifdef VTYSH
case VTYSH_SERV:
- vty_serv_thread = thread_add_read (vty_master, vtysh_accept, vty, sock);
+ vty_serv_thread = NULL;
+ thread_add_read(vty_master, vtysh_accept, vty, sock, &vty_serv_thread);
vector_set_index (Vvty_serv_thread, sock, vty_serv_thread);
break;
case VTYSH_READ:
- vty->t_read = thread_add_read (vty_master, vtysh_read, vty, sock);
+ vty->t_read = NULL;
+ thread_add_read(vty_master, vtysh_read, vty, sock, &vty->t_read);
break;
case VTYSH_WRITE:
- vty->t_write = thread_add_write (vty_master, vtysh_write, vty, sock);
+ vty->t_write = NULL;
+ thread_add_write(vty_master, vtysh_write, vty, sock, &vty->t_write);
break;
#endif /* VTYSH */
case VTY_READ:
- vty->t_read = thread_add_read (vty_master, vty_read, vty, sock);
+ vty->t_read = NULL;
+ thread_add_read(vty_master, vty_read, vty, sock, &vty->t_read);
/* Time out treatment. */
if (vty->v_timeout)
{
if (vty->t_timeout)
thread_cancel (vty->t_timeout);
- vty->t_timeout =
- thread_add_timer (vty_master, vty_timeout, vty, vty->v_timeout);
+ vty->t_timeout = NULL;
+ thread_add_timer(vty_master, vty_timeout, vty, vty->v_timeout,
+ &vty->t_timeout);
}
break;
case VTY_WRITE:
- if (! vty->t_write)
- vty->t_write = thread_add_write (vty_master, vty_flush, vty, sock);
+ thread_add_write(vty_master, vty_flush, vty, sock, &vty->t_write);
break;
case VTY_TIMEOUT_RESET:
if (vty->t_timeout)
@@ -2657,8 +2662,9 @@ vty_event (enum event event, int sock, struct vty *vty)
}
if (vty->v_timeout)
{
- vty->t_timeout =
- thread_add_timer (vty_master, vty_timeout, vty, vty->v_timeout);
+ vty->t_timeout = NULL;
+ thread_add_timer(vty_master, vty_timeout, vty, vty->v_timeout,
+ &vty->t_timeout);
}
break;
}
diff --git a/lib/wheel.c b/lib/wheel.c
index fe53dea299..9bcb1b8743 100644
--- a/lib/wheel.c
+++ b/lib/wheel.c
@@ -60,9 +60,8 @@ wheel_timer_thread (struct thread *t)
slots_to_skip++;
wheel->slots_to_skip = slots_to_skip;
- THREAD_TIMER_MSEC_ON (wheel->master, wheel->timer,
- wheel_timer_thread, wheel,
- wheel->nexttime * slots_to_skip);
+ thread_add_timer_msec(wheel->master, wheel_timer_thread, wheel,
+ wheel->nexttime * slots_to_skip, &wheel->timer);
return 0;
}
@@ -91,9 +90,8 @@ wheel_init (struct thread_master *master, int period, size_t slots,
for (i = 0; i < slots; i++)
wheel->wheel_slot_lists[i] = list_new ();
- THREAD_TIMER_MSEC_ON (wheel->master, wheel->timer,
- wheel_timer_thread, wheel,
- wheel->nexttime);
+ thread_add_timer_msec(wheel->master, wheel_timer_thread, wheel,
+ wheel->nexttime, &wheel->timer);
return wheel;
}
@@ -124,9 +122,8 @@ int
wheel_start (struct timer_wheel *wheel)
{
if (!wheel->timer)
- THREAD_TIMER_MSEC_ON (wheel->master, wheel->timer,
- wheel_timer_thread, wheel,
- wheel->nexttime);
+ thread_add_timer_msec(wheel->master, wheel_timer_thread, wheel,
+ wheel->nexttime, &wheel->timer);
return 0;
}
diff --git a/lib/workqueue.c b/lib/workqueue.c
index 51017b34ea..e997e61b32 100644
--- a/lib/workqueue.c
+++ b/lib/workqueue.c
@@ -126,8 +126,9 @@ work_queue_schedule (struct work_queue *wq, unsigned int delay)
&& (wq->thread == NULL)
&& (listcount (wq->items) > 0) )
{
- wq->thread = thread_add_background (wq->master, work_queue_run,
- wq, delay);
+ wq->thread = NULL;
+ thread_add_background(wq->master, work_queue_run, wq, delay,
+ &wq->thread);
/* set thread yield time, if needed */
if (wq->thread && wq->spec.yield != THREAD_YIELD_TIME_SLOT)
thread_set_yield_time (wq->thread, wq->spec.yield);
diff --git a/lib/zclient.c b/lib/zclient.c
index e3eadf22a4..1d3c93d85d 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -310,8 +310,9 @@ zclient_flush_data(struct thread *thread)
return zclient_failed(zclient);
break;
case BUFFER_PENDING:
- zclient->t_write = thread_add_write(zclient->master, zclient_flush_data,
- zclient, zclient->sock);
+ zclient->t_write = NULL;
+ thread_add_write(zclient->master, zclient_flush_data, zclient, zclient->sock,
+ &zclient->t_write);
break;
case BUFFER_EMPTY:
break;
@@ -336,8 +337,8 @@ zclient_send_message(struct zclient *zclient)
THREAD_OFF(zclient->t_write);
break;
case BUFFER_PENDING:
- THREAD_WRITE_ON(zclient->master, zclient->t_write,
- zclient_flush_data, zclient, zclient->sock);
+ thread_add_write(zclient->master, zclient_flush_data, zclient,
+ zclient->sock, &zclient->t_write);
break;
}
return 0;
@@ -2012,22 +2013,20 @@ zclient_event (enum event event, struct zclient *zclient)
switch (event)
{
case ZCLIENT_SCHEDULE:
- if (! zclient->t_connect)
- zclient->t_connect =
- thread_add_event (zclient->master, zclient_connect, zclient, 0);
+ thread_add_event(zclient->master, zclient_connect, zclient, 0,
+ &zclient->t_connect);
break;
case ZCLIENT_CONNECT:
if (zclient_debug)
zlog_debug ("zclient connect failures: %d schedule interval is now %d",
zclient->fail, zclient->fail < 3 ? 10 : 60);
- if (! zclient->t_connect)
- zclient->t_connect =
- thread_add_timer (zclient->master, zclient_connect, zclient,
- zclient->fail < 3 ? 10 : 60);
+ thread_add_timer(zclient->master, zclient_connect, zclient,
+ zclient->fail < 3 ? 10 : 60, &zclient->t_connect);
break;
case ZCLIENT_READ:
- zclient->t_read =
- thread_add_read (zclient->master, zclient_read, zclient, zclient->sock);
+ zclient->t_read = NULL;
+ thread_add_read(zclient->master, zclient_read, zclient, zclient->sock,
+ &zclient->t_read);
break;
}
}
diff --git a/nhrpd/netlink_arp.c b/nhrpd/netlink_arp.c
index 76419a7ff1..2b222e3c5c 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 d9094ec335..2d92842b5c 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 aab9ec642f..da86c585a4 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 555c0d1de1..b926a8d7b2 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(&reg->reglist_entry);
list_add_tail(&reg->reglist_entry, &nhs->reglist_head);
nhrp_peer_notify_add(reg->peer, &reg->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,
+ &reg->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 36dbdfd777..76c5f15170 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 3cc91a9083..5f1e43a608 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 cd33ff0280..4a6cbce31f 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 07bdb735a3..c29be3cbf9 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 5491bacf7c..244562d547 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)
diff --git a/ospf6d/ospf6_bfd.c b/ospf6d/ospf6_bfd.c
index fed5021208..3bc55441c8 100644
--- a/ospf6d/ospf6_bfd.c
+++ b/ospf6d/ospf6_bfd.c
@@ -251,7 +251,7 @@ ospf6_bfd_interface_dest_update (int command, struct zclient *zclient,
if ((status == BFD_STATUS_DOWN) && (old_status == BFD_STATUS_UP))
{
THREAD_OFF (on->inactivity_timer);
- thread_add_event (master, inactivity_timer, on, 0);
+ thread_add_event(master, inactivity_timer, on, 0, NULL);
}
}
diff --git a/ospf6d/ospf6_flood.c b/ospf6d/ospf6_flood.c
index 6ac93d8984..eb51e353c5 100644
--- a/ospf6d/ospf6_flood.c
+++ b/ospf6d/ospf6_flood.c
@@ -112,8 +112,9 @@ ospf6_lsa_originate (struct ospf6_lsa *lsa)
lsdb_self = ospf6_get_scoped_lsdb_self (lsa);
ospf6_lsdb_add (ospf6_lsa_copy (lsa), lsdb_self);
- lsa->refresh = thread_add_timer (master, ospf6_lsa_refresh, lsa,
- OSPF_LS_REFRESH_TIME);
+ lsa->refresh = NULL;
+ thread_add_timer(master, ospf6_lsa_refresh, lsa, OSPF_LS_REFRESH_TIME,
+ &lsa->refresh);
if (IS_OSPF6_DEBUG_LSA_TYPE (lsa->header->type) ||
IS_OSPF6_DEBUG_ORIGINATE_TYPE (lsa->header->type))
@@ -225,9 +226,11 @@ ospf6_install_lsa (struct ospf6_lsa *lsa)
}
monotime(&now);
- if (! OSPF6_LSA_IS_MAXAGE (lsa))
- lsa->expire = thread_add_timer (master, ospf6_lsa_expire, lsa,
- OSPF_LSA_MAXAGE + lsa->birth.tv_sec - now.tv_sec);
+ if (! OSPF6_LSA_IS_MAXAGE (lsa)) {
+ lsa->expire = NULL;
+ thread_add_timer(master, ospf6_lsa_expire, lsa, OSPF_LSA_MAXAGE + lsa->birth.tv_sec - now.tv_sec,
+ &lsa->expire);
+ }
else
lsa->expire = NULL;
@@ -361,10 +364,8 @@ ospf6_flood_interface (struct ospf6_neighbor *from,
zlog_debug ("Add retrans-list of this neighbor");
ospf6_increment_retrans_count (lsa);
ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list);
- if (on->thread_send_lsupdate == NULL)
- on->thread_send_lsupdate =
- thread_add_timer (master, ospf6_lsupdate_send_neighbor,
- on, on->ospf6_if->rxmt_interval);
+ thread_add_timer(master, ospf6_lsupdate_send_neighbor, on, on->ospf6_if->rxmt_interval,
+ &on->thread_send_lsupdate);
retrans_added++;
}
@@ -406,9 +407,8 @@ ospf6_flood_interface (struct ospf6_neighbor *from,
(oi->type == OSPF_IFTYPE_POINTOPOINT))
{
ospf6_lsdb_add (ospf6_lsa_copy (lsa), oi->lsupdate_list);
- if (oi->thread_send_lsupdate == NULL)
- oi->thread_send_lsupdate =
- thread_add_event (master, ospf6_lsupdate_send_interface, oi, 0);
+ thread_add_event(master, ospf6_lsupdate_send_interface, oi, 0,
+ &oi->thread_send_lsupdate);
}
else
{
@@ -416,8 +416,9 @@ ospf6_flood_interface (struct ospf6_neighbor *from,
for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
{
THREAD_OFF (on->thread_send_lsupdate);
- on->thread_send_lsupdate =
- thread_add_event (master, ospf6_lsupdate_send_neighbor, on, 0);
+ on->thread_send_lsupdate = NULL;
+ thread_add_event(master, ospf6_lsupdate_send_neighbor, on, 0,
+ &on->thread_send_lsupdate);
}
}
}
@@ -577,9 +578,8 @@ ospf6_acknowledge_lsa_bdrouter (struct ospf6_lsa *lsa, int ismore_recent,
zlog_debug ("Delayed acknowledgement (BDR & MoreRecent & from DR)");
/* Delayed acknowledgement */
ospf6_lsdb_add (ospf6_lsa_copy (lsa), oi->lsack_list);
- if (oi->thread_send_lsack == NULL)
- oi->thread_send_lsack =
- thread_add_timer (master, ospf6_lsack_send_interface, oi, 3);
+ thread_add_timer(master, ospf6_lsack_send_interface, oi, 3,
+ &oi->thread_send_lsack);
}
else
{
@@ -601,9 +601,8 @@ ospf6_acknowledge_lsa_bdrouter (struct ospf6_lsa *lsa, int ismore_recent,
zlog_debug ("Delayed acknowledgement (BDR & Duplicate & ImpliedAck & from DR)");
/* Delayed acknowledgement */
ospf6_lsdb_add (ospf6_lsa_copy (lsa), oi->lsack_list);
- if (oi->thread_send_lsack == NULL)
- oi->thread_send_lsack =
- thread_add_timer (master, ospf6_lsack_send_interface, oi, 3);
+ thread_add_timer(master, ospf6_lsack_send_interface, oi, 3,
+ &oi->thread_send_lsack);
}
else
{
@@ -621,9 +620,8 @@ ospf6_acknowledge_lsa_bdrouter (struct ospf6_lsa *lsa, int ismore_recent,
if (is_debug)
zlog_debug ("Direct acknowledgement (BDR & Duplicate)");
ospf6_lsdb_add (ospf6_lsa_copy (lsa), from->lsack_list);
- if (from->thread_send_lsack == NULL)
- from->thread_send_lsack =
- thread_add_event (master, ospf6_lsack_send_neighbor, from, 0);
+ thread_add_event(master, ospf6_lsack_send_neighbor, from, 0,
+ &from->thread_send_lsack);
return;
}
@@ -665,9 +663,8 @@ ospf6_acknowledge_lsa_allother (struct ospf6_lsa *lsa, int ismore_recent,
zlog_debug ("Delayed acknowledgement (AllOther & MoreRecent)");
/* Delayed acknowledgement */
ospf6_lsdb_add (ospf6_lsa_copy (lsa), oi->lsack_list);
- if (oi->thread_send_lsack == NULL)
- oi->thread_send_lsack =
- thread_add_timer (master, ospf6_lsack_send_interface, oi, 3);
+ thread_add_timer(master, ospf6_lsack_send_interface, oi, 3,
+ &oi->thread_send_lsack);
return;
}
@@ -689,9 +686,8 @@ ospf6_acknowledge_lsa_allother (struct ospf6_lsa *lsa, int ismore_recent,
if (is_debug)
zlog_debug ("Direct acknowledgement (AllOther & Duplicate)");
ospf6_lsdb_add (ospf6_lsa_copy (lsa), from->lsack_list);
- if (from->thread_send_lsack == NULL)
- from->thread_send_lsack =
- thread_add_event (master, ospf6_lsack_send_neighbor, from, 0);
+ thread_add_event(master, ospf6_lsack_send_neighbor, from, 0,
+ &from->thread_send_lsack);
return;
}
@@ -828,9 +824,8 @@ ospf6_receive_lsa (struct ospf6_neighbor *from,
/* a) Acknowledge back to neighbor (Direct acknowledgement, 13.5) */
ospf6_lsdb_add (ospf6_lsa_copy (new), from->lsack_list);
- if (from->thread_send_lsack == NULL)
- from->thread_send_lsack =
- thread_add_event (master, ospf6_lsack_send_neighbor, from, 0);
+ thread_add_event(master, ospf6_lsack_send_neighbor, from, 0,
+ &from->thread_send_lsack);
/* b) Discard */
ospf6_lsa_delete (new);
@@ -912,7 +907,8 @@ ospf6_receive_lsa (struct ospf6_neighbor *from,
zlog_debug ("Newer instance of the self-originated LSA");
zlog_debug ("Schedule reorigination");
}
- new->refresh = thread_add_event (master, ospf6_lsa_refresh, new, 0);
+ new->refresh = NULL;
+ thread_add_event(master, ospf6_lsa_refresh, new, 0, &new->refresh);
}
return;
@@ -932,7 +928,7 @@ ospf6_receive_lsa (struct ospf6_neighbor *from,
}
/* BadLSReq */
- thread_add_event (master, bad_lsreq, from, 0);
+ thread_add_event(master, bad_lsreq, from, 0, NULL);
ospf6_lsa_delete (new);
return;
@@ -998,9 +994,8 @@ ospf6_receive_lsa (struct ospf6_neighbor *from,
/* XXX, MinLSArrival check !? RFC 2328 13 (8) */
ospf6_lsdb_add (ospf6_lsa_copy (old), from->lsupdate_list);
- if (from->thread_send_lsupdate == NULL)
- from->thread_send_lsupdate =
- thread_add_event (master, ospf6_lsupdate_send_neighbor, from, 0);
+ thread_add_event(master, ospf6_lsupdate_send_neighbor, from, 0,
+ &from->thread_send_lsupdate);
ospf6_lsa_delete (new);
return;
}
diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c
index 8cf7f4afaa..758688c601 100644
--- a/ospf6d/ospf6_interface.c
+++ b/ospf6d/ospf6_interface.c
@@ -392,9 +392,9 @@ ospf6_interface_state_update (struct interface *ifp)
if (if_is_operative (ifp)
&& (ospf6_interface_get_linklocal_address(oi->interface)
|| if_is_loopback(oi->interface)))
- thread_add_event (master, interface_up, oi, 0);
+ thread_add_event(master, interface_up, oi, 0, NULL);
else
- thread_add_event (master, interface_down, oi, 0);
+ thread_add_event(master, interface_down, oi, 0, NULL);
return;
}
@@ -671,7 +671,7 @@ dr_election (struct ospf6_interface *oi)
if (on->state < OSPF6_NEIGHBOR_TWOWAY)
continue;
/* Schedule AdjOK. */
- thread_add_event (master, adj_ok, on, 0);
+ thread_add_event(master, adj_ok, on, 0, NULL);
}
}
@@ -740,8 +740,8 @@ interface_up (struct thread *thread)
{
zlog_info("Scheduling %s for sso retry, trial count: %d",
oi->interface->name, oi->sso_try_cnt);
- thread_add_timer (master, interface_up, oi,
- OSPF6_INTERFACE_SSO_RETRY_INT);
+ thread_add_timer(master, interface_up, oi,
+ OSPF6_INTERFACE_SSO_RETRY_INT, NULL);
}
return 0;
}
@@ -752,8 +752,10 @@ interface_up (struct thread *thread)
/* Schedule Hello */
if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE) &&
- !if_is_loopback (oi->interface))
- oi->thread_send_hello = thread_add_event (master, ospf6_hello_send, oi, 0);
+ !if_is_loopback (oi->interface)) {
+ oi->thread_send_hello = NULL;
+ thread_add_event(master, ospf6_hello_send, oi, 0, &oi->thread_send_hello);
+ }
/* decide next interface state */
if ((if_is_pointopoint (oi->interface)) ||
@@ -765,7 +767,7 @@ interface_up (struct thread *thread)
else
{
ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi);
- thread_add_timer (master, wait_timer, oi, oi->dead_interval);
+ thread_add_timer(master, wait_timer, oi, oi->dead_interval, NULL);
}
return 0;
@@ -1140,7 +1142,7 @@ DEFUN (ipv6_ospf6_ifmtu,
for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
{
THREAD_OFF (on->inactivity_timer);
- thread_add_event (master, inactivity_timer, on, 0);
+ thread_add_event(master, inactivity_timer, on, 0, NULL);
}
return CMD_SUCCESS;
@@ -1187,7 +1189,7 @@ DEFUN (no_ipv6_ospf6_ifmtu,
for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
{
THREAD_OFF (on->inactivity_timer);
- thread_add_event (master, inactivity_timer, on, 0);
+ thread_add_event(master, inactivity_timer, on, 0, NULL);
}
return CMD_SUCCESS;
@@ -1490,7 +1492,7 @@ DEFUN (ipv6_ospf6_passive,
for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
{
THREAD_OFF (on->inactivity_timer);
- thread_add_event (master, inactivity_timer, on, 0);
+ thread_add_event(master, inactivity_timer, on, 0, NULL);
}
return CMD_SUCCESS;
@@ -1516,8 +1518,8 @@ DEFUN (no_ipv6_ospf6_passive,
UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
THREAD_OFF (oi->thread_send_hello);
- oi->thread_send_hello =
- thread_add_event (master, ospf6_hello_send, oi, 0);
+ oi->thread_send_hello = NULL;
+ thread_add_event(master, ospf6_hello_send, oi, 0, &oi->thread_send_hello);
return CMD_SUCCESS;
}
@@ -1685,8 +1687,8 @@ DEFUN (ipv6_ospf6_network,
}
/* Reset the interface */
- thread_add_event (master, interface_down, oi, 0);
- thread_add_event (master, interface_up, oi, 0);
+ thread_add_event(master, interface_down, oi, 0, NULL);
+ thread_add_event(master, interface_up, oi, 0, NULL);
return CMD_SUCCESS;
}
@@ -1720,8 +1722,8 @@ DEFUN (no_ipv6_ospf6_network,
oi->type = type;
/* Reset the interface */
- thread_add_event (master, interface_down, oi, 0);
- thread_add_event (master, interface_up, oi, 0);
+ thread_add_event(master, interface_down, oi, 0, NULL);
+ thread_add_event(master, interface_up, oi, 0, NULL);
return CMD_SUCCESS;
}
@@ -1864,8 +1866,8 @@ ospf6_interface_clear (struct vty *vty, struct interface *ifp)
zlog_debug ("Interface %s: clear by reset", ifp->name);
/* Reset the interface */
- thread_add_event (master, interface_down, oi, 0);
- thread_add_event (master, interface_up, oi, 0);
+ thread_add_event(master, interface_down, oi, 0, NULL);
+ thread_add_event(master, interface_up, oi, 0, NULL);
}
/* Clear interface */
diff --git a/ospf6d/ospf6_intra.h b/ospf6d/ospf6_intra.h
index c9660b6a5c..9975bbd627 100644
--- a/ospf6d/ospf6_intra.h
+++ b/ospf6d/ospf6_intra.h
@@ -156,40 +156,30 @@ struct ospf6_intra_prefix_lsa
#define OSPF6_ROUTER_LSA_SCHEDULE(oa) \
do { \
- if (! (oa)->thread_router_lsa \
- && CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \
- (oa)->thread_router_lsa = \
- thread_add_event (master, ospf6_router_lsa_originate, oa, 0); \
+ if (CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \
+ thread_add_event (master, ospf6_router_lsa_originate, oa, 0, &(oa)->thread_router_lsa); \
} while (0)
#define OSPF6_NETWORK_LSA_SCHEDULE(oi) \
do { \
- if (! (oi)->thread_network_lsa \
- && ! CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
- (oi)->thread_network_lsa = \
- thread_add_event (master, ospf6_network_lsa_originate, oi, 0); \
+ if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
+ thread_add_event (master, ospf6_network_lsa_originate, oi, 0, &(oi)->thread_network_lsa); \
} while (0)
#define OSPF6_LINK_LSA_SCHEDULE(oi) \
do { \
- if (! (oi)->thread_link_lsa \
- && ! CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
- (oi)->thread_link_lsa = \
- thread_add_event (master, ospf6_link_lsa_originate, oi, 0); \
+ if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
+ thread_add_event (master, ospf6_link_lsa_originate, oi, 0, &(oi)->thread_link_lsa); \
} while (0)
#define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oa) \
do { \
- if (! (oa)->thread_intra_prefix_lsa \
- && CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \
- (oa)->thread_intra_prefix_lsa = \
- thread_add_event (master, ospf6_intra_prefix_lsa_originate_stub, \
- oa, 0); \
+ if (CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \
+ thread_add_event (master, ospf6_intra_prefix_lsa_originate_stub, \
+ oa, 0, &(oa)->thread_intra_prefix_lsa); \
} while (0)
#define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi) \
do { \
- if (! (oi)->thread_intra_prefix_lsa \
- && ! CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
- (oi)->thread_intra_prefix_lsa = \
- thread_add_event (master, ospf6_intra_prefix_lsa_originate_transit, \
- oi, 0); \
+ if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
+ thread_add_event (master, ospf6_intra_prefix_lsa_originate_transit, \
+ oi, 0, &(oi)->thread_intra_prefix_lsa); \
} while (0)
#define OSPF6_NETWORK_LSA_EXECUTE(oi) \
diff --git a/ospf6d/ospf6_lsa.c b/ospf6d/ospf6_lsa.c
index bea153c928..38229541ac 100644
--- a/ospf6d/ospf6_lsa.c
+++ b/ospf6d/ospf6_lsa.c
@@ -696,7 +696,6 @@ ospf6_lsa_refresh (struct thread *thread)
struct ospf6_lsa *old, *self, *new;
struct ospf6_lsdb *lsdb_self;
- assert (thread);
old = (struct ospf6_lsa *) THREAD_ARG (thread);
assert (old && old->header);
@@ -722,8 +721,9 @@ ospf6_lsa_refresh (struct thread *thread)
new = ospf6_lsa_create (self->header);
new->lsdb = old->lsdb;
- new->refresh = thread_add_timer (master, ospf6_lsa_refresh, new,
- OSPF_LS_REFRESH_TIME);
+ new->refresh = NULL;
+ thread_add_timer(master, ospf6_lsa_refresh, new, OSPF_LS_REFRESH_TIME,
+ &new->refresh);
/* store it in the LSDB for self-originated LSAs */
ospf6_lsdb_add (ospf6_lsa_copy (new), lsdb_self);
diff --git a/ospf6d/ospf6_message.c b/ospf6d/ospf6_message.c
index 578b39a641..6746b8104f 100644
--- a/ospf6d/ospf6_message.c
+++ b/ospf6d/ospf6_message.c
@@ -352,9 +352,9 @@ ospf6_hello_recv (struct in6_addr *src, struct in6_addr *dst,
/* Schedule interface events */
if (backupseen)
- thread_add_event (master, backup_seen, oi, 0);
+ thread_add_event (master, backup_seen, oi, 0, NULL);
if (neighborchange)
- thread_add_event (master, neighbor_change, oi, 0);
+ thread_add_event (master, neighbor_change, oi, 0, NULL);
if (neighbor_ifindex_change && on->state == OSPF6_NEIGHBOR_FULL)
OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
@@ -428,7 +428,7 @@ ospf6_dbdesc_recv_master (struct ospf6_header *oh,
{
if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
zlog_debug ("Master/Slave bit mismatch");
- thread_add_event (master, seqnumber_mismatch, on, 0);
+ thread_add_event (master, seqnumber_mismatch, on, 0, NULL);
return;
}
@@ -436,7 +436,7 @@ ospf6_dbdesc_recv_master (struct ospf6_header *oh,
{
if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
zlog_debug ("Initialize bit mismatch");
- thread_add_event (master, seqnumber_mismatch, on, 0);
+ thread_add_event (master, seqnumber_mismatch, on, 0, NULL);
return;
}
@@ -444,7 +444,7 @@ ospf6_dbdesc_recv_master (struct ospf6_header *oh,
{
if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
zlog_debug ("Option field mismatch");
- thread_add_event (master, seqnumber_mismatch, on, 0);
+ thread_add_event (master, seqnumber_mismatch, on, 0, NULL);
return;
}
@@ -453,7 +453,7 @@ ospf6_dbdesc_recv_master (struct ospf6_header *oh,
if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
zlog_debug ("Sequence number mismatch (%#lx expected)",
(u_long) on->dbdesc_seqnum);
- thread_add_event (master, seqnumber_mismatch, on, 0);
+ thread_add_event (master, seqnumber_mismatch, on, 0, NULL);
return;
}
break;
@@ -471,7 +471,7 @@ ospf6_dbdesc_recv_master (struct ospf6_header *oh,
if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
zlog_debug ("Not duplicate dbdesc in state %s",
ospf6_neighbor_state_str[on->state]);
- thread_add_event (master, seqnumber_mismatch, on, 0);
+ thread_add_event (master, seqnumber_mismatch, on, 0, NULL);
return;
default:
@@ -517,7 +517,7 @@ ospf6_dbdesc_recv_master (struct ospf6_header *oh,
if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
zlog_debug ("SeqNumMismatch (E-bit mismatch), discard");
ospf6_lsa_delete (his);
- thread_add_event (master, seqnumber_mismatch, on, 0);
+ thread_add_event (master, seqnumber_mismatch, on, 0, NULL);
return;
}
@@ -549,19 +549,20 @@ ospf6_dbdesc_recv_master (struct ospf6_header *oh,
on->dbdesc_seqnum ++;
/* schedule send lsreq */
- if (on->request_list->count && (on->thread_send_lsreq == NULL))
- on->thread_send_lsreq =
- thread_add_event (master, ospf6_lsreq_send, on, 0);
+ if (on->request_list->count)
+ thread_add_event (master, ospf6_lsreq_send, on, 0, &on->thread_send_lsreq);
THREAD_OFF (on->thread_send_dbdesc);
/* More bit check */
if (! CHECK_FLAG (dbdesc->bits, OSPF6_DBDESC_MBIT) &&
! CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT))
- thread_add_event (master, exchange_done, on, 0);
- else
- on->thread_send_dbdesc =
- thread_add_event (master, ospf6_dbdesc_send_newone, on, 0);
+ thread_add_event (master, exchange_done, on, 0, NULL);
+ else {
+ on->thread_send_dbdesc = NULL;
+ thread_add_event(master, ospf6_dbdesc_send_newone, on, 0,
+ &on->thread_send_dbdesc);
+ }
/* save last received dbdesc */
memcpy (&on->dbdesc_last, dbdesc, sizeof (struct ospf6_dbdesc));
@@ -637,8 +638,9 @@ ospf6_dbdesc_recv_slave (struct ospf6_header *oh,
if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
zlog_debug ("Duplicated dbdesc causes retransmit");
THREAD_OFF (on->thread_send_dbdesc);
- on->thread_send_dbdesc =
- thread_add_event (master, ospf6_dbdesc_send, on, 0);
+ on->thread_send_dbdesc = NULL;
+ thread_add_event(master, ospf6_dbdesc_send, on, 0,
+ &on->thread_send_dbdesc);
return;
}
@@ -646,7 +648,7 @@ ospf6_dbdesc_recv_slave (struct ospf6_header *oh,
{
if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
zlog_debug ("Master/Slave bit mismatch");
- thread_add_event (master, seqnumber_mismatch, on, 0);
+ thread_add_event (master, seqnumber_mismatch, on, 0, NULL);
return;
}
@@ -654,7 +656,7 @@ ospf6_dbdesc_recv_slave (struct ospf6_header *oh,
{
if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
zlog_debug ("Initialize bit mismatch");
- thread_add_event (master, seqnumber_mismatch, on, 0);
+ thread_add_event (master, seqnumber_mismatch, on, 0, NULL);
return;
}
@@ -662,7 +664,7 @@ ospf6_dbdesc_recv_slave (struct ospf6_header *oh,
{
if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
zlog_debug ("Option field mismatch");
- thread_add_event (master, seqnumber_mismatch, on, 0);
+ thread_add_event (master, seqnumber_mismatch, on, 0, NULL);
return;
}
@@ -671,7 +673,7 @@ ospf6_dbdesc_recv_slave (struct ospf6_header *oh,
if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
zlog_debug ("Sequence number mismatch (%#lx expected)",
(u_long) on->dbdesc_seqnum + 1);
- thread_add_event (master, seqnumber_mismatch, on, 0);
+ thread_add_event (master, seqnumber_mismatch, on, 0, NULL);
return;
}
break;
@@ -684,15 +686,14 @@ ospf6_dbdesc_recv_slave (struct ospf6_header *oh,
if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
zlog_debug ("Duplicated dbdesc causes retransmit");
THREAD_OFF (on->thread_send_dbdesc);
- on->thread_send_dbdesc =
- thread_add_event (master, ospf6_dbdesc_send, on, 0);
+ thread_add_event (master, ospf6_dbdesc_send, on, 0, &on->thread_send_dbdesc);
return;
}
if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
zlog_debug ("Not duplicate dbdesc in state %s",
ospf6_neighbor_state_str[on->state]);
- thread_add_event (master, seqnumber_mismatch, on, 0);
+ thread_add_event (master, seqnumber_mismatch, on, 0, NULL);
return;
default:
@@ -735,7 +736,7 @@ ospf6_dbdesc_recv_slave (struct ospf6_header *oh,
if (IS_OSPF6_DEBUG_MESSAGE (oh->type, RECV))
zlog_debug ("E-bit mismatch with LSA Headers");
ospf6_lsa_delete (his);
- thread_add_event (master, seqnumber_mismatch, on, 0);
+ thread_add_event (master, seqnumber_mismatch, on, 0, NULL);
return;
}
@@ -756,14 +757,11 @@ ospf6_dbdesc_recv_slave (struct ospf6_header *oh,
on->dbdesc_seqnum = ntohl (dbdesc->seqnum);
/* schedule send lsreq */
- if ((on->thread_send_lsreq == NULL) &&
- (on->request_list->count))
- on->thread_send_lsreq =
- thread_add_event (master, ospf6_lsreq_send, on, 0);
+ if (on->request_list->count)
+ thread_add_event (master, ospf6_lsreq_send, on, 0, &on->thread_send_lsreq);
THREAD_OFF (on->thread_send_dbdesc);
- on->thread_send_dbdesc =
- thread_add_event (master, ospf6_dbdesc_send_newone, on, 0);
+ thread_add_event (master, ospf6_dbdesc_send_newone, on, 0, &on->thread_send_dbdesc);
/* save last received dbdesc */
memcpy (&on->dbdesc_last, dbdesc, sizeof (struct ospf6_dbdesc));
@@ -880,7 +878,7 @@ ospf6_lsreq_recv (struct in6_addr *src, struct in6_addr *dst,
zlog_debug ("Can't find requested [%s Id:%s Adv:%s]",
ospf6_lstype_name (e->type), id, adv_router);
}
- thread_add_event (master, bad_lsreq, on, 0);
+ thread_add_event (master, bad_lsreq, on, 0, NULL);
return;
}
@@ -891,8 +889,7 @@ ospf6_lsreq_recv (struct in6_addr *src, struct in6_addr *dst,
/* schedule send lsupdate */
THREAD_OFF (on->thread_send_lsupdate);
- on->thread_send_lsupdate =
- thread_add_event (master, ospf6_lsupdate_send_neighbor, on, 0);
+ thread_add_event (master, ospf6_lsupdate_send_neighbor, on, 0, &on->thread_send_lsupdate);
}
/* Verify, that the specified memory area contains exactly N valid IPv6
@@ -1532,7 +1529,7 @@ ospf6_receive (struct thread *thread)
/* add next read thread */
sockfd = THREAD_FD (thread);
- thread_add_read (master, ospf6_receive, NULL, sockfd);
+ thread_add_read (master, ospf6_receive, NULL, sockfd, NULL);
/* initialize */
memset (&src, 0, sizeof (src));
@@ -1739,8 +1736,7 @@ ospf6_hello_send (struct thread *thread)
}
/* set next thread */
- oi->thread_send_hello = thread_add_timer (master, ospf6_hello_send,
- oi, oi->hello_interval);
+ thread_add_timer (master, ospf6_hello_send, oi, oi->hello_interval, &oi->thread_send_hello);
memset (sendbuf, 0, iobuflen);
oh = (struct ospf6_header *) sendbuf;
@@ -1804,9 +1800,9 @@ ospf6_dbdesc_send (struct thread *thread)
/* set next thread if master */
if (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT))
- on->thread_send_dbdesc =
- thread_add_timer (master, ospf6_dbdesc_send, on,
- on->ospf6_if->rxmt_interval);
+ thread_add_timer (master, ospf6_dbdesc_send, on,
+ on->ospf6_if->rxmt_interval,
+ &on->thread_send_dbdesc);
memset (sendbuf, 0, iobuflen);
oh = (struct ospf6_header *) sendbuf;
@@ -1896,7 +1892,7 @@ ospf6_dbdesc_send_newone (struct thread *thread)
if (! CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT) && /* Slave */
! CHECK_FLAG (on->dbdesc_last.bits, OSPF6_DBDESC_MBIT) &&
! CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT))
- thread_add_event (master, exchange_done, on, 0);
+ thread_add_event (master, exchange_done, on, 0, NULL);
thread_execute (master, ospf6_dbdesc_send, on, 0);
return 0;
@@ -1927,7 +1923,7 @@ ospf6_lsreq_send (struct thread *thread)
/* schedule loading_done if request list is empty */
if (on->request_list->count == 0)
{
- thread_add_event (master, loading_done, on, 0);
+ thread_add_event (master, loading_done, on, 0, NULL);
return 0;
}
@@ -1978,9 +1974,9 @@ ospf6_lsreq_send (struct thread *thread)
/* set next thread */
if (on->request_list->count != 0)
{
- on->thread_send_lsreq =
- thread_add_timer (master, ospf6_lsreq_send, on,
- on->ospf6_if->rxmt_interval);
+ on->thread_send_lsreq = NULL;
+ thread_add_timer(master, ospf6_lsreq_send, on, on->ospf6_if->rxmt_interval,
+ &on->thread_send_lsreq);
}
return 0;
@@ -2097,13 +2093,16 @@ ospf6_lsupdate_send_neighbor (struct thread *thread)
on->ospf6_if, oh);
}
- if (on->lsupdate_list->count != 0)
- on->thread_send_lsupdate =
- thread_add_event (master, ospf6_lsupdate_send_neighbor, on, 0);
- else if (on->retrans_list->count != 0)
- on->thread_send_lsupdate =
- thread_add_timer (master, ospf6_lsupdate_send_neighbor, on,
- on->ospf6_if->rxmt_interval);
+ if (on->lsupdate_list->count != 0) {
+ on->thread_send_lsupdate = NULL;
+ thread_add_event(master, ospf6_lsupdate_send_neighbor, on, 0,
+ &on->thread_send_lsupdate);
+ }
+ else if (on->retrans_list->count != 0) {
+ on->thread_send_lsupdate = NULL;
+ thread_add_timer(master, ospf6_lsupdate_send_neighbor, on, on->ospf6_if->rxmt_interval,
+ &on->thread_send_lsupdate);
+ }
return 0;
}
@@ -2178,8 +2177,9 @@ ospf6_lsupdate_send_interface (struct thread *thread)
if (oi->lsupdate_list->count > 0)
{
- oi->thread_send_lsupdate =
- thread_add_event (master, ospf6_lsupdate_send_interface, oi, 0);
+ oi->thread_send_lsupdate = NULL;
+ thread_add_event(master, ospf6_lsupdate_send_interface, oi, 0,
+ &oi->thread_send_lsupdate);
}
return 0;
@@ -2223,8 +2223,7 @@ ospf6_lsack_send_neighbor (struct thread *thread)
/* if we run out of packet size/space here,
better to try again soon. */
THREAD_OFF (on->thread_send_lsack);
- on->thread_send_lsack =
- thread_add_event (master, ospf6_lsack_send_neighbor, on, 0);
+ thread_add_event (master, ospf6_lsack_send_neighbor, on, 0, &on->thread_send_lsack);
ospf6_lsdb_lsa_unlock (lsa);
break;
@@ -2248,11 +2247,8 @@ ospf6_lsack_send_neighbor (struct thread *thread)
on->ospf6_if, oh);
}
- if (on->thread_send_lsack == NULL && on->lsack_list->count > 0)
- {
- on->thread_send_lsack =
- thread_add_event (master, ospf6_lsack_send_neighbor, on, 0);
- }
+ if (on->lsack_list->count > 0)
+ thread_add_event (master, ospf6_lsack_send_neighbor, on, 0, &on->thread_send_lsack);
return 0;
}
@@ -2295,8 +2291,8 @@ ospf6_lsack_send_interface (struct thread *thread)
/* if we run out of packet size/space here,
better to try again soon. */
THREAD_OFF (oi->thread_send_lsack);
- oi->thread_send_lsack =
- thread_add_event (master, ospf6_lsack_send_interface, oi, 0);
+ thread_add_event (master, ospf6_lsack_send_interface, oi, 0,
+ &oi->thread_send_lsack);
ospf6_lsdb_lsa_unlock (lsa);
break;
@@ -2324,11 +2320,8 @@ ospf6_lsack_send_interface (struct thread *thread)
ospf6_send (oi->linklocal_addr, &alldrouters6, oi, oh);
}
- if (oi->thread_send_lsack == NULL && oi->lsack_list->count > 0)
- {
- oi->thread_send_lsack =
- thread_add_event (master, ospf6_lsack_send_interface, oi, 0);
- }
+ if (oi->lsack_list->count > 0)
+ thread_add_event (master, ospf6_lsack_send_interface, oi, 0, &oi->thread_send_lsack);
return 0;
}
diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c
index 118210dfc7..09d3a523a3 100644
--- a/ospf6d/ospf6_neighbor.c
+++ b/ospf6d/ospf6_neighbor.c
@@ -238,8 +238,9 @@ hello_received (struct thread *thread)
/* reset Inactivity Timer */
THREAD_OFF (on->inactivity_timer);
- on->inactivity_timer = thread_add_timer (master, inactivity_timer, on,
- on->ospf6_if->dead_interval);
+ on->inactivity_timer = NULL;
+ thread_add_timer(master, inactivity_timer, on, on->ospf6_if->dead_interval,
+ &on->inactivity_timer);
if (on->state <= OSPF6_NEIGHBOR_DOWN)
ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT, on,
@@ -262,7 +263,7 @@ twoway_received (struct thread *thread)
if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
zlog_debug ("Neighbor Event %s: *2Way-Received*", on->name);
- thread_add_event (master, neighbor_change, on->ospf6_if, 0);
+ thread_add_event(master, neighbor_change, on->ospf6_if, 0, NULL);
if (! need_adjacency (on))
{
@@ -278,8 +279,8 @@ twoway_received (struct thread *thread)
SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
THREAD_OFF (on->thread_send_dbdesc);
- on->thread_send_dbdesc =
- thread_add_event (master, ospf6_dbdesc_send, on, 0);
+ on->thread_send_dbdesc = NULL;
+ thread_add_event(master, ospf6_dbdesc_send, on, 0, &on->thread_send_dbdesc);
return 0;
}
@@ -385,9 +386,8 @@ exchange_done (struct thread *thread)
ospf6_neighbor_state_change (OSPF6_NEIGHBOR_LOADING, on,
OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE);
- if (on->thread_send_lsreq == NULL)
- on->thread_send_lsreq =
- thread_add_event (master, ospf6_lsreq_send, on, 0);
+ thread_add_event(master, ospf6_lsreq_send, on, 0,
+ &on->thread_send_lsreq);
}
return 0;
@@ -406,13 +406,14 @@ ospf6_check_nbr_loading (struct ospf6_neighbor *on)
(on->state == OSPF6_NEIGHBOR_EXCHANGE))
{
if (on->request_list->count == 0)
- thread_add_event (master, loading_done, on, 0);
+ thread_add_event(master, loading_done, on, 0, NULL);
else if (on->last_ls_req == NULL)
{
if (on->thread_send_lsreq != NULL)
THREAD_OFF (on->thread_send_lsreq);
- on->thread_send_lsreq =
- thread_add_event (master, ospf6_lsreq_send, on, 0);
+ on->thread_send_lsreq = NULL;
+ thread_add_event(master, ospf6_lsreq_send, on, 0,
+ &on->thread_send_lsreq);
}
}
}
@@ -460,8 +461,9 @@ adj_ok (struct thread *thread)
SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
THREAD_OFF (on->thread_send_dbdesc);
- on->thread_send_dbdesc =
- thread_add_event (master, ospf6_dbdesc_send, on, 0);
+ on->thread_send_dbdesc = NULL;
+ thread_add_event(master, ospf6_dbdesc_send, on, 0,
+ &on->thread_send_dbdesc);
}
else if (on->state >= OSPF6_NEIGHBOR_EXSTART &&
@@ -515,8 +517,8 @@ seqnumber_mismatch (struct thread *thread)
THREAD_OFF (on->thread_send_dbdesc);
on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */
- on->thread_send_dbdesc =
- thread_add_event (master, ospf6_dbdesc_send, on, 0);
+ on->thread_send_dbdesc = NULL;
+ thread_add_event(master, ospf6_dbdesc_send, on, 0, &on->thread_send_dbdesc);
return 0;
}
@@ -554,8 +556,8 @@ bad_lsreq (struct thread *thread)
THREAD_OFF (on->thread_send_dbdesc);
on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */
- on->thread_send_dbdesc =
- thread_add_event (master, ospf6_dbdesc_send, on, 0);
+ on->thread_send_dbdesc = NULL;
+ thread_add_event(master, ospf6_dbdesc_send, on, 0, &on->thread_send_dbdesc);
return 0;
}
@@ -577,7 +579,7 @@ oneway_received (struct thread *thread)
ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT, on,
OSPF6_NEIGHBOR_EVENT_ONEWAY_RCVD);
- thread_add_event (master, neighbor_change, on->ospf6_if, 0);
+ thread_add_event(master, neighbor_change, on->ospf6_if, 0, NULL);
ospf6_lsdb_remove_all (on->summary_list);
ospf6_lsdb_remove_all (on->request_list);
@@ -613,7 +615,7 @@ inactivity_timer (struct thread *thread)
ospf6_neighbor_state_change (OSPF6_NEIGHBOR_DOWN, on,
OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER);
- thread_add_event (master, neighbor_change, on->ospf6_if, 0);
+ thread_add_event(master, neighbor_change, on->ospf6_if, 0, NULL);
listnode_delete (on->ospf6_if->neighbor_list, on);
ospf6_neighbor_delete (on);
diff --git a/ospf6d/ospf6_spf.c b/ospf6d/ospf6_spf.c
index 333ce5588e..6a10ba7ad5 100644
--- a/ospf6d/ospf6_spf.c
+++ b/ospf6d/ospf6_spf.c
@@ -727,8 +727,9 @@ ospf6_spf_schedule (struct ospf6 *ospf6, unsigned int reason)
zlog_info ("SPF: Scheduled in %ld msec", delay);
- ospf6->t_spf_calc =
- thread_add_timer_msec (master, ospf6_spf_calculation_thread, ospf6, delay);
+ ospf6->t_spf_calc = NULL;
+ thread_add_timer_msec(master, ospf6_spf_calculation_thread, ospf6, delay,
+ &ospf6->t_spf_calc);
}
void
diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c
index e592d3c4f9..85f7e0ce3a 100644
--- a/ospf6d/ospf6_top.c
+++ b/ospf6d/ospf6_top.c
@@ -286,9 +286,9 @@ ospf6_maxage_remover (struct thread *thread)
void
ospf6_maxage_remove (struct ospf6 *o)
{
- if (o && ! o->maxage_remover)
- o->maxage_remover = thread_add_timer (master, ospf6_maxage_remover, o,
- OSPF_LSA_MAXAGE_REMOVE_DELAY_DEFAULT);
+ if (o)
+ thread_add_timer(master, ospf6_maxage_remover, o, OSPF_LSA_MAXAGE_REMOVE_DELAY_DEFAULT,
+ &o->maxage_remover);
}
/* start ospf6 */
diff --git a/ospf6d/ospf6d.c b/ospf6d/ospf6d.c
index aa219c7807..7933975707 100644
--- a/ospf6d/ospf6d.c
+++ b/ospf6d/ospf6d.c
@@ -1252,7 +1252,7 @@ ospf6_init (void)
/* Make ospf protocol socket. */
ospf6_serv_sock ();
- thread_add_read (master, ospf6_receive, NULL, ospf6_sock);
+ thread_add_read(master, ospf6_receive, NULL, ospf6_sock, NULL);
}
void
diff --git a/ospfclient/ospfclient.c b/ospfclient/ospfclient.c
index 43ffa1da8e..1c2ec7d1cc 100644
--- a/ospfclient/ospfclient.c
+++ b/ospfclient/ospfclient.c
@@ -168,7 +168,7 @@ lsa_read (struct thread *thread)
}
/* Reschedule read thread */
- thread_add_read (master, lsa_read, oclient, fd);
+ thread_add_read(master, lsa_read, oclient, fd, NULL);
return 0;
}
@@ -224,13 +224,13 @@ ready_callback (u_char lsa_type, u_char opaque_type, struct in_addr addr)
lsa_type, opaque_type, inet_ntoa (addr));
/* Schedule opaque LSA originate in 5 secs */
- thread_add_timer (master, lsa_inject, oclient, 5);
+ thread_add_timer(master, lsa_inject, oclient, 5, NULL);
/* Schedule opaque LSA update with new value */
- thread_add_timer (master, lsa_inject, oclient, 10);
+ thread_add_timer(master, lsa_inject, oclient, 10, NULL);
/* Schedule delete */
- thread_add_timer (master, lsa_delete, oclient, 30);
+ thread_add_timer(master, lsa_delete, oclient, 30, NULL);
}
static void
@@ -340,7 +340,7 @@ main (int argc, char *argv[])
ospf_apiclient_sync_lsdb (oclient);
/* Schedule thread that handles asynchronous messages */
- thread_add_read (master, lsa_read, oclient, oclient->fd_async);
+ thread_add_read(master, lsa_read, oclient, oclient->fd_async, NULL);
/* Now connection is established, run loop */
while (1)
diff --git a/ospfd/ospf_abr.c b/ospfd/ospf_abr.c
index a54170e048..ee90ceccf9 100644
--- a/ospfd/ospf_abr.c
+++ b/ospfd/ospf_abr.c
@@ -1881,7 +1881,6 @@ ospf_schedule_abr_task (struct ospf *ospf)
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("Scheduling ABR task");
- if (ospf->t_abr_task == NULL)
- ospf->t_abr_task = thread_add_timer (master, ospf_abr_task_timer,
- ospf, OSPF_ABR_TASK_DELAY);
+ thread_add_timer(master, ospf_abr_task_timer, ospf, OSPF_ABR_TASK_DELAY,
+ &ospf->t_abr_task);
}
diff --git a/ospfd/ospf_apiserver.c b/ospfd/ospf_apiserver.c
index 620dacb157..633b22346d 100644
--- a/ospfd/ospf_apiserver.c
+++ b/ospfd/ospf_apiserver.c
@@ -301,31 +301,27 @@ ospf_apiserver_event (enum event event, int fd,
switch (event)
{
case OSPF_APISERVER_ACCEPT:
- (void)thread_add_read (master, ospf_apiserver_accept, apiserv, fd);
+ (void) thread_add_read(master, ospf_apiserver_accept, apiserv, fd, NULL);
break;
case OSPF_APISERVER_SYNC_READ:
- apiserv->t_sync_read =
- thread_add_read (master, ospf_apiserver_read, apiserv, fd);
+ apiserv->t_sync_read = NULL;
+ thread_add_read(master, ospf_apiserver_read, apiserv, fd,
+ &apiserv->t_sync_read);
break;
#ifdef USE_ASYNC_READ
case OSPF_APISERVER_ASYNC_READ:
- apiserv->t_async_read =
- thread_add_read (master, ospf_apiserver_read, apiserv, fd);
+ apiserv->t_async_read = NULL;
+ thread_add_read(master, ospf_apiserver_read, apiserv, fd,
+ &apiserv->t_async_read);
break;
#endif /* USE_ASYNC_READ */
case OSPF_APISERVER_SYNC_WRITE:
- if (!apiserv->t_sync_write)
- {
- apiserv->t_sync_write =
- thread_add_write (master, ospf_apiserver_sync_write, apiserv, fd);
- }
+ thread_add_write(master, ospf_apiserver_sync_write, apiserv, fd,
+ &apiserv->t_sync_write);
break;
case OSPF_APISERVER_ASYNC_WRITE:
- if (!apiserv->t_async_write)
- {
- apiserv->t_async_write =
- thread_add_write (master, ospf_apiserver_async_write, apiserv, fd);
- }
+ thread_add_write(master, ospf_apiserver_async_write, apiserv, fd,
+ &apiserv->t_async_write);
break;
}
}
diff --git a/ospfd/ospf_ase.c b/ospfd/ospf_ase.c
index b063f317e2..a30df19937 100644
--- a/ospfd/ospf_ase.c
+++ b/ospfd/ospf_ase.c
@@ -705,9 +705,8 @@ ospf_ase_calculate_timer_add (struct ospf *ospf)
if (ospf == NULL)
return;
- if (! ospf->t_ase_calc)
- ospf->t_ase_calc = thread_add_timer (master, ospf_ase_calculate_timer,
- ospf, OSPF_ASE_CALC_INTERVAL);
+ thread_add_timer(master, ospf_ase_calculate_timer, ospf,
+ OSPF_ASE_CALC_INTERVAL, &ospf->t_ase_calc);
}
void
diff --git a/ospfd/ospf_flood.c b/ospfd/ospf_flood.c
index 417a7aa8d2..4cc28f7486 100644
--- a/ospfd/ospf_flood.c
+++ b/ospfd/ospf_flood.c
@@ -260,7 +260,6 @@ ospf_flood (struct ospf *ospf, struct ospf_neighbor *nbr,
(void *)current,
dump_lsa_key (new));
- lsa_ack_flag = 0;
oi = nbr->oi;
/* If there is already a database copy, and if the
diff --git a/ospfd/ospf_ism.h b/ospfd/ospf_ism.h
index fa8e6d70f6..180000ae97 100644
--- a/ospfd/ospf_ism.h
+++ b/ospfd/ospf_ism.h
@@ -48,30 +48,23 @@
#define ISM_InterfaceDown 7
#define OSPF_ISM_EVENT_MAX 8
-#define OSPF_ISM_WRITE_ON(O) \
- do \
- { \
- if (oi->on_write_q == 0) \
- { \
- listnode_add ((O)->oi_write_q, oi); \
- oi->on_write_q = 1; \
- } \
- if ((O)->t_write == NULL) \
- (O)->t_write = \
- thread_add_write (master, ospf_write, (O), (O)->fd); \
- } while (0)
+#define OSPF_ISM_WRITE_ON(O) \
+ do \
+ { \
+ if (oi->on_write_q == 0) \
+ { \
+ listnode_add ((O)->oi_write_q, oi); \
+ oi->on_write_q = 1; \
+ } \
+ thread_add_write (master, ospf_write, (O), (O)->fd, &(O)->t_write); \
+ } while (0)
/* Macro for OSPF ISM timer turn on. */
#define OSPF_ISM_TIMER_ON(T,F,V) \
- do { \
- if (!(T)) \
- (T) = thread_add_timer (master, (F), oi, (V)); \
- } while (0)
+ thread_add_timer (master, (F), oi, (V), &(T))
+
#define OSPF_ISM_TIMER_MSEC_ON(T,F,V) \
- do { \
- if (!(T)) \
- (T) = thread_add_timer_msec (master, (F), oi, (V)); \
- } while (0)
+ thread_add_timer_msec (master, (F), oi, (V), &(T))
/* convenience macro to set hello timer correctly, according to
* whether fast-hello is set or not
@@ -98,7 +91,7 @@
/* Macro for OSPF schedule event. */
#define OSPF_ISM_EVENT_SCHEDULE(I,E) \
- thread_add_event (master, ospf_ism_event, (I), (E))
+ thread_add_event (master, ospf_ism_event, (I), (E), NULL)
/* Macro for OSPF execute event. */
#define OSPF_ISM_EVENT_EXECUTE(I,E) \
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c
index cf9943893a..9067acb7f5 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -3553,7 +3553,7 @@ ospf_schedule_lsa_flood_area (struct ospf_area *area, struct ospf_lsa *lsa)
data->area = area;
data->lsa = ospf_lsa_lock (lsa); /* Message / Flood area */
- thread_add_event (master, ospf_lsa_action, data, 0);
+ thread_add_event(master, ospf_lsa_action, data, 0, NULL);
}
void
@@ -3566,7 +3566,7 @@ ospf_schedule_lsa_flush_area (struct ospf_area *area, struct ospf_lsa *lsa)
data->area = area;
data->lsa = ospf_lsa_lock (lsa); /* Message / Flush area */
- thread_add_event (master, ospf_lsa_action, data, 0);
+ thread_add_event(master, ospf_lsa_action, data, 0, NULL);
}
@@ -3741,8 +3741,9 @@ ospf_lsa_refresh_walker (struct thread *t)
}
}
- ospf->t_lsa_refresher = thread_add_timer (master, ospf_lsa_refresh_walker,
- ospf, ospf->lsa_refresh_interval);
+ ospf->t_lsa_refresher = NULL;
+ thread_add_timer(master, ospf_lsa_refresh_walker, ospf, ospf->lsa_refresh_interval,
+ &ospf->t_lsa_refresher);
ospf->lsa_refresher_started = monotime(NULL);
for (ALL_LIST_ELEMENTS (lsa_to_refresh, node, nnode, lsa))
diff --git a/ospfd/ospf_nsm.h b/ospfd/ospf_nsm.h
index 4531f6ec7d..2bd8f065cf 100644
--- a/ospfd/ospf_nsm.h
+++ b/ospfd/ospf_nsm.h
@@ -57,11 +57,7 @@
#define OSPF_NSM_EVENT_MAX 14
/* Macro for OSPF NSM timer turn on. */
-#define OSPF_NSM_TIMER_ON(T,F,V) \
- do { \
- if (!(T)) \
- (T) = thread_add_timer (master, (F), nbr, (V)); \
- } while (0)
+#define OSPF_NSM_TIMER_ON(T,F,V) thread_add_timer (master, (F), nbr, (V), &(T))
/* Macro for OSPF NSM timer turn off. */
#define OSPF_NSM_TIMER_OFF(X) \
@@ -75,7 +71,7 @@
/* Macro for OSPF NSM schedule event. */
#define OSPF_NSM_EVENT_SCHEDULE(N,E) \
- thread_add_event (master, ospf_nsm_event, (N), (E))
+ thread_add_event (master, ospf_nsm_event, (N), (E), NULL)
/* Macro for OSPF NSM execute event. */
#define OSPF_NSM_EVENT_EXECUTE(N,E) \
diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c
index 56efa2ebd6..af22d0f29a 100644
--- a/ospfd/ospf_opaque.c
+++ b/ospfd/ospf_opaque.c
@@ -1342,8 +1342,9 @@ ospf_opaque_lsa_originate_schedule (struct ospf_interface *oi, int *delay0)
{
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("Schedule Type-9 Opaque-LSA origination in %d ms later.", delay);
- oi->t_opaque_lsa_self =
- thread_add_timer_msec (master, ospf_opaque_type9_lsa_originate, oi, delay);
+ oi->t_opaque_lsa_self = NULL;
+ thread_add_timer_msec(master, ospf_opaque_type9_lsa_originate, oi, delay,
+ &oi->t_opaque_lsa_self);
delay += top->min_ls_interval;
}
@@ -1358,9 +1359,9 @@ ospf_opaque_lsa_originate_schedule (struct ospf_interface *oi, int *delay0)
*/
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("Schedule Type-10 Opaque-LSA origination in %d ms later.", delay);
- area->t_opaque_lsa_self =
- thread_add_timer_msec (master, ospf_opaque_type10_lsa_originate,
- area, delay);
+ area->t_opaque_lsa_self = NULL;
+ thread_add_timer_msec(master, ospf_opaque_type10_lsa_originate, area, delay,
+ &area->t_opaque_lsa_self);
delay += top->min_ls_interval;
}
@@ -1375,9 +1376,9 @@ ospf_opaque_lsa_originate_schedule (struct ospf_interface *oi, int *delay0)
*/
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("Schedule Type-11 Opaque-LSA origination in %d ms later.", delay);
- top->t_opaque_lsa_self =
- thread_add_timer_msec (master, ospf_opaque_type11_lsa_originate,
- top, delay);
+ top->t_opaque_lsa_self = NULL;
+ thread_add_timer_msec(master, ospf_opaque_type11_lsa_originate, top, delay,
+ &top->t_opaque_lsa_self);
delay += top->min_ls_interval;
}
@@ -1654,9 +1655,7 @@ ospf_opaque_lsa_refresh (struct ospf_lsa *lsa)
* triggered by external interventions (vty session, signaling, etc).
*------------------------------------------------------------------------*/
-#define OSPF_OPAQUE_TIMER_ON(T,F,L,V) \
- if (!(T)) \
- (T) = thread_add_timer_msec (master, (F), (L), (V))
+#define OSPF_OPAQUE_TIMER_ON(T,F,L,V) thread_add_timer_msec (master, (F), (L), (V), &(T))
static struct ospf_lsa *pseudo_lsa (struct ospf_interface *oi, struct ospf_area *area, u_char lsa_type, u_char opaque_type);
static int ospf_opaque_type9_lsa_reoriginate_timer (struct thread *t);
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index b7721adb3e..8446ebcea7 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -487,7 +487,8 @@ ospf_ls_req_event (struct ospf_neighbor *nbr)
thread_cancel (nbr->t_ls_req);
nbr->t_ls_req = NULL;
}
- nbr->t_ls_req = thread_add_event (master, ospf_ls_req_timer, nbr, 0);
+ nbr->t_ls_req = NULL;
+ thread_add_event(master, ospf_ls_req_timer, nbr, 0, &nbr->t_ls_req);
}
/* Cyclic timer function. Fist registered in ospf_nbr_new () in
@@ -850,9 +851,10 @@ ospf_write (struct thread *thread)
}
/* If packets still remain in queue, call write thread. */
- if (!list_isempty (ospf->oi_write_q))
- ospf->t_write =
- thread_add_write (master, ospf_write, ospf, ospf->fd);
+ if (!list_isempty (ospf->oi_write_q)) {
+ ospf->t_write = NULL;
+ thread_add_write(master, ospf_write, ospf, ospf->fd, &ospf->t_write);
+ }
return 0;
}
@@ -2772,7 +2774,8 @@ ospf_read (struct thread *thread)
ospf = THREAD_ARG (thread);
/* prepare for next packet. */
- ospf->t_read = thread_add_read (master, ospf_read, ospf, ospf->fd);
+ ospf->t_read = NULL;
+ thread_add_read(master, ospf_read, ospf, ospf->fd, &ospf->t_read);
stream_reset(ospf->ibuf);
if (!(ibuf = ospf_recv_packet (ospf->fd, &ifp, ospf->ibuf)))
@@ -3802,8 +3805,9 @@ ospf_ls_upd_send_queue_event (struct thread *thread)
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_ls_upd_send_queue: update lists not cleared,"
" %d nodes to try again, raising new event", again);
- oi->t_ls_upd_event =
- thread_add_event (master, ospf_ls_upd_send_queue_event, oi, 0);
+ oi->t_ls_upd_event = NULL;
+ thread_add_event(master, ospf_ls_upd_send_queue_event, oi, 0,
+ &oi->t_ls_upd_event);
}
if (IS_DEBUG_OSPF_EVENT)
@@ -3858,9 +3862,8 @@ ospf_ls_upd_send (struct ospf_neighbor *nbr, struct list *update, int flag)
for (ALL_LIST_ELEMENTS_RO (update, node, lsa))
listnode_add (rn->info, ospf_lsa_lock (lsa)); /* oi->ls_upd_queue */
- if (oi->t_ls_upd_event == NULL)
- oi->t_ls_upd_event =
- thread_add_event (master, ospf_ls_upd_send_queue_event, oi, 0);
+ thread_add_event(master, ospf_ls_upd_send_queue_event, oi, 0,
+ &oi->t_ls_upd_event);
}
static void
@@ -3921,9 +3924,8 @@ ospf_ls_ack_send (struct ospf_neighbor *nbr, struct ospf_lsa *lsa)
listnode_add (oi->ls_ack_direct.ls_ack, ospf_lsa_lock (lsa));
- if (oi->t_ls_ack_direct == NULL)
- oi->t_ls_ack_direct =
- thread_add_event (master, ospf_ls_ack_send_event, oi, 0);
+ thread_add_event(master, ospf_ls_ack_send_event, oi, 0,
+ &oi->t_ls_ack_direct);
}
/* Send Link State Acknowledgment delayed. */
diff --git a/ospfd/ospf_spf.c b/ospfd/ospf_spf.c
index 31f0d9d286..3d8d7f8e03 100644
--- a/ospfd/ospf_spf.c
+++ b/ospfd/ospf_spf.c
@@ -1464,6 +1464,7 @@ ospf_spf_calculate_schedule (struct ospf *ospf, ospf_spf_reason_t reason)
zlog_info ("SPF: Scheduled in %ld msec", delay);
- ospf->t_spf_calc =
- thread_add_timer_msec (master, ospf_spf_calculate_timer, ospf, delay);
+ ospf->t_spf_calc = NULL;
+ thread_add_timer_msec(master, ospf_spf_calculate_timer, ospf, delay,
+ &ospf->t_spf_calc);
}
diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c
index 449f9e7b97..a89d67c6bb 100644
--- a/ospfd/ospf_te.c
+++ b/ospfd/ospf_te.c
@@ -1480,12 +1480,12 @@ ospf_mpls_te_lsa_originate_as (void *arg)
if (IS_FLOOD_AS (lp->type))
{
top = (struct ospf *) arg;
- rc = ospf_mpls_te_lsa_originate2 (top, lp);
+ ospf_mpls_te_lsa_originate2 (top, lp);
}
else
{
area = (struct ospf_area *) arg;
- rc = ospf_mpls_te_lsa_originate1 (area, lp);
+ ospf_mpls_te_lsa_originate1 (area, lp);
}
}
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index abb6db0347..c22793a098 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -883,7 +883,7 @@ ospf_redistribute_default_set (struct ospf *ospf, int originate,
if (ospf->router_id.s_addr == 0)
ospf->external_origin |= (1 << DEFAULT_ROUTE);
else
- thread_add_timer (master, ospf_default_originate_timer, ospf, 1);
+ thread_add_timer(master, ospf_default_originate_timer, ospf, 1, NULL);
ospf_asbr_status_update (ospf, ++ospf->redistribute);
@@ -1278,9 +1278,9 @@ ospf_distribute_list_update (struct ospf *ospf, uintptr_t type,
return;
/* Set timer. */
- ospf->t_distribute_update =
- thread_add_timer_msec (master, ospf_distribute_list_update_timer,
- (void *) type, ospf->min_ls_interval);
+ ospf->t_distribute_update = NULL;
+ thread_add_timer_msec(master, ospf_distribute_list_update_timer, (void *)type, ospf->min_ls_interval,
+ &ospf->t_distribute_update);
}
/* If access-list is updated, apply some check. */
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index 30b1e9622f..0c3230d367 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -135,11 +135,12 @@ ospf_router_id_update (struct ospf *ospf)
/* Originate each redistributed external route. */
for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
if (ospf->external_origin & (1 << type))
- thread_add_event (master, ospf_external_lsa_originate_timer,
- ospf, type);
+ thread_add_event(master, ospf_external_lsa_originate_timer,
+ ospf, type, NULL);
/* Originate Deafult. */
if (ospf->external_origin & (1 << ZEBRA_ROUTE_MAX))
- thread_add_event (master, ospf_default_originate_timer, ospf, 0);
+ thread_add_event(master, ospf_default_originate_timer, ospf, 0,
+ NULL);
ospf->external_origin = 0;
}
@@ -184,9 +185,9 @@ ospf_router_id_update (struct ospf *ospf)
/* Originate each redistributed external route. */
for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
- thread_add_event (master, ospf_external_lsa_originate_timer,
- ospf, type);
- thread_add_event (master, ospf_default_originate_timer, ospf, 0);
+ thread_add_event(master, ospf_external_lsa_originate_timer, ospf,
+ type, NULL);
+ thread_add_event(master, ospf_default_originate_timer, ospf, 0, NULL);
/* update router-lsa's for each area */
ospf_router_lsa_update (ospf);
@@ -263,17 +264,18 @@ ospf_new (u_short instance)
/* MaxAge init. */
new->maxage_delay = OSPF_LSA_MAXAGE_REMOVE_DELAY_DEFAULT;
new->maxage_lsa = route_table_init();
- new->t_maxage_walker =
- thread_add_timer (master, ospf_lsa_maxage_walker,
- new, OSPF_LSA_MAXAGE_CHECK_INTERVAL);
+ new->t_maxage_walker = NULL;
+ thread_add_timer(master, ospf_lsa_maxage_walker, new, OSPF_LSA_MAXAGE_CHECK_INTERVAL,
+ &new->t_maxage_walker);
/* Distance table init. */
new->distance_table = route_table_init ();
new->lsa_refresh_queue.index = 0;
new->lsa_refresh_interval = OSPF_LSA_REFRESH_INTERVAL_DEFAULT;
- new->t_lsa_refresher = thread_add_timer (master, ospf_lsa_refresh_walker,
- new, new->lsa_refresh_interval);
+ new->t_lsa_refresher = NULL;
+ thread_add_timer(master, ospf_lsa_refresh_walker, new, new->lsa_refresh_interval,
+ &new->t_lsa_refresher);
new->lsa_refresher_started = monotime(NULL);
if ((new->fd = ospf_sock_init()) < 0)
@@ -288,7 +290,8 @@ ospf_new (u_short instance)
OSPF_MAX_PACKET_SIZE+1);
exit(1);
}
- new->t_read = thread_add_read (master, ospf_read, new, new->fd);
+ new->t_read = NULL;
+ thread_add_read(master, ospf_read, new, new->fd, &new->t_read);
new->oi_write_q = list_new ();
new->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT;
@@ -1592,8 +1595,8 @@ ospf_timers_refresh_set (struct ospf *ospf, int interval)
if (time_left > interval)
{
OSPF_TIMER_OFF (ospf->t_lsa_refresher);
- ospf->t_lsa_refresher =
- thread_add_timer (master, ospf_lsa_refresh_walker, ospf, interval);
+ thread_add_timer(master, ospf_lsa_refresh_walker, ospf, interval,
+ &ospf->t_lsa_refresher);
}
ospf->lsa_refresh_interval = interval;
@@ -1611,9 +1614,9 @@ ospf_timers_refresh_unset (struct ospf *ospf)
if (time_left > OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
{
OSPF_TIMER_OFF (ospf->t_lsa_refresher);
- ospf->t_lsa_refresher =
- thread_add_timer (master, ospf_lsa_refresh_walker, ospf,
- OSPF_LSA_REFRESH_INTERVAL_DEFAULT);
+ ospf->t_lsa_refresher = NULL;
+ thread_add_timer(master, ospf_lsa_refresh_walker, ospf, OSPF_LSA_REFRESH_INTERVAL_DEFAULT,
+ &ospf->t_lsa_refresher);
}
ospf->lsa_refresh_interval = OSPF_LSA_REFRESH_INTERVAL_DEFAULT;
diff --git a/ospfd/ospfd.h b/ospfd/ospfd.h
index 9198d5c620..c5b0324b86 100644
--- a/ospfd/ospfd.h
+++ b/ospfd/ospfd.h
@@ -480,26 +480,10 @@ struct ospf_nbr_nbma
#define LSA_OPTIONS_NSSA_GET(area) \
(((area)->external_routing == OSPF_AREA_NSSA) ? OSPF_OPTION_NP : 0)
-#define OSPF_TIMER_ON(T,F,V) \
- do { \
- if (!(T)) \
- (T) = thread_add_timer (master, (F), ospf, (V)); \
- } while (0)
-
-#define OSPF_AREA_TIMER_ON(T,F,V) \
- do { \
- if (!(T)) \
- (T) = thread_add_timer (master, (F), area, (V)); \
- } while (0)
-
-#define OSPF_POLL_TIMER_ON(T,F,V) \
- do { \
- if (!(T)) \
- (T) = thread_add_timer (master, (F), nbr_nbma, (V)); \
- } while (0)
-
-#define OSPF_POLL_TIMER_OFF(X) OSPF_TIMER_OFF((X))
-
+#define OSPF_TIMER_ON(T,F,V) thread_add_timer (master,(F),ospf,(V),&(T))
+#define OSPF_AREA_TIMER_ON(T,F,V) thread_add_timer (master, (F), area, (V), &(T))
+#define OSPF_POLL_TIMER_ON(T,F,V) thread_add_timer (master, (F), nbr_nbma, (V), &(T))
+#define OSPF_POLL_TIMER_OFF(X) OSPF_TIMER_OFF((X))
#define OSPF_TIMER_OFF(X) \
do { \
if (X) \
diff --git a/pimd/pim_assert.c b/pimd/pim_assert.c
index 17f5fcfe0f..a11cce9433 100644
--- a/pimd/pim_assert.c
+++ b/pimd/pim_assert.c
@@ -576,9 +576,8 @@ static void pim_assert_timer_set(struct pim_ifchannel *ch,
ch->sg_str, interval, ch->interface->name);
}
- THREAD_TIMER_ON(master, ch->t_ifassert_timer,
- on_assert_timer,
- ch, interval);
+ thread_add_timer(master, on_assert_timer, ch, interval,
+ &ch->t_ifassert_timer);
}
static void pim_assert_timer_reset(struct pim_ifchannel *ch)
diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c
index f4fe609605..9f98631335 100644
--- a/pimd/pim_ifchannel.c
+++ b/pimd/pim_ifchannel.c
@@ -855,9 +855,8 @@ void pim_ifchannel_join_add(struct interface *ifp,
}
if (holdtime != 0xFFFF) {
- THREAD_TIMER_ON(master, ch->t_ifjoin_expiry_timer,
- on_ifjoin_expiry_timer,
- ch, holdtime);
+ thread_add_timer(master, on_ifjoin_expiry_timer, ch, holdtime,
+ &ch->t_ifjoin_expiry_timer);
}
}
@@ -907,12 +906,11 @@ void pim_ifchannel_prune(struct interface *ifp,
THREAD_OFF(ch->t_ifjoin_prune_pending_timer);
THREAD_OFF(ch->t_ifjoin_expiry_timer);
- THREAD_TIMER_MSEC_ON(master, ch->t_ifjoin_prune_pending_timer,
- on_ifjoin_prune_pending_timer,
- ch, jp_override_interval_msec);
- THREAD_TIMER_ON(master, ch->t_ifjoin_expiry_timer,
- on_ifjoin_expiry_timer,
- ch, holdtime);
+ thread_add_timer_msec(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);
pim_upstream_update_join_desired(ch->upstream);
}
break;
@@ -932,17 +930,16 @@ void pim_ifchannel_prune(struct interface *ifp,
be taken not to use "ch" afterwards since it would be
deleted. */
THREAD_OFF(ch->t_ifjoin_prune_pending_timer);
- THREAD_TIMER_MSEC_ON(master, ch->t_ifjoin_prune_pending_timer,
- on_ifjoin_prune_pending_timer,
- ch, jp_override_interval_msec);
+ thread_add_timer_msec(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_TIMER_ON(master, ch->t_ifjoin_expiry_timer,
- on_ifjoin_expiry_timer,
- ch, holdtime);
+ thread_add_timer(master, on_ifjoin_expiry_timer, ch, holdtime,
+ &ch->t_ifjoin_expiry_timer);
}
break;
case PIM_IFJOIN_PRUNE_TMP:
@@ -950,9 +947,8 @@ void pim_ifchannel_prune(struct interface *ifp,
{
ch->ifjoin_state = PIM_IFJOIN_PRUNE;
THREAD_OFF(ch->t_ifjoin_expiry_timer);
- THREAD_TIMER_ON(master, ch->t_ifjoin_expiry_timer,
- on_ifjoin_expiry_timer,
- ch, holdtime);
+ thread_add_timer(master, on_ifjoin_expiry_timer, ch, holdtime,
+ &ch->t_ifjoin_expiry_timer);
}
break;
case PIM_IFJOIN_PRUNE_PENDING_TMP:
@@ -960,9 +956,8 @@ void pim_ifchannel_prune(struct interface *ifp,
{
ch->ifjoin_state = PIM_IFJOIN_PRUNE_PENDING;
THREAD_OFF(ch->t_ifjoin_expiry_timer);
- THREAD_TIMER_ON(master, ch->t_ifjoin_expiry_timer,
- on_ifjoin_expiry_timer,
- ch, holdtime);
+ thread_add_timer(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 ee88e7d8ea..af0ddef232 100644
--- a/pimd/pim_igmp.c
+++ b/pimd/pim_igmp.c
@@ -247,9 +247,9 @@ void pim_igmp_other_querier_timer_on(struct igmp_sock *igmp)
other_querier_present_interval_msec % 1000);
}
- THREAD_TIMER_MSEC_ON(master, igmp->t_other_querier_timer,
- pim_igmp_other_querier_expire,
- igmp, other_querier_present_interval_msec);
+ thread_add_timer_msec(master, pim_igmp_other_querier_expire, igmp,
+ other_querier_present_interval_msec,
+ &igmp->t_other_querier_timer);
}
void pim_igmp_other_querier_timer_off(struct igmp_sock *igmp)
@@ -551,9 +551,8 @@ void pim_igmp_general_query_on(struct igmp_sock *igmp)
igmp->fd);
}
igmp->t_igmp_query_timer = NULL;
- THREAD_TIMER_ON(master, igmp->t_igmp_query_timer,
- pim_igmp_general_query,
- igmp, query_interval);
+ thread_add_timer(master, pim_igmp_general_query, igmp, query_interval,
+ &igmp->t_igmp_query_timer);
}
void pim_igmp_general_query_off(struct igmp_sock *igmp)
@@ -896,7 +895,7 @@ igmp_read_on (struct igmp_sock *igmp)
igmp->fd);
}
igmp->t_igmp_read = NULL;
- THREAD_READ_ON(master, igmp->t_igmp_read, pim_igmp_read, igmp, igmp->fd);
+ thread_add_read(master, pim_igmp_read, igmp, igmp->fd, &igmp->t_igmp_read);
}
@@ -1029,9 +1028,8 @@ void igmp_group_timer_on(struct igmp_group *group,
*/
zassert(group->group_filtermode_isexcl);
- THREAD_TIMER_MSEC_ON(master, group->t_group_timer,
- igmp_group_timer,
- group, interval_msec);
+ thread_add_timer_msec(master, igmp_group_timer, group, interval_msec,
+ &group->t_group_timer);
}
struct igmp_group *
diff --git a/pimd/pim_igmpv3.c b/pimd/pim_igmpv3.c
index 86509a20c4..e0b1d3fc2a 100644
--- a/pimd/pim_igmpv3.c
+++ b/pimd/pim_igmpv3.c
@@ -215,9 +215,8 @@ static void igmp_source_timer_on(struct igmp_group *group,
group->group_igmp_sock->interface->name);
}
- THREAD_TIMER_MSEC_ON(master, source->t_source_timer,
- igmp_source_timer,
- source, interval_msec);
+ thread_add_timer_msec(master, igmp_source_timer, source, interval_msec,
+ &source->t_source_timer);
zassert(source->t_source_timer);
/*
@@ -1328,9 +1327,8 @@ static void group_retransmit_timer_on(struct igmp_group *group)
igmp->interface->name);
}
- THREAD_TIMER_MSEC_ON(master, group->t_group_query_retransmit_timer,
- igmp_group_retransmit,
- group, lmqi_msec);
+ thread_add_timer_msec(master, igmp_group_retransmit, group, lmqi_msec,
+ &group->t_group_query_retransmit_timer);
}
static long igmp_group_timer_remain_msec(struct igmp_group *group)
diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c
index ce2f98f318..76851fa810 100644
--- a/pimd/pim_mroute.c
+++ b/pimd/pim_mroute.c
@@ -636,8 +636,8 @@ static void mroute_read_on()
{
zassert(!qpim_mroute_socket_reader);
- THREAD_READ_ON(master, qpim_mroute_socket_reader,
- mroute_read, 0, qpim_mroute_socket_fd);
+ thread_add_read(master, mroute_read, 0, qpim_mroute_socket_fd,
+ &qpim_mroute_socket_reader);
}
static void mroute_read_off()
diff --git a/pimd/pim_msdp.c b/pimd/pim_msdp.c
index 93141f39de..06cc24ddba 100644
--- a/pimd/pim_msdp.c
+++ b/pimd/pim_msdp.c
@@ -82,8 +82,8 @@ pim_msdp_sa_adv_timer_setup(bool start)
{
THREAD_OFF(msdp->sa_adv_timer);
if (start) {
- THREAD_TIMER_ON(msdp->master, msdp->sa_adv_timer,
- pim_msdp_sa_adv_timer_cb, NULL, PIM_MSDP_SA_ADVERTISMENT_TIME);
+ thread_add_timer(msdp->master, pim_msdp_sa_adv_timer_cb, NULL,
+ PIM_MSDP_SA_ADVERTISMENT_TIME, &msdp->sa_adv_timer);
}
}
@@ -108,8 +108,8 @@ pim_msdp_sa_state_timer_setup(struct pim_msdp_sa *sa, bool start)
{
THREAD_OFF(sa->sa_state_timer);
if (start) {
- THREAD_TIMER_ON(msdp->master, sa->sa_state_timer,
- pim_msdp_sa_state_timer_cb, sa, PIM_MSDP_SA_HOLD_TIME);
+ thread_add_timer(msdp->master, pim_msdp_sa_state_timer_cb, sa,
+ PIM_MSDP_SA_HOLD_TIME, &sa->sa_state_timer);
}
}
@@ -920,8 +920,8 @@ pim_msdp_peer_hold_timer_setup(struct pim_msdp_peer *mp, bool start)
{
THREAD_OFF(mp->hold_timer);
if (start) {
- THREAD_TIMER_ON(msdp->master, mp->hold_timer,
- pim_msdp_peer_hold_timer_cb, mp, PIM_MSDP_PEER_HOLD_TIME);
+ thread_add_timer(msdp->master, pim_msdp_peer_hold_timer_cb, mp,
+ PIM_MSDP_PEER_HOLD_TIME, &mp->hold_timer);
}
}
@@ -948,8 +948,8 @@ pim_msdp_peer_ka_timer_setup(struct pim_msdp_peer *mp, bool start)
{
THREAD_OFF(mp->ka_timer);
if (start) {
- THREAD_TIMER_ON(msdp->master, mp->ka_timer,
- pim_msdp_peer_ka_timer_cb, mp, PIM_MSDP_PEER_KA_TIME);
+ thread_add_timer(msdp->master, pim_msdp_peer_ka_timer_cb, mp,
+ PIM_MSDP_PEER_KA_TIME, &mp->ka_timer);
}
}
@@ -1013,8 +1013,8 @@ pim_msdp_peer_cr_timer_setup(struct pim_msdp_peer *mp, bool start)
{
THREAD_OFF(mp->cr_timer);
if (start) {
- THREAD_TIMER_ON(msdp->master, mp->cr_timer,
- pim_msdp_peer_cr_timer_cb, mp, PIM_MSDP_PEER_CONNECT_RETRY_TIME);
+ thread_add_timer(msdp->master, pim_msdp_peer_cr_timer_cb, mp,
+ PIM_MSDP_PEER_CONNECT_RETRY_TIME, &mp->cr_timer);
}
}
diff --git a/pimd/pim_msdp.h b/pimd/pim_msdp.h
index 33c1d88a45..57a7c22440 100644
--- a/pimd/pim_msdp.h
+++ b/pimd/pim_msdp.h
@@ -197,8 +197,11 @@ struct pim_msdp {
struct pim_msdp_mg *mg;
};
-#define PIM_MSDP_PEER_READ_ON(mp) THREAD_READ_ON(msdp->master, mp->t_read, pim_msdp_read, mp, mp->fd);
-#define PIM_MSDP_PEER_WRITE_ON(mp) THREAD_WRITE_ON(msdp->master, mp->t_write, pim_msdp_write, mp, mp->fd);
+#define PIM_MSDP_PEER_READ_ON(mp) \
+ thread_add_read (msdp->master, pim_msdp_read, mp, mp->fd, &mp->t_read)
+
+#define PIM_MSDP_PEER_WRITE_ON(mp) \
+ thread_add_write (msdp->master, pim_msdp_write, mp, mp->fd, &mp->t_write)
#define PIM_MSDP_PEER_READ_OFF(mp) THREAD_READ_OFF(mp->t_read)
#define PIM_MSDP_PEER_WRITE_OFF(mp) THREAD_WRITE_OFF(mp->t_write)
diff --git a/pimd/pim_msdp_socket.c b/pimd/pim_msdp_socket.c
index 805e812cae..8ceddfa39d 100644
--- a/pimd/pim_msdp_socket.c
+++ b/pimd/pim_msdp_socket.c
@@ -70,8 +70,9 @@ pim_msdp_sock_accept(struct thread *thread)
zlog_err ("accept_sock is negative value %d", accept_sock);
return -1;
}
- listener->thread = thread_add_read(master, pim_msdp_sock_accept,
- listener, accept_sock);
+ listener->thread = NULL;
+ thread_add_read(master, pim_msdp_sock_accept, listener, accept_sock,
+ &listener->thread);
/* accept client connection. */
msdp_sock = sockunion_accept(accept_sock, &su);
@@ -173,7 +174,9 @@ pim_msdp_sock_listen(void)
/* add accept thread */
listener->fd = sock;
memcpy(&listener->su, &sin, socklen);
- listener->thread = thread_add_read(msdp->master, pim_msdp_sock_accept, listener, sock);
+ listener->thread = NULL;
+ thread_add_read(msdp->master, pim_msdp_sock_accept, listener, sock,
+ &listener->thread);
msdp->flags |= PIM_MSDPF_LISTENER;
return 0;
diff --git a/pimd/pim_neighbor.c b/pimd/pim_neighbor.c
index de0f75e380..5dccc3cfb7 100644
--- a/pimd/pim_neighbor.c
+++ b/pimd/pim_neighbor.c
@@ -262,9 +262,8 @@ void pim_neighbor_timer_reset(struct pim_neighbor *neigh, uint16_t holdtime)
neigh->holdtime, src_str, neigh->interface->name);
}
- THREAD_TIMER_ON(master, neigh->t_expire_timer,
- on_neighbor_timer,
- neigh, neigh->holdtime);
+ thread_add_timer(master, on_neighbor_timer, neigh, neigh->holdtime,
+ &neigh->t_expire_timer);
}
static int
@@ -286,9 +285,8 @@ on_neighbor_jp_timer (struct thread *t)
rpf.rpf_addr.u.prefix4 = neigh->source_addr;
pim_joinprune_send(&rpf, neigh->upstream_jp_agg);
- THREAD_TIMER_ON(master, neigh->jp_timer,
- on_neighbor_jp_timer,
- neigh, qpim_t_periodic);
+ thread_add_timer(master, on_neighbor_jp_timer, neigh, qpim_t_periodic,
+ &neigh->jp_timer);
return 0;
}
@@ -297,9 +295,8 @@ static void
pim_neighbor_start_jp_timer (struct pim_neighbor *neigh)
{
THREAD_TIMER_OFF(neigh->jp_timer);
- THREAD_TIMER_ON(master, neigh->jp_timer,
- on_neighbor_jp_timer,
- neigh, qpim_t_periodic);
+ thread_add_timer(master, on_neighbor_jp_timer, neigh, qpim_t_periodic,
+ &neigh->jp_timer);
}
static struct pim_neighbor *pim_neighbor_new(struct interface *ifp,
diff --git a/pimd/pim_pim.c b/pimd/pim_pim.c
index 9886cd6ad2..57b9e6c793 100644
--- a/pimd/pim_pim.c
+++ b/pimd/pim_pim.c
@@ -383,8 +383,8 @@ static void pim_sock_read_on(struct interface *ifp)
pim_ifp->pim_sock_fd);
}
pim_ifp->t_pim_sock_read = NULL;
- THREAD_READ_ON(master, pim_ifp->t_pim_sock_read, pim_sock_read, ifp,
- pim_ifp->pim_sock_fd);
+ thread_add_read(master, pim_sock_read, ifp, pim_ifp->pim_sock_fd,
+ &pim_ifp->t_pim_sock_read);
}
static int pim_sock_open(struct interface *ifp)
@@ -703,9 +703,8 @@ static void hello_resched(struct interface *ifp)
pim_ifp->pim_hello_period, ifp->name);
}
THREAD_OFF(pim_ifp->t_pim_hello_timer);
- THREAD_TIMER_ON(master, pim_ifp->t_pim_hello_timer,
- on_pim_hello_send,
- ifp, pim_ifp->pim_hello_period);
+ thread_add_timer(master, on_pim_hello_send, ifp, pim_ifp->pim_hello_period,
+ &pim_ifp->t_pim_hello_timer);
}
/*
@@ -814,9 +813,8 @@ void pim_hello_restart_triggered(struct interface *ifp)
random_msec, ifp->name);
}
- THREAD_TIMER_MSEC_ON(master, pim_ifp->t_pim_hello_timer,
- on_pim_hello_send,
- ifp, random_msec);
+ thread_add_timer_msec(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 76b327ab07..eda044f184 100644
--- a/pimd/pim_ssmpingd.c
+++ b/pimd/pim_ssmpingd.c
@@ -331,8 +331,8 @@ static int ssmpingd_sock_read(struct thread *t)
static void ssmpingd_read_on(struct ssmpingd_sock *ss)
{
zassert(!ss->t_sock_read);
- THREAD_READ_ON(master, ss->t_sock_read,
- ssmpingd_sock_read, ss, ss->sock_fd);
+ thread_add_read(master, ssmpingd_sock_read, ss, ss->sock_fd,
+ &ss->t_sock_read);
}
static struct ssmpingd_sock *ssmpingd_new(struct in_addr source_addr)
diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c
index dd6eab9cfe..88b6694147 100644
--- a/pimd/pim_upstream.c
+++ b/pimd/pim_upstream.c
@@ -340,9 +340,8 @@ join_timer_start(struct pim_upstream *up)
else
{
THREAD_OFF (up->t_join_timer);
- THREAD_TIMER_ON(master, up->t_join_timer,
- on_join_timer,
- up, qpim_t_periodic);
+ thread_add_timer(master, on_join_timer, up, qpim_t_periodic,
+ &up->t_join_timer);
}
pim_jp_agg_upstream_verification (up, true);
}
@@ -371,9 +370,8 @@ static void pim_upstream_join_timer_restart_msec(struct pim_upstream *up,
}
THREAD_OFF(up->t_join_timer);
- THREAD_TIMER_MSEC_ON(master, up->t_join_timer,
- on_join_timer,
- up, interval_msec);
+ thread_add_timer_msec(master, on_join_timer, up, interval_msec,
+ &up->t_join_timer);
}
void pim_upstream_join_suppress(struct pim_upstream *up,
@@ -1119,10 +1117,8 @@ pim_upstream_keep_alive_timer_start (struct pim_upstream *up,
zlog_debug ("kat start on %s with no stream reference", up->sg_str);
}
THREAD_OFF (up->t_ka_timer);
- THREAD_TIMER_ON (master,
- up->t_ka_timer,
- pim_upstream_keep_alive_timer,
- up, time);
+ thread_add_timer(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 */
@@ -1146,8 +1142,8 @@ void
pim_upstream_msdp_reg_timer_start(struct pim_upstream *up)
{
THREAD_OFF(up->t_msdp_reg_timer);
- THREAD_TIMER_ON(master, up->t_msdp_reg_timer,
- pim_upstream_msdp_reg_timer, up, PIM_MSDP_REG_RXED_PERIOD);
+ thread_add_timer(master, pim_upstream_msdp_reg_timer, up,
+ PIM_MSDP_REG_RXED_PERIOD, &up->t_msdp_reg_timer);
pim_msdp_sa_local_update(up);
}
@@ -1408,9 +1404,8 @@ pim_upstream_start_register_stop_timer (struct pim_upstream *up, int null_regist
zlog_debug ("%s: (S,G)=%s Starting upstream register stop timer %d",
__PRETTY_FUNCTION__, up->sg_str, time);
}
- THREAD_TIMER_ON (master, up->t_rs_timer,
- pim_upstream_register_stop_timer,
- up, time);
+ thread_add_timer(master, pim_upstream_register_stop_timer, up, time,
+ &up->t_rs_timer);
}
int
diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c
index b2a7319bf1..62be3a69dd 100644
--- a/pimd/pim_zebra.c
+++ b/pimd/pim_zebra.c
@@ -617,9 +617,9 @@ void sched_rpf_cache_refresh(void)
qpim_rpf_cache_refresh_delay_msec);
}
- THREAD_TIMER_MSEC_ON(master, qpim_rpf_cache_refresher,
- on_rpf_cache_refresh,
- 0, qpim_rpf_cache_refresh_delay_msec);
+ thread_add_timer_msec(master, on_rpf_cache_refresh, 0,
+ qpim_rpf_cache_refresh_delay_msec,
+ &qpim_rpf_cache_refresher);
}
static void
diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c
index 27bd137043..16dbb3ef56 100644
--- a/pimd/pim_zlookup.c
+++ b/pimd/pim_zlookup.c
@@ -77,9 +77,8 @@ static void zclient_lookup_sched(struct zclient *zlookup, int delay)
{
zassert(!zlookup->t_connect);
- THREAD_TIMER_ON(master, zlookup->t_connect,
- zclient_lookup_connect,
- zlookup, delay);
+ thread_add_timer(master, zclient_lookup_connect, zlookup, delay,
+ &zlookup->t_connect);
zlog_notice("%s: zclient lookup connection scheduled for %d seconds",
__PRETTY_FUNCTION__, delay);
@@ -89,9 +88,8 @@ static void zclient_lookup_sched(struct zclient *zlookup, int delay)
static void zclient_lookup_sched_now(struct zclient *zlookup)
{
zassert(!zlookup->t_connect);
-
- zlookup->t_connect = thread_add_event(master, zclient_lookup_connect,
- zlookup, 0);
+ thread_add_event(master, zclient_lookup_connect, zlookup, 0,
+ &zlookup->t_connect);
zlog_notice("%s: zclient lookup immediate connection scheduled",
__PRETTY_FUNCTION__);
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index a4ee2ba570..57c49c6313 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -1011,9 +1011,8 @@ rip_enable_apply (struct interface *ifp)
zlog_debug ("turn on %s", ifp->name);
/* Add interface wake up thread. */
- if (! ri->t_wakeup)
- ri->t_wakeup = thread_add_timer (master, rip_interface_wakeup,
- ifp, 1);
+ thread_add_timer(master, rip_interface_wakeup, ifp, 1,
+ &ri->t_wakeup);
rip_connect_set (ifp, 1);
}
}
diff --git a/ripd/rip_peer.c b/ripd/rip_peer.c
index 6a3add640a..2477740b9b 100644
--- a/ripd/rip_peer.c
+++ b/ripd/rip_peer.c
@@ -107,8 +107,9 @@ rip_peer_get (struct in_addr *addr)
}
/* Update timeout thread. */
- peer->t_timeout = thread_add_timer (master, rip_peer_timeout, peer,
- RIP_PEER_TIMER_DEFAULT);
+ peer->t_timeout = NULL;
+ thread_add_timer(master, rip_peer_timeout, peer, RIP_PEER_TIMER_DEFAULT,
+ &peer->t_timeout);
/* Last update time set. */
time (&peer->uptime);
diff --git a/ripd/ripd.c b/ripd/ripd.c
index b668b0a0b4..4a42aff78f 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -2398,7 +2398,6 @@ rip_output_process (struct connected *ifc, struct sockaddr_in *to,
if (ret >= 0 && IS_RIP_DEBUG_SEND)
rip_packet_dump ((struct rip_packet *)STREAM_DATA (s),
stream_get_endp (s), "SEND");
- num = 0;
stream_reset (s);
}
@@ -2625,8 +2624,9 @@ rip_triggered_update (struct thread *t)
update is triggered when the timer expires. */
interval = (random () % 5) + 1;
- rip->t_triggered_interval =
- thread_add_timer (master, rip_triggered_interval, NULL, interval);
+ rip->t_triggered_interval = NULL;
+ thread_add_timer(master, rip_triggered_interval, NULL, interval,
+ &rip->t_triggered_interval);
return 0;
}
@@ -2781,21 +2781,20 @@ rip_event (enum rip_event event, int sock)
switch (event)
{
case RIP_READ:
- rip->t_read = thread_add_read (master, rip_read, NULL, sock);
+ rip->t_read = NULL;
+ thread_add_read(master, rip_read, NULL, sock, &rip->t_read);
break;
case RIP_UPDATE_EVENT:
RIP_TIMER_OFF (rip->t_update);
jitter = rip_update_jitter (rip->update_time);
- rip->t_update =
- thread_add_timer (master, rip_update, NULL,
- sock ? 2 : rip->update_time + jitter);
+ thread_add_timer(master, rip_update, NULL, sock ? 2 : rip->update_time + jitter,
+ &rip->t_update);
break;
case RIP_TRIGGERED_UPDATE:
if (rip->t_triggered_interval)
- rip->trigger = 1;
- else if (! rip->t_triggered_update)
- rip->t_triggered_update =
- thread_add_event (master, rip_triggered_update, NULL, 0);
+ rip->trigger = 1;
+ else thread_add_event(master, rip_triggered_update, NULL, 0,
+ &rip->t_triggered_update);
break;
default:
break;
diff --git a/ripd/ripd.h b/ripd/ripd.h
index eeb008e3d5..aad0c2f112 100644
--- a/ripd/ripd.h
+++ b/ripd/ripd.h
@@ -371,11 +371,7 @@ enum rip_event
};
/* Macro for timer turn on. */
-#define RIP_TIMER_ON(T,F,V) \
- do { \
- if (!(T)) \
- (T) = thread_add_timer (master, (F), rinfo, (V)); \
- } while (0)
+#define RIP_TIMER_ON(T,F,V) thread_add_timer (master, (F), rinfo, (V), &(T))
/* Macro for timer turn off. */
#define RIP_TIMER_OFF(X) THREAD_TIMER_OFF(X)
diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c
index 1ac9e40f67..dbffa1a88a 100644
--- a/ripngd/ripng_interface.c
+++ b/ripngd/ripng_interface.c
@@ -761,9 +761,8 @@ ripng_enable_apply (struct interface *ifp)
zlog_debug ("RIPng turn on %s", ifp->name);
/* Add interface wake up thread. */
- if (! ri->t_wakeup)
- ri->t_wakeup = thread_add_timer (master, ripng_interface_wakeup,
- ifp, 1);
+ thread_add_timer(master, ripng_interface_wakeup, ifp, 1,
+ &ri->t_wakeup);
ripng_connect_set (ifp, 1);
}
diff --git a/ripngd/ripng_peer.c b/ripngd/ripng_peer.c
index b12e146041..69af4f214f 100644
--- a/ripngd/ripng_peer.c
+++ b/ripngd/ripng_peer.c
@@ -115,8 +115,9 @@ ripng_peer_get (struct in6_addr *addr)
}
/* Update timeout thread. */
- peer->t_timeout = thread_add_timer (master, ripng_peer_timeout, peer,
- RIPNG_PEER_TIMER_DEFAULT);
+ peer->t_timeout = NULL;
+ thread_add_timer(master, ripng_peer_timeout, peer, RIPNG_PEER_TIMER_DEFAULT,
+ &peer->t_timeout);
/* Last update time set. */
time (&peer->uptime);
diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c
index a883bec3c4..399435fb24 100644
--- a/ripngd/ripngd.c
+++ b/ripngd/ripngd.c
@@ -970,11 +970,11 @@ ripng_redistribute_add (int type, int sub_type, struct prefix_ipv6 *p,
}
}
- rinfo = ripng_ecmp_replace (&newinfo);
+ ripng_ecmp_replace (&newinfo);
route_unlock_node (rp);
}
else
- rinfo = ripng_ecmp_add (&newinfo);
+ ripng_ecmp_add (&newinfo);
if (IS_RIPNG_DEBUG_EVENT) {
if (!nexthop)
@@ -1539,8 +1539,9 @@ ripng_triggered_update (struct thread *t)
update is triggered when the timer expires. */
interval = (random () % 5) + 1;
- ripng->t_triggered_interval =
- thread_add_timer (master, ripng_triggered_interval, NULL, interval);
+ ripng->t_triggered_interval = NULL;
+ thread_add_timer(master, ripng_triggered_interval, NULL, interval,
+ &ripng->t_triggered_interval);
return 0;
}
@@ -1898,8 +1899,7 @@ ripng_event (enum ripng_event event, int sock)
switch (event)
{
case RIPNG_READ:
- if (!ripng->t_read)
- ripng->t_read = thread_add_read (master, ripng_read, NULL, sock);
+ thread_add_read(master, ripng_read, NULL, sock, &ripng->t_read);
break;
case RIPNG_UPDATE_EVENT:
if (ripng->t_update)
@@ -1910,16 +1910,15 @@ ripng_event (enum ripng_event event, int sock)
/* Update timer jitter. */
jitter = ripng_update_jitter (ripng->update_time);
- ripng->t_update =
- thread_add_timer (master, ripng_update, NULL,
- sock ? 2 : ripng->update_time + jitter);
+ ripng->t_update = NULL;
+ thread_add_timer(master, ripng_update, NULL, sock ? 2 : ripng->update_time + jitter,
+ &ripng->t_update);
break;
case RIPNG_TRIGGERED_UPDATE:
if (ripng->t_triggered_interval)
ripng->trigger = 1;
- else if (! ripng->t_triggered_update)
- ripng->t_triggered_update =
- thread_add_event (master, ripng_triggered_update, NULL, 0);
+ else thread_add_event(master, ripng_triggered_update, NULL, 0,
+ &ripng->t_triggered_update);
break;
default:
break;
@@ -2021,11 +2020,11 @@ DEFUN (show_ipv6_ripng,
p = (struct prefix_ipv6 *) &rp->p;
#ifdef DEBUG
- len = vty_out (vty, "R(a) %d/%d %s/%d ",
+ vty_out (vty, "R(a) %d/%d %s/%d ",
aggregate->count, aggregate->suppress,
inet6_ntoa (p->prefix), p->prefixlen);
#else
- len = vty_out (vty, "R(a) %s/%d ",
+ vty_out (vty, "R(a) %s/%d ",
inet6_ntoa (p->prefix), p->prefixlen);
#endif /* DEBUG */
vty_out (vty, "%s", VTY_NEWLINE);
@@ -2043,13 +2042,13 @@ DEFUN (show_ipv6_ripng,
p = (struct prefix_ipv6 *) &rp->p;
#ifdef DEBUG
- len = vty_out (vty, "%c(%s) 0/%d %s/%d ",
+ vty_out (vty, "%c(%s) 0/%d %s/%d ",
zebra_route_char(rinfo->type),
ripng_route_subtype_print(rinfo),
rinfo->suppress,
inet6_ntoa (p->prefix), p->prefixlen);
#else
- len = vty_out (vty, "%c(%s) %s/%d ",
+ vty_out (vty, "%c(%s) %s/%d ",
zebra_route_char(rinfo->type),
ripng_route_subtype_print(rinfo),
inet6_ntoa (p->prefix), p->prefixlen);
diff --git a/ripngd/ripngd.h b/ripngd/ripngd.h
index 70cba3c680..e40fd17b56 100644
--- a/ripngd/ripngd.h
+++ b/ripngd/ripngd.h
@@ -324,11 +324,7 @@ enum ripng_event
};
/* RIPng timer on/off macro. */
-#define RIPNG_TIMER_ON(T,F,V) \
-do { \
- if (!(T)) \
- (T) = thread_add_timer (master, (F), rinfo, (V)); \
-} while (0)
+#define RIPNG_TIMER_ON(T,F,V) thread_add_timer (master, (F), rinfo, (V), &(T))
#define RIPNG_TIMER_OFF(T) \
do { \
diff --git a/tests/helpers/c/main.c b/tests/helpers/c/main.c
index b3e6e706ff..e422c7e621 100644
--- a/tests/helpers/c/main.c
+++ b/tests/helpers/c/main.c
@@ -59,14 +59,14 @@ test_timer (struct thread *thread)
int *count = THREAD_ARG(thread);
printf ("run %d of timer\n", (*count)++);
- thread_add_timer (master, test_timer, count, 5);
+ thread_add_timer(master, test_timer, count, 5, NULL);
return 0;
}
static void
test_timer_init()
{
- thread_add_timer (master, test_timer, &timer_count, 10);
+ thread_add_timer(master, test_timer, &timer_count, 10, NULL);
}
static void
diff --git a/tests/lib/test_heavy_thread.c b/tests/lib/test_heavy_thread.c
index c43fa76c0e..57f0a6070a 100644
--- a/tests/lib/test_heavy_thread.c
+++ b/tests/lib/test_heavy_thread.c
@@ -91,7 +91,7 @@ clear_something (struct thread *thread)
ws->i++;
if (thread_should_yield(thread))
{
- thread_add_background(master, clear_something, ws, 0);
+ thread_add_background(master, clear_something, ws, 0, NULL);
return 0;
}
}
@@ -135,7 +135,7 @@ DEFUN (clear_foo,
ws->vty = vty;
ws->i = ITERS_FIRST;
- thread_add_background(master, clear_something, ws, 0);
+ thread_add_background(master, clear_something, ws, 0, NULL);
return CMD_SUCCESS;
}
diff --git a/tests/lib/test_timer_correctness.c b/tests/lib/test_timer_correctness.c
index e523929be1..b0643b907b 100644
--- a/tests/lib/test_timer_correctness.c
+++ b/tests/lib/test_timer_correctness.c
@@ -139,7 +139,9 @@ int main(int argc, char **argv)
/* Schedule timers to expire in 0..5 seconds */
interval_msec = prng_rand(prng) % 5000;
arg = XMALLOC(MTYPE_TMP, TIMESTR_LEN + 1);
- timers[i] = thread_add_timer_msec(master, timer_func, arg, interval_msec);
+ timers[i] = NULL;
+ thread_add_timer_msec(master, timer_func, arg, interval_msec,
+ &timers[i]);
ret = snprintf(arg, TIMESTR_LEN + 1, "%lld.%06lld",
(long long)timers[i]->u.sands.tv_sec,
(long long)timers[i]->u.sands.tv_usec);
diff --git a/tests/lib/test_timer_performance.c b/tests/lib/test_timer_performance.c
index a7d09beecc..da0355f660 100644
--- a/tests/lib/test_timer_performance.c
+++ b/tests/lib/test_timer_performance.c
@@ -56,8 +56,10 @@ int main(int argc, char **argv)
/* create thread structures so they won't be allocated during the
* time measurement */
- for (i = 0; i < SCHEDULE_TIMERS; i++)
- timers[i] = thread_add_timer_msec(master, dummy_func, NULL, 0);
+ for (i = 0; i < SCHEDULE_TIMERS; i++) {
+ timers[i] = NULL;
+ thread_add_timer_msec(master, dummy_func, NULL, 0, &timers[i]);
+ }
for (i = 0; i < SCHEDULE_TIMERS; i++)
thread_cancel(timers[i]);
@@ -68,8 +70,9 @@ int main(int argc, char **argv)
long interval_msec;
interval_msec = prng_rand(prng) % (100 * SCHEDULE_TIMERS);
- timers[i] = thread_add_timer_msec(master, dummy_func,
- NULL, interval_msec);
+ timers[i] = NULL;
+ thread_add_timer_msec(master, dummy_func, NULL, interval_msec,
+ &timers[i]);
}
monotime(&tv_lap);
diff --git a/tools/.gitignore b/tools/.gitignore
index 066b0887ae..2e3b89cc26 100644
--- a/tools/.gitignore
+++ b/tools/.gitignore
@@ -5,4 +5,5 @@
*.loT
.libs
*.o
-permutations
+/permutations
+/ssd
diff --git a/tools/permutations.c b/tools/permutations.c
index 6e1a37981a..88d1464697 100644
--- a/tools/permutations.c
+++ b/tools/permutations.c
@@ -87,8 +87,11 @@ permute (struct graph_node *start)
bool skip = false;
if (stok->type == FORK_TKN && tok->type != FORK_TKN)
for (ALL_LIST_ELEMENTS_RO (position, ln, gnn))
- if (gnn == gn && (skip = true))
+ if (gnn == gn)
+ {
+ skip = true;
break;
+ }
if (!skip)
permute (gn);
}
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index b029db2337..3967cfc934 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -264,7 +264,7 @@ vtysh_pager_init (void)
if (pager_defined)
vtysh_pager_name = strdup (pager_defined);
else
- vtysh_pager_name = strdup ("more");
+ vtysh_pager_name = strdup (VTYSH_PAGER);
}
/* Command execution over the vty interface. */
diff --git a/watchfrr/watchfrr.c b/watchfrr/watchfrr.c
index 6edce242b3..4097cb4d66 100644
--- a/watchfrr/watchfrr.c
+++ b/watchfrr/watchfrr.c
@@ -373,8 +373,9 @@ static int restart_kill(struct thread *t_kill)
(long)delay.tv_sec, (restart->kills ? SIGKILL : SIGTERM));
kill(-restart->pid, (restart->kills ? SIGKILL : SIGTERM));
restart->kills++;
- restart->t_kill = thread_add_timer(master, restart_kill, restart,
- gs.restart_timeout);
+ restart->t_kill = NULL;
+ thread_add_timer(master, restart_kill, restart, gs.restart_timeout,
+ &restart->t_kill);
return 0;
}
@@ -487,9 +488,9 @@ run_job(struct restart_info *restart, const char *cmdtype, const char *command,
char cmd[strlen(command) + strlen(restart->name) + 1];
snprintf(cmd, sizeof(cmd), command, restart->name);
if ((restart->pid = run_background(cmd)) > 0) {
- restart->t_kill =
- thread_add_timer(master, restart_kill, restart,
- gs.restart_timeout);
+ restart->t_kill = NULL;
+ thread_add_timer(master, restart_kill, restart, gs.restart_timeout,
+ &restart->t_kill);
restart->what = cmdtype;
gs.numpids++;
} else
@@ -510,19 +511,31 @@ run_job(struct restart_info *restart, const char *cmdtype, const char *command,
}
#define SET_READ_HANDLER(DMN) \
- (DMN)->t_read = thread_add_read(master,handle_read,(DMN),(DMN)->fd)
-
-#define SET_WAKEUP_DOWN(DMN) \
- (DMN)->t_wakeup = thread_add_timer_msec(master,wakeup_down,(DMN), \
- FUZZY(gs.period))
-
-#define SET_WAKEUP_UNRESPONSIVE(DMN) \
- (DMN)->t_wakeup = thread_add_timer_msec(master,wakeup_unresponsive,(DMN), \
- FUZZY(gs.period))
+ do { \
+ (DMN)->t_read = NULL; \
+ thread_add_read (master, handle_read, (DMN), (DMN)->fd, &(DMN)->t_read); \
+ } while (0);
+
+#define SET_WAKEUP_DOWN(DMN) \
+ do { \
+ (DMN)->t_wakeup = NULL; \
+ thread_add_timer_msec (master, wakeup_down, (DMN), FUZZY(gs.period), \
+ &(DMN)->t_wakeup); \
+ } while (0);
+
+#define SET_WAKEUP_UNRESPONSIVE(DMN) \
+ do { \
+ (DMN)->t_wakeup = NULL; \
+ thread_add_timer_msec (master, wakeup_unresponsive, (DMN), \
+ FUZZY(gs.period), &(DMN)->t_wakeup); \
+ } while (0);
#define SET_WAKEUP_ECHO(DMN) \
- (DMN)->t_wakeup = thread_add_timer_msec(master,wakeup_send_echo,(DMN), \
- FUZZY(gs.period))
+ do { \
+ (DMN)->t_wakeup = NULL; \
+ thread_add_timer_msec (master, wakeup_send_echo, (DMN), \
+ FUZZY(gs.period), &(DMN)->t_wakeup); \
+ } while (0);
static int wakeup_down(struct thread *t_wakeup)
{
@@ -775,11 +788,11 @@ static int try_connect(struct daemon *dmn)
zlog_debug("%s: connection in progress", dmn->name);
dmn->state = DAEMON_CONNECTING;
dmn->fd = sock;
- dmn->t_write =
- thread_add_write(master, check_connect, dmn, dmn->fd);
- dmn->t_wakeup =
- thread_add_timer(master, wakeup_connect_hanging, dmn,
- gs.timeout);
+ dmn->t_write = NULL;
+ thread_add_write(master, check_connect, dmn, dmn->fd,
+ &dmn->t_write);dmn->t_wakeup = NULL;
+ thread_add_timer(master, wakeup_connect_hanging, dmn, gs.timeout,
+ &dmn->t_wakeup);
SET_READ_HANDLER(dmn);
return 0;
}
@@ -804,8 +817,9 @@ static void set_phase(restart_phase_t new_phase)
gs.phase = new_phase;
if (gs.t_phase_hanging)
thread_cancel(gs.t_phase_hanging);
- gs.t_phase_hanging = thread_add_timer(master, phase_hanging, NULL,
- PHASE_TIMEOUT);
+ gs.t_phase_hanging = NULL;
+ thread_add_timer(master, phase_hanging, NULL, PHASE_TIMEOUT,
+ &gs.t_phase_hanging);
}
static void phase_check(void)
@@ -962,8 +976,9 @@ static int wakeup_send_echo(struct thread *t_wakeup)
daemon_down(dmn, why);
} else {
gettimeofday(&dmn->echo_sent, NULL);
- dmn->t_wakeup =
- thread_add_timer(master, wakeup_no_answer, dmn, gs.timeout);
+ dmn->t_wakeup = NULL;
+ thread_add_timer(master, wakeup_no_answer, dmn, gs.timeout,
+ &dmn->t_wakeup);
}
return 0;
}
@@ -1310,9 +1325,9 @@ int main(int argc, char **argv)
gs.numdaemons++;
gs.numdown++;
dmn->fd = -1;
- dmn->t_wakeup =
- thread_add_timer_msec(master, wakeup_init, dmn,
- 100 + (random() % 900));
+ dmn->t_wakeup = NULL;
+ thread_add_timer_msec(master, wakeup_init, dmn, 100 + (random() % 900),
+ &dmn->t_wakeup);
dmn->restart.interval = gs.min_restart_interval;
if (tail)
tail->next = dmn;
diff --git a/zebra/debug.c b/zebra/debug.c
index a42d5aa3ef..cb1ed359a8 100644
--- a/zebra/debug.c
+++ b/zebra/debug.c
@@ -384,6 +384,16 @@ config_write_debug (struct vty *vty)
vty_out (vty, "debug zebra kernel%s", VTY_NEWLINE);
write++;
}
+ if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV)
+ {
+ vty_out (vty, "debug zebra kernel msgdump recv%s", VTY_NEWLINE);
+ write++;
+ }
+ if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND)
+ {
+ vty_out (vty, "debug zebra kernel msgdump send%s", VTY_NEWLINE);
+ write++;
+ }
/* Check here using flags as the 'macro' does an OR */
if (CHECK_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB))
{
diff --git a/zebra/irdp_interface.c b/zebra/irdp_interface.c
index 5cabe7e62f..21f8beadf2 100644
--- a/zebra/irdp_interface.c
+++ b/zebra/irdp_interface.c
@@ -259,10 +259,9 @@ irdp_if_start(struct interface *ifp, int multicast, int set_defaults)
ifp->name,
timer);
- irdp->t_advertise = thread_add_timer(zebrad.master,
- irdp_send_thread,
- ifp,
- timer);
+ irdp->t_advertise = NULL;
+ thread_add_timer(zebrad.master, irdp_send_thread, ifp, timer,
+ &irdp->t_advertise);
}
static void
diff --git a/zebra/irdp_main.c b/zebra/irdp_main.c
index 7fa4ad4cbe..5c17570f05 100644
--- a/zebra/irdp_main.c
+++ b/zebra/irdp_main.c
@@ -114,7 +114,8 @@ irdp_sock_init (void)
return ret;
};
- t_irdp_raw = thread_add_read (zebrad.master, irdp_read_raw, NULL, sock);
+ t_irdp_raw = NULL;
+ thread_add_read(zebrad.master, irdp_read_raw, NULL, sock, &t_irdp_raw);
return sock;
}
@@ -244,7 +245,9 @@ int irdp_send_thread(struct thread *t_advert)
if(irdp->flags & IF_DEBUG_MISC)
zlog_debug("IRDP: New timer for %s set to %u\n", ifp->name, timer);
- irdp->t_advertise = thread_add_timer(zebrad.master, irdp_send_thread, ifp, timer);
+ irdp->t_advertise = NULL;
+ thread_add_timer(zebrad.master, irdp_send_thread, ifp, timer,
+ &irdp->t_advertise);
return 0;
}
@@ -296,10 +299,9 @@ void process_solicit (struct interface *ifp)
timer = (random () % MAX_RESPONSE_DELAY) + 1;
- irdp->t_advertise = thread_add_timer(zebrad.master,
- irdp_send_thread,
- ifp,
- timer);
+ irdp->t_advertise = NULL;
+ thread_add_timer(zebrad.master, irdp_send_thread, ifp, timer,
+ &irdp->t_advertise);
}
void irdp_finish()
diff --git a/zebra/irdp_packet.c b/zebra/irdp_packet.c
index 4c58b6b35d..269d4c0449 100644
--- a/zebra/irdp_packet.c
+++ b/zebra/irdp_packet.c
@@ -232,7 +232,8 @@ int irdp_read_raw(struct thread *r)
int ret, ifindex = 0;
int irdp_sock = THREAD_FD (r);
- t_irdp_raw = thread_add_read (zebrad.master, irdp_read_raw, NULL, irdp_sock);
+ t_irdp_raw = NULL;
+ thread_add_read(zebrad.master, irdp_read_raw, NULL, irdp_sock, &t_irdp_raw);
ret = irdp_recvmsg (irdp_sock, (u_char *) buf, IRDP_RX_BUF, &ifindex);
diff --git a/zebra/kernel_netlink.c b/zebra/kernel_netlink.c
index e974203219..27beaf0c82 100644
--- a/zebra/kernel_netlink.c
+++ b/zebra/kernel_netlink.c
@@ -283,8 +283,9 @@ kernel_read (struct thread *thread)
{
struct zebra_ns *zns = (struct zebra_ns *)THREAD_ARG (thread);
netlink_parse_info (netlink_information_fetch, &zns->netlink, zns, 5, 0);
- zns->t_netlink = thread_add_read (zebrad.master, kernel_read, zns,
- zns->netlink.sock);
+ zns->t_netlink = NULL;
+ thread_add_read(zebrad.master, kernel_read, zns, zns->netlink.sock,
+ &zns->t_netlink);
return 0;
}
@@ -521,7 +522,7 @@ netlink_parse_info (int (*filter) (struct sockaddr_nl *, struct nlmsghdr *,
if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV)
{
zlog_debug("%s: << netlink message dump [recv]", __func__);
- zlog_hexdump(&msg, sizeof(msg));
+ zlog_hexdump(buf, status);
}
read_in++;
@@ -704,7 +705,7 @@ netlink_talk (int (*filter) (struct sockaddr_nl *, struct nlmsghdr *,
if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND)
{
zlog_debug("%s: >> netlink message dump [sent]", __func__);
- zlog_hexdump(&msg, sizeof(msg));
+ zlog_hexdump(n, n->nlmsg_len);
}
if (status < 0)
@@ -813,8 +814,9 @@ kernel_init (struct zebra_ns *zns)
netlink_recvbuf (&zns->netlink, nl_rcvbufsize);
netlink_install_filter (zns->netlink.sock, zns->netlink_cmd.snl.nl_pid);
- zns->t_netlink = thread_add_read (zebrad.master, kernel_read, zns,
- zns->netlink.sock);
+ zns->t_netlink = NULL;
+ thread_add_read(zebrad.master, kernel_read, zns, zns->netlink.sock,
+ &zns->t_netlink);
}
}
diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c
index 7212ed6f26..0e15153e1d 100644
--- a/zebra/kernel_socket.c
+++ b/zebra/kernel_socket.c
@@ -1282,7 +1282,7 @@ kernel_read (struct thread *thread)
return 0;
}
- thread_add_read (zebrad.master, kernel_read, NULL, sock);
+ thread_add_read(zebrad.master, kernel_read, NULL, sock, NULL);
if (IS_ZEBRA_DEBUG_KERNEL)
rtmsg_debug (&buf.r.rtm);
@@ -1355,7 +1355,7 @@ routing_socket (struct zebra_ns *zns)
zlog_err ("routing_socket: Can't lower privileges");
/* kernel_read needs rewrite. */
- thread_add_read (zebrad.master, kernel_read, NULL, routing_sock);
+ thread_add_read(zebrad.master, kernel_read, NULL, routing_sock, NULL);
}
/* Exported interface function. This function simply calls
diff --git a/zebra/label_manager.c b/zebra/label_manager.c
index bf67141cd4..e60f7a4a6a 100644
--- a/zebra/label_manager.c
+++ b/zebra/label_manager.c
@@ -141,9 +141,8 @@ static int zclient_connect(struct thread *t)
if (zclient_socket_connect(zclient) < 0) {
zlog_err("Error connecting synchronous zclient!");
- THREAD_TIMER_ON(zebrad.master, zclient->t_connect,
- zclient_connect,
- zclient, CONNECTION_DELAY);
+ thread_add_timer(zebrad.master, zclient_connect, zclient,
+ CONNECTION_DELAY, &zclient->t_connect);
return -1;
}
@@ -205,7 +204,6 @@ struct label_manager_chunk *assign_label_chunk(u_char proto, u_short instance,
struct label_manager_chunk *lmc;
struct listnode *node;
- node = lbl_mgr.lc_list->head;
/* first check if there's one available */
for (ALL_LIST_ELEMENTS_RO(lbl_mgr.lc_list, node, lmc)) {
if (lmc->proto == NO_PROTO && lmc->end - lmc->start + 1 == size) {
diff --git a/zebra/rtadv.c b/zebra/rtadv.c
index 12e4873adf..03b7ace9b3 100644
--- a/zebra/rtadv.c
+++ b/zebra/rtadv.c
@@ -1574,11 +1574,8 @@ rtadv_event (struct zebra_ns *zns, enum rtadv_event event, int val)
switch (event)
{
case RTADV_START:
- if (! rtadv->ra_read)
- rtadv->ra_read = thread_add_read (zebrad.master, rtadv_read, zns, val);
- if (! rtadv->ra_timer)
- rtadv->ra_timer = thread_add_event (zebrad.master, rtadv_timer,
- zns, 0);
+ thread_add_read(zebrad.master, rtadv_read, zns, val, &rtadv->ra_read);
+ thread_add_event(zebrad.master, rtadv_timer, zns, 0, &rtadv->ra_timer);
break;
case RTADV_STOP:
if (rtadv->ra_timer)
@@ -1593,18 +1590,14 @@ rtadv_event (struct zebra_ns *zns, enum rtadv_event event, int val)
}
break;
case RTADV_TIMER:
- if (! rtadv->ra_timer)
- rtadv->ra_timer = thread_add_timer (zebrad.master, rtadv_timer, zns,
- val);
+ thread_add_timer(zebrad.master, rtadv_timer, zns, val, &rtadv->ra_timer);
break;
case RTADV_TIMER_MSEC:
- if (! rtadv->ra_timer)
- rtadv->ra_timer = thread_add_timer_msec (zebrad.master, rtadv_timer,
- zns, val);
+ thread_add_timer_msec(zebrad.master, rtadv_timer, zns, val,
+ &rtadv->ra_timer);
break;
case RTADV_READ:
- if (! rtadv->ra_read)
- rtadv->ra_read = thread_add_read (zebrad.master, rtadv_read, zns, val);
+ thread_add_read(zebrad.master, rtadv_read, zns, val, &rtadv->ra_read);
break;
default:
break;
diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c
index 405b2e9f79..cf8f78afe9 100644
--- a/zebra/zebra_fpm.c
+++ b/zebra/zebra_fpm.c
@@ -487,8 +487,8 @@ zfpm_read_on (void)
assert (!zfpm_g->t_read);
assert (zfpm_g->sock >= 0);
- THREAD_READ_ON (zfpm_g->master, zfpm_g->t_read, zfpm_read_cb, 0,
- zfpm_g->sock);
+ thread_add_read(zfpm_g->master, zfpm_read_cb, 0, zfpm_g->sock,
+ &zfpm_g->t_read);
}
/*
@@ -500,8 +500,8 @@ zfpm_write_on (void)
assert (!zfpm_g->t_write);
assert (zfpm_g->sock >= 0);
- THREAD_WRITE_ON (zfpm_g->master, zfpm_g->t_write, zfpm_write_cb, 0,
- zfpm_g->sock);
+ thread_add_write(zfpm_g->master, zfpm_write_cb, 0, zfpm_g->sock,
+ &zfpm_g->t_write);
}
/*
@@ -535,7 +535,6 @@ zfpm_conn_up_thread_cb (struct thread *thread)
zfpm_rnodes_iter_t *iter;
rib_dest_t *dest;
- assert (zfpm_g->t_conn_up);
zfpm_g->t_conn_up = NULL;
iter = &zfpm_g->t_conn_up_state.iter;
@@ -565,9 +564,9 @@ zfpm_conn_up_thread_cb (struct thread *thread)
zfpm_g->stats.t_conn_up_yields++;
zfpm_rnodes_iter_pause (iter);
- zfpm_g->t_conn_up = thread_add_background (zfpm_g->master,
- zfpm_conn_up_thread_cb,
- 0, 0);
+ zfpm_g->t_conn_up = NULL;
+ thread_add_background(zfpm_g->master, zfpm_conn_up_thread_cb, 0, 0,
+ &zfpm_g->t_conn_up);
return 0;
}
@@ -599,8 +598,9 @@ zfpm_connection_up (const char *detail)
zfpm_rnodes_iter_init (&zfpm_g->t_conn_up_state.iter);
zfpm_debug ("Starting conn_up thread");
- zfpm_g->t_conn_up = thread_add_background (zfpm_g->master,
- zfpm_conn_up_thread_cb, 0, 0);
+ zfpm_g->t_conn_up = NULL;
+ thread_add_background(zfpm_g->master, zfpm_conn_up_thread_cb, 0, 0,
+ &zfpm_g->t_conn_up);
zfpm_g->stats.t_conn_up_starts++;
}
@@ -654,7 +654,6 @@ zfpm_conn_down_thread_cb (struct thread *thread)
assert (zfpm_g->state == ZFPM_STATE_IDLE);
- assert (zfpm_g->t_conn_down);
zfpm_g->t_conn_down = NULL;
iter = &zfpm_g->t_conn_down_state.iter;
@@ -689,9 +688,9 @@ zfpm_conn_down_thread_cb (struct thread *thread)
zfpm_g->stats.t_conn_down_yields++;
zfpm_rnodes_iter_pause (iter);
- zfpm_g->t_conn_down = thread_add_background (zfpm_g->master,
- zfpm_conn_down_thread_cb,
- 0, 0);
+ zfpm_g->t_conn_down = NULL;
+ thread_add_background(zfpm_g->master, zfpm_conn_down_thread_cb, 0, 0,
+ &zfpm_g->t_conn_down);
return 0;
}
@@ -737,8 +736,9 @@ zfpm_connection_down (const char *detail)
assert (!zfpm_g->t_conn_down);
zfpm_debug ("Starting conn_down thread");
zfpm_rnodes_iter_init (&zfpm_g->t_conn_down_state.iter);
- zfpm_g->t_conn_down = thread_add_background (zfpm_g->master,
- zfpm_conn_down_thread_cb, 0, 0);
+ zfpm_g->t_conn_down = NULL;
+ thread_add_background(zfpm_g->master, zfpm_conn_down_thread_cb, 0, 0,
+ &zfpm_g->t_conn_down);
zfpm_g->stats.t_conn_down_starts++;
zfpm_set_state (ZFPM_STATE_IDLE, detail);
@@ -756,7 +756,6 @@ zfpm_read_cb (struct thread *thread)
fpm_msg_hdr_t *hdr;
zfpm_g->stats.read_cb_calls++;
- assert (zfpm_g->t_read);
zfpm_g->t_read = NULL;
/*
@@ -1045,7 +1044,6 @@ zfpm_write_cb (struct thread *thread)
int num_writes;
zfpm_g->stats.write_cb_calls++;
- assert (zfpm_g->t_write);
zfpm_g->t_write = NULL;
/*
@@ -1137,7 +1135,6 @@ zfpm_connect_cb (struct thread *t)
int sock, ret;
struct sockaddr_in serv;
- assert (zfpm_g->t_connect);
zfpm_g->t_connect = NULL;
assert (zfpm_g->state == ZFPM_STATE_ACTIVE);
@@ -1294,8 +1291,8 @@ zfpm_start_connect_timer (const char *reason)
delay_secs = zfpm_calc_connect_delay();
zfpm_debug ("scheduling connect in %ld seconds", delay_secs);
- THREAD_TIMER_ON (zfpm_g->master, zfpm_g->t_connect, zfpm_connect_cb, 0,
- delay_secs);
+ thread_add_timer(zfpm_g->master, zfpm_connect_cb, 0, delay_secs,
+ &zfpm_g->t_connect);
zfpm_set_state (ZFPM_STATE_ACTIVE, reason);
}
@@ -1388,7 +1385,6 @@ zfpm_trigger_update (struct route_node *rn, const char *reason)
static int
zfpm_stats_timer_cb (struct thread *t)
{
- assert (zfpm_g->t_stats);
zfpm_g->t_stats = NULL;
/*
@@ -1434,8 +1430,8 @@ zfpm_start_stats_timer (void)
{
assert (!zfpm_g->t_stats);
- THREAD_TIMER_ON (zfpm_g->master, zfpm_g->t_stats, zfpm_stats_timer_cb, 0,
- ZFPM_STATS_IVL_SECS);
+ thread_add_timer(zfpm_g->master, zfpm_stats_timer_cb, 0,
+ ZFPM_STATS_IVL_SECS, &zfpm_g->t_stats);
}
/*
diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c
index 76263024c5..65e7f9ab95 100644
--- a/zebra/zebra_mpls.c
+++ b/zebra/zebra_mpls.c
@@ -156,7 +156,7 @@ static int
snhlfe_del_all (zebra_slsp_t *slsp);
static char *
snhlfe2str (zebra_snhlfe_t *snhlfe, char *buf, int size);
-static void
+static int
mpls_processq_init (struct zebra_t *zebra);
@@ -185,10 +185,6 @@ lsp_install (struct zebra_vrf *zvrf, mpls_label_t label,
if (!lsp_table)
return -1;
- /* See if route entry is selected; we really expect only 1 entry here. */
- if (!CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
- return 0;
-
lsp_type = lsp_type_from_rib_type (rib->type);
added = changed = 0;
@@ -1041,6 +1037,12 @@ lsp_processq_add (zebra_lsp_t *lsp)
if (CHECK_FLAG (lsp->flags, LSP_FLAG_SCHEDULED))
return 0;
+ if (zebrad.lsp_process_q == NULL)
+ {
+ zlog_err ("%s: work_queue does not exist!", __func__);
+ return -1;
+ }
+
work_queue_add (zebrad.lsp_process_q, lsp);
SET_FLAG (lsp->flags, LSP_FLAG_SCHEDULED);
return 0;
@@ -1697,14 +1699,14 @@ snhlfe2str (zebra_snhlfe_t *snhlfe, char *buf, int size)
/*
* Initialize work queue for processing changed LSPs.
*/
-static void
+static int
mpls_processq_init (struct zebra_t *zebra)
{
zebra->lsp_process_q = work_queue_new (zebra->master, "LSP processing");
if (!zebra->lsp_process_q)
{
zlog_err ("%s: could not initialise work queue!", __func__);
- return;
+ return -1;
}
zebra->lsp_process_q->spec.workfunc = &lsp_process;
@@ -1713,6 +1715,8 @@ mpls_processq_init (struct zebra_t *zebra)
zebra->lsp_process_q->spec.completion_func = &lsp_processq_complete;
zebra->lsp_process_q->spec.max_retries = 0;
zebra->lsp_process_q->spec.hold = 10;
+
+ return 0;
}
@@ -1766,13 +1770,29 @@ mpls_str2label (const char *label_str, u_int8_t *num_labels,
*/
char *
mpls_label2str (u_int8_t num_labels, mpls_label_t *labels,
- char *buf, int len)
+ char *buf, int len, int pretty)
{
+ char *buf_ptr = buf;
buf[0] = '\0';
- if (num_labels == 1)
- snprintf (buf, len, "%u", labels[0]);
- else if (num_labels == 2)
- snprintf (buf, len, "%u/%u", labels[0], labels[1]);
+
+ if (pretty) {
+ if (num_labels == 1) {
+ label2str(labels[0], buf, len);
+ } else if (num_labels == 2) {
+ label2str(labels[0], buf, len);
+ buf_ptr += strlen(buf);
+
+ snprintf (buf_ptr, len, "/");
+ buf_ptr++;
+
+ label2str(labels[1], buf_ptr, len);
+ }
+ } else {
+ if (num_labels == 1)
+ snprintf (buf, len, "%u", labels[0]);
+ else if (num_labels == 2)
+ snprintf (buf, len, "%u/%u", labels[0], labels[1]);
+ }
return buf;
}
@@ -2966,12 +2986,14 @@ zebra_mpls_init_tables (struct zebra_vrf *zvrf)
void
zebra_mpls_init (void)
{
+ mpls_enabled = 0;
+
if (mpls_kernel_init () < 0)
{
zlog_warn ("Disabling MPLS support (no kernel support)");
return;
}
- mpls_enabled = 1;
- mpls_processq_init (&zebrad);
+ if (! mpls_processq_init (&zebrad))
+ mpls_enabled = 1;
}
diff --git a/zebra/zebra_mpls.h b/zebra/zebra_mpls.h
index e271edd2eb..b5a8f3173e 100644
--- a/zebra/zebra_mpls.h
+++ b/zebra/zebra_mpls.h
@@ -184,7 +184,7 @@ mpls_str2label (const char *label_str, u_int8_t *num_labels,
*/
char *
mpls_label2str (u_int8_t num_labels, mpls_label_t *labels,
- char *buf, int len);
+ char *buf, int len, int pretty);
/*
* Add/update global label block.
diff --git a/zebra/zebra_mpls_null.c b/zebra/zebra_mpls_null.c
index 168c8d003c..0333b6e6b4 100644
--- a/zebra/zebra_mpls_null.c
+++ b/zebra/zebra_mpls_null.c
@@ -32,7 +32,7 @@ int mpls_enabled;
char *
mpls_label2str (u_int8_t num_labels, mpls_label_t *labels,
- char *buf, int len)
+ char *buf, int len, int pretty)
{
return NULL;
}
diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c
index bc924842d4..4141cdd907 100644
--- a/zebra/zebra_ptm.c
+++ b/zebra/zebra_ptm.c
@@ -182,12 +182,14 @@ zebra_ptm_flush_messages (struct thread *thread)
close(ptm_cb.ptm_sock);
ptm_cb.ptm_sock = -1;
zebra_ptm_reset_status(0);
- ptm_cb.t_timer = thread_add_timer (zebrad.master, zebra_ptm_connect,
- NULL, ptm_cb.reconnect_time);
+ ptm_cb.t_timer = NULL;
+ thread_add_timer(zebrad.master, zebra_ptm_connect, NULL, ptm_cb.reconnect_time,
+ &ptm_cb.t_timer);
return (-1);
case BUFFER_PENDING:
- ptm_cb.t_write = thread_add_write(zebrad.master, zebra_ptm_flush_messages,
- NULL, ptm_cb.ptm_sock);
+ ptm_cb.t_write = NULL;
+ thread_add_write(zebrad.master, zebra_ptm_flush_messages, NULL, ptm_cb.ptm_sock,
+ &ptm_cb.t_write);
break;
case BUFFER_EMPTY:
break;
@@ -207,15 +209,16 @@ zebra_ptm_send_message(char *data, int size)
close(ptm_cb.ptm_sock);
ptm_cb.ptm_sock = -1;
zebra_ptm_reset_status(0);
- ptm_cb.t_timer = thread_add_timer (zebrad.master, zebra_ptm_connect,
- NULL, ptm_cb.reconnect_time);
+ ptm_cb.t_timer = NULL;
+ thread_add_timer(zebrad.master, zebra_ptm_connect, NULL, ptm_cb.reconnect_time,
+ &ptm_cb.t_timer);
return -1;
case BUFFER_EMPTY:
THREAD_OFF(ptm_cb.t_write);
break;
case BUFFER_PENDING:
- THREAD_WRITE_ON(zebrad.master, ptm_cb.t_write,
- zebra_ptm_flush_messages, NULL, ptm_cb.ptm_sock);
+ thread_add_write(zebrad.master, zebra_ptm_flush_messages, NULL,
+ ptm_cb.ptm_sock, &ptm_cb.t_write);
break;
}
@@ -234,8 +237,9 @@ zebra_ptm_connect (struct thread *t)
if (ptm_cb.ptm_sock != -1) {
if (init) {
- ptm_cb.t_read = thread_add_read (zebrad.master, zebra_ptm_sock_read,
- NULL, ptm_cb.ptm_sock);
+ ptm_cb.t_read = NULL;
+ thread_add_read(zebrad.master, zebra_ptm_sock_read, NULL, ptm_cb.ptm_sock,
+ &ptm_cb.t_read);
zebra_bfd_peer_replay_req();
}
zebra_ptm_send_status_req();
@@ -245,8 +249,9 @@ zebra_ptm_connect (struct thread *t)
if (ptm_cb.reconnect_time > ZEBRA_PTM_RECONNECT_TIME_MAX)
ptm_cb.reconnect_time = ZEBRA_PTM_RECONNECT_TIME_MAX;
- ptm_cb.t_timer = thread_add_timer (zebrad.master, zebra_ptm_connect, NULL,
- ptm_cb.reconnect_time);
+ ptm_cb.t_timer = NULL;
+ thread_add_timer(zebrad.master, zebra_ptm_connect, NULL, ptm_cb.reconnect_time,
+ &ptm_cb.t_timer);
} else if (ptm_cb.reconnect_time >= ZEBRA_PTM_RECONNECT_TIME_MAX){
ptm_cb.reconnect_time = ZEBRA_PTM_RECONNECT_TIME_INITIAL;
}
@@ -653,14 +658,16 @@ zebra_ptm_sock_read (struct thread *thread)
close (ptm_cb.ptm_sock);
ptm_cb.ptm_sock = -1;
zebra_ptm_reset_status(0);
- ptm_cb.t_timer = thread_add_timer (zebrad.master, zebra_ptm_connect,
- NULL, ptm_cb.reconnect_time);
+ ptm_cb.t_timer = NULL;
+ thread_add_timer(zebrad.master, zebra_ptm_connect, NULL, ptm_cb.reconnect_time,
+ &ptm_cb.t_timer);
return (-1);
}
}
- ptm_cb.t_read = thread_add_read (zebrad.master, zebra_ptm_sock_read,
- NULL, ptm_cb.ptm_sock);
+ ptm_cb.t_read = NULL;
+ thread_add_read(zebrad.master, zebra_ptm_sock_read, NULL, ptm_cb.ptm_sock,
+ &ptm_cb.t_read);
return 0;
}
@@ -697,8 +704,9 @@ zebra_ptm_bfd_dst_register (struct zserv *client, int sock, u_short length,
if (ptm_cb.ptm_sock == -1)
{
- ptm_cb.t_timer = thread_add_timer (zebrad.master, zebra_ptm_connect,
- NULL, ptm_cb.reconnect_time);
+ ptm_cb.t_timer = NULL;
+ thread_add_timer(zebrad.master, zebra_ptm_connect, NULL, ptm_cb.reconnect_time,
+ &ptm_cb.t_timer);
return -1;
}
@@ -854,8 +862,9 @@ zebra_ptm_bfd_dst_deregister (struct zserv *client, int sock, u_short length,
if (ptm_cb.ptm_sock == -1)
{
- ptm_cb.t_timer = thread_add_timer (zebrad.master, zebra_ptm_connect,
- NULL, ptm_cb.reconnect_time);
+ ptm_cb.t_timer = NULL;
+ thread_add_timer(zebrad.master, zebra_ptm_connect, NULL, ptm_cb.reconnect_time,
+ &ptm_cb.t_timer);
return -1;
}
@@ -976,8 +985,9 @@ zebra_ptm_bfd_client_register (struct zserv *client, int sock, u_short length)
if (ptm_cb.ptm_sock == -1)
{
- ptm_cb.t_timer = thread_add_timer (zebrad.master, zebra_ptm_connect,
- NULL, ptm_cb.reconnect_time);
+ ptm_cb.t_timer = NULL;
+ thread_add_timer(zebrad.master, zebra_ptm_connect, NULL, ptm_cb.reconnect_time,
+ &ptm_cb.t_timer);
return -1;
}
@@ -1026,8 +1036,9 @@ zebra_ptm_bfd_client_deregister (int proto)
if (ptm_cb.ptm_sock == -1)
{
- ptm_cb.t_timer = thread_add_timer (zebrad.master, zebra_ptm_connect,
- NULL, ptm_cb.reconnect_time);
+ ptm_cb.t_timer = NULL;
+ thread_add_timer(zebrad.master, zebra_ptm_connect, NULL, ptm_cb.reconnect_time,
+ &ptm_cb.t_timer);
return;
}
diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c
index 847da52952..1738b0b053 100644
--- a/zebra/zebra_routemap.c
+++ b/zebra/zebra_routemap.c
@@ -1403,10 +1403,11 @@ static void
zebra_route_map_mark_update (const char *rmap_name)
{
/* rmap_update_timer of 0 means don't do route updates */
- if (zebra_rmap_update_timer && !zebra_t_rmap_update)
- zebra_t_rmap_update =
- thread_add_timer(zebrad.master, zebra_route_map_update_timer, NULL,
- zebra_rmap_update_timer);
+ if (zebra_rmap_update_timer && !zebra_t_rmap_update) {
+ zebra_t_rmap_update = NULL;
+ thread_add_timer(zebrad.master, zebra_route_map_update_timer, NULL, zebra_rmap_update_timer,
+ &zebra_t_rmap_update);
+ }
}
static void
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 1708138d83..c5c462c8da 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -46,7 +46,7 @@
extern int allow_delete;
static int do_show_ip_route(struct vty *vty, const char *vrf_name,
- safi_t safi, u_char use_json);
+ safi_t safi, bool use_fib, u_char use_json);
static void vty_show_ip_route_detail (struct vty *vty, struct route_node *rn,
int mcast);
@@ -304,7 +304,7 @@ DEFUN (show_ip_rpf,
IP_STR
"Display RPF information for multicast source\n")
{
- return do_show_ip_route(vty, VRF_DEFAULT_NAME, SAFI_MULTICAST, 0);
+ return do_show_ip_route(vty, VRF_DEFAULT_NAME, SAFI_MULTICAST, false, 0);
}
DEFUN (show_ip_rpf_addr,
@@ -781,9 +781,9 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
/* Label information */
if (nexthop->nh_label && nexthop->nh_label->num_labels)
{
- vty_out (vty, " label %s",
+ vty_out (vty, ", label %s",
mpls_label2str (nexthop->nh_label->num_labels,
- nexthop->nh_label->label, buf, BUFSIZ));
+ nexthop->nh_label->label, buf, BUFSIZ, 1));
}
vty_out (vty, "%s", VTY_NEWLINE);
@@ -803,6 +803,7 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib,
json_object *json_nexthops = NULL;
json_object *json_nexthop = NULL;
json_object *json_route = NULL;
+ json_object *json_labels = NULL;
if (json)
{
@@ -932,6 +933,16 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib,
break;
}
+ if (nexthop->nh_label && nexthop->nh_label->num_labels)
+ {
+ json_labels = json_object_new_array();
+
+ for (int label_index = 0; label_index < nexthop->nh_label->num_labels; label_index++)
+ json_object_array_add(json_labels, json_object_new_int(nexthop->nh_label->label[label_index]));
+
+ json_object_object_add(json_nexthop, "labels", json_labels);
+ }
+
json_object_array_add(json_nexthops, json_nexthop);
}
@@ -1030,9 +1041,9 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib,
/* Label information */
if (nexthop->nh_label && nexthop->nh_label->num_labels)
{
- vty_out (vty, " label %s",
+ vty_out (vty, ", label %s",
mpls_label2str (nexthop->nh_label->num_labels,
- nexthop->nh_label->label, buf, BUFSIZ));
+ nexthop->nh_label->label, buf, BUFSIZ, 1));
}
if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
@@ -1069,20 +1080,28 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib,
}
}
+static bool
+use_fib (struct cmd_token *token)
+{
+ return strncmp(token->arg, "route", strlen(token->arg));
+}
+
DEFUN (show_ip_route,
show_ip_route_cmd,
- "show ip route [json]",
+ "show ip <fib|route> [json]",
SHOW_STR
IP_STR
+ "IP forwarding table\n"
"IP routing table\n"
JSON_STR)
{
- return do_show_ip_route (vty, VRF_DEFAULT_NAME, SAFI_UNICAST, use_json(argc, argv));
+ return do_show_ip_route (vty, VRF_DEFAULT_NAME, SAFI_UNICAST,
+ use_fib(argv[2]), use_json(argc, argv));
}
static int
do_show_ip_route (struct vty *vty, const char *vrf_name, safi_t safi,
- u_char use_json)
+ bool use_fib, u_char use_json)
{
struct route_table *table;
struct route_node *rn;
@@ -1128,6 +1147,8 @@ do_show_ip_route (struct vty *vty, const char *vrf_name, safi_t safi,
{
RNODE_FOREACH_RIB (rn, rib)
{
+ if (use_fib && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
+ continue;
if (!json_prefix)
json_prefix = json_object_new_array();
vty_show_ip_route (vty, rn, rib, json_prefix);
@@ -1151,6 +1172,8 @@ do_show_ip_route (struct vty *vty, const char *vrf_name, safi_t safi,
{
RNODE_FOREACH_RIB (rn, rib)
{
+ if (use_fib && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
+ continue;
if (first)
{
vty_out (vty, SHOW_ROUTE_V4_HEADER);
@@ -1166,17 +1189,19 @@ do_show_ip_route (struct vty *vty, const char *vrf_name, safi_t safi,
DEFUN (show_ip_route_vrf,
show_ip_route_vrf_cmd,
- "show ip route vrf NAME [json]",
+ "show ip <fib|route> vrf NAME [json]",
SHOW_STR
IP_STR
+ "IP forwarding table\n"
"IP routing table\n"
VRF_CMD_HELP_STR
JSON_STR)
{
int idx_vrf = 4;
+ bool uf = use_fib(argv[2]);
u_char uj = use_json(argc, argv);
- return do_show_ip_route (vty, argv[idx_vrf]->arg, SAFI_UNICAST, uj);
+ return do_show_ip_route (vty, argv[idx_vrf]->arg, SAFI_UNICAST, uf, uj);
}
DEFUN (show_ip_nht,
@@ -1323,14 +1348,16 @@ DEFUN (no_ipv6_nht_default_route,
DEFUN (show_ip_route_tag,
show_ip_route_tag_cmd,
- "show ip route [vrf NAME] tag (1-4294967295)",
+ "show ip <fib|route> [vrf NAME] tag (1-4294967295)",
SHOW_STR
IP_STR
+ "IP forwarding table\n"
"IP routing table\n"
VRF_CMD_HELP_STR
"Show only routes with tag\n"
"Tag value\n")
{
+ bool uf = use_fib(argv[2]);
int idx_vrf = 3;
int idx_name = 4;
int idx_tag = 6;
@@ -1360,6 +1387,8 @@ DEFUN (show_ip_route_tag,
for (rn = route_top (table); rn; rn = route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
{
+ if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
+ continue;
if (rib->tag != tag)
continue;
@@ -1375,9 +1404,10 @@ DEFUN (show_ip_route_tag,
DEFUN (show_ip_route_prefix_longer,
show_ip_route_prefix_longer_cmd,
- "show ip route [vrf NAME] A.B.C.D/M longer-prefixes",
+ "show ip <fib|route> [vrf NAME] A.B.C.D/M longer-prefixes",
SHOW_STR
IP_STR
+ "IP forwarding table\n"
"IP routing table\n"
VRF_CMD_HELP_STR
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
@@ -1389,6 +1419,7 @@ DEFUN (show_ip_route_prefix_longer,
struct prefix p;
int ret;
int first = 1;
+ bool uf = use_fib(argv[2]);
vrf_id_t vrf_id = VRF_DEFAULT;
if (strmatch(argv[3]->text, "vrf"))
@@ -1416,6 +1447,8 @@ DEFUN (show_ip_route_prefix_longer,
RNODE_FOREACH_RIB (rn, rib)
if (prefix_match (&p, &rn->p))
{
+ if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
+ continue;
if (first)
{
vty_out (vty, SHOW_ROUTE_V4_HEADER);
@@ -1428,9 +1461,10 @@ DEFUN (show_ip_route_prefix_longer,
DEFUN (show_ip_route_supernets,
show_ip_route_supernets_cmd,
- "show ip route [vrf NAME] supernets-only",
+ "show ip <fib|route> [vrf NAME] supernets-only",
SHOW_STR
IP_STR
+ "IP forwarding table\n"
"IP routing table\n"
VRF_CMD_HELP_STR
"Show supernet entries only\n")
@@ -1441,6 +1475,7 @@ DEFUN (show_ip_route_supernets,
u_int32_t addr;
int first = 1;
vrf_id_t vrf_id = VRF_DEFAULT;
+ bool uf = use_fib(argv[2]);
if (strmatch(argv[3]->text, "vrf"))
VRF_GET_ID (vrf_id, argv[4]->arg);
@@ -1453,6 +1488,8 @@ DEFUN (show_ip_route_supernets,
for (rn = route_top (table); rn; rn = route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
{
+ if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
+ continue;
addr = ntohl (rn->p.u.prefix4.s_addr);
if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
@@ -1472,9 +1509,10 @@ DEFUN (show_ip_route_supernets,
DEFUN (show_ip_route_protocol,
show_ip_route_protocol_cmd,
- "show ip route [vrf NAME] " FRR_IP_REDIST_STR_ZEBRA,
+ "show ip <fib|route> [vrf NAME] " FRR_IP_REDIST_STR_ZEBRA,
SHOW_STR
IP_STR
+ "IP forwarding table\n"
"IP routing table\n"
VRF_CMD_HELP_STR
FRR_IP_REDIST_HELP_STR_ZEBRA)
@@ -1485,6 +1523,7 @@ DEFUN (show_ip_route_protocol,
struct rib *rib;
int first = 1;
vrf_id_t vrf_id = VRF_DEFAULT;
+ bool uf = use_fib(argv[2]);
int idx = 0;
if (argv_find (argv, argc, "NAME", &idx))
@@ -1508,6 +1547,8 @@ DEFUN (show_ip_route_protocol,
RNODE_FOREACH_RIB (rn, rib)
if (rib->type == type)
{
+ if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
+ continue;
if (first)
{
vty_out (vty, SHOW_ROUTE_V4_HEADER);
@@ -1521,9 +1562,10 @@ DEFUN (show_ip_route_protocol,
DEFUN (show_ip_route_ospf_instance,
show_ip_route_ospf_instance_cmd,
- "show ip route ospf (1-65535)",
+ "show ip <fib|route> ospf (1-65535)",
SHOW_STR
IP_STR
+ "IP forwarding table\n"
"IP routing table\n"
"Open Shortest Path First (OSPFv2)\n"
"Instance ID\n")
@@ -1534,6 +1576,7 @@ DEFUN (show_ip_route_ospf_instance,
struct rib *rib;
int first = 1;
u_short instance = 0;
+ bool uf = use_fib(argv[2]);
VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg);
@@ -1546,6 +1589,8 @@ DEFUN (show_ip_route_ospf_instance,
RNODE_FOREACH_RIB (rn, rib)
if (rib->type == ZEBRA_ROUTE_OSPF && rib->instance == instance)
{
+ if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
+ continue;
if (first)
{
vty_out (vty, SHOW_ROUTE_V4_HEADER);
@@ -1858,9 +1903,10 @@ DEFUN (show_ip_route_summary_prefix,
DEFUN (show_ip_route_vrf_all,
show_ip_route_vrf_all_cmd,
- "show ip route vrf all",
+ "show ip <fib|route> vrf all",
SHOW_STR
IP_STR
+ "IP forwarding table\n"
"IP routing table\n"
VRF_ALL_CMD_HELP_STR)
{
@@ -1871,6 +1917,7 @@ DEFUN (show_ip_route_vrf_all,
struct zebra_vrf *zvrf;
int first = 1;
int vrf_header = 1;
+ bool uf = use_fib(argv[2]);
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
{
@@ -1882,6 +1929,8 @@ DEFUN (show_ip_route_vrf_all,
for (rn = route_top (table); rn; rn = route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
{
+ if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
+ continue;
if (first)
{
vty_out (vty, SHOW_ROUTE_V4_HEADER);
@@ -1903,9 +1952,10 @@ DEFUN (show_ip_route_vrf_all,
DEFUN (show_ip_route_vrf_all_tag,
show_ip_route_vrf_all_tag_cmd,
- "show ip route vrf all tag (1-4294967295)",
+ "show ip <fib|route> vrf all tag (1-4294967295)",
SHOW_STR
IP_STR
+ "IP forwarding table\n"
"IP routing table\n"
VRF_ALL_CMD_HELP_STR
"Show only routes with tag\n"
@@ -1920,6 +1970,7 @@ DEFUN (show_ip_route_vrf_all_tag,
int first = 1;
int vrf_header = 1;
route_tag_t tag = 0;
+ bool uf = use_fib(argv[2]);
if (argv[idx_number]->arg)
VTY_GET_INTEGER_RANGE("tag", tag, argv[idx_number]->arg, 0, 4294967295);
@@ -1934,6 +1985,8 @@ DEFUN (show_ip_route_vrf_all_tag,
for (rn = route_top (table); rn; rn = route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
{
+ if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
+ continue;
if (rib->tag != tag)
continue;
@@ -1957,9 +2010,10 @@ DEFUN (show_ip_route_vrf_all_tag,
DEFUN (show_ip_route_vrf_all_prefix_longer,
show_ip_route_vrf_all_prefix_longer_cmd,
- "show ip route vrf all A.B.C.D/M longer-prefixes",
+ "show ip <fib|route> vrf all A.B.C.D/M longer-prefixes",
SHOW_STR
IP_STR
+ "IP forwarding table\n"
"IP routing table\n"
VRF_ALL_CMD_HELP_STR
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
@@ -1975,6 +2029,7 @@ DEFUN (show_ip_route_vrf_all_prefix_longer,
int ret;
int first = 1;
int vrf_header = 1;
+ bool uf = use_fib(argv[2]);
ret = str2prefix (argv[idx_ipv4_prefixlen]->arg, &p);
if (! ret)
@@ -1994,6 +2049,8 @@ DEFUN (show_ip_route_vrf_all_prefix_longer,
RNODE_FOREACH_RIB (rn, rib)
if (prefix_match (&p, &rn->p))
{
+ if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
+ continue;
if (first)
{
vty_out (vty, SHOW_ROUTE_V4_HEADER);
@@ -2015,9 +2072,10 @@ DEFUN (show_ip_route_vrf_all_prefix_longer,
DEFUN (show_ip_route_vrf_all_supernets,
show_ip_route_vrf_all_supernets_cmd,
- "show ip route vrf all supernets-only",
+ "show ip <fib|route> vrf all supernets-only",
SHOW_STR
IP_STR
+ "IP forwarding table\n"
"IP routing table\n"
VRF_ALL_CMD_HELP_STR
"Show supernet entries only\n")
@@ -2030,6 +2088,7 @@ DEFUN (show_ip_route_vrf_all_supernets,
u_int32_t addr;
int first = 1;
int vrf_header = 1;
+ bool uf = use_fib(argv[2]);
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
{
@@ -2041,6 +2100,9 @@ DEFUN (show_ip_route_vrf_all_supernets,
for (rn = route_top (table); rn; rn = route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
{
+ if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
+ continue;
+
addr = ntohl (rn->p.u.prefix4.s_addr);
if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
@@ -2068,9 +2130,10 @@ DEFUN (show_ip_route_vrf_all_supernets,
DEFUN (show_ip_route_vrf_all_protocol,
show_ip_route_vrf_all_protocol_cmd,
- "show ip route vrf all " FRR_IP_REDIST_STR_ZEBRA,
+ "show ip <fib|route> vrf all " FRR_IP_REDIST_STR_ZEBRA,
SHOW_STR
IP_STR
+ "IP forwarding table\n"
"IP routing table\n"
VRF_ALL_CMD_HELP_STR
FRR_IP_REDIST_HELP_STR_ZEBRA"\n")
@@ -2083,6 +2146,7 @@ DEFUN (show_ip_route_vrf_all_protocol,
struct zebra_vrf *zvrf;
int first = 1;
int vrf_header = 1;
+ bool uf = use_fib(argv[2]);
char *proto = argv[argc - 1]->text;
type = proto_redistnum (AFI_IP, proto);
@@ -2104,6 +2168,8 @@ DEFUN (show_ip_route_vrf_all_protocol,
RNODE_FOREACH_RIB (rn, rib)
if (rib->type == type)
{
+ if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
+ continue;
if (first)
{
vty_out (vty, SHOW_ROUTE_V4_HEADER);
@@ -2319,7 +2385,7 @@ static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd)
if (si->snh_label.num_labels)
vty_out (vty, " label %s",
mpls_label2str (si->snh_label.num_labels,
- si->snh_label.label, buf, sizeof buf));
+ si->snh_label.label, buf, sizeof buf, 0));
vty_out (vty, "%s", VTY_NEWLINE);
@@ -2915,9 +2981,10 @@ DEFUN (no_ipv6_route_ifname_flags,
DEFUN (show_ipv6_route,
show_ipv6_route_cmd,
- "show ipv6 route [vrf NAME] [json]",
+ "show ipv6 <fib|route> [vrf NAME] [json]",
SHOW_STR
IP_STR
+ "IPv6 forwarding table\n"
"IPv6 routing table\n"
VRF_CMD_HELP_STR
"Output JSON\n")
@@ -2931,6 +2998,7 @@ DEFUN (show_ipv6_route,
char buf[SRCDEST2STR_BUFFER];
json_object *json = NULL;
json_object *json_prefix = NULL;
+ bool uf = use_fib(argv[2]);
int vrf = (argc > 3 && strmatch (argv[3]->text, "vrf"));
int uj = vrf ? argc == 6 : argc == 4;
@@ -2976,6 +3044,8 @@ DEFUN (show_ipv6_route,
{
RNODE_FOREACH_RIB (rn, rib)
{
+ if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
+ continue;
if (!json_prefix)
json_prefix = json_object_new_array();
vty_show_ip_route (vty, rn, rib, json_prefix);
@@ -2999,6 +3069,8 @@ DEFUN (show_ipv6_route,
{
RNODE_FOREACH_RIB (rn, rib)
{
+ if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
+ continue;
if (first)
{
vty_out (vty, SHOW_ROUTE_V6_HEADER);
@@ -3014,9 +3086,10 @@ DEFUN (show_ipv6_route,
DEFUN (show_ipv6_route_tag,
show_ipv6_route_tag_cmd,
- "show ipv6 route [vrf NAME] tag (1-4294967295)",
+ "show ipv6 <fib|route> [vrf NAME] tag (1-4294967295)",
SHOW_STR
IP_STR
+ "IPv6 forwarding table\n"
"IPv6 routing table\n"
VRF_CMD_HELP_STR
"Show only routes with tag\n"
@@ -3031,6 +3104,7 @@ DEFUN (show_ipv6_route_tag,
int first = 1;
route_tag_t tag = 0;
vrf_id_t vrf_id = VRF_DEFAULT;
+ bool uf = use_fib(argv[2]);
if (strmatch(argv[idx_vrf]->text, "vrf"))
{
@@ -3051,6 +3125,8 @@ DEFUN (show_ipv6_route_tag,
for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
{
+ if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
+ continue;
if (rib->tag != tag)
continue;
@@ -3066,9 +3142,10 @@ DEFUN (show_ipv6_route_tag,
DEFUN (show_ipv6_route_prefix_longer,
show_ipv6_route_prefix_longer_cmd,
- "show ipv6 route [vrf NAME] X:X::X:X/M longer-prefixes",
+ "show ipv6 <fib|route> [vrf NAME] X:X::X:X/M longer-prefixes",
SHOW_STR
IP_STR
+ "IPv6 forwarding table\n"
"IPv6 routing table\n"
VRF_CMD_HELP_STR
"IPv6 prefix\n"
@@ -3081,6 +3158,7 @@ DEFUN (show_ipv6_route_prefix_longer,
int ret;
int first = 1;
vrf_id_t vrf_id = VRF_DEFAULT;
+ bool uf = use_fib(argv[2]);
if (strmatch(argv[3]->text, "vrf"))
{
@@ -3109,6 +3187,8 @@ DEFUN (show_ipv6_route_prefix_longer,
struct prefix *p, *src_p;
srcdest_rnode_prefixes(rn, &p, &src_p);
+ if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
+ continue;
if (prefix_match (p, &rn->p))
{
if (first)
@@ -3124,10 +3204,11 @@ DEFUN (show_ipv6_route_prefix_longer,
DEFUN (show_ipv6_route_protocol,
show_ipv6_route_protocol_cmd,
- "show ipv6 route [vrf NAME] " FRR_IP6_REDIST_STR_ZEBRA,
+ "show ipv6 <fib|route> [vrf NAME] " FRR_IP6_REDIST_STR_ZEBRA,
SHOW_STR
IP_STR
- "IP routing table\n"
+ "IPv6 forwarding table\n"
+ "IPv6 routing table\n"
VRF_CMD_HELP_STR
FRR_IP6_REDIST_HELP_STR_ZEBRA)
{
@@ -3137,6 +3218,7 @@ DEFUN (show_ipv6_route_protocol,
struct rib *rib;
int first = 1;
vrf_id_t vrf_id = VRF_DEFAULT;
+ bool uf = use_fib(argv[2]);
int idx = 0;
if (argv_find (argv, argc, "NAME", &idx))
@@ -3160,6 +3242,8 @@ DEFUN (show_ipv6_route_protocol,
RNODE_FOREACH_RIB (rn, rib)
if (rib->type == type)
{
+ if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
+ continue;
if (first)
{
vty_out (vty, SHOW_ROUTE_V6_HEADER);
@@ -3362,9 +3446,10 @@ DEFUN (show_ipv6_mroute,
DEFUN (show_ipv6_route_vrf_all,
show_ipv6_route_vrf_all_cmd,
- "show ipv6 route vrf all",
+ "show ipv6 <fib|route> vrf all",
SHOW_STR
IP_STR
+ "IPv6 forwarding table\n"
"IPv6 routing table\n"
VRF_ALL_CMD_HELP_STR)
{
@@ -3375,6 +3460,7 @@ DEFUN (show_ipv6_route_vrf_all,
struct zebra_vrf *zvrf;
int first = 1;
int vrf_header = 1;
+ bool uf = use_fib(argv[2]);
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
{
@@ -3386,6 +3472,8 @@ DEFUN (show_ipv6_route_vrf_all,
for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
{
+ if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
+ continue;
if (first)
{
vty_out (vty, SHOW_ROUTE_V6_HEADER);
@@ -3407,9 +3495,10 @@ DEFUN (show_ipv6_route_vrf_all,
DEFUN (show_ipv6_route_vrf_all_tag,
show_ipv6_route_vrf_all_tag_cmd,
- "show ipv6 route vrf all tag (1-4294967295)",
+ "show ipv6 <fib|route> vrf all tag (1-4294967295)",
SHOW_STR
IP_STR
+ "IPv6 forwarding table\n"
"IPv6 routing table\n"
VRF_ALL_CMD_HELP_STR
"Show only routes with tag\n"
@@ -3424,6 +3513,7 @@ DEFUN (show_ipv6_route_vrf_all_tag,
int first = 1;
int vrf_header = 1;
route_tag_t tag = 0;
+ bool uf = use_fib(argv[2]);
if (argv[idx_number]->arg)
VTY_GET_INTEGER_RANGE("tag", tag, argv[idx_number]->arg, 0, 4294967295);
@@ -3438,6 +3528,8 @@ DEFUN (show_ipv6_route_vrf_all_tag,
for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
{
+ if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
+ continue;
if (rib->tag != tag)
continue;
@@ -3462,9 +3554,10 @@ DEFUN (show_ipv6_route_vrf_all_tag,
DEFUN (show_ipv6_route_vrf_all_prefix_longer,
show_ipv6_route_vrf_all_prefix_longer_cmd,
- "show ipv6 route vrf all X:X::X:X/M longer-prefixes",
+ "show ipv6 <fib|route> vrf all X:X::X:X/M longer-prefixes",
SHOW_STR
IP_STR
+ "IPv6 forwarding table\n"
"IPv6 routing table\n"
VRF_ALL_CMD_HELP_STR
"IPv6 prefix\n"
@@ -3480,6 +3573,7 @@ DEFUN (show_ipv6_route_vrf_all_prefix_longer,
int ret;
int first = 1;
int vrf_header = 1;
+ bool uf = use_fib(argv[2]);
ret = str2prefix (argv[idx_ipv6_prefixlen]->arg, &p);
if (! ret)
@@ -3500,6 +3594,8 @@ DEFUN (show_ipv6_route_vrf_all_prefix_longer,
{
struct prefix *p, *src_p;
srcdest_rnode_prefixes(rn, &p, &src_p);
+ if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
+ continue;
if (prefix_match (p, &rn->p))
{
if (first)
@@ -3524,10 +3620,11 @@ DEFUN (show_ipv6_route_vrf_all_prefix_longer,
DEFUN (show_ipv6_route_vrf_all_protocol,
show_ipv6_route_vrf_all_protocol_cmd,
- "show ipv6 route vrf all " FRR_IP6_REDIST_STR_ZEBRA,
+ "show ipv6 <fib|route> vrf all " FRR_IP6_REDIST_STR_ZEBRA,
SHOW_STR
IP_STR
- "IP routing table\n"
+ "IPv6 forwarding table\n"
+ "IPv6 routing table\n"
VRF_ALL_CMD_HELP_STR
FRR_IP6_REDIST_HELP_STR_ZEBRA)
{
@@ -3539,6 +3636,7 @@ DEFUN (show_ipv6_route_vrf_all_protocol,
struct zebra_vrf *zvrf;
int first = 1;
int vrf_header = 1;
+ bool uf = use_fib(argv[2]);
char *proto = argv[argc - 1]->text;
type = proto_redistnum (AFI_IP6, proto);
@@ -3560,6 +3658,8 @@ DEFUN (show_ipv6_route_vrf_all_protocol,
RNODE_FOREACH_RIB (rn, rib)
if (rib->type == type)
{
+ if (uf && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
+ continue;
if (first)
{
vty_out (vty, SHOW_ROUTE_V6_HEADER);
@@ -3812,7 +3912,7 @@ static_config_ipv6 (struct vty *vty)
if (si->snh_label.num_labels)
vty_out (vty, " label %s",
mpls_label2str (si->snh_label.num_labels,
- si->snh_label.label, buf, sizeof buf));
+ si->snh_label.label, buf, sizeof buf, 0));
vty_out (vty, "%s", VTY_NEWLINE);
diff --git a/zebra/zserv.c b/zebra/zserv.c
index 416e5444ea..aa08ddc04b 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -95,8 +95,9 @@ zserv_flush_data(struct thread *thread)
client = NULL;
break;
case BUFFER_PENDING:
- client->t_write = thread_add_write(zebrad.master, zserv_flush_data,
- client, client->sock);
+ client->t_write = NULL;
+ thread_add_write(zebrad.master, zserv_flush_data, client, client->sock,
+ &client->t_write);
break;
case BUFFER_EMPTY:
break;
@@ -128,15 +129,16 @@ zebra_server_send_message(struct zserv *client)
one do not check the return code. They do not allow for the
possibility that an I/O error may have caused the client to be
deleted. */
- client->t_suicide = thread_add_event(zebrad.master, zserv_delayed_close,
- client, 0);
+ client->t_suicide = NULL;
+ thread_add_event(zebrad.master, zserv_delayed_close, client, 0,
+ &client->t_suicide);
return -1;
case BUFFER_EMPTY:
THREAD_OFF(client->t_write);
break;
case BUFFER_PENDING:
- THREAD_WRITE_ON(zebrad.master, client->t_write,
- zserv_flush_data, client, client->sock);
+ thread_add_write(zebrad.master, zserv_flush_data, client, client->sock,
+ &client->t_write);
break;
}
@@ -934,7 +936,7 @@ zserv_rnh_unregister (struct zserv *client, int sock, u_short length,
return 0;
}
-#define ZEBRA_MIN_FEC_LENGTH 9
+#define ZEBRA_MIN_FEC_LENGTH 5
/* FEC register */
static int
@@ -2588,11 +2590,12 @@ zebra_event (enum event event, int sock, struct zserv *client)
switch (event)
{
case ZEBRA_SERV:
- thread_add_read (zebrad.master, zebra_accept, client, sock);
+ thread_add_read(zebrad.master, zebra_accept, client, sock, NULL);
break;
case ZEBRA_READ:
- client->t_read =
- thread_add_read (zebrad.master, zebra_client_read, client, sock);
+ client->t_read = NULL;
+ thread_add_read(zebrad.master, zebra_client_read, client, sock,
+ &client->t_read);
break;
case ZEBRA_WRITE:
/**/