summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2004-07-28 16:00:03 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2004-07-28 16:00:03 +0000
commit3196515d0cf5bd8616e8238b0d6e08a5b4d79fd8 (patch)
tree5335ffa061416d18d201de0b39daf6ddd39d332b /usr.sbin
parenta7365d42f8c5ca96ce75c274dcff0d463bde74bc (diff)
The hole dance to close a mrt file after fd passing in the parent is not
needed as the fd is closed while beeing passed. looks good henning@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpd/bgpd.c22
-rw-r--r--usr.sbin/bgpd/mrt.c30
-rw-r--r--usr.sbin/bgpd/mrt.h3
3 files changed, 8 insertions, 47 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c
index be79c0c27b8..2676885171a 100644
--- a/usr.sbin/bgpd/bgpd.c
+++ b/usr.sbin/bgpd/bgpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.c,v 1.101 2004/07/05 02:13:43 henning Exp $ */
+/* $OpenBSD: bgpd.c,v 1.102 2004/07/28 16:00:02 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -42,7 +42,7 @@ int main(int, char *[]);
int check_child(pid_t, const char *);
int reconfigure(char *, struct bgpd_config *, struct mrt_head *,
struct peer **, struct filter_head *);
-int dispatch_imsg(struct imsgbuf *, int, struct mrt_head *);
+int dispatch_imsg(struct imsgbuf *, int);
int rfd = -1;
volatile sig_atomic_t mrtdump = 0;
@@ -276,15 +276,13 @@ main(int argc, char *argv[])
if (nfds > 0 && pfd[PFD_PIPE_SESSION].revents & POLLIN) {
nfds--;
- if (dispatch_imsg(&ibuf_se, PFD_PIPE_SESSION,
- &mrt_l) == -1)
+ if (dispatch_imsg(&ibuf_se, PFD_PIPE_SESSION) == -1)
quit = 1;
}
if (nfds > 0 && pfd[PFD_PIPE_ROUTE].revents & POLLIN) {
nfds--;
- if (dispatch_imsg(&ibuf_rde, PFD_PIPE_ROUTE,
- &mrt_l) == -1)
+ if (dispatch_imsg(&ibuf_rde, PFD_PIPE_ROUTE) == -1)
quit = 1;
}
@@ -428,10 +426,9 @@ reconfigure(char *conffile, struct bgpd_config *conf, struct mrt_head *mrt_l,
}
int
-dispatch_imsg(struct imsgbuf *ibuf, int idx, struct mrt_head *mrt_l)
+dispatch_imsg(struct imsgbuf *ibuf, int idx)
{
struct imsg imsg;
- struct mrt mrt;
int n;
if ((n = imsg_read(ibuf)) == -1)
@@ -450,15 +447,6 @@ dispatch_imsg(struct imsgbuf *ibuf, int idx, struct mrt_head *mrt_l)
break;
switch (imsg.hdr.type) {
- case IMSG_MRT_CLOSE:
- if (imsg.hdr.len != IMSG_HEADER_SIZE +
- sizeof(struct mrt)) {
- log_warnx("wrong imsg len");
- break;
- }
- memcpy(&mrt, imsg.data, sizeof(struct mrt));
- mrt_close(mrt_get(mrt_l, &mrt));
- break;
case IMSG_KROUTE_CHANGE:
if (idx != PFD_PIPE_ROUTE)
log_warnx("route request not from RDE");
diff --git a/usr.sbin/bgpd/mrt.c b/usr.sbin/bgpd/mrt.c
index 2eca017029e..ae32e699ac3 100644
--- a/usr.sbin/bgpd/mrt.c
+++ b/usr.sbin/bgpd/mrt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mrt.c,v 1.35 2004/07/07 21:18:06 claudio Exp $ */
+/* $OpenBSD: mrt.c,v 1.36 2004/07/28 16:00:02 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org>
@@ -364,7 +364,6 @@ mrt_open(struct mrt *mrt, time_t now)
enum imsg_type type;
int i;
- mrt_close(mrt);
if (strftime(MRT2MC(mrt)->file, sizeof(MRT2MC(mrt)->file),
MRT2MC(mrt)->name, localtime(&now)) == 0) {
log_warnx("mrt_open: strftime conversion failed");
@@ -388,35 +387,11 @@ mrt_open(struct mrt *mrt, time_t now)
if (imsg_compose_fdpass(mrt_imsgbuf[i], type, mrt->fd,
mrt, sizeof(struct mrt)) == -1)
- log_warn("mrt_close");
+ log_warn("mrt_open");
return (1);
}
-void
-mrt_close(struct mrt *mrt)
-{
- if (mrt == NULL)
- return;
- /*
- * this function is normaly called twice. First because of a imsg
- * form the child to inform the parent to close the fd. The second time
- * it is called after reconfigure when the mrt file gets removed.
- * In that case the parent must inform the child to close and remove
- * this mrt dump descriptor.
- */
- if (MRT2MC(mrt)->state == MRT_STATE_REMOVE)
- if (imsg_compose(
- mrt_imsgbuf[mrt->type == MRT_TABLE_DUMP ? 0 : 1],
- IMSG_MRT_CLOSE, 0, mrt, sizeof(struct mrt)) == -1)
- log_warn("mrt_close");
-
- if (mrt->fd == -1)
- return;
- close(mrt->fd);
- mrt->fd = -1;
-}
-
int
mrt_timeout(struct mrt_head *mrt)
{
@@ -459,7 +434,6 @@ mrt_reconfigure(struct mrt_head *mrt)
MRT2MC(m)->state = MRT_STATE_RUNNING;
}
if (MRT2MC(m)->state == MRT_STATE_REMOVE) {
- mrt_close(m);
LIST_REMOVE(m, entry);
free(m);
continue;
diff --git a/usr.sbin/bgpd/mrt.h b/usr.sbin/bgpd/mrt.h
index ab3d366da6f..d104a8a14b7 100644
--- a/usr.sbin/bgpd/mrt.h
+++ b/usr.sbin/bgpd/mrt.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mrt.h,v 1.12 2004/07/13 17:57:20 jaredy Exp $ */
+/* $OpenBSD: mrt.h,v 1.13 2004/07/28 16:00:02 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org>
@@ -285,7 +285,6 @@ void mrt_dump_upcall(struct pt_entry *, void *);
int mrt_write(struct mrt *);
void mrt_clean(struct mrt *);
void mrt_init(struct imsgbuf *, struct imsgbuf *);
-void mrt_close(struct mrt *);
int mrt_timeout(struct mrt_head *);
void mrt_reconfigure(struct mrt_head *);
void mrt_handler(struct mrt_head *);