Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
labs
BIRD Internet Routing Daemon
Commits
a6f79ca5
Commit
a6f79ca5
authored
Nov 28, 2017
by
Ondřej Zajíček
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Timers: Revert temporary names and remove old timer.h
parent
574b2324
Changes
30
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
195 additions
and
261 deletions
+195
-261
conf/conf.c
conf/conf.c
+6
-6
conf/conf.h
conf/conf.h
+1
-1
conf/flowspec.Y
conf/flowspec.Y
+0
-10
lib/timer.c
lib/timer.c
+23
-23
lib/timer.h
lib/timer.h
+21
-21
nest/proto.c
nest/proto.c
+6
-6
nest/protocol.h
nest/protocol.h
+0
-1
nest/route.h
nest/route.h
+0
-1
proto/babel/babel.c
proto/babel/babel.c
+8
-8
proto/babel/babel.h
proto/babel/babel.h
+1
-1
proto/bfd/bfd.c
proto/bfd/bfd.c
+18
-19
proto/bfd/bfd.h
proto/bfd/bfd.h
+2
-2
proto/bfd/io.c
proto/bfd/io.c
+2
-2
proto/bgp/bgp.c
proto/bgp/bgp.c
+18
-18
proto/ospf/dbdes.c
proto/ospf/dbdes.c
+5
-5
proto/ospf/iface.c
proto/ospf/iface.c
+14
-14
proto/ospf/lsupd.c
proto/ospf/lsupd.c
+7
-7
proto/ospf/neighbor.c
proto/ospf/neighbor.c
+13
-13
proto/ospf/ospf.c
proto/ospf/ospf.c
+3
-3
proto/ospf/ospf.h
proto/ospf/ospf.h
+1
-1
proto/ospf/rt.c
proto/ospf/rt.c
+3
-3
proto/radv/radv.c
proto/radv/radv.c
+3
-3
proto/radv/radv.h
proto/radv/radv.h
+1
-1
proto/rip/rip.c
proto/rip/rip.c
+10
-10
proto/rip/rip.h
proto/rip/rip.h
+1
-1
proto/rpki/rpki.c
proto/rpki/rpki.c
+11
-11
sysdep/linux/netlink.c
sysdep/linux/netlink.c
+0
-1
sysdep/unix/io.c
sysdep/unix/io.c
+2
-3
sysdep/unix/krt.c
sysdep/unix/krt.c
+15
-15
sysdep/unix/timer.h
sysdep/unix/timer.h
+0
-51
No files found.
conf/conf.c
View file @
a6f79ca5
...
...
@@ -52,7 +52,7 @@
#include "lib/resource.h"
#include "lib/string.h"
#include "lib/event.h"
#include "
sysdep/unix
/timer.h"
#include "
lib
/timer.h"
#include "conf/conf.h"
#include "filter/filter.h"
...
...
@@ -341,9 +341,9 @@ config_commit(struct config *c, int type, uint timeout)
undo_available
=
1
;
if
(
timeout
)
tm
2
_start
(
config_timer
,
timeout
S
);
tm_start
(
config_timer
,
timeout
S
);
else
tm
2
_stop
(
config_timer
);
tm_stop
(
config_timer
);
if
(
configuring
)
{
...
...
@@ -384,7 +384,7 @@ config_confirm(void)
if
(
config_timer
->
expires
==
0
)
return
CONF_NOTHING
;
tm
2
_stop
(
config_timer
);
tm_stop
(
config_timer
);
return
CONF_CONFIRM
;
}
...
...
@@ -420,7 +420,7 @@ config_undo(void)
return
CONF_NOTHING
;
undo_available
=
0
;
tm
2
_stop
(
config_timer
);
tm_stop
(
config_timer
);
if
(
configuring
)
{
...
...
@@ -468,7 +468,7 @@ config_init(void)
config_event
=
ev_new
(
&
root_pool
);
config_event
->
hook
=
config_done
;
config_timer
=
tm
2
_new
(
&
root_pool
);
config_timer
=
tm_new
(
&
root_pool
);
config_timer
->
hook
=
config_timeout
;
}
...
...
conf/conf.h
View file @
a6f79ca5
...
...
@@ -13,7 +13,7 @@
#include "lib/ip.h"
#include "lib/hash.h"
#include "lib/resource.h"
#include "
sysdep/unix
/timer.h"
#include "
lib
/timer.h"
/* Configuration structure */
...
...
conf/flowspec.Y
View file @
a6f79ca5
...
...
@@ -11,16 +11,6 @@ CF_HDR
#define PARSER 1
#include "nest/bird.h"
#include "conf/conf.h"
#include "lib/resource.h"
#include "lib/socket.h"
#include "sysdep/unix/timer.h"
#include "lib/string.h"
#include "nest/protocol.h"
#include "nest/iface.h"
#include "nest/route.h"
#include "nest/cli.h"
#include "filter/filter.h"
#include "lib/flowspec.h"
...
...
lib/timer.c
View file @
a6f79ca5
...
...
@@ -93,17 +93,17 @@ current_real_time(void)
static
void
tm
2
_free
(
resource
*
r
)
tm_free
(
resource
*
r
)
{
timer
2
*
t
=
(
timer2
*
)
r
;
timer
*
t
=
(
void
*
)
r
;
tm
2
_stop
(
t
);
tm_stop
(
t
);
}
static
void
tm
2
_dump
(
resource
*
r
)
tm_dump
(
resource
*
r
)
{
timer
2
*
t
=
(
timer2
*
)
r
;
timer
*
t
=
(
void
*
)
r
;
debug
(
"(code %p, data %p, "
,
t
->
hook
,
t
->
data
);
if
(
t
->
randomize
)
...
...
@@ -117,25 +117,25 @@ tm2_dump(resource *r)
}
static
struct
resclass
tm
2
_class
=
{
static
struct
resclass
tm_class
=
{
"Timer"
,
sizeof
(
timer
2
),
tm
2
_free
,
tm
2
_dump
,
sizeof
(
timer
),
tm_free
,
tm_dump
,
NULL
,
NULL
};
timer
2
*
tm
2
_new
(
pool
*
p
)
timer
*
tm_new
(
pool
*
p
)
{
timer
2
*
t
=
ralloc
(
p
,
&
tm
2
_class
);
timer
*
t
=
ralloc
(
p
,
&
tm_class
);
t
->
index
=
-
1
;
return
t
;
}
void
tm
2
_set
(
timer
2
*
t
,
btime
when
)
tm_set
(
timer
*
t
,
btime
when
)
{
struct
timeloop
*
loop
=
timeloop_current
();
uint
tc
=
timers_count
(
loop
);
...
...
@@ -145,17 +145,17 @@ tm2_set(timer2 *t, btime when)
t
->
index
=
++
tc
;
t
->
expires
=
when
;
BUFFER_PUSH
(
loop
->
timers
)
=
t
;
HEAP_INSERT
(
loop
->
timers
.
data
,
tc
,
timer
2
*
,
TIMER_LESS
,
TIMER_SWAP
);
HEAP_INSERT
(
loop
->
timers
.
data
,
tc
,
timer
*
,
TIMER_LESS
,
TIMER_SWAP
);
}
else
if
(
t
->
expires
<
when
)
{
t
->
expires
=
when
;
HEAP_INCREASE
(
loop
->
timers
.
data
,
tc
,
timer
2
*
,
TIMER_LESS
,
TIMER_SWAP
,
t
->
index
);
HEAP_INCREASE
(
loop
->
timers
.
data
,
tc
,
timer
*
,
TIMER_LESS
,
TIMER_SWAP
,
t
->
index
);
}
else
if
(
t
->
expires
>
when
)
{
t
->
expires
=
when
;
HEAP_DECREASE
(
loop
->
timers
.
data
,
tc
,
timer
2
*
,
TIMER_LESS
,
TIMER_SWAP
,
t
->
index
);
HEAP_DECREASE
(
loop
->
timers
.
data
,
tc
,
timer
*
,
TIMER_LESS
,
TIMER_SWAP
,
t
->
index
);
}
#ifdef CONFIG_BFD
...
...
@@ -166,13 +166,13 @@ tm2_set(timer2 *t, btime when)
}
void
tm
2
_start
(
timer
2
*
t
,
btime
after
)
tm_start
(
timer
*
t
,
btime
after
)
{
tm
2
_set
(
t
,
current_time
()
+
MAX
(
after
,
0
));
tm_set
(
t
,
current_time
()
+
MAX
(
after
,
0
));
}
void
tm
2
_stop
(
timer
2
*
t
)
tm_stop
(
timer
*
t
)
{
if
(
!
t
->
expires
)
return
;
...
...
@@ -180,7 +180,7 @@ tm2_stop(timer2 *t)
struct
timeloop
*
loop
=
timeloop_current
();
uint
tc
=
timers_count
(
loop
);
HEAP_DELETE
(
loop
->
timers
.
data
,
tc
,
timer
2
*
,
TIMER_LESS
,
TIMER_SWAP
,
t
->
index
);
HEAP_DELETE
(
loop
->
timers
.
data
,
tc
,
timer
*
,
TIMER_LESS
,
TIMER_SWAP
,
t
->
index
);
BUFFER_POP
(
loop
->
timers
);
t
->
index
=
-
1
;
...
...
@@ -202,7 +202,7 @@ void
timers_fire
(
struct
timeloop
*
loop
)
{
btime
base_time
;
timer
2
*
t
;
timer
*
t
;
times_update
(
loop
);
base_time
=
loop
->
last_time
;
...
...
@@ -222,10 +222,10 @@ timers_fire(struct timeloop *loop)
if
(
t
->
randomize
)
when
+=
random
()
%
(
t
->
randomize
+
1
);
tm
2
_set
(
t
,
when
);
tm_set
(
t
,
when
);
}
else
tm
2
_stop
(
t
);
tm_stop
(
t
);
/* This is ugly hack, we want to log just timers executed from the main I/O loop */
if
(
loop
==
&
main_timeloop
)
...
...
lib/timer.h
View file @
a6f79ca5
...
...
@@ -7,18 +7,18 @@
* Can be freely distributed and used under the terms of the GNU GPL.
*/
#ifndef _BIRD_TIMER
2
_H_
#define _BIRD_TIMER
2
_H_
#ifndef _BIRD_TIMER_H_
#define _BIRD_TIMER_H_
#include "nest/bird.h"
#include "lib/buffer.h"
#include "lib/resource.h"
typedef
struct
timer
2
typedef
struct
timer
{
resource
r
;
void
(
*
hook
)(
struct
timer
2
*
);
void
(
*
hook
)(
struct
timer
*
);
void
*
data
;
btime
expires
;
/* 0=inactive */
...
...
@@ -26,11 +26,11 @@ typedef struct timer2
uint
recurrent
;
/* Timer recurrence */
int
index
;
}
timer
2
;
}
timer
;
struct
timeloop
{
BUFFER
(
timer
2
*
)
timers
;
BUFFER
(
timer
*
)
timers
;
btime
last_time
;
btime
real_time
;
};
...
...
@@ -38,7 +38,7 @@ struct timeloop
static
inline
uint
timers_count
(
struct
timeloop
*
loop
)
{
return
loop
->
timers
.
used
-
1
;
}
static
inline
timer
2
*
timers_first
(
struct
timeloop
*
loop
)
static
inline
timer
*
timers_first
(
struct
timeloop
*
loop
)
{
return
(
loop
->
timers
.
used
>
1
)
?
loop
->
timers
.
data
[
1
]
:
NULL
;
}
extern
struct
timeloop
main_timeloop
;
...
...
@@ -50,28 +50,28 @@ btime current_real_time(void);
//#define now_real (current_real_time() TO_S)
extern
btime
boot_time
;
timer
2
*
tm
2
_new
(
pool
*
p
);
void
tm
2
_set
(
timer
2
*
t
,
btime
when
);
void
tm
2
_start
(
timer
2
*
t
,
btime
after
);
void
tm
2
_stop
(
timer
2
*
t
);
timer
*
tm_new
(
pool
*
p
);
void
tm_set
(
timer
*
t
,
btime
when
);
void
tm_start
(
timer
*
t
,
btime
after
);
void
tm_stop
(
timer
*
t
);
static
inline
int
tm
2
_active
(
timer
2
*
t
)
tm_active
(
timer
*
t
)
{
return
t
->
expires
!=
0
;
}
static
inline
btime
tm
2
_remains
(
timer
2
*
t
)
tm_remains
(
timer
*
t
)
{
btime
now_
=
current_time
();
return
(
t
->
expires
>
now_
)
?
(
t
->
expires
-
now_
)
:
0
;
}
static
inline
timer
2
*
tm
2
_new_init
(
pool
*
p
,
void
(
*
hook
)(
struct
timer
2
*
),
void
*
data
,
uint
rec
,
uint
rand
)
static
inline
timer
*
tm_new_init
(
pool
*
p
,
void
(
*
hook
)(
struct
timer
*
),
void
*
data
,
uint
rec
,
uint
rand
)
{
timer
2
*
t
=
tm
2
_new
(
p
);
timer
*
t
=
tm_new
(
p
);
t
->
hook
=
hook
;
t
->
data
=
data
;
t
->
recurrent
=
rec
;
...
...
@@ -80,17 +80,17 @@ tm2_new_init(pool *p, void (*hook)(struct timer2 *), void *data, uint rec, uint
}
static
inline
void
tm
2
_set_max
(
timer
2
*
t
,
btime
when
)
tm_set_max
(
timer
*
t
,
btime
when
)
{
if
(
when
>
t
->
expires
)
tm
2
_set
(
t
,
when
);
tm_set
(
t
,
when
);
}
static
inline
void
tm
2
_start_max
(
timer
2
*
t
,
btime
after
)
tm_start_max
(
timer
*
t
,
btime
after
)
{
btime
rem
=
tm
2
_remains
(
t
);
tm
2
_start
(
t
,
MAX_
(
rem
,
after
));
btime
rem
=
tm_remains
(
t
);
tm_start
(
t
,
MAX_
(
rem
,
after
));
}
/* In sysdep code */
...
...
nest/proto.c
View file @
a6f79ca5
...
...
@@ -1083,8 +1083,8 @@ graceful_restart_init(void)
}
graceful_restart_state
=
GRS_ACTIVE
;
gr_wait_timer
=
tm
2
_new_init
(
proto_pool
,
graceful_restart_done
,
NULL
,
0
,
0
);
tm
2
_start
(
gr_wait_timer
,
config
->
gr_wait
S
);
gr_wait_timer
=
tm_new_init
(
proto_pool
,
graceful_restart_done
,
NULL
,
0
,
0
);
tm_start
(
gr_wait_timer
,
config
->
gr_wait
S
);
}
/**
...
...
@@ -1135,7 +1135,7 @@ graceful_restart_show_status(void)
cli_msg
(
-
24
,
"Graceful restart recovery in progress"
);
cli_msg
(
-
24
,
" Waiting for %d channels to recover"
,
graceful_restart_locks
);
cli_msg
(
-
24
,
" Wait timer is %t/%u"
,
tm
2
_remains
(
gr_wait_timer
),
config
->
gr_wait
);
cli_msg
(
-
24
,
" Wait timer is %t/%u"
,
tm_remains
(
gr_wait_timer
),
config
->
gr_wait
);
}
/**
...
...
@@ -1181,7 +1181,7 @@ channel_graceful_restart_unlock(struct channel *c)
graceful_restart_locks
--
;
if
((
graceful_restart_state
==
GRS_ACTIVE
)
&&
!
graceful_restart_locks
)
tm
2
_start
(
gr_wait_timer
,
0
);
tm_start
(
gr_wait_timer
,
0
);
}
...
...
@@ -1288,7 +1288,7 @@ protos_build(void)
#endif
proto_pool
=
rp_new
(
&
root_pool
,
"Protocols"
);
proto_shutdown_timer
=
tm
2
_new
(
proto_pool
);
proto_shutdown_timer
=
tm_new
(
proto_pool
);
proto_shutdown_timer
->
hook
=
proto_shutdown_loop
;
}
...
...
@@ -1328,7 +1328,7 @@ proto_schedule_down(struct proto *p, byte restart, byte code)
p
->
down_sched
=
restart
?
PDS_RESTART
:
PDS_DISABLE
;
p
->
down_code
=
code
;
tm
2
_start_max
(
proto_shutdown_timer
,
restart
?
250
MS
:
0
);
tm_start_max
(
proto_shutdown_timer
,
restart
?
250
MS
:
0
);
}
...
...
nest/protocol.h
View file @
a6f79ca5
...
...
@@ -12,7 +12,6 @@
#include "lib/lists.h"
#include "lib/resource.h"
#include "lib/event.h"
#include "sysdep/unix/timer.h"
#include "nest/route.h"
#include "conf/conf.h"
...
...
nest/route.h
View file @
a6f79ca5
...
...
@@ -11,7 +11,6 @@
#include "lib/lists.h"
#include "lib/resource.h"
#include "sysdep/unix/timer.h"
#include "lib/net.h"
struct
ea_list
;
...
...
proto/babel/babel.c
View file @
a6f79ca5
...
...
@@ -1433,14 +1433,14 @@ babel_iface_timer(timer *t)
btime
next_event
=
MIN
(
ifa
->
next_hello
,
ifa
->
next_regular
);
if
(
ifa
->
want_triggered
)
next_event
=
MIN
(
next_event
,
ifa
->
next_triggered
);
tm
2
_set
(
ifa
->
timer
,
next_event
);
tm_set
(
ifa
->
timer
,
next_event
);
}
static
inline
void
babel_iface_kick_timer
(
struct
babel_iface
*
ifa
)
{
if
(
ifa
->
timer
->
expires
>
(
current_time
()
+
100
MS
))
tm
2
_start
(
ifa
->
timer
,
100
MS
);
tm_start
(
ifa
->
timer
,
100
MS
);
}
static
void
...
...
@@ -1454,7 +1454,7 @@ babel_iface_start(struct babel_iface *ifa)
ifa
->
next_regular
=
current_time
()
+
(
random
()
%
ifa
->
cf
->
update_interval
);
ifa
->
next_triggered
=
current_time
()
+
MIN
(
1
S
,
ifa
->
cf
->
update_interval
/
2
);
ifa
->
want_triggered
=
0
;
/* We send an immediate update (below) */
tm
2
_start
(
ifa
->
timer
,
100
MS
);
tm_start
(
ifa
->
timer
,
100
MS
);
ifa
->
up
=
1
;
babel_send_hello
(
ifa
);
...
...
@@ -1487,7 +1487,7 @@ babel_iface_stop(struct babel_iface *ifa)
}
}
tm
2
_stop
(
ifa
->
timer
);
tm_stop
(
ifa
->
timer
);
ifa
->
up
=
0
;
}
...
...
@@ -1585,7 +1585,7 @@ babel_add_iface(struct babel_proto *p, struct iface *new, struct babel_iface_con
init_list
(
&
ifa
->
neigh_list
);
ifa
->
hello_seqno
=
1
;
ifa
->
timer
=
tm
2
_new_init
(
ifa
->
pool
,
babel_iface_timer
,
ifa
,
0
,
0
);
ifa
->
timer
=
tm_new_init
(
ifa
->
pool
,
babel_iface_timer
,
ifa
,
0
,
0
);
init_list
(
&
ifa
->
msg_queue
);
ifa
->
send_event
=
ev_new
(
ifa
->
pool
);
...
...
@@ -2050,7 +2050,7 @@ static inline void
babel_kick_timer
(
struct
babel_proto
*
p
)
{
if
(
p
->
timer
->
expires
>
(
current_time
()
+
100
MS
))
tm
2
_start
(
p
->
timer
,
100
MS
);
tm_start
(
p
->
timer
,
100
MS
);
}
...
...
@@ -2214,8 +2214,8 @@ babel_start(struct proto *P)
OFFSETOF
(
struct
babel_entry
,
n
),
0
,
babel_init_entry
);
init_list
(
&
p
->
interfaces
);
p
->
timer
=
tm
2
_new_init
(
P
->
pool
,
babel_timer
,
p
,
1
S
,
0
);
tm
2
_start
(
p
->
timer
,
1
S
);
p
->
timer
=
tm_new_init
(
P
->
pool
,
babel_timer
,
p
,
1
S
,
0
);
tm_start
(
p
->
timer
,
1
S
);
p
->
update_seqno
=
1
;
p
->
router_id
=
proto_get_router_id
(
&
cf
->
c
);
...
...
proto/babel/babel.h
View file @
a6f79ca5
...
...
@@ -23,7 +23,7 @@
#include "lib/lists.h"
#include "lib/socket.h"
#include "lib/string.h"
#include "
sysdep/unix
/timer.h"
#include "
lib
/timer.h"
#define EA_BABEL_METRIC EA_CODE(EAP_BABEL, 0)
#define EA_BABEL_ROUTER_ID EA_CODE(EAP_BABEL, 1)
...
...
proto/bfd/bfd.c
View file @
a6f79ca5
...
...
@@ -64,16 +64,15 @@
* ready, the protocol just creates a BFD request like any other protocol.
*
* The protocol uses a new generic event loop (structure &birdloop) from |io.c|,
* which supports sockets, timers and events like the main loop. Timers
* (structure &timer2) are new microsecond based timers, while sockets and
* events are the same. A birdloop is associated with a thread (field @thread)
* in which event hooks are executed. Most functions for setting event sources
* (like sk_start() or tm2_start()) must be called from the context of that
* thread. Birdloop allows to temporarily acquire the context of that thread for
* the main thread by calling birdloop_enter() and then birdloop_leave(), which
* also ensures mutual exclusion with all event hooks. Note that resources
* associated with a birdloop (like timers) should be attached to the
* independent resource pool, detached from the main resource tree.
* which supports sockets, timers and events like the main loop. A birdloop is
* associated with a thread (field @thread) in which event hooks are executed.
* Most functions for setting event sources (like sk_start() or tm_start()) must
* be called from the context of that thread. Birdloop allows to temporarily
* acquire the context of that thread for the main thread by calling
* birdloop_enter() and then birdloop_leave(), which also ensures mutual
* exclusion with all event hooks. Note that resources associated with a
* birdloop (like timers) should be attached to the independent resource pool,
* detached from the main resource tree.
*
* There are two kinds of interaction between the BFD core (running in the BFD
* thread) and the rest of BFD (running in the main thread). The first kind are
...
...
@@ -177,7 +176,7 @@ bfd_session_update_tx_interval(struct bfd_session *s)
return
;
/* Set timer relative to last tx_timer event */
tm
2
_set
(
s
->
tx_timer
,
s
->
last_tx
+
tx_int_l
);
tm_set
(
s
->
tx_timer
,
s
->
last_tx
+
tx_int_l
);
}
static
void
...
...
@@ -191,7 +190,7 @@ bfd_session_update_detection_time(struct bfd_session *s, int kick)
if
(
!
s
->
last_rx
)
return
;
tm
2
_set
(
s
->
hold_timer
,
s
->
last_rx
+
timeout
);
tm_set
(
s
->
hold_timer
,
s
->
last_rx
+
timeout
);
}
static
void
...
...
@@ -212,16 +211,16 @@ bfd_session_control_tx_timer(struct bfd_session *s, int reset)
goto
stop
;
/* So TX timer should run */
if
(
reset
||
!
tm
2
_active
(
s
->
tx_timer
))
if
(
reset
||
!
tm_active
(
s
->
tx_timer
))
{
s
->
last_tx
=
0
;
tm
2
_start
(
s
->
tx_timer
,
0
);
tm_start
(
s
->
tx_timer
,
0
);
}
return
;
stop:
tm
2
_stop
(
s
->
tx_timer
);
tm_stop
(
s
->
tx_timer
);
s
->
last_tx
=
0
;
}
...
...
@@ -380,7 +379,7 @@ bfd_find_session_by_addr(struct bfd_proto *p, ip_addr addr)
}
static
void
bfd_tx_timer_hook
(
timer
2
*
t
)
bfd_tx_timer_hook
(
timer
*
t
)
{
struct
bfd_session
*
s
=
t
->
data
;
...
...
@@ -389,7 +388,7 @@ bfd_tx_timer_hook(timer2 *t)
}
static
void
bfd_hold_timer_hook
(
timer
2
*
t
)
bfd_hold_timer_hook
(
timer
*
t
)
{
bfd_session_timeout
(
t
->
data
);
}
...
...
@@ -433,8 +432,8 @@ bfd_add_session(struct bfd_proto *p, ip_addr addr, ip_addr local, struct iface *
s
->
passive
=
ifa
->
cf
->
passive
;
s
->
tx_csn
=
random_u32
();
s
->
tx_timer
=
tm
2
_new_init
(
p
->
tpool
,
bfd_tx_timer_hook
,
s
,
0
,
0
);
s
->
hold_timer
=
tm
2
_new_init
(
p
->
tpool
,
bfd_hold_timer_hook
,
s
,
0
,
0
);
s
->
tx_timer
=
tm_new_init
(
p
->
tpool
,
bfd_tx_timer_hook
,
s
,
0
,
0
);
s
->
hold_timer
=
tm_new_init
(
p
->
tpool
,
bfd_hold_timer_hook
,
s
,
0
,
0
);
bfd_session_update_tx_interval
(
s
);
bfd_session_control_tx_timer
(
s
,
1
);
...
...
proto/bfd/bfd.h
View file @
a6f79ca5
...
...
@@ -140,8 +140,8 @@ struct bfd_session
btime
last_tx
;
/* Time of last sent periodic control packet */
btime
last_rx
;
/* Time of last received valid control packet */
timer
2
*
tx_timer
;
/* Periodic control packet timer */
timer
2
*
hold_timer
;
/* Timer for session down detection time */
timer
*
tx_timer
;
/* Periodic control packet timer */
timer
*
hold_timer
;
/* Timer for session down detection time */
list
request_list
;
/* List of client requests (struct bfd_request) */
btime
last_state_change
;
/* Time of last state change */
...
...
proto/bfd/io.c
View file @
a6f79ca5
...
...
@@ -477,7 +477,7 @@ static void *
birdloop_main
(
void
*
arg
)
{
struct
birdloop
*
loop
=
arg
;
timer
2
*
t
;
timer
*
t
;
int
rv
,
timeout
;
birdloop_set_current
(
loop
);
...
...
@@ -492,7 +492,7 @@ birdloop_main(void *arg)
if
(
events_waiting
(
loop
))
timeout
=
0
;
else
if
(
t
=
timers_first
(
&
loop
->
time
))
timeout
=
(
tm
2
_remains
(
t
)
TO_MS
)
+
1
;
timeout
=
(
tm_remains
(
t
)
TO_MS
)
+
1
;
else
timeout
=
-
1
;
...
...
proto/bgp/bgp.c
View file @
a6f79ca5
...
...
@@ -328,10 +328,10 @@ bgp_start_timer(timer *t, uint value)
/* The randomization procedure is specified in RFC 4271 section 10 */
btime
time
=
value
S
;
btime
randomize
=
random
()
%
((
time
/
4
)
+
1
);
tm
2
_start
(
t
,
time
-
randomize
);
tm_start
(
t
,
time
-
randomize
);
}
else
tm
2
_stop
(
t
);
tm_stop
(
t
);
}
/**
...
...
@@ -517,7 +517,7 @@ bgp_conn_enter_established_state(struct bgp_conn *conn)
int
peer_gr_ready
=
peer
->
gr_aware
&&
!
(
peer
->
gr_flags
&
BGP_GRF_RESTART
);
if
(
p
->
gr_active_num
)
tm
2
_stop
(
p
->
gr_timer
);
tm_stop
(
p
->
gr_timer
);
/* Number of active channels */
int
num
=
0
;
...
...
@@ -616,7 +616,7 @@ bgp_conn_enter_close_state(struct bgp_conn *conn)
int
os
=
conn
->
state
;
bgp_conn_set_state
(
conn
,
BS_CLOSE
);
tm
2
_stop
(
conn
->
keepalive_timer
);
tm_stop
(
conn
->
keepalive_timer
);
conn
->
sk
->
rx_hook
=
NULL
;
/* Timeout for CLOSE state, if we cannot send notification soon then we just hangup */
...
...
@@ -779,7 +779,7 @@ bgp_send_open(struct bgp_conn *conn)
DBG
(
"BGP: Sending open
\n
"
);
conn
->
sk
->
rx_hook
=
bgp_rx
;
conn
->
sk
->
tx_hook
=
bgp_tx
;
tm
2
_stop
(
conn
->
connect_timer
);
tm_stop
(
conn
->
connect_timer
);
bgp_schedule_packet
(
conn
,
NULL
,
PKT_OPEN
);
bgp_conn_set_state
(
conn
,
BS_OPENSENT
);
bgp_start_timer
(
conn
->
hold_timer
,
conn
->
bgp
->
cf
->
initial_hold_time
);
...
...
@@ -888,9 +888,9 @@ bgp_setup_conn(struct bgp_proto *p, struct bgp_conn *conn)
conn
->
last_channel
=
0
;
conn
->
last_channel_count
=
0
;
conn
->
connect_timer
=
tm
2
_new_init
(
p
->
p
.
pool
,
bgp_connect_timeout
,
conn
,
0
,
0
);
conn
->
hold_timer
=
tm
2
_new_init
(
p
->
p
.
pool
,
bgp_hold_timeout
,
conn
,
0
,
0
);
conn
->
keepalive_timer
=
tm
2
_new_init
(
p
->
p
.
pool
,
bgp_keepalive_timeout
,
conn
,
0
,
0
);
conn
->
connect_timer
=
tm_new_init
(
p
->
p
.
pool
,
bgp_connect_timeout
,
conn
,
0
,
0
);
conn
->
hold_timer
=
tm_new_init
(
p
->
p
.
pool
,
bgp_hold_timeout
,
conn
,
0
,
0
);
conn
->
keepalive_timer
=
tm_new_init
(
p
->
p
.
pool
,
bgp_keepalive_timeout
,
conn
,
0
,
0
);
conn
->
tx_ev
=
ev_new
(
p
->
p
.
pool
);
conn
->
tx_ev
->
hook
=
bgp_kick_tx
;
...
...
@@ -1303,8 +1303,8 @@ bgp_start(struct proto *P)
p
->
event
->
hook
=
bgp_decision
;
p
->
event
->
data
=
p
;
p
->
startup_timer
=
tm
2
_new_init
(
p
->
p
.
pool
,
bgp_startup_timeout
,
p
,
0
,
0
);
p
->
gr_timer
=
tm
2
_new_init
(
p
->
p
.
pool
,
bgp_graceful_restart_timeout
,
p
,
0
,
0
);
p
->
startup_timer
=
tm_new_init
(
p
->
p
.
pool
,
bgp_startup_timeout
,
p
,
0
,
0
);
p
->
gr_timer
=
tm_new_init
(
p
->
p
.
pool
,
bgp_graceful_restart_timeout
,
p
,
0
,
0
);
p
->
local_id
=
proto_get_router_id
(
P
->
cf
);
if
(
p
->
rr_client
)
...
...
@@ -2004,18 +2004,18 @@ bgp_show_proto_info(struct proto *P)
struct
bgp_conn
*
oc
=
&
p
->
outgoing_conn
;
if
((
p
->
start_state
<
BSS_CONNECT
)
&&
(
tm
2
_active
(
p
->
startup_timer
)))
(
tm_active
(
p
->
startup_timer
)))
cli_msg
(
-
1006
,
" Error wait: %t/%u"
,