diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2019-02-14 13:13:34 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2019-02-14 13:13:34 +0000 |
commit | dd14bdf00843467e4603059720bfadb4393a8b45 (patch) | |
tree | ad18cd534ed3c99d5d1f7f4e07603b4f91959215 /usr.sbin/bgpd | |
parent | 52df606b1f5911fa3ceaec622e99ce94791fb214 (diff) |
mrt_timeout should just return -1 when there is no timeout set instead
of some strange maximum. The poll loop in bgpd.c already limits the
maximum wait time so there is no need to double it.
While there switch to using time_t for the calculation.
OK phessler@
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r-- | usr.sbin/bgpd/bgpd.c | 9 | ||||
-rw-r--r-- | usr.sbin/bgpd/bgpd.h | 5 | ||||
-rw-r--r-- | usr.sbin/bgpd/mrt.c | 11 |
3 files changed, 13 insertions, 12 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c index 79c00368808..1e42d93eb52 100644 --- a/usr.sbin/bgpd/bgpd.c +++ b/usr.sbin/bgpd/bgpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.c,v 1.210 2019/02/14 10:38:04 claudio Exp $ */ +/* $OpenBSD: bgpd.c,v 1.211 2019/02/14 13:13:33 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -102,13 +102,14 @@ main(int argc, char *argv[]) struct bgpd_config *conf; struct peer *peer_l, *p; struct pollfd pfd[POLL_MAX]; + time_t timeout; pid_t se_pid = 0, rde_pid = 0, pid; char *conffile; char *saved_argv0; int debug = 0; int rflag = 0, sflag = 0; int rfd = -1; - int ch, timeout, status; + int ch, status; int pipe_m2s[2]; int pipe_m2r[2]; @@ -262,9 +263,9 @@ BROKEN if (pledge("stdio rpath wpath cpath fattr unix route recvfd sendfd", pfd[PFD_SOCK_ROUTE].events = POLLIN; timeout = mrt_timeout(conf->mrt); - if (timeout > MAX_TIMEOUT) - timeout = MAX_TIMEOUT; + if (timeout < 0 || timeout > MAX_TIMEOUT) + timeout = MAX_TIMEOUT; if (poll(pfd, POLL_MAX, timeout * 1000) == -1) if (errno != EINTR) { log_warn("poll error"); diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index 317df573863..041efa98563 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.367 2019/02/14 10:38:04 claudio Exp $ */ +/* $OpenBSD: bgpd.h,v 1.368 2019/02/14 13:13:33 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -1093,7 +1093,6 @@ struct rde_hashstats { #define MRT_FILE_LEN 512 #define MRT2MC(x) ((struct mrt_config *)(x)) -#define MRT_MAX_TIMEOUT 7200 enum mrt_type { MRT_NONE, @@ -1195,7 +1194,7 @@ void mrt_clear_seq(void); void mrt_write(struct mrt *); void mrt_clean(struct mrt *); void mrt_init(struct imsgbuf *, struct imsgbuf *); -int mrt_timeout(struct mrt_head *); +time_t mrt_timeout(struct mrt_head *); void mrt_reconfigure(struct mrt_head *); void mrt_handler(struct mrt_head *); struct mrt *mrt_get(struct mrt_head *, struct mrt *); diff --git a/usr.sbin/bgpd/mrt.c b/usr.sbin/bgpd/mrt.c index 5659c9abd1b..94834b0fac3 100644 --- a/usr.sbin/bgpd/mrt.c +++ b/usr.sbin/bgpd/mrt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mrt.c,v 1.91 2019/02/14 10:38:04 claudio Exp $ */ +/* $OpenBSD: mrt.c,v 1.92 2019/02/14 13:13:33 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> @@ -909,12 +909,12 @@ mrt_open(struct mrt *mrt, time_t now) return (1); } -int +time_t mrt_timeout(struct mrt_head *mrt) { struct mrt *m; time_t now; - int timeout = MRT_MAX_TIMEOUT; + time_t timeout = -1; now = time(NULL); LIST_FOREACH(m, mrt, entry) { @@ -925,11 +925,12 @@ mrt_timeout(struct mrt_head *mrt) MRT2MC(m)->ReopenTimer = now + MRT2MC(m)->ReopenTimerInterval; } - if (MRT2MC(m)->ReopenTimer - now < timeout) + if (timeout == -1 || + MRT2MC(m)->ReopenTimer - now < timeout) timeout = MRT2MC(m)->ReopenTimer - now; } } - return (timeout > 0 ? timeout : 0); + return (timeout); } void |