summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd/bgpd.c
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2004-02-03 17:36:31 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2004-02-03 17:36:31 +0000
commitab1646f12bbbdd3cbd6d1ef6748d0840536d1f52 (patch)
tree595e3b8d812768c1c7e1dcfbcc9a8ea4914fae26 /usr.sbin/bgpd/bgpd.c
parenta13d137c08a9e9b337b3baf4be3893558ac7723c (diff)
defer free()ing the previous peer list until after parsing the config file
so in the parser we can access it. will be needed soon.
Diffstat (limited to 'usr.sbin/bgpd/bgpd.c')
-rw-r--r--usr.sbin/bgpd/bgpd.c22
1 files changed, 8 insertions, 14 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)) {