diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2013-06-01 19:28:56 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2013-06-01 19:28:56 +0000 |
commit | 0d280fd51bac4c2dbd825217f2df566e4074a5fd (patch) | |
tree | a44b2224392f45aa1486add1aef31f534d1cd203 /usr.sbin | |
parent | 0d6f6e84ba46d7cbfb788d215270ca2e88568678 (diff) |
The keepalive timeout should be configured on a global basis and not per
interface.
Remove the iface pointer from the 'nbr' structure because it's not
needed anymore.
Diff from Renato Westphal
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ldpd/hello.c | 4 | ||||
-rw-r--r-- | usr.sbin/ldpd/init.c | 10 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpd.conf.5 | 4 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpd.h | 6 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpe.h | 5 | ||||
-rw-r--r-- | usr.sbin/ldpd/neighbor.c | 8 | ||||
-rw-r--r-- | usr.sbin/ldpd/parse.y | 25 | ||||
-rw-r--r-- | usr.sbin/ldpd/printconf.c | 4 |
8 files changed, 30 insertions, 36 deletions
diff --git a/usr.sbin/ldpd/hello.c b/usr.sbin/ldpd/hello.c index d7e24d9919b..c8952ba843d 100644 --- a/usr.sbin/ldpd/hello.c +++ b/usr.sbin/ldpd/hello.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hello.c,v 1.17 2013/06/01 18:47:07 claudio Exp $ */ +/* $OpenBSD: hello.c,v 1.18 2013/06/01 19:28:55 claudio Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -129,7 +129,7 @@ recv_hello(struct iface *iface, struct in_addr src, char *buf, u_int16_t len) else a = address; - nbr = nbr_new(ldp.lsr_id, iface, a); + nbr = nbr_new(ldp.lsr_id, a); /* set neighbor parameters */ nbr->hello_type = flags; diff --git a/usr.sbin/ldpd/init.c b/usr.sbin/ldpd/init.c index cccc347bbca..0a940e562dd 100644 --- a/usr.sbin/ldpd/init.c +++ b/usr.sbin/ldpd/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.9 2013/06/01 18:47:07 claudio Exp $ */ +/* $OpenBSD: init.c,v 1.10 2013/06/01 19:28:55 claudio Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -37,6 +37,8 @@ #include "log.h" #include "ldpe.h" +extern struct ldpd_conf *leconf; + int gen_init_prms_tlv(struct ibuf *, struct nbr *, u_int16_t); int tlv_decode_opt_init_prms(char *, u_int16_t); @@ -100,8 +102,8 @@ recv_init(struct nbr *nbr, char *buf, u_int16_t len) return (-1); } - if (nbr->iface->keepalive < ntohs(sess.keepalive_time)) - nbr->keepalive = nbr->iface->keepalive; + if (leconf->keepalive < ntohs(sess.keepalive_time)) + nbr->keepalive = leconf->keepalive; else nbr->keepalive = ntohs(sess.keepalive_time); @@ -122,7 +124,7 @@ gen_init_prms_tlv(struct ibuf *buf, struct nbr *nbr, u_int16_t size) parms.type = htons(TLV_TYPE_COMMONSESSION); parms.length = htons(size); parms.proto_version = htons(LDP_VERSION); - parms.keepalive_time = htons(nbr->iface->keepalive); + parms.keepalive_time = htons(leconf->keepalive); parms.reserved = 0; parms.pvlim = 0; parms.max_pdu_len = 0; diff --git a/usr.sbin/ldpd/ldpd.conf.5 b/usr.sbin/ldpd/ldpd.conf.5 index 04ca539034e..1a31c010920 100644 --- a/usr.sbin/ldpd/ldpd.conf.5 +++ b/usr.sbin/ldpd/ldpd.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ldpd.conf.5,v 1.10 2013/06/01 18:47:07 claudio Exp $ +.\" $OpenBSD: ldpd.conf.5,v 1.11 2013/06/01 19:28:55 claudio Exp $ .\" .\" Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> .\" Copyright (c) 2005, 2006 Esben Norby <norby@openbsd.org> @@ -81,7 +81,7 @@ The default is Set the router ID; in combination with labelspace it forms the LSR-ID. .Pp .It Ic keepalive Ar seconds -Set the keepalive interval in seconds. +Set the keepalive timeout in seconds. The default value is 180; valid range is 1\-65535. .Pp .It Xo diff --git a/usr.sbin/ldpd/ldpd.h b/usr.sbin/ldpd/ldpd.h index 585880d701f..9fafcf2be02 100644 --- a/usr.sbin/ldpd/ldpd.h +++ b/usr.sbin/ldpd/ldpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpd.h,v 1.34 2013/06/01 18:47:07 claudio Exp $ */ +/* $OpenBSD: ldpd.h,v 1.35 2013/06/01 19:28:55 claudio Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -211,7 +211,6 @@ struct iface { int state; int mtu; u_int16_t holdtime; - u_int16_t keepalive; u_int16_t hello_interval; u_int16_t flags; enum iface_type type; @@ -253,6 +252,7 @@ struct ldpd_conf { int ldp_session_socket; int flags; u_int8_t mode; + u_int16_t keepalive; }; /* kroute */ @@ -312,7 +312,6 @@ struct ctl_iface { }; struct ctl_nbr { - char name[IF_NAMESIZE]; struct in_addr id; struct in_addr addr; struct in_addr dr; @@ -324,7 +323,6 @@ struct ctl_nbr { u_int32_t ls_retrans_lst_cnt; u_int32_t state_chng_cnt; int nbr_state; - int iface_state; u_int8_t priority; u_int8_t options; }; diff --git a/usr.sbin/ldpd/ldpe.h b/usr.sbin/ldpd/ldpe.h index 430a278ce9a..6148c95d193 100644 --- a/usr.sbin/ldpd/ldpe.h +++ b/usr.sbin/ldpd/ldpe.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpe.h,v 1.20 2013/06/01 18:47:07 claudio Exp $ */ +/* $OpenBSD: ldpe.h,v 1.21 2013/06/01 19:28:55 claudio Exp $ */ /* * Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org> @@ -54,7 +54,6 @@ struct nbr { struct in_addr id; struct ibuf_read *rbuf; - struct iface *iface; time_t uptime; u_int32_t peerid; /* unique ID in DB */ @@ -149,7 +148,7 @@ int if_set_tos(int, int); int if_set_reuse(int, int); /* neighbor.c */ -struct nbr *nbr_new(u_int32_t, struct iface *, struct in_addr); +struct nbr *nbr_new(u_int32_t, struct in_addr); void nbr_del(struct nbr *); struct nbr *nbr_find_ip(u_int32_t); diff --git a/usr.sbin/ldpd/neighbor.c b/usr.sbin/ldpd/neighbor.c index 64d0bb2005f..cb0a70409f4 100644 --- a/usr.sbin/ldpd/neighbor.c +++ b/usr.sbin/ldpd/neighbor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: neighbor.c,v 1.31 2013/06/01 18:47:07 claudio Exp $ */ +/* $OpenBSD: neighbor.c,v 1.32 2013/06/01 19:28:55 claudio Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -233,7 +233,7 @@ nbr_fsm(struct nbr *nbr, enum nbr_event event) } struct nbr * -nbr_new(u_int32_t nbr_id, struct iface *iface, struct in_addr a) +nbr_new(u_int32_t nbr_id, struct in_addr a) { struct nbr *nbr; @@ -244,7 +244,6 @@ nbr_new(u_int32_t nbr_id, struct iface *iface, struct in_addr a) nbr->state = NBR_STA_DOWN; nbr->id.s_addr = nbr_id; - nbr->iface = iface; nbr->addr = a; /* get next unused peerid */ @@ -661,12 +660,9 @@ nbr_to_ctl(struct nbr *nbr) static struct ctl_nbr nctl; struct timeval tv, now, res; - memcpy(nctl.name, nbr->iface->name, sizeof(nctl.name)); memcpy(&nctl.id, &nbr->id, sizeof(nctl.id)); memcpy(&nctl.addr, &nbr->addr, sizeof(nctl.addr)); - nctl.nbr_state = nbr->state; - nctl.iface_state = nbr->iface->state; gettimeofday(&now, NULL); if (evtimer_pending(&nbr->inactivity_timer, &tv)) { diff --git a/usr.sbin/ldpd/parse.y b/usr.sbin/ldpd/parse.y index 31f3a31078e..77e643c62a8 100644 --- a/usr.sbin/ldpd/parse.y +++ b/usr.sbin/ldpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.13 2013/06/01 18:47:07 claudio Exp $ */ +/* $OpenBSD: parse.y,v 1.14 2013/06/01 19:28:55 claudio Exp $ */ /* * Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org> @@ -87,9 +87,7 @@ struct iface *iface = NULL; struct config_defaults { u_int16_t holdtime; - u_int16_t keepalive; u_int16_t hello_interval; - u_int8_t mode; }; struct config_defaults globaldefs; @@ -213,6 +211,15 @@ conf_main : ROUTERID STRING { YYERROR; } } + | KEEPALIVE NUMBER { + if ($2 < MIN_KEEPALIVE || + $2 > MAX_KEEPALIVE) { + yyerror("keepalive out of range (%d-%d)", + MIN_KEEPALIVE, MAX_KEEPALIVE); + YYERROR; + } + conf->keepalive = $2; + } | defaults ; defaults : HOLDTIME NUMBER { @@ -224,15 +231,6 @@ defaults : HOLDTIME NUMBER { } defs->holdtime = $2; } - | KEEPALIVE NUMBER { - if ($2 < MIN_KEEPALIVE || - $2 > MAX_KEEPALIVE) { - yyerror("keepalive out of range (%d-%d)", - MIN_KEEPALIVE, MAX_KEEPALIVE); - YYERROR; - } - defs->keepalive = $2; - } | HELLOINTERVAL NUMBER { if ($2 < MIN_HELLO_INTERVAL || $2 > MAX_HELLO_INTERVAL) { @@ -299,7 +297,6 @@ interface : INTERFACE STRING { defs = &ifacedefs; } interface_block { iface->holdtime = defs->holdtime; - iface->keepalive = defs->keepalive; iface->hello_interval = defs->hello_interval; iface = NULL; @@ -686,11 +683,11 @@ parse_config(char *filename, int opts) if ((conf = calloc(1, sizeof(struct ldpd_conf))) == NULL) fatal("parse_config"); conf->opts = opts; + conf->keepalive = DEFAULT_KEEPALIVE; bzero(&globaldefs, sizeof(globaldefs)); defs = &globaldefs; defs->holdtime = DEFAULT_HOLDTIME; - defs->keepalive = DEFAULT_KEEPALIVE; defs->hello_interval = DEFAULT_HELLO_INTERVAL; conf->mode = (MODE_DIST_INDEPENDENT | MODE_RET_LIBERAL | diff --git a/usr.sbin/ldpd/printconf.c b/usr.sbin/ldpd/printconf.c index 3cfbcda0e13..fce387a9f13 100644 --- a/usr.sbin/ldpd/printconf.c +++ b/usr.sbin/ldpd/printconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: printconf.c,v 1.4 2013/06/01 18:35:02 claudio Exp $ */ +/* $OpenBSD: printconf.c,v 1.5 2013/06/01 19:28:55 claudio Exp $ */ /* * Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org> @@ -50,6 +50,8 @@ print_mainconf(struct ldpd_conf *conf) printf("advertisement ondemand\n"); else printf("advertisement unsolicited\n"); + + printf("keepalive %u\n", conf->keepalive); } void |