BGP: Update to new timers
This commit is contained in:
parent
b32d557a6e
commit
cc881bd155
3 changed files with 28 additions and 31 deletions
|
@ -314,23 +314,24 @@ err1:
|
||||||
/**
|
/**
|
||||||
* bgp_start_timer - start a BGP timer
|
* bgp_start_timer - start a BGP timer
|
||||||
* @t: 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
|
* 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
|
* randomization suggested by the BGP standard. Please use it for all BGP
|
||||||
* timers.
|
* timers.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
bgp_start_timer(timer *t, int value)
|
bgp_start_timer(timer *t, uint value)
|
||||||
{
|
{
|
||||||
if (value)
|
if (value)
|
||||||
{
|
{
|
||||||
/* The randomization procedure is specified in RFC 1771: 9.2.3.3 */
|
/* The randomization procedure is specified in RFC 4271 section 10 */
|
||||||
int randomize = random() % ((value / 4) + 1);
|
btime time = value S;
|
||||||
tm_start(t, value - randomize);
|
btime randomize = random() % ((time / 4) + 1);
|
||||||
|
tm2_start(t, time - randomize);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
tm_stop(t);
|
tm2_stop(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -383,10 +384,10 @@ bgp_update_startup_delay(struct bgp_proto *p)
|
||||||
|
|
||||||
DBG("BGP: Updating startup delay\n");
|
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->startup_delay = 0;
|
||||||
|
|
||||||
p->last_proto_error = now;
|
p->last_proto_error = current_time();
|
||||||
|
|
||||||
if (cf->disable_after_error)
|
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);
|
int peer_gr_ready = peer->gr_aware && !(peer->gr_flags & BGP_GRF_RESTART);
|
||||||
|
|
||||||
if (p->gr_active_num)
|
if (p->gr_active_num)
|
||||||
tm_stop(p->gr_timer);
|
tm2_stop(p->gr_timer);
|
||||||
|
|
||||||
/* Number of active channels */
|
/* Number of active channels */
|
||||||
int num = 0;
|
int num = 0;
|
||||||
|
@ -615,7 +616,7 @@ bgp_conn_enter_close_state(struct bgp_conn *conn)
|
||||||
int os = conn->state;
|
int os = conn->state;
|
||||||
|
|
||||||
bgp_conn_set_state(conn, BS_CLOSE);
|
bgp_conn_set_state(conn, BS_CLOSE);
|
||||||
tm_stop(conn->keepalive_timer);
|
tm2_stop(conn->keepalive_timer);
|
||||||
conn->sk->rx_hook = NULL;
|
conn->sk->rx_hook = NULL;
|
||||||
|
|
||||||
/* Timeout for CLOSE state, if we cannot send notification soon then we just hangup */
|
/* 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");
|
DBG("BGP: Sending open\n");
|
||||||
conn->sk->rx_hook = bgp_rx;
|
conn->sk->rx_hook = bgp_rx;
|
||||||
conn->sk->tx_hook = bgp_tx;
|
conn->sk->tx_hook = bgp_tx;
|
||||||
tm_stop(conn->connect_timer);
|
tm2_stop(conn->connect_timer);
|
||||||
bgp_schedule_packet(conn, NULL, PKT_OPEN);
|
bgp_schedule_packet(conn, NULL, PKT_OPEN);
|
||||||
bgp_conn_set_state(conn, BS_OPENSENT);
|
bgp_conn_set_state(conn, BS_OPENSENT);
|
||||||
bgp_start_timer(conn->hold_timer, conn->bgp->cf->initial_hold_time);
|
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 = 0;
|
||||||
conn->last_channel_count = 0;
|
conn->last_channel_count = 0;
|
||||||
|
|
||||||
conn->connect_timer = tm_new_set(p->p.pool, bgp_connect_timeout, conn, 0, 0);
|
conn->connect_timer = tm2_new_init(p->p.pool, bgp_connect_timeout, conn, 0, 0);
|
||||||
conn->hold_timer = tm_new_set(p->p.pool, bgp_hold_timeout, conn, 0, 0);
|
conn->hold_timer = tm2_new_init(p->p.pool, bgp_hold_timeout, conn, 0, 0);
|
||||||
conn->keepalive_timer = tm_new_set(p->p.pool, bgp_keepalive_timeout, conn, 0, 0);
|
conn->keepalive_timer = tm2_new_init(p->p.pool, bgp_keepalive_timeout, conn, 0, 0);
|
||||||
|
|
||||||
conn->tx_ev = ev_new(p->p.pool);
|
conn->tx_ev = ev_new(p->p.pool);
|
||||||
conn->tx_ev->hook = bgp_kick_tx;
|
conn->tx_ev->hook = bgp_kick_tx;
|
||||||
|
@ -1302,13 +1303,8 @@ bgp_start(struct proto *P)
|
||||||
p->event->hook = bgp_decision;
|
p->event->hook = bgp_decision;
|
||||||
p->event->data = p;
|
p->event->data = p;
|
||||||
|
|
||||||
p->startup_timer = tm_new(p->p.pool);
|
p->startup_timer = tm2_new_init(p->p.pool, bgp_startup_timeout, p, 0, 0);
|
||||||
p->startup_timer->hook = bgp_startup_timeout;
|
p->gr_timer = tm2_new_init(p->p.pool, bgp_graceful_restart_timeout, p, 0, 0);
|
||||||
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->local_id = proto_get_router_id(P->cf);
|
p->local_id = proto_get_router_id(P->cf);
|
||||||
if (p->rr_client)
|
if (p->rr_client)
|
||||||
|
@ -2008,16 +2004,16 @@ bgp_show_proto_info(struct proto *P)
|
||||||
struct bgp_conn *oc = &p->outgoing_conn;
|
struct bgp_conn *oc = &p->outgoing_conn;
|
||||||
|
|
||||||
if ((p->start_state < BSS_CONNECT) &&
|
if ((p->start_state < BSS_CONNECT) &&
|
||||||
(tm_active(p->startup_timer)))
|
(tm2_active(p->startup_timer)))
|
||||||
cli_msg(-1006, " Error wait: %t/%u",
|
cli_msg(-1006, " Error wait: %t/%u",
|
||||||
tm2_remains(p->startup_timer), p->startup_delay);
|
tm2_remains(p->startup_timer), p->startup_delay);
|
||||||
|
|
||||||
if ((oc->state == BS_ACTIVE) &&
|
if ((oc->state == BS_ACTIVE) &&
|
||||||
(tm_active(oc->connect_timer)))
|
(tm2_active(oc->connect_timer)))
|
||||||
cli_msg(-1006, " Connect delay: %t/%u",
|
cli_msg(-1006, " Connect delay: %t/%u",
|
||||||
tm2_remains(oc->connect_timer), p->cf->connect_delay_time);
|
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 && tm2_active(p->gr_timer))
|
||||||
cli_msg(-1006, " Restart timer: %t/-",
|
cli_msg(-1006, " Restart timer: %t/-",
|
||||||
tm2_remains(p->gr_timer));
|
tm2_remains(p->gr_timer));
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,6 +108,7 @@ struct bgp_config {
|
||||||
int allow_local_pref; /* Allow LOCAL_PREF in EBGP sessions */
|
int allow_local_pref; /* Allow LOCAL_PREF in EBGP sessions */
|
||||||
int gr_mode; /* Graceful restart mode (BGP_GR_*) */
|
int gr_mode; /* Graceful restart mode (BGP_GR_*) */
|
||||||
int setkey; /* Set MD5 password to system SA/SP database */
|
int setkey; /* Set MD5 password to system SA/SP database */
|
||||||
|
/* Times below are in seconds */
|
||||||
unsigned gr_time; /* Graceful restart timeout */
|
unsigned gr_time; /* Graceful restart timeout */
|
||||||
unsigned connect_delay_time; /* Minimum delay between connect attempts */
|
unsigned connect_delay_time; /* Minimum delay between connect attempts */
|
||||||
unsigned connect_retry_time; /* Timeout for 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 */
|
event *event; /* Event for respawning and shutting process */
|
||||||
timer *startup_timer; /* Timer used to delay protocol startup due to previous errors (startup_delay) */
|
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 */
|
timer *gr_timer; /* Timer waiting for reestablishment after graceful restart */
|
||||||
unsigned startup_delay; /* Time to delay protocol startup by due to errors */
|
uint startup_delay; /* Delay (in seconds) of protocol startup due to previous errors */
|
||||||
bird_clock_t last_proto_error; /* Time of last error that leads to protocol stop */
|
btime last_proto_error; /* Time of last error that leads to protocol stop */
|
||||||
u8 last_error_class; /* Error class of last error */
|
u8 last_error_class; /* Error class of last error */
|
||||||
u32 last_error_code; /* Error code of last error. BGP protocol errors
|
u32 last_error_code; /* Error code of last error. BGP protocol errors
|
||||||
are encoded as (bgp_err_code << 16 | bgp_err_subcode) */
|
are encoded as (bgp_err_code << 16 | bgp_err_subcode) */
|
||||||
|
@ -422,7 +423,7 @@ extern struct linpool *bgp_linpool;
|
||||||
extern struct linpool *bgp_linpool2;
|
extern struct linpool *bgp_linpool2;
|
||||||
|
|
||||||
|
|
||||||
void bgp_start_timer(timer *t, int value);
|
void bgp_start_timer(timer *t, uint value);
|
||||||
void bgp_check_config(struct bgp_config *c);
|
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_error(struct bgp_conn *c, unsigned code, unsigned subcode, byte *data, int len);
|
||||||
void bgp_close_conn(struct bgp_conn *c);
|
void bgp_close_conn(struct bgp_conn *c);
|
||||||
|
|
|
@ -269,10 +269,10 @@ struct ospf_iface
|
||||||
sock *sk; /* IP socket */
|
sock *sk; /* IP socket */
|
||||||
list neigh_list; /* List of neighbors (struct ospf_neighbor) */
|
list neigh_list; /* List of neighbors (struct ospf_neighbor) */
|
||||||
u32 cost; /* Cost of iface */
|
u32 cost; /* Cost of iface */
|
||||||
u32 waitint; /* number of sec before changing state from wait */
|
u32 waitint; /* Number of seconds before changing state from wait */
|
||||||
u32 rxmtint; /* number of seconds between LSA retransmissions */
|
u32 rxmtint; /* Number of seconds between LSA retransmissions */
|
||||||
u32 pollint; /* Poll interval */
|
u32 pollint; /* Poll interval in seconds */
|
||||||
u32 deadint; /* after "deadint" missing hellos is router dead */
|
u32 deadint; /* After deadint seconds without hellos is router dead */
|
||||||
u32 iface_id; /* Interface ID (iface->index or new value for vlinks) */
|
u32 iface_id; /* Interface ID (iface->index or new value for vlinks) */
|
||||||
u32 vid; /* ID of peer of virtual link */
|
u32 vid; /* ID of peer of virtual link */
|
||||||
ip_addr vip; /* IP of peer of virtual link */
|
ip_addr vip; /* IP of peer of virtual link */
|
||||||
|
|
Loading…
Reference in a new issue