diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2013-05-30 16:14:51 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2013-05-30 16:14:51 +0000 |
commit | 52c68f7659b12bec7c8ef0539aca056f2550327b (patch) | |
tree | 5895c2f329f04742df05988cea9deabc5504b350 /usr.sbin | |
parent | 6f30701e5e6932a58f7914d96db0f8a13323dd20 (diff) |
Simplify hello holdtime calculation and stop the timeout timer if the
holdtime is "infinite".
Diff from Renato Westphal [renatowestphal at gmail.com]
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ldpd/hello.c | 23 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldp.h | 5 | ||||
-rw-r--r-- | usr.sbin/ldpd/neighbor.c | 7 |
3 files changed, 15 insertions, 20 deletions
diff --git a/usr.sbin/ldpd/hello.c b/usr.sbin/ldpd/hello.c index 3a3c3bf8923..3bf9be54bd1 100644 --- a/usr.sbin/ldpd/hello.c +++ b/usr.sbin/ldpd/hello.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hello.c,v 1.12 2011/03/12 01:57:13 claudio Exp $ */ +/* $OpenBSD: hello.c,v 1.13 2013/05/30 16:14:50 claudio Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -136,21 +136,14 @@ recv_hello(struct iface *iface, struct in_addr src, char *buf, u_int16_t len) /* set neighbor parameters */ nbr->hello_type = flags; - if (holdtime == 0) { - /* XXX: lacks support for targeted hellos */ - if (iface->holdtime < LINK_DFLT_HOLDTIME) - nbr->holdtime = iface->holdtime; - else - nbr->holdtime = LINK_DFLT_HOLDTIME; - } else if (holdtime == INFINITE_HOLDTIME) { - /* No timeout for this neighbor */ + /* XXX: lacks support for targeted hellos */ + if (holdtime == 0) + holdtime = LINK_DFLT_HOLDTIME; + + if (iface->holdtime < holdtime) nbr->holdtime = iface->holdtime; - } else { - if (iface->holdtime < holdtime) - nbr->holdtime = iface->holdtime; - else - nbr->holdtime = holdtime; - } + else + nbr->holdtime = holdtime; } nbr_fsm(nbr, NBR_EVT_HELLO_RCVD); diff --git a/usr.sbin/ldpd/ldp.h b/usr.sbin/ldpd/ldp.h index 62e1f667be3..6558bbedbd3 100644 --- a/usr.sbin/ldpd/ldp.h +++ b/usr.sbin/ldpd/ldp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ldp.h,v 1.9 2011/01/10 11:58:39 claudio Exp $ */ +/* $OpenBSD: ldp.h,v 1.10 2013/05/30 16:14:50 claudio Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -31,13 +31,13 @@ #define LDP_MAX_LEN 4096 -#define INFINITE_TMR (-1) #define LINK_DFLT_HOLDTIME 15 #define TARGETED_DFLT_HOLDTIME 45 #define DEFAULT_HOLDTIME 15 #define MIN_HOLDTIME 1 #define MAX_HOLDTIME 0xffff +#define INFINITE_HOLDTIME 0xffff #define DEFAULT_KEEPALIVE 180 #define MIN_KEEPALIVE 1 @@ -94,7 +94,6 @@ struct ldp_hdr { } __packed; #define LDP_HDR_SIZE 10 -#define INFINITE_HOLDTIME 0xffff /* TLV record */ struct tlv { diff --git a/usr.sbin/ldpd/neighbor.c b/usr.sbin/ldpd/neighbor.c index 4331c97c9b7..f25e0f22354 100644 --- a/usr.sbin/ldpd/neighbor.c +++ b/usr.sbin/ldpd/neighbor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: neighbor.c,v 1.24 2011/03/12 01:57:13 claudio Exp $ */ +/* $OpenBSD: neighbor.c,v 1.25 2013/05/30 16:14:50 claudio Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -167,7 +167,10 @@ nbr_fsm(struct nbr *nbr, enum nbr_event event) switch (nbr_fsm_tbl[i].action) { case NBR_ACT_RST_ITIMER: case NBR_ACT_STRT_ITIMER: - nbr_start_itimer(nbr); + if (nbr->holdtime != INFINITE_HOLDTIME) + nbr_start_itimer(nbr); + else + nbr_stop_itimer(nbr); break; case NBR_ACT_RST_KTIMEOUT: nbr_start_ktimeout(nbr); |