diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2012-09-18 09:45:52 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2012-09-18 09:45:52 +0000 |
commit | 8e3a0bd30351f06e84bde4a5f627c11842819e1f (patch) | |
tree | b0e71ce92c1e4d84d28733ba8ec0f33df5a23bdc /usr.sbin | |
parent | 3ca5cf3cbd3e1c182a2e36bcd033ef9bf7540b6d (diff) |
Only allow one reload request at a time in bgpd. Needed for further work.
OK sthen@, benno@, henning@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bgpd/bgpd.c | 22 | ||||
-rw-r--r-- | usr.sbin/bgpd/bgpd.h | 3 | ||||
-rw-r--r-- | usr.sbin/bgpd/log.h | 3 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde.c | 4 | ||||
-rw-r--r-- | usr.sbin/bgpd/session.c | 4 |
5 files changed, 29 insertions, 7 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c index cc860449726..13b576d7dd3 100644 --- a/usr.sbin/bgpd/bgpd.c +++ b/usr.sbin/bgpd/bgpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.c,v 1.168 2011/08/20 19:02:28 sthen Exp $ */ +/* $OpenBSD: bgpd.c,v 1.169 2012/09/18 09:45:51 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -53,6 +53,7 @@ volatile sig_atomic_t quit; volatile sig_atomic_t sigchld; volatile sig_atomic_t reconfig; pid_t reconfpid; +int reconfpending; struct imsgbuf *ibuf_se; struct imsgbuf *ibuf_rde; struct rib_names ribnames = SIMPLEQ_HEAD_INITIALIZER(ribnames); @@ -293,7 +294,6 @@ main(int argc, char *argv[]) u_int error; reconfig = 0; - log_info("rereading config"); switch (reconfigure(conffile, &conf, &mrt_l, &peer_l)) { case -1: /* fatal error */ quit = 1; @@ -301,6 +301,9 @@ main(int argc, char *argv[]) case 0: /* all OK */ error = 0; break; + case 2: + error = CTL_RES_PENDING; + break; default: /* parse error */ error = CTL_RES_PARSE_ERROR; break; @@ -422,6 +425,13 @@ reconfigure(char *conffile, struct bgpd_config *conf, struct mrt_head *mrt_l, struct rde_rib *rr; struct rdomain *rd; + if (reconfpending) { + log_info("previous reload still running"); + return (2); + } + reconfpending = 2; /* one per child */ + + log_info("rereading config"); if (parse_config(conffile, conf, mrt_l, peer_l, &net_l, &rules_l, &rdom_l)) { log_warnx("config file %s has errors, not reloading", @@ -643,9 +653,10 @@ dispatch_imsg(struct imsgbuf *ibuf, int idx) case IMSG_CTL_RELOAD: if (idx != PFD_PIPE_SESSION) log_warnx("reload request not from SE"); - else + else { reconfig = 1; reconfpid = imsg.hdr.pid; + } break; case IMSG_CTL_FIB_COUPLE: if (idx != PFD_PIPE_SESSION) @@ -695,6 +706,11 @@ dispatch_imsg(struct imsgbuf *ibuf, int idx) memcpy(&verbose, imsg.data, sizeof(verbose)); log_verbose(verbose); break; + case IMSG_RECONF_DONE: + if (reconfpending == 0) + log_warnx("unexpected RECONF_DONE received"); + reconfpending--; + break; default: break; } diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index 85736efe262..a188907850d 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.271 2012/09/12 05:56:22 claudio Exp $ */ +/* $OpenBSD: bgpd.h,v 1.272 2012/09/18 09:45:51 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -417,6 +417,7 @@ enum ctl_results { CTL_RES_DENIED, CTL_RES_NOCAP, CTL_RES_PARSE_ERROR, + CTL_RES_PENDING, CTL_RES_NOMEM }; diff --git a/usr.sbin/bgpd/log.h b/usr.sbin/bgpd/log.h index 54444949ec4..c15f482e343 100644 --- a/usr.sbin/bgpd/log.h +++ b/usr.sbin/bgpd/log.h @@ -1,4 +1,4 @@ -/* $OpenBSD: log.h,v 1.13 2012/06/10 11:16:08 claudio Exp $ */ +/* $OpenBSD: log.h,v 1.14 2012/09/18 09:45:51 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -117,6 +117,7 @@ static const char * const ctl_res_strerror[] = { "permission denied", "neighbor does not have this capability", "config file has errors, reload failed", + "previous reload still running", "out of memory" }; diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index 242d9171fa6..cc34a065a3e 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.319 2012/09/17 18:03:28 miod Exp $ */ +/* $OpenBSD: rde.c,v 1.320 2012/09/18 09:45:51 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -882,6 +882,8 @@ rde_dispatch_imsg_parent(struct imsgbuf *ibuf) rules_l = newrules; log_info("RDE reconfigured"); + imsg_compose(ibuf_main, IMSG_RECONF_DONE, 0, 0, + -1, NULL, 0); break; case IMSG_NEXTHOP_UPDATE: nexthop_update(imsg.data); diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index 878f3eb1611..598f02d4f6e 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.324 2012/09/12 05:56:22 claudio Exp $ */ +/* $OpenBSD: session.c,v 1.325 2012/09/18 09:45:50 claudio Exp $ */ /* * Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org> @@ -2718,6 +2718,8 @@ session_dispatch_imsg(struct imsgbuf *ibuf, int idx, u_int *listener_cnt) nconf = NULL; pending_reconf = 0; log_info("SE reconfigured"); + imsg_compose(ibuf_main, IMSG_RECONF_DONE, 0, 0, + -1, NULL, 0); break; case IMSG_IFINFO: if (idx != PFD_PIPE_MAIN) |