diff options
author | 2016-05-23 15:41:04 +0000 | |
---|---|---|
committer | 2016-05-23 15:41:04 +0000 | |
commit | 3d39db89ef50da4a6d521173acaf49641ee2c5d9 (patch) | |
tree | 0875f5764d982a5e86b7ec09286920469a7b52eb | |
parent | Filter our RTM_GET messages which are not from us. (diff) | |
download | wireguard-openbsd-3d39db89ef50da4a6d521173acaf49641ee2c5d9.tar.xz wireguard-openbsd-3d39db89ef50da4a6d521173acaf49641ee2c5d9.zip |
Allow setting the session holdtime per neighbor.
-rw-r--r-- | usr.sbin/ldpd/init.c | 7 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpd.c | 3 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpd.conf.5 | 6 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpe.h | 3 | ||||
-rw-r--r-- | usr.sbin/ldpd/neighbor.c | 14 | ||||
-rw-r--r-- | usr.sbin/ldpd/parse.y | 16 | ||||
-rw-r--r-- | usr.sbin/ldpd/printconf.c | 4 |
7 files changed, 41 insertions, 12 deletions
diff --git a/usr.sbin/ldpd/init.c b/usr.sbin/ldpd/init.c index b888d8be954..4879ccce941 100644 --- a/usr.sbin/ldpd/init.c +++ b/usr.sbin/ldpd/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.16 2016/05/23 15:14:07 renato Exp $ */ +/* $OpenBSD: init.c,v 1.17 2016/05/23 15:41:04 renato Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -106,7 +106,8 @@ recv_init(struct nbr *nbr, char *buf, u_int16_t len) return (-1); } - nbr->keepalive = min(leconf->keepalive, ntohs(sess.keepalive_time)); + nbr->keepalive = min(nbr_get_keepalive(nbr->addr), + ntohs(sess.keepalive_time)); if (!nbr_pending_idtimer(nbr)) nbr_fsm(nbr, NBR_EVT_INIT_RCVD); @@ -126,7 +127,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(leconf->keepalive); + parms.keepalive_time = htons(nbr_get_keepalive(nbr->addr)); parms.reserved = 0; parms.pvlim = 0; parms.max_pdu_len = 0; diff --git a/usr.sbin/ldpd/ldpd.c b/usr.sbin/ldpd/ldpd.c index 4de47ec6a1c..318ccd120dd 100644 --- a/usr.sbin/ldpd/ldpd.c +++ b/usr.sbin/ldpd/ldpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpd.c,v 1.29 2016/05/23 15:14:07 renato Exp $ */ +/* $OpenBSD: ldpd.c,v 1.30 2016/05/23 15:41:04 renato Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -719,6 +719,7 @@ merge_config(struct ldpd_conf *conf, struct ldpd_conf *xconf) } /* update existing nbrps */ + nbrp->keepalive = xn->keepalive; nbrp->auth.method = xn->auth.method; strlcpy(nbrp->auth.md5key, xn->auth.md5key, sizeof(nbrp->auth.md5key)); diff --git a/usr.sbin/ldpd/ldpd.conf.5 b/usr.sbin/ldpd/ldpd.conf.5 index c59f9083ef3..ef32391294e 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.20 2016/05/23 15:36:53 renato Exp $ +.\" $OpenBSD: ldpd.conf.5,v 1.21 2016/05/23 15:41:04 renato Exp $ .\" .\" Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> .\" Copyright (c) 2005, 2006 Esben Norby <norby@openbsd.org> @@ -179,6 +179,10 @@ neighbor A.B.C.D { .Pp Neighbor-specific parameters are listed below. .Bl -tag -width Ds +.It Ic keepalive Ar seconds +Set the keepalive timeout in seconds. +Inherited from the global configuration if not given. +The default value is 180; valid range is 1\-65535. .It Ic password Ar secret Enable TCP MD5 signatures per RFC 5036. .El diff --git a/usr.sbin/ldpd/ldpe.h b/usr.sbin/ldpd/ldpe.h index e5fc4848f61..ceee13bf4c6 100644 --- a/usr.sbin/ldpd/ldpe.h +++ b/usr.sbin/ldpd/ldpe.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpe.h,v 1.42 2015/07/21 05:02:57 renato Exp $ */ +/* $OpenBSD: ldpe.h,v 1.43 2016/05/23 15:41:04 renato Exp $ */ /* * Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org> @@ -220,6 +220,7 @@ int nbr_pending_idtimer(struct nbr *); int nbr_pending_connect(struct nbr *); int nbr_establish_connection(struct nbr *); +uint16_t nbr_get_keepalive(struct in_addr); struct nbr_params *nbr_params_new(struct in_addr); struct nbr_params *nbr_params_find(struct ldpd_conf *, struct in_addr); diff --git a/usr.sbin/ldpd/neighbor.c b/usr.sbin/ldpd/neighbor.c index 81b42a8ab74..79cc6e33be9 100644 --- a/usr.sbin/ldpd/neighbor.c +++ b/usr.sbin/ldpd/neighbor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: neighbor.c,v 1.53 2016/05/23 15:14:07 renato Exp $ */ +/* $OpenBSD: neighbor.c,v 1.54 2016/05/23 15:41:04 renato Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -598,6 +598,18 @@ nbr_params_find(struct ldpd_conf *xconf, struct in_addr addr) return (NULL); } +uint16_t +nbr_get_keepalive(struct in_addr addr) +{ + struct nbr_params *nbrp; + + nbrp = nbr_params_find(leconf, addr); + if (nbrp && (nbrp->flags & F_NBRP_KEEPALIVE)) + return (nbrp->keepalive); + + return (leconf->keepalive); +} + struct ctl_nbr * nbr_to_ctl(struct nbr *nbr) { diff --git a/usr.sbin/ldpd/parse.y b/usr.sbin/ldpd/parse.y index c8f971ef8e3..7b2dc2d48a0 100644 --- a/usr.sbin/ldpd/parse.y +++ b/usr.sbin/ldpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.34 2016/05/23 15:32:48 renato Exp $ */ +/* $OpenBSD: parse.y,v 1.35 2016/05/23 15:41:04 renato Exp $ */ /* * Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org> @@ -233,8 +233,7 @@ conf_main : ROUTERID STRING { conf->flags |= LDPD_FLAG_TH_ACCEPT; } | KEEPALIVE NUMBER { - if ($2 < MIN_KEEPALIVE || - $2 > MAX_KEEPALIVE) { + if ($2 < MIN_KEEPALIVE || $2 > MAX_KEEPALIVE) { yyerror("keepalive out of range (%d-%d)", MIN_KEEPALIVE, MAX_KEEPALIVE); YYERROR; @@ -287,7 +286,16 @@ tnbr_defaults : THELLOHOLDTIME NUMBER { } ; -nbr_opts : PASSWORD STRING { +nbr_opts : KEEPALIVE NUMBER { + if ($2 < MIN_KEEPALIVE || $2 > MAX_KEEPALIVE) { + yyerror("keepalive out of range (%d-%d)", + MIN_KEEPALIVE, MAX_KEEPALIVE); + YYERROR; + } + nbrp->keepalive = $2; + nbrp->flags |= F_NBRP_KEEPALIVE; + } + | PASSWORD STRING { if (strlcpy(nbrp->auth.md5key, $2, sizeof(nbrp->auth.md5key)) >= sizeof(nbrp->auth.md5key)) { diff --git a/usr.sbin/ldpd/printconf.c b/usr.sbin/ldpd/printconf.c index 1ac3a0dece6..1a12fab968d 100644 --- a/usr.sbin/ldpd/printconf.c +++ b/usr.sbin/ldpd/printconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: printconf.c,v 1.11 2015/07/21 04:52:29 renato Exp $ */ +/* $OpenBSD: printconf.c,v 1.12 2016/05/23 15:41:04 renato Exp $ */ /* * Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org> @@ -75,6 +75,8 @@ void print_nbrp(struct nbr_params *nbrp) { printf("\nneighbor %s {\n", inet_ntoa(nbrp->addr)); + if (nbrp->flags & F_NBRP_KEEPALIVE) + printf("\tkeepalive %u\n", nbrp->keepalive); if (nbrp->auth.method == AUTH_MD5SIG) printf("\tpassword XXXXXX\n"); printf("}\n"); |