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
cc881bd1
Commit
cc881bd1
authored
Jun 21, 2017
by
Ondřej Zajíček
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BGP: Update to new timers
parent
b32d557a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
31 deletions
+28
-31
proto/bgp/bgp.c
proto/bgp/bgp.c
+20
-24
proto/bgp/bgp.h
proto/bgp/bgp.h
+4
-3
proto/ospf/ospf.h
proto/ospf/ospf.h
+4
-4
No files found.
proto/bgp/bgp.c
View file @
cc881bd1
...
...
@@ -314,23 +314,24 @@ err1:
/**
* bgp_start_timer - start a BGP timer
* @t: timer
* @value: time to fire (0 to disable the timer)
* @value: time
(in seconds)
to fire (0 to disable the timer)
*
* This functions calls tm_start() on @t with time @value and the amount of
* randomization suggested by the BGP standard. Please use it for all BGP
* timers.
*/
void
bgp_start_timer
(
timer
*
t
,
int
value
)
bgp_start_timer
(
timer
*
t
,
u
int
value
)
{
if
(
value
)
{
/* The randomization procedure is specified in RFC 1771: 9.2.3.3 */
int
randomize
=
random
()
%
((
value
/
4
)
+
1
);
tm_start
(
t
,
value
-
randomize
);
/* The randomization procedure is specified in RFC 4271 section 10 */
btime
time
=
value
S
;
btime
randomize
=
random
()
%
((
time
/
4
)
+
1
);
tm2_start
(
t
,
time
-
randomize
);
}
else
tm_stop
(
t
);
tm
2
_stop
(
t
);
}
/**
...
...
@@ -383,10 +384,10 @@ bgp_update_startup_delay(struct bgp_proto *p)
DBG
(
"BGP: Updating startup delay
\n
"
);
if
(
p
->
last_proto_error
&&
((
now
-
p
->
last_proto_error
)
>=
(
int
)
cf
->
error_amnesia_time
))
if
(
p
->
last_proto_error
&&
((
current_time
()
-
p
->
last_proto_error
)
>=
cf
->
error_amnesia_time
S
))
p
->
startup_delay
=
0
;
p
->
last_proto_error
=
now
;
p
->
last_proto_error
=
current_time
()
;
if
(
cf
->
disable_after_error
)
{
...
...
@@ -516,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_stop
(
p
->
gr_timer
);
tm
2
_stop
(
p
->
gr_timer
);
/* Number of active channels */
int
num
=
0
;
...
...
@@ -615,7 +616,7 @@ bgp_conn_enter_close_state(struct bgp_conn *conn)
int
os
=
conn
->
state
;
bgp_conn_set_state
(
conn
,
BS_CLOSE
);
tm_stop
(
conn
->
keepalive_timer
);
tm
2
_stop
(
conn
->
keepalive_timer
);
conn
->
sk
->
rx_hook
=
NULL
;
/* Timeout for CLOSE state, if we cannot send notification soon then we just hangup */
...
...
@@ -778,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_stop
(
conn
->
connect_timer
);
tm
2
_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
);
...
...
@@ -887,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_new_
se
t
(
p
->
p
.
pool
,
bgp_connect_timeout
,
conn
,
0
,
0
);
conn
->
hold_timer
=
tm_new_
se
t
(
p
->
p
.
pool
,
bgp_hold_timeout
,
conn
,
0
,
0
);
conn
->
keepalive_timer
=
tm_new_
se
t
(
p
->
p
.
pool
,
bgp_keepalive_timeout
,
conn
,
0
,
0
);
conn
->
connect_timer
=
tm
2
_new_
ini
t
(
p
->
p
.
pool
,
bgp_connect_timeout
,
conn
,
0
,
0
);
conn
->
hold_timer
=
tm
2
_new_
ini
t
(
p
->
p
.
pool
,
bgp_hold_timeout
,
conn
,
0
,
0
);
conn
->
keepalive_timer
=
tm
2
_new_
ini
t
(
p
->
p
.
pool
,
bgp_keepalive_timeout
,
conn
,
0
,
0
);
conn
->
tx_ev
=
ev_new
(
p
->
p
.
pool
);
conn
->
tx_ev
->
hook
=
bgp_kick_tx
;
...
...
@@ -1302,13 +1303,8 @@ bgp_start(struct proto *P)
p
->
event
->
hook
=
bgp_decision
;
p
->
event
->
data
=
p
;
p
->
startup_timer
=
tm_new
(
p
->
p
.
pool
);
p
->
startup_timer
->
hook
=
bgp_startup_timeout
;
p
->
startup_timer
->
data
=
p
;
p
->
gr_timer
=
tm_new
(
p
->
p
.
pool
);
p
->
gr_timer
->
hook
=
bgp_graceful_restart_timeout
;
p
->
gr_timer
->
data
=
p
;
p
->
startup_timer
=
tm2_new_init
(
p
->
p
.
pool
,
bgp_startup_timeout
,
p
,
0
,
0
);
p
->
gr_timer
=
tm2_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
)
...
...
@@ -2008,16 +2004,16 @@ bgp_show_proto_info(struct proto *P)
struct
bgp_conn
*
oc
=
&
p
->
outgoing_conn
;
if
((
p
->
start_state
<
BSS_CONNECT
)
&&
(
tm_active
(
p
->
startup_timer
)))
(
tm
2
_active
(
p
->
startup_timer
)))
cli_msg
(
-
1006
,
" Error wait: %t/%u"
,
tm2_remains
(
p
->
startup_timer
),
p
->
startup_delay
);
if
((
oc
->
state
==
BS_ACTIVE
)
&&
(
tm_active
(
oc
->
connect_timer
)))
(
tm
2
_active
(
oc
->
connect_timer
)))
cli_msg
(
-
1006
,
" Connect delay: %t/%u"
,
tm2_remains
(
oc
->
connect_timer
),
p
->
cf
->
connect_delay_time
);
if
(
p
->
gr_active_num
&&
tm_active
(
p
->
gr_timer
))
if
(
p
->
gr_active_num
&&
tm
2
_active
(
p
->
gr_timer
))
cli_msg
(
-
1006
,
" Restart timer: %t/-"
,
tm2_remains
(
p
->
gr_timer
));
}
...
...
proto/bgp/bgp.h
View file @
cc881bd1
...
...
@@ -108,6 +108,7 @@ struct bgp_config {
int
allow_local_pref
;
/* Allow LOCAL_PREF in EBGP sessions */
int
gr_mode
;
/* Graceful restart mode (BGP_GR_*) */
int
setkey
;
/* Set MD5 password to system SA/SP database */
/* Times below are in seconds */
unsigned
gr_time
;
/* Graceful restart timeout */
unsigned
connect_delay_time
;
/* Minimum delay between connect attempts */
unsigned
connect_retry_time
;
/* Timeout for connect attempts */
...
...
@@ -257,8 +258,8 @@ struct bgp_proto {
event
*
event
;
/* Event for respawning and shutting process */
timer
*
startup_timer
;
/* Timer used to delay protocol startup due to previous errors (startup_delay) */
timer
*
gr_timer
;
/* Timer waiting for reestablishment after graceful restart */
u
nsigned
startup_delay
;
/*
Time to delay
protocol startup
by
due to errors */
b
ird_clock_t
last_proto_error
;
/* Time of last error that leads to protocol stop */
u
int
startup_delay
;
/*
Delay (in seconds) of
protocol startup due to
previous
errors */
b
time
last_proto_error
;
/* Time of last error that leads to protocol stop */
u8
last_error_class
;
/* Error class of last error */
u32
last_error_code
;
/* Error code of last error. BGP protocol errors
are encoded as (bgp_err_code << 16 | bgp_err_subcode) */
...
...
@@ -422,7 +423,7 @@ extern struct linpool *bgp_linpool;
extern
struct
linpool
*
bgp_linpool2
;
void
bgp_start_timer
(
timer
*
t
,
int
value
);
void
bgp_start_timer
(
timer
*
t
,
u
int
value
);
void
bgp_check_config
(
struct
bgp_config
*
c
);
void
bgp_error
(
struct
bgp_conn
*
c
,
unsigned
code
,
unsigned
subcode
,
byte
*
data
,
int
len
);
void
bgp_close_conn
(
struct
bgp_conn
*
c
);
...
...
proto/ospf/ospf.h
View file @
cc881bd1
...
...
@@ -269,10 +269,10 @@ struct ospf_iface
sock
*
sk
;
/* IP socket */
list
neigh_list
;
/* List of neighbors (struct ospf_neighbor) */
u32
cost
;
/* Cost of iface */
u32
waitint
;
/*
n
umber of sec before changing state from wait */
u32
rxmtint
;
/*
n
umber of seconds between LSA retransmissions */
u32
pollint
;
/* Poll interval */
u32
deadint
;
/*
a
fter
"
deadint
" missing
hellos is router dead */
u32
waitint
;
/*
N
umber of sec
onds
before changing state from wait */
u32
rxmtint
;
/*
N
umber of seconds between LSA retransmissions */
u32
pollint
;
/* Poll interval
in seconds
*/
u32
deadint
;
/*
A
fter deadint
seconds without
hellos is router dead */
u32
iface_id
;
/* Interface ID (iface->index or new value for vlinks) */
u32
vid
;
/* ID of peer of virtual link */
ip_addr
vip
;
/* IP of peer of virtual link */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment