summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2014-07-12 20:16:39 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2014-07-12 20:16:39 +0000
commit93f226fdd7fd863d667ca20568296621176a26d3 (patch)
tree30c7a25aa8da5b4c855e46c9df765fb8e80ed899 /usr.sbin
parent968d9aade2b89c5889776f17a59253ccf5d649e3 (diff)
Close connections when msgbuf_write() returns 0.
ok claudio@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ldpd/lde.c10
-rw-r--r--usr.sbin/ldpd/ldpd.c10
-rw-r--r--usr.sbin/ldpd/ldpe.c10
-rw-r--r--usr.sbin/ospf6d/ospf6d.c10
-rw-r--r--usr.sbin/ospf6d/ospfe.c10
-rw-r--r--usr.sbin/ospf6d/rde.c10
-rw-r--r--usr.sbin/ospfd/ospfd.c10
-rw-r--r--usr.sbin/ospfd/ospfe.c10
-rw-r--r--usr.sbin/ospfd/rde.c10
-rw-r--r--usr.sbin/ripd/rde.c10
-rw-r--r--usr.sbin/ripd/ripd.c10
-rw-r--r--usr.sbin/ripd/ripe.c10
12 files changed, 84 insertions, 36 deletions
diff --git a/usr.sbin/ldpd/lde.c b/usr.sbin/ldpd/lde.c
index c089ca2b2df..99fd3b44ed7 100644
--- a/usr.sbin/ldpd/lde.c
+++ b/usr.sbin/ldpd/lde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lde.c,v 1.28 2013/11/26 11:59:38 henning Exp $ */
+/* $OpenBSD: lde.c,v 1.29 2014/07/12 20:16:38 krw Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -211,8 +211,10 @@ lde_dispatch_imsg(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN)
+ if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
+ if (n == 0) /* connection closed */
+ shut = 1;
}
clock_gettime(CLOCK_MONOTONIC, &tp);
@@ -367,8 +369,10 @@ lde_dispatch_parent(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN)
+ if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
+ if (n == 0) /* connection closed */
+ shut = 1;
}
for (;;) {
diff --git a/usr.sbin/ldpd/ldpd.c b/usr.sbin/ldpd/ldpd.c
index a590ee4d288..621ff71d7a6 100644
--- a/usr.sbin/ldpd/ldpd.c
+++ b/usr.sbin/ldpd/ldpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpd.c,v 1.19 2013/11/26 11:59:38 henning Exp $ */
+/* $OpenBSD: ldpd.c,v 1.20 2014/07/12 20:16:38 krw Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -339,8 +339,10 @@ main_dispatch_ldpe(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN)
+ if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
+ if (n == 0)
+ shut = 1;
}
for (;;) {
@@ -415,8 +417,10 @@ main_dispatch_lde(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN)
+ if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
+ if (n == 0)
+ shut = 1;
}
for (;;) {
diff --git a/usr.sbin/ldpd/ldpe.c b/usr.sbin/ldpd/ldpe.c
index 47ac0dcce48..565da95d759 100644
--- a/usr.sbin/ldpd/ldpe.c
+++ b/usr.sbin/ldpd/ldpe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpe.c,v 1.23 2013/11/26 11:59:38 henning Exp $ */
+/* $OpenBSD: ldpe.c,v 1.24 2014/07/12 20:16:38 krw Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -330,8 +330,10 @@ ldpe_dispatch_main(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN)
+ if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("ldpe_dispatch_main: msgbuf_write");
+ if (n == 0)
+ shut = 1;
}
for (;;) {
@@ -470,8 +472,10 @@ ldpe_dispatch_lde(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN)
+ if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("ldpe_dispatch_lde: msgbuf_write");
+ if (n == 0)
+ shut = 1;
}
for (;;) {
diff --git a/usr.sbin/ospf6d/ospf6d.c b/usr.sbin/ospf6d/ospf6d.c
index 6effc98507d..4478b527df6 100644
--- a/usr.sbin/ospf6d/ospf6d.c
+++ b/usr.sbin/ospf6d/ospf6d.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospf6d.c,v 1.24 2013/11/13 20:49:49 benno Exp $ */
+/* $OpenBSD: ospf6d.c,v 1.25 2014/07/12 20:16:38 krw Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -366,8 +366,10 @@ main_dispatch_ospfe(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN)
+ if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
+ if (n == 0) /* connection closed */
+ shut = 1;
}
for (;;) {
@@ -438,8 +440,10 @@ main_dispatch_rde(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN)
+ if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
+ if (n == 0) /* connection closed */
+ shut = 1;
}
for (;;) {
diff --git a/usr.sbin/ospf6d/ospfe.c b/usr.sbin/ospf6d/ospfe.c
index 7722637cbda..38c705a0212 100644
--- a/usr.sbin/ospf6d/ospfe.c
+++ b/usr.sbin/ospf6d/ospfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfe.c,v 1.42 2013/11/13 20:49:49 benno Exp $ */
+/* $OpenBSD: ospfe.c,v 1.43 2014/07/12 20:16:38 krw Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -266,8 +266,10 @@ ospfe_dispatch_main(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN)
+ if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
+ if (n == 0) /* connection closed */
+ shut = 1;
}
for (;;) {
@@ -446,8 +448,10 @@ ospfe_dispatch_rde(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN)
+ if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
+ if (n == 0) /* connection closed */
+ shut = 1;
}
for (;;) {
diff --git a/usr.sbin/ospf6d/rde.c b/usr.sbin/ospf6d/rde.c
index cdd5dc9dae7..b60d263e756 100644
--- a/usr.sbin/ospf6d/rde.c
+++ b/usr.sbin/ospf6d/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.61 2013/11/13 20:49:49 benno Exp $ */
+/* $OpenBSD: rde.c,v 1.62 2014/07/12 20:16:38 krw Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -266,8 +266,10 @@ rde_dispatch_imsg(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN)
+ if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
+ if (n == 0) /* connection closed */
+ shut = 1;
}
clock_gettime(CLOCK_MONOTONIC, &tp);
@@ -638,8 +640,10 @@ rde_dispatch_parent(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN)
+ if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
+ if (n == 0) /* connection closed */
+ shut = 1;
}
for (;;) {
diff --git a/usr.sbin/ospfd/ospfd.c b/usr.sbin/ospfd/ospfd.c
index 5a18ea2b58e..f24d947d94b 100644
--- a/usr.sbin/ospfd/ospfd.c
+++ b/usr.sbin/ospfd/ospfd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfd.c,v 1.80 2013/11/13 20:43:00 benno Exp $ */
+/* $OpenBSD: ospfd.c,v 1.81 2014/07/12 20:16:38 krw Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -384,8 +384,10 @@ main_dispatch_ospfe(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN)
+ if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
+ if (n == 0) /* connection closed */
+ shut = 1;
}
for (;;) {
@@ -469,8 +471,10 @@ main_dispatch_rde(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN)
+ if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
+ if (n == 0) /* connection closed */
+ shut = 1;
}
for (;;) {
diff --git a/usr.sbin/ospfd/ospfe.c b/usr.sbin/ospfd/ospfe.c
index e7749c93794..c4e5e1fe2dd 100644
--- a/usr.sbin/ospfd/ospfe.c
+++ b/usr.sbin/ospfd/ospfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfe.c,v 1.87 2013/11/13 20:43:00 benno Exp $ */
+/* $OpenBSD: ospfe.c,v 1.88 2014/07/12 20:16:38 krw Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -279,8 +279,10 @@ ospfe_dispatch_main(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN)
+ if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
+ if (n == 0) /* connection closed */
+ shut = 1;
}
for (;;) {
@@ -439,8 +441,10 @@ ospfe_dispatch_rde(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN)
+ if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
+ if (n == 0) /* connection closed */
+ shut = 1;
}
for (;;) {
diff --git a/usr.sbin/ospfd/rde.c b/usr.sbin/ospfd/rde.c
index 2441639b5b5..c1fa9f5e8c3 100644
--- a/usr.sbin/ospfd/rde.c
+++ b/usr.sbin/ospfd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.95 2013/11/13 20:43:00 benno Exp $ */
+/* $OpenBSD: rde.c,v 1.96 2014/07/12 20:16:38 krw Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -261,8 +261,10 @@ rde_dispatch_imsg(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN)
+ if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
+ if (n == 0) /* connection closed */
+ shut = 1;
}
clock_gettime(CLOCK_MONOTONIC, &tp);
@@ -624,8 +626,10 @@ rde_dispatch_parent(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN)
+ if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
+ if (n == 0) /* connection closed */
+ shut = 1;
}
for (;;) {
diff --git a/usr.sbin/ripd/rde.c b/usr.sbin/ripd/rde.c
index 8f03f5bc57f..6915add3d1c 100644
--- a/usr.sbin/ripd/rde.c
+++ b/usr.sbin/ripd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.16 2013/11/19 22:25:32 benno Exp $ */
+/* $OpenBSD: rde.c,v 1.17 2014/07/12 20:16:38 krw Exp $ */
/*
* Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
@@ -198,8 +198,10 @@ rde_dispatch_imsg(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN)
+ if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
+ if (n == 0) /* connection closed */
+ shut = 1;
}
for (;;) {
@@ -298,8 +300,10 @@ rde_dispatch_parent(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN)
+ if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
+ if (n == 0) /* connection closed */
+ shut = 1;
}
for (;;) {
diff --git a/usr.sbin/ripd/ripd.c b/usr.sbin/ripd/ripd.c
index 3e083997390..9ba92b91f81 100644
--- a/usr.sbin/ripd/ripd.c
+++ b/usr.sbin/ripd/ripd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ripd.c,v 1.22 2013/11/19 22:25:32 benno Exp $ */
+/* $OpenBSD: ripd.c,v 1.23 2014/07/12 20:16:38 krw Exp $ */
/*
* Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
@@ -353,8 +353,10 @@ main_dispatch_ripe(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN)
+ if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
+ if (n == 0) /* connection closed */
+ shut = 1;
}
for (;;) {
@@ -430,8 +432,10 @@ main_dispatch_rde(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN)
+ if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
+ if (n == 0) /* connection closed */
+ shut = 1;
}
for (;;) {
diff --git a/usr.sbin/ripd/ripe.c b/usr.sbin/ripd/ripe.c
index ca6b7a83f7b..6d9a8ad07a7 100644
--- a/usr.sbin/ripd/ripe.c
+++ b/usr.sbin/ripd/ripe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ripe.c,v 1.15 2013/11/26 12:00:19 henning Exp $ */
+/* $OpenBSD: ripe.c,v 1.16 2014/07/12 20:16:38 krw Exp $ */
/*
* Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
@@ -240,8 +240,10 @@ ripe_dispatch_main(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN)
+ if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
+ if (n == 0) /* connection closed */
+ shut = 1;
}
for (;;) {
@@ -318,8 +320,10 @@ ripe_dispatch_rde(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if (msgbuf_write(&ibuf->w) == -1 && errno != EAGAIN)
+ if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
+ if (n == 0) /* connection closed */
+ shut = 1;
}
for (;;) {