From cecb080267c037f0f026aa1029e950bf9ca00309 Mon Sep 17 00:00:00 2001 From: job Date: Thu, 25 Nov 2021 14:03:40 +0000 Subject: [PATCH] Replace MAX_REPO_TIMEOUT with repo_timeout, which is set to 1/4th of timeout, or if timeout is disabled set to 24 hours. OK claudio@ --- usr.sbin/rpki-client/extern.h | 5 +---- usr.sbin/rpki-client/main.c | 9 ++++++++- usr.sbin/rpki-client/repo.c | 7 ++++--- usr.sbin/rpki-client/rpki-client.8 | 6 ++++-- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/usr.sbin/rpki-client/extern.h b/usr.sbin/rpki-client/extern.h index a41e2ccd1d6..bfee4fd0194 100644 --- a/usr.sbin/rpki-client/extern.h +++ b/usr.sbin/rpki-client/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.97 2021/11/24 15:24:16 claudio Exp $ */ +/* $OpenBSD: extern.h,v 1.98 2021/11/25 14:03:40 job Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -627,7 +627,4 @@ int mkpath(const char *); /* Maximum allowd repositories per tal */ #define MAX_REPO_PER_TAL 1000 -/* Timeout for repository synchronisation, in seconds */ -#define MAX_REPO_TIMEOUT (15 * 60) - #endif /* ! EXTERN_H */ diff --git a/usr.sbin/rpki-client/main.c b/usr.sbin/rpki-client/main.c index 36d43dc8d0c..3fba29ef0dc 100644 --- a/usr.sbin/rpki-client/main.c +++ b/usr.sbin/rpki-client/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.165 2021/11/19 09:47:30 job Exp $ */ +/* $OpenBSD: main.c,v 1.166 2021/11/25 14:03:40 job Exp $ */ /* * Copyright (c) 2021 Claudio Jeker * Copyright (c) 2019 Kristaps Dzonsons @@ -68,6 +68,7 @@ const char *bird_tablename = "ROAS"; int verbose; int noop; int rrdpon = 1; +int repo_timeout = 15*60; struct stats stats; @@ -753,6 +754,12 @@ main(int argc, char *argv[]) timeout = strtonum(optarg, 0, 24*60*60, &errs); if (errs) errx(1, "-s: %s", errs); + if (timeout == 0) + repo_timeout = 24*60*60; + else if (timeout < 1) + errx(1, "-s: %i too small", timeout); + else + repo_timeout = timeout / 4; break; case 't': if (talsz >= TALSZ_MAX) diff --git a/usr.sbin/rpki-client/repo.c b/usr.sbin/rpki-client/repo.c index 5c6aa5f17dd..506c84e8854 100644 --- a/usr.sbin/rpki-client/repo.c +++ b/usr.sbin/rpki-client/repo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: repo.c,v 1.13 2021/11/25 12:55:34 claudio Exp $ */ +/* $OpenBSD: repo.c,v 1.14 2021/11/25 14:03:40 job Exp $ */ /* * Copyright (c) 2021 Claudio Jeker * Copyright (c) 2019 Kristaps Dzonsons @@ -40,6 +40,7 @@ extern struct stats stats; extern int noop; extern int rrdpon; +extern int repo_timeout; enum repo_state { REPO_LOADING = 0, @@ -620,7 +621,7 @@ repo_alloc(int talid) rp->id = ++repoid; rp->talid = talid; - rp->alarm = getmonotime() + MAX_REPO_TIMEOUT; + rp->alarm = getmonotime() + repo_timeout; TAILQ_INIT(&rp->queue); SLIST_INSERT_HEAD(&repos, rp, entry); @@ -1227,7 +1228,7 @@ static void repo_fail(struct repo *rp) { /* reset the alarm since code may fallback to rsync */ - rp->alarm = getmonotime() + MAX_REPO_TIMEOUT; + rp->alarm = getmonotime() + repo_timeout; if (rp->ta) http_finish(rp->ta->id, HTTP_FAILED, NULL); diff --git a/usr.sbin/rpki-client/rpki-client.8 b/usr.sbin/rpki-client/rpki-client.8 index 46d4156f564..1d676739a6d 100644 --- a/usr.sbin/rpki-client/rpki-client.8 +++ b/usr.sbin/rpki-client/rpki-client.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: rpki-client.8,v 1.49 2021/10/26 13:26:53 claudio Exp $ +.\" $OpenBSD: rpki-client.8,v 1.50 2021/11/25 14:03:40 job Exp $ .\" .\" Copyright (c) 2019 Kristaps Dzonsons .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: October 26 2021 $ +.Dd $Mdocdate: November 25 2021 $ .Dt RPKI-CLIENT 8 .Os .Sh NAME @@ -131,6 +131,8 @@ seconds of runtime, because normal practice will restart from .Xr cron 8 . Disable by specifying 0. Defaults to 1 hour. +Individual Publication Points are timed out after one fourth of +.Em timeout . .It Fl T Ar table For BIRD output generated with the .Fl B -- 2.20.1