summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2004-01-06 19:19:22 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2004-01-06 19:19:22 +0000
commit1ed474925992b650da2233b2dd608768530dee9b (patch)
tree08e25973e98cc4d81f64195631b5b22d034ae2c9
parenta167874ff2aade9b04ef15616f95164022ac3cd0 (diff)
properly punish oscillating neighbors.
previously we were to forgiving so the punishment didn't kick in as intended
-rw-r--r--usr.sbin/bgpd/session.c24
-rw-r--r--usr.sbin/bgpd/session.h10
2 files changed, 27 insertions, 7 deletions
diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c
index 44794b4c0ba..2ada617d482 100644
--- a/usr.sbin/bgpd/session.c
+++ b/usr.sbin/bgpd/session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.c,v 1.67 2004/01/06 18:01:26 henning Exp $ */
+/* $OpenBSD: session.c,v 1.68 2004/01/06 19:19:21 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -240,6 +240,17 @@ session_main(struct bgpd_config *config, struct peer *cpeers, int pipe_m2s[2],
bgp_fsm(p, EVNT_TIMER_KEEPALIVE);
if (timer_due(p->IdleHoldTimer))
bgp_fsm(p, EVNT_START);
+ if (timer_due(p->IdleHoldResetTimer)) {
+ p->IdleHoldTime /= 2;
+ if (p->IdleHoldTime <=
+ INTERVAL_IDLE_HOLD_INITIAL) {
+ p->IdleHoldTime =
+ INTERVAL_IDLE_HOLD_INITIAL;
+ p->IdleHoldResetTimer = 0;
+ } else
+ p->IdleHoldResetTimer =
+ time(NULL) + p->IdleHoldTime;
+ }
/* set nextaction to the first expiring timer */
if (p->ConnectRetryTimer &&
@@ -251,6 +262,9 @@ session_main(struct bgpd_config *config, struct peer *cpeers, int pipe_m2s[2],
nextaction = p->KeepaliveTimer;
if (p->IdleHoldTimer && p->IdleHoldTimer < nextaction)
nextaction = p->IdleHoldTimer;
+ if (p->IdleHoldResetTimer &&
+ p->IdleHoldResetTimer < nextaction)
+ nextaction = p->IdleHoldResetTimer;
/* are we waiting for a write? */
if (p->wbuf.queued > 0)
@@ -625,6 +639,7 @@ change_state(struct peer *peer, enum session_state state,
peer->ConnectRetryTimer = 0;
peer->KeepaliveTimer = 0;
peer->HoldTimer = 0;
+ peer->IdleHoldResetTimer = 0;
session_close_connection(peer);
msgbuf_clear(&peer->wbuf);
free(peer->rbuf);
@@ -633,7 +648,8 @@ change_state(struct peer *peer, enum session_state state,
session_down(peer);
if (event != EVNT_STOP) {
peer->IdleHoldTimer = time(NULL) + peer->IdleHoldTime;
- if (peer->IdleHoldTime < UINT_MAX / 2)
+ if (event != EVNT_NONE &&
+ peer->IdleHoldTime < MAX_IDLE_HOLD/2)
peer->IdleHoldTime *= 2;
}
break;
@@ -651,7 +667,9 @@ change_state(struct peer *peer, enum session_state state,
break;
case STATE_ESTABLISHED:
peer->events = POLLIN;
- peer->IdleHoldTime = INTERVAL_IDLE_HOLD_INITIAL;
+ if (peer->IdleHoldTime > INTERVAL_IDLE_HOLD_INITIAL)
+ peer->IdleHoldResetTimer =
+ time(NULL) + peer->IdleHoldTime;
session_up(peer);
break;
default: /* something seriously fucked */
diff --git a/usr.sbin/bgpd/session.h b/usr.sbin/bgpd/session.h
index 4e0200eab55..12721f951d3 100644
--- a/usr.sbin/bgpd/session.h
+++ b/usr.sbin/bgpd/session.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.h,v 1.13 2004/01/06 18:01:27 henning Exp $ */
+/* $OpenBSD: session.h,v 1.14 2004/01/06 19:19:21 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -23,9 +23,10 @@
#define INTERVAL_CONNECTRETRY 120
#define INTERVAL_HOLD_INITIAL 240
#define INTERVAL_HOLD 90
-#define INTERVAL_IDLE_HOLD_INITIAL 90
-#define MSGSIZE_HEADER 19
-#define MSGSIZE_HEADER_MARKER 16
+#define INTERVAL_IDLE_HOLD_INITIAL 90
+#define MAX_IDLE_HOLD 3600
+#define MSGSIZE_HEADER 19
+#define MSGSIZE_HEADER_MARKER 16
#define MSGSIZE_NOTIFICATION_MIN 21 /* 19 hdr + 1 code + 1 sub */
#define MSGSIZE_OPEN_MIN 29
#define MSGSIZE_UPDATE_MIN 23
@@ -139,6 +140,7 @@ struct peer {
time_t KeepaliveTimer;
time_t HoldTimer;
time_t IdleHoldTimer;
+ time_t IdleHoldResetTimer;
u_int IdleHoldTime;
int sock;
int events;