summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2018-09-29 07:58:07 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2018-09-29 07:58:07 +0000
commitd036d37464c59cd3ed85183b9251d7de0622e405 (patch)
tree2588cf8fc30899ee17c0407203ff0b14679db2a9
parenta81999f645d29a3b581ec2deb1491fba67308a2a (diff)
With the introduction of sets the config that is shipped to the RDE got
potentially much bigger. In bad cases the SE activated the config way before the RDE which is not ideal. Introduce IMSG_RECONF_DRAIN which acts as a barrier and ensures that both childs got all the config. Only after that the IMSG_RECONF_DONE message is sent activating the config in the childs more or less simultaneous. OK benno@
-rw-r--r--usr.sbin/bgpd/bgpd.c30
-rw-r--r--usr.sbin/bgpd/bgpd.h3
-rw-r--r--usr.sbin/bgpd/rde.c6
-rw-r--r--usr.sbin/bgpd/session.c8
4 files changed, 39 insertions, 8 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c
index 7c2e215b2a9..bc7a0445f16 100644
--- a/usr.sbin/bgpd/bgpd.c
+++ b/usr.sbin/bgpd/bgpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.c,v 1.202 2018/09/25 07:58:11 claudio Exp $ */
+/* $OpenBSD: bgpd.c,v 1.203 2018/09/29 07:58:06 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -632,8 +632,10 @@ reconfigure(char *conffile, struct bgpd_config *conf, struct peer **peer_l)
free(rd);
}
- /* signal the SE first then the RDE to activate the new config */
- if (imsg_compose(ibuf_se, IMSG_RECONF_DONE, 0, 0, -1, NULL, 0) == -1)
+ /* send a drain message to know when all messages where processed */
+ if (imsg_compose(ibuf_se, IMSG_RECONF_DRAIN, 0, 0, -1, NULL, 0) == -1)
+ return (-1);
+ if (imsg_compose(ibuf_rde, IMSG_RECONF_DRAIN, 0, 0, -1, NULL, 0) == -1)
return (-1);
/* mrt changes can be sent out of bound */
@@ -785,9 +787,11 @@ dispatch_imsg(struct imsgbuf *ibuf, int idx, struct bgpd_config *conf)
log_setverbose(verbose);
break;
case IMSG_RECONF_DONE:
- if (reconfpending == 0)
+ if (reconfpending == 0) {
log_warnx("unexpected RECONF_DONE received");
- else if (reconfpending == 2) {
+ break;
+ }
+ if (idx == PFD_PIPE_SESSION) {
imsg_compose(ibuf_rde, IMSG_RECONF_DONE, 0,
0, -1, NULL, 0);
@@ -799,6 +803,22 @@ dispatch_imsg(struct imsgbuf *ibuf, int idx, struct bgpd_config *conf)
}
reconfpending--;
break;
+ case IMSG_RECONF_DRAIN:
+ if (reconfpending == 0) {
+ log_warnx("unexpected RECONF_DRAIN received");
+ break;
+ }
+ reconfpending--;
+ if (reconfpending == 0) {
+ /*
+ * SE goes first to bring templated neighbors
+ * in sync.
+ */
+ imsg_compose(ibuf_se, IMSG_RECONF_DONE, 0,
+ 0, -1, NULL, 0);
+ reconfpending = 2; /* expecting 2 DONE msg */
+ }
+ break;
default:
break;
}
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h
index 08fac2c5ceb..b35e09fd804 100644
--- a/usr.sbin/bgpd/bgpd.h
+++ b/usr.sbin/bgpd/bgpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.h,v 1.345 2018/09/26 15:48:01 claudio Exp $ */
+/* $OpenBSD: bgpd.h,v 1.346 2018/09/29 07:58:06 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -435,6 +435,7 @@ enum imsg_type {
IMSG_RECONF_AS_SET_DONE,
IMSG_RECONF_ROA_SET,
IMSG_RECONF_ROA_AS_SET_ITEMS,
+ IMSG_RECONF_DRAIN,
IMSG_RECONF_DONE,
IMSG_UPDATE,
IMSG_UPDATE_ERR,
diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c
index 21d40c97614..53c0b4078aa 100644
--- a/usr.sbin/bgpd/rde.c
+++ b/usr.sbin/bgpd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.428 2018/09/29 07:43:36 claudio Exp $ */
+/* $OpenBSD: rde.c,v 1.429 2018/09/29 07:58:06 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -984,6 +984,10 @@ rde_dispatch_imsg_parent(struct imsgbuf *ibuf)
case IMSG_RECONF_RDOMAIN_DONE:
parent_set = NULL;
break;
+ case IMSG_RECONF_DRAIN:
+ imsg_compose(ibuf_main, IMSG_RECONF_DRAIN, 0, 0,
+ -1, NULL, 0);
+ break;
case IMSG_RECONF_DONE:
if (nconf == NULL)
fatalx("got IMSG_RECONF_DONE but no config");
diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c
index e106927a815..b680a72c869 100644
--- a/usr.sbin/bgpd/session.c
+++ b/usr.sbin/bgpd/session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.c,v 1.368 2018/09/20 11:06:04 benno Exp $ */
+/* $OpenBSD: session.c,v 1.369 2018/09/29 07:58:06 claudio Exp $ */
/*
* Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org>
@@ -2733,6 +2733,12 @@ session_dispatch_imsg(struct imsgbuf *ibuf, int idx, u_int *listener_cnt)
csock = imsg.fd;
}
break;
+ case IMSG_RECONF_DRAIN:
+ if (idx != PFD_PIPE_MAIN)
+ fatalx("reconf request not from parent");
+ imsg_compose(ibuf_main, IMSG_RECONF_DRAIN, 0, 0,
+ -1, NULL, 0);
+ break;
case IMSG_RECONF_DONE:
if (idx != PFD_PIPE_MAIN)
fatalx("reconf request not from parent");