diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2006-05-27 21:24:37 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2006-05-27 21:24:37 +0000 |
commit | 8170c37f9a8981056680aa66004e3454464d4987 (patch) | |
tree | f5ab4c9899d626d9c2f5e9fcef1881e748602648 /usr.sbin/bgpd | |
parent | 2d85c039d9f9bf43ce8804f85cd1bfe2ebc07774 (diff) |
Pass a IMSG_CTL_RESULT messgae back to bgpctl on reloads to indicate if
the reload was successful or not. OK henning@
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r-- | usr.sbin/bgpd/bgpd.c | 28 | ||||
-rw-r--r-- | usr.sbin/bgpd/bgpd.h | 5 | ||||
-rw-r--r-- | usr.sbin/bgpd/control.c | 4 | ||||
-rw-r--r-- | usr.sbin/bgpd/log.h | 5 | ||||
-rw-r--r-- | usr.sbin/bgpd/session.c | 3 |
5 files changed, 34 insertions, 11 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c index c5b4e24d129..3da06935170 100644 --- a/usr.sbin/bgpd/bgpd.c +++ b/usr.sbin/bgpd/bgpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.c,v 1.136 2006/04/26 20:00:03 claudio Exp $ */ +/* $OpenBSD: bgpd.c,v 1.137 2006/05/27 21:24:36 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -53,8 +53,9 @@ struct filter_set_head *staticset; struct filter_set_head *staticset6; volatile sig_atomic_t mrtdump = 0; volatile sig_atomic_t quit = 0; -volatile sig_atomic_t reconfig = 0; volatile sig_atomic_t sigchld = 0; +volatile sig_atomic_t reconfig = 0; +pid_t reconfpid = 0; struct imsgbuf *ibuf_se; struct imsgbuf *ibuf_rde; @@ -309,9 +310,27 @@ main(int argc, char *argv[]) } if (reconfig) { + u_int error; + reconfig = 0; log_info("rereading config"); - reconfigure(conffile, &conf, &mrt_l, &peer_l, rules_l); + switch (reconfigure(conffile, &conf, &mrt_l, &peer_l, + rules_l)) { + case -1: /* fatal error */ + quit = 1; + break; + case 0: /* all OK */ + error = 0; + break; + default: /* parse error */ + error = CTL_RES_PARSE_ERROR; + break; + } + if (reconfpid != 0) { + send_imsg_session(IMSG_CTL_RESULT, reconfpid, + &error, sizeof(error)); + reconfpid = 0; + } } if (sigchld) { @@ -421,7 +440,7 @@ reconfigure(char *conffile, struct bgpd_config *conf, struct mrt_head *mrt_l, if (parse_config(conffile, conf, mrt_l, peer_l, &net_l, rules_l)) { log_warnx("config file %s has errors, not reloading", conffile); - return (-1); + return (1); } cflags = conf->flags; @@ -596,6 +615,7 @@ dispatch_imsg(struct imsgbuf *ibuf, int idx) log_warnx("reload request not from SE"); else reconfig = 1; + reconfpid = imsg.hdr.pid; break; case IMSG_CTL_FIB_COUPLE: if (idx != PFD_PIPE_SESSION) diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index b35de4629da..c6d8e566d8d 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.200 2006/05/23 12:11:38 henning Exp $ */ +/* $OpenBSD: bgpd.h,v 1.201 2006/05/27 21:24:36 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -346,7 +346,8 @@ enum ctl_results { CTL_RES_OK, CTL_RES_NOSUCHPEER, CTL_RES_DENIED, - CTL_RES_NOCAP + CTL_RES_NOCAP, + CTL_RES_PARSE_ERROR }; /* needed for session.h parse prototype */ diff --git a/usr.sbin/bgpd/control.c b/usr.sbin/bgpd/control.c index 01dd6ba8085..d3a2ab64d0f 100644 --- a/usr.sbin/bgpd/control.c +++ b/usr.sbin/bgpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.51 2006/05/27 15:43:13 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.52 2006/05/27 21:24:36 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -271,7 +271,6 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt) 0, 0, -1, p, sizeof(struct peer)); imsg_compose(&c->ibuf, IMSG_CTL_END, 0, 0, -1, NULL, 0); break; - case IMSG_CTL_RELOAD: case IMSG_CTL_FIB_COUPLE: case IMSG_CTL_FIB_DECOUPLE: imsg_compose_parent(imsg.hdr.type, 0, NULL, 0); @@ -320,6 +319,7 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt) log_warnx("got IMSG_CTL_NEIGHBOR_ with " "wrong length"); break; + case IMSG_CTL_RELOAD: case IMSG_CTL_KROUTE: case IMSG_CTL_KROUTE_ADDR: case IMSG_CTL_SHOW_NEXTHOP: diff --git a/usr.sbin/bgpd/log.h b/usr.sbin/bgpd/log.h index b99e757dd9a..ee0a4b62305 100644 --- a/usr.sbin/bgpd/log.h +++ b/usr.sbin/bgpd/log.h @@ -1,4 +1,4 @@ -/* $OpenBSD: log.h,v 1.7 2006/05/23 12:11:38 henning Exp $ */ +/* $OpenBSD: log.h,v 1.8 2006/05/27 21:24:36 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -108,5 +108,6 @@ static const char * const ctl_res_strerror[] = { "no error", "no such neighbor", "permission denied", - "neighbor does not have this capability" + "neighbor does not have this capability", + "config file has errors, reload failed" }; diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index f537113c18e..a2317feffde 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.248 2006/05/27 15:43:13 claudio Exp $ */ +/* $OpenBSD: session.c,v 1.249 2006/05/27 21:24:36 claudio Exp $ */ /* * Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org> @@ -2394,6 +2394,7 @@ session_dispatch_imsg(struct imsgbuf *ibuf, int idx, u_int *listener_cnt) control_imsg_relay(&imsg); break; case IMSG_CTL_END: + case IMSG_CTL_RESULT: control_imsg_relay(&imsg); break; case IMSG_UPDATE: |