summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2013-05-30 20:29:28 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2013-05-30 20:29:28 +0000
commitf542787a8a777c0f971ef7a469259e84d02b63b2 (patch)
tree30a94115e6cb1db02ded8e26efa671413f5eea4d /usr.sbin/bgpd
parent569ae32ba71dd8164a9cc653f2a8ea6e049faac5 (diff)
When removing "dump (all|updates)" from bgpd.conf and reloading, tell
the session engine to actually stop logging. Found the hard way by benno@. with & ok benno@ input & ok claudio@
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r--usr.sbin/bgpd/mrt.c25
-rw-r--r--usr.sbin/bgpd/session.c9
-rw-r--r--usr.sbin/bgpd/session.h3
3 files changed, 21 insertions, 16 deletions
diff --git a/usr.sbin/bgpd/mrt.c b/usr.sbin/bgpd/mrt.c
index bd36c546bd6..c6e5bb41daf 100644
--- a/usr.sbin/bgpd/mrt.c
+++ b/usr.sbin/bgpd/mrt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mrt.c,v 1.74 2013/05/20 11:25:02 claudio Exp $ */
+/* $OpenBSD: mrt.c,v 1.75 2013/05/30 20:29:27 florian Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org>
@@ -82,6 +82,13 @@ int mrt_open(struct mrt *, time_t);
} \
} while (0)
+#define RDEIDX 0
+#define SEIDX 1
+#define TYPE2IDX(x) ((x == MRT_TABLE_DUMP || \
+ x == MRT_TABLE_DUMP_MP || \
+ x == MRT_TABLE_DUMP_V2) ? RDEIDX : SEIDX \
+ )
+
void
mrt_dump_bgp_msg(struct mrt *mrt, void *pkg, u_int16_t pkglen,
struct peer *peer)
@@ -848,15 +855,15 @@ static struct imsgbuf *mrt_imsgbuf[2];
void
mrt_init(struct imsgbuf *rde, struct imsgbuf *se)
{
- mrt_imsgbuf[0] = rde;
- mrt_imsgbuf[1] = se;
+ mrt_imsgbuf[RDEIDX] = rde;
+ mrt_imsgbuf[SEIDX] = se;
}
int
mrt_open(struct mrt *mrt, time_t now)
{
enum imsg_type type;
- int i = 1, fd;
+ int fd;
if (strftime(MRT2MC(mrt)->file, sizeof(MRT2MC(mrt)->file),
MRT2MC(mrt)->name, localtime(&now)) == 0) {
@@ -876,11 +883,7 @@ mrt_open(struct mrt *mrt, time_t now)
else
type = IMSG_MRT_REOPEN;
- if (mrt->type == MRT_TABLE_DUMP || mrt->type == MRT_TABLE_DUMP_MP ||
- mrt->type == MRT_TABLE_DUMP_V2)
- i = 0;
-
- if (imsg_compose(mrt_imsgbuf[i], type, 0, 0, fd,
+ if (imsg_compose(mrt_imsgbuf[TYPE2IDX(mrt->type)], type, 0, 0, fd,
mrt, sizeof(struct mrt)) == -1)
log_warn("mrt_open");
@@ -929,6 +932,10 @@ mrt_reconfigure(struct mrt_head *mrt)
m->state = MRT_STATE_RUNNING;
}
if (m->state == MRT_STATE_REMOVE) {
+ if (imsg_compose(mrt_imsgbuf[TYPE2IDX(m->type)],
+ IMSG_MRT_CLOSE, 0, 0, -1, m, sizeof(struct mrt)) ==
+ -1)
+ log_warn("mrt_reconfigure");
LIST_REMOVE(m, entry);
free(m);
continue;
diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c
index 795efad892e..cc588d7b2ac 100644
--- a/usr.sbin/bgpd/session.c
+++ b/usr.sbin/bgpd/session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.c,v 1.330 2013/05/30 10:13:58 sthen Exp $ */
+/* $OpenBSD: session.c,v 1.331 2013/05/30 20:29:27 florian Exp $ */
/*
* Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org>
@@ -2829,11 +2829,8 @@ session_dispatch_imsg(struct imsgbuf *ibuf, int idx, u_int *listener_cnt)
memcpy(&xmrt, imsg.data, sizeof(struct mrt));
mrt = mrt_get(&mrthead, &xmrt);
- if (mrt != NULL) {
- mrt_clean(mrt);
- LIST_REMOVE(mrt, entry);
- free(mrt);
- }
+ if (mrt != NULL)
+ mrt_done(mrt);
break;
case IMSG_CTL_KROUTE:
case IMSG_CTL_KROUTE_ADDR:
diff --git a/usr.sbin/bgpd/session.h b/usr.sbin/bgpd/session.h
index a7f8aa674fd..375e41e42c3 100644
--- a/usr.sbin/bgpd/session.h
+++ b/usr.sbin/bgpd/session.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.h,v 1.115 2013/03/07 21:26:28 claudio Exp $ */
+/* $OpenBSD: session.h,v 1.116 2013/05/30 20:29:27 florian Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -269,6 +269,7 @@ void mrt_dump_bgp_msg(struct mrt *, void *, u_int16_t,
struct peer *);
void mrt_dump_state(struct mrt *, u_int16_t, u_int16_t,
struct peer *);
+void mrt_done(void *);
/* parse.y */
int parse_config(char *, struct bgpd_config *, struct mrt_head *,