summaryrefslogtreecommitdiff
path: root/usr.sbin/ospfd
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2010-02-16 08:39:06 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2010-02-16 08:39:06 +0000
commitbe5c5edbf390cc04a11dddd20cbf3d5251afc6b7 (patch)
treee6c8838676aaeac241ea2f37c4de59ea9dcc8bd5 /usr.sbin/ospfd
parentf8705765f4e91d61e6ae819383ee511c58d0613b (diff)
implement support for fast hello packets.
if route-dead-time is set to "minimal" (rather than a number of seconds), the dead time is set to 1 second and hellos are sent at the interval specified by fast-hello-interval in msecs. this is non standard wrt to the ospf rfc, but it does interoperate with at least one other router vendor. this allows much better responsiveness to l3 topology changes than the standard intervals allow. if i yank a cable to one of my upstreams, the routes adjust in a second rather than the default of 40 i was running with before. the users dont even notice something changed. developed while working with joshua atterbury. ok claudio@ as part of a larger diff. dedicated to zan rowe who thinks she is a bigger nerd than me.
Diffstat (limited to 'usr.sbin/ospfd')
-rw-r--r--usr.sbin/ospfd/interface.c15
-rw-r--r--usr.sbin/ospfd/ospf.h8
-rw-r--r--usr.sbin/ospfd/ospfd.conf.517
-rw-r--r--usr.sbin/ospfd/ospfd.h6
-rw-r--r--usr.sbin/ospfd/parse.y46
-rw-r--r--usr.sbin/ospfd/printconf.c12
6 files changed, 81 insertions, 23 deletions
diff --git a/usr.sbin/ospfd/interface.c b/usr.sbin/ospfd/interface.c
index a5d53ab9b0a..92a9e6f1ee2 100644
--- a/usr.sbin/ospfd/interface.c
+++ b/usr.sbin/ospfd/interface.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: interface.c,v 1.66 2009/09/30 14:39:07 claudio Exp $ */
+/* $OpenBSD: interface.c,v 1.67 2010/02/16 08:39:05 dlg Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -278,7 +278,10 @@ if_hello_timer(int fd, short event, void *arg)
/* reschedule hello_timer */
timerclear(&tv);
- tv.tv_sec = iface->hello_interval;
+ if (iface->dead_interval == FAST_RTR_DEAD_TIME)
+ tv.tv_usec = iface->fast_hello_interval * 1000;
+ else
+ tv.tv_sec = iface->hello_interval;
if (evtimer_add(&iface->hello_timer, &tv) == -1)
fatal("if_hello_timer");
}
@@ -629,6 +632,7 @@ if_to_ctl(struct iface *iface)
ictl.adj_cnt = 0;
ictl.baudrate = iface->baudrate;
ictl.dead_interval = iface->dead_interval;
+ ictl.fast_hello_interval = iface->fast_hello_interval;
ictl.transmit_delay = iface->transmit_delay;
ictl.hello_interval = iface->hello_interval;
ictl.flags = iface->flags;
@@ -645,9 +649,10 @@ if_to_ctl(struct iface *iface)
gettimeofday(&now, NULL);
if (evtimer_pending(&iface->hello_timer, &tv)) {
timersub(&tv, &now, &res);
- ictl.hello_timer = res.tv_sec;
- } else
- ictl.hello_timer = -1;
+ ictl.hello_timer = res;
+ } else {
+ ictl.hello_timer.tv_sec = -1;
+ }
if (iface->state != IF_STA_DOWN) {
ictl.uptime = now.tv_sec - iface->uptime;
diff --git a/usr.sbin/ospfd/ospf.h b/usr.sbin/ospfd/ospf.h
index cb950898a61..1bddb36de20 100644
--- a/usr.sbin/ospfd/ospf.h
+++ b/usr.sbin/ospfd/ospf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospf.h,v 1.17 2010/02/16 08:22:42 dlg Exp $ */
+/* $OpenBSD: ospf.h,v 1.18 2010/02/16 08:39:05 dlg Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -44,7 +44,13 @@
#define MIN_HELLO_INTERVAL 1
#define MAX_HELLO_INTERVAL 65535
+/* msec */
+#define DEFAULT_FAST_INTERVAL 333
+#define MIN_FAST_INTERVAL 50
+#define MAX_FAST_INTERVAL 333
+
#define DEFAULT_RTR_DEAD_TIME 40
+#define FAST_RTR_DEAD_TIME 1
#define MIN_RTR_DEAD_TIME 2
#define MAX_RTR_DEAD_TIME 2147483647
diff --git a/usr.sbin/ospfd/ospfd.conf.5 b/usr.sbin/ospfd/ospfd.conf.5
index 51c9140f298..4e23bd9a01a 100644
--- a/usr.sbin/ospfd/ospfd.conf.5
+++ b/usr.sbin/ospfd/ospfd.conf.5
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ospfd.conf.5,v 1.41 2010/02/16 08:27:31 dlg Exp $
+.\" $OpenBSD: ospfd.conf.5,v 1.42 2010/02/16 08:39:05 dlg Exp $
.\"
.\" Copyright (c) 2005 Esben Norby <norby@openbsd.org>
.\" Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
@@ -341,6 +341,11 @@ demotion counter by 1 on the given interface group, usually
when the interface state is going down.
The demotion counter will be decreased when the interface
state is active again.
+.It Ic fast-hello-interval Ic msec Ar microseconds
+If the interface is configured to use
+.Ic router-dead-time minimal ,
+hello packets will be sent using this timer.
+The default value is 333; valid range is 50\-333 microseconds.
.It Ic hello-interval Ar seconds
Set the hello interval.
The default value is 10; valid range is 1\-65535 seconds.
@@ -353,9 +358,17 @@ The specified interface will be announced as a stub network.
.It Ic retransmit-interval Ar seconds
Set retransmit interval.
The default value is 5 seconds; valid range is 5\-3600 seconds.
-.It Ic router-dead-time Ar seconds
+.It Xo
+.Ic router-dead-time
+.Po Ar seconds Ns \&| Ns Ic minimal Pc
+.Xc
Set the router dead time, a.k.a. neighbor inactivity timer.
The default value is 40 seconds; valid range is 2\-2147483647 seconds.
+If the router dead time has been set to
+.Ic minimal ,
+the timer is set to 1 second and hello packets are sent using the interval
+specified by
+.Ic fast-hello-interval .
When a neighbor has been
inactive for router-dead-time its state is set to DOWN.
Neighbors
diff --git a/usr.sbin/ospfd/ospfd.h b/usr.sbin/ospfd/ospfd.h
index 0e52b2394a4..4d3ba0fba01 100644
--- a/usr.sbin/ospfd/ospfd.h
+++ b/usr.sbin/ospfd/ospfd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfd.h,v 1.84 2009/11/02 20:20:54 claudio Exp $ */
+/* $OpenBSD: ospfd.h,v 1.85 2010/02/16 08:39:05 dlg Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -322,6 +322,7 @@ struct iface {
u_int64_t baudrate;
u_int32_t dead_interval;
+ u_int32_t fast_hello_interval;
u_int32_t ls_ack_cnt;
u_int32_t crypt_seq_num;
time_t uptime;
@@ -434,10 +435,11 @@ struct ctl_iface {
struct in_addr dr_addr;
struct in_addr bdr_id;
struct in_addr bdr_addr;
- time_t hello_timer;
+ struct timeval hello_timer;
time_t uptime;
u_int64_t baudrate;
u_int32_t dead_interval;
+ u_int32_t fast_hello_interval;
unsigned int ifindex;
int state;
int mtu;
diff --git a/usr.sbin/ospfd/parse.y b/usr.sbin/ospfd/parse.y
index c26ac5fa290..93a3518969d 100644
--- a/usr.sbin/ospfd/parse.y
+++ b/usr.sbin/ospfd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.69 2010/02/16 08:22:42 dlg Exp $ */
+/* $OpenBSD: parse.y,v 1.70 2010/02/16 08:39:05 dlg Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -87,6 +87,7 @@ struct config_defaults {
char auth_key[MAX_SIMPLE_AUTH_LEN];
struct auth_md_head md_list;
u_int32_t dead_interval;
+ u_int32_t fast_hello_interval;
u_int16_t transmit_delay;
u_int16_t hello_interval;
u_int16_t rxmt_interval;
@@ -119,17 +120,18 @@ typedef struct {
%token RFC1583COMPAT STUB ROUTER SPFDELAY SPFHOLDTIME EXTTAG
%token AUTHKEY AUTHTYPE AUTHMD AUTHMDKEYID
%token METRIC PASSIVE
-%token HELLOINTERVAL TRANSMITDELAY
+%token HELLOINTERVAL FASTHELLOINTERVAL TRANSMITDELAY
%token RETRANSMITINTERVAL ROUTERDEADTIME ROUTERPRIORITY
%token SET TYPE
%token YES NO
-%token MSEC
+%token MSEC MINIMAL
%token DEMOTE
%token INCLUDE
%token ERROR
%token <v.string> STRING
%token <v.number> NUMBER
%type <v.number> yesno no optlist optlist_l option demotecount msec
+%type <v.number> deadtime
%type <v.string> string
%type <v.redist> redistribute
@@ -449,12 +451,7 @@ defaults : METRIC NUMBER {
}
defs->priority = $2;
}
- | ROUTERDEADTIME NUMBER {
- if ($2 < MIN_RTR_DEAD_TIME || $2 > MAX_RTR_DEAD_TIME) {
- yyerror("router-dead-time out of range (%d-%d)",
- MIN_RTR_DEAD_TIME, MAX_RTR_DEAD_TIME);
- YYERROR;
- }
+ | ROUTERDEADTIME deadtime {
defs->dead_interval = $2;
}
| TRANSMITDELAY NUMBER {
@@ -475,6 +472,16 @@ defaults : METRIC NUMBER {
}
defs->hello_interval = $2;
}
+ | FASTHELLOINTERVAL MSEC NUMBER {
+ if ($3 < MIN_FAST_INTERVAL ||
+ $3 > MAX_FAST_INTERVAL) {
+ yyerror("fast-hello-interval msec out of "
+ "range (%d-%d)", MIN_FAST_INTERVAL,
+ MAX_FAST_INTERVAL);
+ YYERROR;
+ }
+ defs->fast_hello_interval = $3;
+ }
| RETRANSMITINTERVAL NUMBER {
if ($2 < MIN_RXMT_INTERVAL || $2 > MAX_RXMT_INTERVAL) {
yyerror("retransmit-interval out of range "
@@ -490,6 +497,18 @@ defaults : METRIC NUMBER {
| authmd
;
+deadtime : NUMBER {
+ if ($1 < MIN_RTR_DEAD_TIME || $1 > MAX_RTR_DEAD_TIME) {
+ yyerror("router-dead-time out of range (%d-%d)",
+ MIN_RTR_DEAD_TIME, MAX_RTR_DEAD_TIME);
+ YYERROR;
+ }
+ $$ = $1;
+ }
+ | MINIMAL {
+ $$ = FAST_RTR_DEAD_TIME;
+ }
+
optnl : '\n' optnl
|
;
@@ -613,8 +632,12 @@ interface : INTERFACE STRING {
defs = &ifacedefs;
} interface_block {
iface->dead_interval = defs->dead_interval;
+ iface->fast_hello_interval = defs->fast_hello_interval;
iface->transmit_delay = defs->transmit_delay;
- iface->hello_interval = defs->hello_interval;
+ if (iface->dead_interval == FAST_RTR_DEAD_TIME)
+ iface->hello_interval = 0;
+ else
+ iface->hello_interval = defs->hello_interval;
iface->rxmt_interval = defs->rxmt_interval;
iface->metric = defs->metric;
iface->priority = defs->priority;
@@ -699,10 +722,12 @@ lookup(char *s)
{"demote", DEMOTE},
{"external-tag", EXTTAG},
{"fib-update", FIBUPDATE},
+ {"fast-hello-interval", FASTHELLOINTERVAL},
{"hello-interval", HELLOINTERVAL},
{"include", INCLUDE},
{"interface", INTERFACE},
{"metric", METRIC},
+ {"minimal", MINIMAL},
{"msec", MSEC},
{"no", NO},
{"passive", PASSIVE},
@@ -1055,6 +1080,7 @@ parse_config(char *filename, int opts)
defs = &globaldefs;
TAILQ_INIT(&defs->md_list);
defs->dead_interval = DEFAULT_RTR_DEAD_TIME;
+ defs->fast_hello_interval = DEFAULT_FAST_INTERVAL;
defs->transmit_delay = DEFAULT_TRANSMIT_DELAY;
defs->hello_interval = DEFAULT_HELLO_INTERVAL;
defs->rxmt_interval = DEFAULT_RXMT_INTERVAL;
diff --git a/usr.sbin/ospfd/printconf.c b/usr.sbin/ospfd/printconf.c
index 0b2b65b54cf..a99efa484ea 100644
--- a/usr.sbin/ospfd/printconf.c
+++ b/usr.sbin/ospfd/printconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printconf.c,v 1.14 2010/02/16 08:22:42 dlg Exp $ */
+/* $OpenBSD: printconf.c,v 1.15 2010/02/16 08:39:05 dlg Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -115,7 +115,6 @@ print_iface(struct iface *iface)
printf("\tinterface %s:%s {\n", iface->name, inet_ntoa(iface->addr));
- printf("\t\thello-interval %d\n", iface->hello_interval);
printf("\t\tmetric %d\n", iface->metric);
if (iface->passive)
@@ -124,7 +123,14 @@ print_iface(struct iface *iface)
printf("\t\tdemote %s\n", iface->demote_group);
printf("\t\tretransmit-interval %d\n", iface->rxmt_interval);
- printf("\t\trouter-dead-time %d\n", iface->dead_interval);
+ if (iface->dead_interval == FAST_RTR_DEAD_TIME) {
+ printf("\t\trouter-dead-time minimal\n");
+ printf("\t\tfast-hello-interval msec %u\n",
+ iface->fast_hello_interval);
+ } else {
+ printf("\t\trouter-dead-time %d\n", iface->dead_interval);
+ printf("\t\thello-interval %d\n", iface->hello_interval);
+ }
printf("\t\trouter-priority %d\n", iface->priority);
printf("\t\ttransmit-delay %d\n", iface->transmit_delay);