summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpd/bgpd.c22
-rw-r--r--usr.sbin/bgpd/parse.y11
2 files changed, 17 insertions, 16 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c
index 2f5df44386b..0089eea2a53 100644
--- a/usr.sbin/bgpd/bgpd.c
+++ b/usr.sbin/bgpd/bgpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.c,v 1.72 2004/01/23 21:18:12 henning Exp $ */
+/* $OpenBSD: bgpd.c,v 1.73 2004/02/03 17:36:30 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -41,7 +41,7 @@ void usage(void);
int main(int, char *[]);
int check_child(pid_t, const char *);
int reconfigure(char *, struct bgpd_config *, struct mrt_head *,
- struct peer *);
+ struct peer **);
int dispatch_imsg(struct imsgbuf *, int, struct mrt_head *);
int rfd = -1;
@@ -93,7 +93,7 @@ int
main(int argc, char *argv[])
{
struct bgpd_config conf;
- struct peer *peer_l, *p, *next;
+ struct peer *peer_l;
struct mrt_head mrt_l;
struct network_head net_l;
struct network *net;
@@ -210,10 +210,6 @@ main(int argc, char *argv[])
if ((rfd = kr_init(!(conf.flags & BGPD_FLAG_NO_FIB_UPDATE))) == -1)
quit = 1;
- for (p = peer_l; p != NULL; p = next) {
- next = p->next;
- free(p);
- }
for (net = TAILQ_FIRST(&net_l); net != TAILQ_END(&net_l);
net = TAILQ_FIRST(&net_l)) {
TAILQ_REMOVE(&net_l, net, network_l);
@@ -282,7 +278,7 @@ main(int argc, char *argv[])
if (reconfig) {
log_info("rereading config");
- reconfigure(conffile, &conf, &mrt_l, peer_l);
+ reconfigure(conffile, &conf, &mrt_l, &peer_l);
reconfig = 0;
}
@@ -341,13 +337,13 @@ check_child(pid_t pid, const char *pname)
int
reconfigure(char *conffile, struct bgpd_config *conf, struct mrt_head *mrt_l,
- struct peer *peer_l)
+ struct peer **peer_l)
{
struct network_head net_l;
struct network *n;
- struct peer *p, *next;
+ struct peer *p;
- if (parse_config(conffile, conf, mrt_l, &peer_l, &net_l)) {
+ if (parse_config(conffile, conf, mrt_l, peer_l, &net_l)) {
log_warnx("config file %s has errors, not reloading",
conffile);
return (-1);
@@ -359,15 +355,13 @@ reconfigure(char *conffile, struct bgpd_config *conf, struct mrt_head *mrt_l,
if (imsg_compose(&ibuf_rde, IMSG_RECONF_CONF, 0,
conf, sizeof(struct bgpd_config)) == -1)
return (-1);
- for (p = peer_l; p != NULL; p = next) {
- next = p->next;
+ for (p = *peer_l; p != NULL; p = p->next) {
if (imsg_compose(&ibuf_se, IMSG_RECONF_PEER, p->conf.id,
&p->conf, sizeof(struct peer_config)) == -1)
return (-1);
if (imsg_compose(&ibuf_rde, IMSG_RECONF_PEER, p->conf.id,
&p->conf, sizeof(struct peer_config)) == -1)
return (-1);
- free(p);
}
for (n = TAILQ_FIRST(&net_l); n != TAILQ_END(&net_l);
n = TAILQ_FIRST(&net_l)) {
diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y
index 71a3f3ae3b4..37f0e390f55 100644
--- a/usr.sbin/bgpd/parse.y
+++ b/usr.sbin/bgpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.45 2004/02/01 19:46:05 claudio Exp $ */
+/* $OpenBSD: parse.y,v 1.46 2004/02/03 17:36:30 henning Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -40,7 +40,7 @@
static struct bgpd_config *conf;
static struct mrt_head *mrtconf;
static struct network_head *netconf;
-static struct peer *peer_l;
+static struct peer *peer_l, *peer_l_old;
static struct peer *curpeer;
static struct peer *curgroup;
static FILE *fin = NULL;
@@ -652,6 +652,7 @@ parse_config(char *filename, struct bgpd_config *xconf,
struct mrt_head *xmconf, struct peer **xpeers, struct network_head* nc)
{
struct sym *sym, *next;
+ struct peer *p, *pnext;
if ((conf = calloc(1, sizeof(struct bgpd_config))) == NULL)
fatal(NULL);
@@ -662,6 +663,7 @@ parse_config(char *filename, struct bgpd_config *xconf,
TAILQ_INIT(netconf);
peer_l = NULL;
+ peer_l_old = *xpeers;
curpeer = NULL;
curgroup = NULL;
lineno = 1;
@@ -702,6 +704,11 @@ parse_config(char *filename, struct bgpd_config *xconf,
errors += mrt_mergeconfig(xmconf, mrtconf);
*xpeers = peer_l;
+ for (p = peer_l_old; p != NULL; p = pnext) {
+ pnext = p->next;
+ free(p);
+ }
+
free(conf);
free(mrtconf);