summaryrefslogtreecommitdiff
path: root/proto/bgp
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2017-06-01 12:33:20 +0200
committerOndrej Zajicek (work) <santiago@crfreenet.org>2017-12-07 13:49:27 +0100
commit025525266f6861437ca54aca2a86eb505a486baf (patch)
tree8a4f2035ef7edbcd77224ed76598ec0806f24512 /proto/bgp
parent28a7d3943ef915c405b3552ae06f639a86f4dc1e (diff)
Timers: Replace old timers with microsecond timers
The old timer interface is still kept, but implemented by new timers. The plan is to switch from the old inteface to the new interface, then clean it up.
Diffstat (limited to 'proto/bgp')
-rw-r--r--proto/bgp/bgp.c19
-rw-r--r--proto/bgp/bgp.h16
2 files changed, 19 insertions, 16 deletions
diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c
index a8d5cf9d..dba7c875 100644
--- a/proto/bgp/bgp.c
+++ b/proto/bgp/bgp.c
@@ -103,6 +103,8 @@
#undef LOCAL_DEBUG
+#include <stdlib.h>
+
#include "nest/bird.h"
#include "nest/iface.h"
#include "nest/protocol.h"
@@ -324,8 +326,8 @@ bgp_start_timer(timer *t, int value)
if (value)
{
/* The randomization procedure is specified in RFC 1771: 9.2.3.3 */
- t->randomize = value / 4;
- tm_start(t, value - t->randomize);
+ int randomize = random() % ((value / 4) + 1);
+ tm_start(t, value - randomize);
}
else
tm_stop(t);
@@ -2006,17 +2008,18 @@ bgp_show_proto_info(struct proto *P)
struct bgp_conn *oc = &p->outgoing_conn;
if ((p->start_state < BSS_CONNECT) &&
- (p->startup_timer->expires))
+ (tm_active(p->startup_timer)))
cli_msg(-1006, " Error wait: %d/%d",
- p->startup_timer->expires - now, p->startup_delay);
+ (int) tm_remains(p->startup_timer), p->startup_delay);
if ((oc->state == BS_ACTIVE) &&
- (oc->connect_timer->expires))
+ (tm_active(oc->connect_timer)))
cli_msg(-1006, " Connect delay: %d/%d",
- oc->connect_timer->expires - now, p->cf->connect_delay_time);
+ (int) tm_remains(oc->connect_timer), p->cf->connect_delay_time);
- if (p->gr_active_num && p->gr_timer->expires)
- cli_msg(-1006, " Restart timer: %d/-", p->gr_timer->expires - now);
+ if (p->gr_active_num && tm_active(p->gr_timer))
+ cli_msg(-1006, " Restart timer: %d/-",
+ (int) tm_remains(p->gr_timer));
}
else if (P->proto_state == PS_UP)
{
diff --git a/proto/bgp/bgp.h b/proto/bgp/bgp.h
index 7ffcb68a..3b38c05f 100644
--- a/proto/bgp/bgp.h
+++ b/proto/bgp/bgp.h
@@ -210,10 +210,10 @@ struct bgp_conn {
struct bgp_caps *local_caps;
struct bgp_caps *remote_caps;
- struct timer *connect_timer;
- struct timer *hold_timer;
- struct timer *keepalive_timer;
- struct event *tx_ev;
+ timer *connect_timer;
+ timer *hold_timer;
+ timer *keepalive_timer;
+ event *tx_ev;
u32 packets_to_send; /* Bitmap of packet types to be sent */
u32 channels_to_send; /* Bitmap of channels with packets to be sent */
u8 last_channel; /* Channel used last time for TX */
@@ -254,9 +254,9 @@ struct bgp_proto {
struct bfd_request *bfd_req; /* BFD request, if BFD is used */
ip_addr source_addr; /* Local address used as an advertised next hop */
ip_addr link_addr; /* Link-local version of source_addr */
- struct event *event; /* Event for respawning and shutting process */
- struct timer *startup_timer; /* Timer used to delay protocol startup due to previous errors (startup_delay) */
- struct timer *gr_timer; /* Timer waiting for reestablishment after graceful restart */
+ 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 */
unsigned startup_delay; /* Time to delay protocol startup by due to errors */
bird_clock_t last_proto_error; /* Time of last error that leads to protocol stop */
u8 last_error_class; /* Error class of last error */
@@ -422,7 +422,7 @@ extern struct linpool *bgp_linpool;
extern struct linpool *bgp_linpool2;
-void bgp_start_timer(struct timer *t, int value);
+void bgp_start_timer(timer *t, 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);