summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/bgpd/bgpd.conf.58
-rw-r--r--usr.sbin/bgpd/bgpd.h4
-rw-r--r--usr.sbin/bgpd/parse.y18
-rw-r--r--usr.sbin/bgpd/session.c19
4 files changed, 41 insertions, 8 deletions
diff --git a/usr.sbin/bgpd/bgpd.conf.5 b/usr.sbin/bgpd/bgpd.conf.5
index b60234a0a2c..fd31a037c27 100644
--- a/usr.sbin/bgpd/bgpd.conf.5
+++ b/usr.sbin/bgpd/bgpd.conf.5
@@ -1,4 +1,4 @@
-.\" $OpenBSD: bgpd.conf.5,v 1.11 2004/01/06 03:43:50 henning Exp $
+.\" $OpenBSD: bgpd.conf.5,v 1.12 2004/01/06 20:41:55 henning Exp $
.\"
.\" Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
.\" Copyright (c) 2002 Daniel Hartmeier <dhartmei@openbsd.org>
@@ -191,6 +191,12 @@ If this is not the case the
statement defines the maximum hops the neighbor is away.
.It Ar passive
Do not attempt to actively open a TCP connection to the neighbor system.
+.It Ar holdtime
+Set the holdtime in seconds.
+Inherit from the global configuration if not given.
+.It Ar holdtime min
+Set the minimal acceptable holdtime.
+Inherit from the global configuration if not given.
.El
.Sh FILES
.Bl -tag -width "/etc/bgpd.conf" -compact
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h
index 8ee24bb0327..488bc9f6683 100644
--- a/usr.sbin/bgpd/bgpd.h
+++ b/usr.sbin/bgpd/bgpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.h,v 1.55 2004/01/06 03:43:50 henning Exp $ */
+/* $OpenBSD: bgpd.h,v 1.56 2004/01/06 20:41:55 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -112,6 +112,8 @@ struct peer_config {
u_int8_t ebgp; /* 1 = ebgp, 0 = ibgp */
u_int8_t distance; /* 1 = direct, >1 = multihop */
u_int8_t passive;
+ u_int16_t holdtime;
+ u_int16_t min_holdtime;
enum reconf_action reconf_action;
};
diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y
index 00be1c056d4..a2d171710f1 100644
--- a/usr.sbin/bgpd/parse.y
+++ b/usr.sbin/bgpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.31 2004/01/06 03:43:50 henning Exp $ */
+/* $OpenBSD: parse.y,v 1.32 2004/01/06 20:41:55 henning Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -298,6 +298,22 @@ peeropts : REMOTEAS number {
| PASSIVE {
curpeer->conf.passive = 1;
}
+ | HOLDTIME number {
+ if ($2 < MIN_HOLDTIME) {
+ yyerror("holdtime must be at least %u",
+ MIN_HOLDTIME);
+ YYERROR;
+ }
+ curpeer->conf.holdtime = $2;
+ }
+ | HOLDTIME YMIN number {
+ if ($3 < MIN_HOLDTIME) {
+ yyerror("holdtime min must be at least %u",
+ MIN_HOLDTIME);
+ YYERROR;
+ }
+ curpeer->conf.min_holdtime = $3;
+ }
;
%%
diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c
index 2ada617d482..9c954c3e07a 100644
--- a/usr.sbin/bgpd/session.c
+++ b/usr.sbin/bgpd/session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.c,v 1.68 2004/01/06 19:19:21 henning Exp $ */
+/* $OpenBSD: session.c,v 1.69 2004/01/06 20:41:55 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -353,6 +353,10 @@ init_peers(void)
change_state(p, STATE_IDLE, EVNT_NONE);
p->IdleHoldTimer = time(NULL); /* start ASAP */
}
+ if (!p->conf.holdtime)
+ p->conf.holdtime = conf->holdtime;
+ if (!p->conf.min_holdtime)
+ p->conf.min_holdtime = conf->min_holdtime;
}
}
@@ -837,7 +841,7 @@ session_open(struct peer *peer)
msg.header.type = OPEN;
msg.version = 4;
msg.myas = htons(conf->as);
- msg.holdtime = htons(conf->holdtime);
+ msg.holdtime = htons(peer->conf.holdtime);
msg.bgpid = conf->bgpid; /* is already in network byte order */
msg.optparamlen = 0;
@@ -1212,17 +1216,17 @@ parse_open(struct peer *peer)
p += sizeof(oholdtime);
holdtime = ntohs(oholdtime);
- if (holdtime && holdtime < conf->min_holdtime) {
+ if (holdtime && holdtime < peer->conf.min_holdtime) {
log_peer_errx(peer, "peer requests unacceptable holdtime %u",
holdtime);
session_notification(peer, ERR_OPEN, ERR_OPEN_HOLDTIME,
NULL, 0);
return (-1);
}
- if (holdtime < conf->holdtime)
+ if (holdtime < peer->conf.holdtime)
peer->holdtime = holdtime;
else
- peer->holdtime = conf->holdtime;
+ peer->holdtime = peer->conf.holdtime;
memcpy(&bgpid, p, sizeof(bgpid));
p += sizeof(bgpid);
@@ -1378,6 +1382,11 @@ session_dispatch_imsg(struct imsgbuf *ibuf, int idx)
if (pconf->reconf_action > reconf)
p->conf.reconf_action = pconf->reconf_action;
+ if (!p->conf.holdtime)
+ p->conf.holdtime = nconf->holdtime;
+ if (!p->conf.min_holdtime)
+ p->conf.min_holdtime = nconf->min_holdtime;
+
if (p->state >= STATE_OPENSENT) {
if (p->holdtime == conf->holdtime &&
nconf->holdtime > conf->holdtime)