diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2003-12-17 19:26:27 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2003-12-17 19:26:27 +0000 |
commit | 3836b0551d6538053b77358121af0883adcccde5 (patch) | |
tree | f76ef78f4b530cfd94f4a4295fed769153890c18 /usr.sbin/bgpd | |
parent | d17ca583628738de2f82b146975342e5f16da78b (diff) |
send reconf requests to the RDE as well and handle them there; syncing peer
data with RIB missing
use same message in RDE and SE for consistency
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r-- | usr.sbin/bgpd/bgpd.c | 28 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde.c | 45 | ||||
-rw-r--r-- | usr.sbin/bgpd/session.c | 4 |
3 files changed, 58 insertions, 19 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c index f4dbf5d3c72..2125ca1d6f8 100644 --- a/usr.sbin/bgpd/bgpd.c +++ b/usr.sbin/bgpd/bgpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.c,v 1.1 2003/12/17 11:46:54 henning Exp $ */ +/* $OpenBSD: bgpd.c,v 1.2 2003/12/17 19:26:26 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -36,7 +36,7 @@ void sighdlr(int); void usage(void); int main(int, char *[]); -int reconfigure(char *, int, int *, struct bgpd_config *, +int reconfigure(char *, int, int *, int, int *, struct bgpd_config *, struct mrt_config *); int dispatch_imsg(int, int, struct mrt_config *, int, int *); @@ -244,7 +244,7 @@ main(int argc, char *argv[]) if (reconfig) { logit(LOG_CRIT, "rereading config"); reconfigure(conffile, pipe_m2s[0], &m2s_writes_queued, - &conf, &mrtconf); + pipe_m2r[0], &m2r_writes_queued, &conf, &mrtconf); LIST_FOREACH(mconf, &mrtconf, list) mrt_state(mconf, IMSG_NONE, pipe_m2r[0], &m2r_writes_queued); @@ -272,8 +272,8 @@ main(int argc, char *argv[]) } int -reconfigure(char *conffile, int fd, int *waiting, struct bgpd_config *conf, - struct mrt_config *mrtc) +reconfigure(char *conffile, int se_fd, int *se_waiting, int rde_fd, + int *rde_waiting, struct bgpd_config *conf, struct mrt_config *mrtc) { struct peer *p; @@ -282,12 +282,18 @@ reconfigure(char *conffile, int fd, int *waiting, struct bgpd_config *conf, conffile); return (-1); } - *waiting += imsg_compose(fd, IMSG_RECONF_CONF, 0, (u_char *)conf, - sizeof(struct bgpd_config)); - for (p = conf->peers; p != NULL; p = p->next) - *waiting += imsg_compose(fd, IMSG_RECONF_PEER, p->conf.id, - (u_char *)&p->conf, sizeof(struct peer_config)); - *waiting += imsg_compose(fd, IMSG_RECONF_DONE, 0, NULL, 0); + *se_waiting += imsg_compose(se_fd, IMSG_RECONF_CONF, 0, + (u_char *)conf, sizeof(struct bgpd_config)); + *rde_waiting += imsg_compose(rde_fd, IMSG_RECONF_CONF, 0, + (u_char *)conf, sizeof(struct bgpd_config)); + for (p = conf->peers; p != NULL; p = p->next) { + *se_waiting += imsg_compose(se_fd, IMSG_RECONF_PEER, + p->conf.id, (u_char *)&p->conf, sizeof(struct peer_config)); + *rde_waiting += imsg_compose(rde_fd, IMSG_RECONF_PEER, + p->conf.id, (u_char *)&p->conf, sizeof(struct peer_config)); + } + *se_waiting += imsg_compose(se_fd, IMSG_RECONF_DONE, 0, NULL, 0); + *rde_waiting += imsg_compose(rde_fd, IMSG_RECONF_DONE, 0, NULL, 0); return (0); } diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index 0ad75456eba..ff2c074ecdd 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.2 2003/12/17 18:11:31 henning Exp $ */ +/* $OpenBSD: rde.c,v 1.3 2003/12/17 19:26:26 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -49,7 +49,7 @@ void peer_up(u_int32_t, u_int32_t); void peer_down(u_int32_t); volatile sig_atomic_t rde_quit = 0; -struct bgpd_config *conf; +struct bgpd_config *conf, *nconf; int se_queued_writes = 0; int se_sock; int main_queued_writes = 0; @@ -168,18 +168,51 @@ rde_main(struct bgpd_config *config, int pipe_m2r[2], int pipe_s2r[2]) void rde_dispatch_imsg(int fd, int idx) { - struct imsg imsg; - u_int32_t rid; + struct imsg imsg; + struct peer_config *pconf; + struct rde_peer *p; + u_int32_t rid; + int reconf; if (get_imsg(fd, &imsg) > 0) { switch (imsg.hdr.type) { case IMSG_RECONF_CONF: + if (idx != PFD_PIPE_MAIN) + fatal("reconf request not from parent", 0); + if ((nconf = malloc(sizeof(struct bgpd_config))) == + NULL) + fatal(NULL, errno); + memcpy(nconf, imsg.data, sizeof(struct bgpd_config)); + nconf->peers = NULL; + break; case IMSG_RECONF_PEER: + if (idx != PFD_PIPE_MAIN) + fatal("reconf request not from parent", 0); + pconf = (struct peer_config *)imsg.data; + p = peer_get(pconf->id); /* will always fail atm */ + if (p == NULL) { + if ((p = calloc(1, sizeof(struct rde_peer))) == + NULL) + fatal("new peer", errno); + p->state = PEER_NONE; + reconf = RECONF_REINIT; + /* XXXC peer_add */ + } else + reconf = RECONF_KEEP; + + memcpy(&p->conf, pconf, sizeof(struct peer_config)); + p->conf.reconf_action = reconf; + if (pconf->reconf_action > reconf) + p->conf.reconf_action = pconf->reconf_action; + break; case IMSG_RECONF_DONE: if (idx != PFD_PIPE_MAIN) fatal("reconf request not from parent", 0); - logit(LOG_DEBUG, "RDE: got reconf request"); - /* rde_request_dispatch() */ + if (nconf == NULL) + fatal("got IMSG_RECONF_DONE but no config", 0); + /* XXXC merge in as needed */ + free(nconf); + logit(LOG_INFO, "RDE reconfigured"); break; case IMSG_UPDATE: if (idx != PFD_PIPE_SESSION) diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index da68b2a1050..9afb034c48d 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.2 2003/12/17 18:11:31 henning Exp $ */ +/* $OpenBSD: session.c,v 1.3 2003/12/17 19:26:26 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -1277,7 +1277,7 @@ session_dispatch_imsg(int fd, int idx) p->conf.reconf_action = RECONF_DELETE; free(nconf); pending_reconf = 0; - logit(LOG_INFO, "got new configuration"); + logit(LOG_INFO, "SE reconfigured"); break; default: } |