From 52c68f7659b12bec7c8ef0539aca056f2550327b Mon Sep 17 00:00:00 2001 From: Claudio Jeker Date: Thu, 30 May 2013 16:14:51 +0000 Subject: Simplify hello holdtime calculation and stop the timeout timer if the holdtime is "infinite". Diff from Renato Westphal [renatowestphal at gmail.com] --- usr.sbin/ldpd/hello.c | 23 ++++++++--------------- usr.sbin/ldpd/ldp.h | 5 ++--- usr.sbin/ldpd/neighbor.c | 7 +++++-- 3 files changed, 15 insertions(+), 20 deletions(-) (limited to 'usr.sbin') 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 @@ -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 @@ -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 @@ -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); -- cgit v1.2.3