[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bgpd listener fix
- To: tech_(_at_)_openbsd_(_dot_)_org
- Subject: bgpd listener fix
- From: Claudio Jeker <claudio_(_at_)_cvs_(_dot_)_openbsd_(_dot_)_org>
- Date: Thu, 17 Mar 2005 19:16:54 +0059
- Cc: Henning Brauer <henning_(_at_)_openbsd_(_dot_)_org>, Esben Norby <norby_(_at_)_openbsd_(_dot_)_org>
- Mail-followup-to: Claudio Jeker <claudio_(_at_)_cvs_(_dot_)_openbsd_(_dot_)_org>, tech_(_at_)_openbsd_(_dot_)_org, Henning Brauer <henning_(_at_)_openbsd_(_dot_)_org>, Esben Norby <norby_(_at_)_openbsd_(_dot_)_org>
Hey bgpd users,
this diff needs your attention.
There is a major bug in the fd passing code that resulted in duplicate
listener fds passed to the SE. The result was normaly a CLOSED listener
and bgpd no longer accepting connections.
Here is a diff that solves that issue that needs to be tested ASAP by as
many people as possible.
To test you need to add/remove "listen on <IP>" statements from the config
and issue a "bgpctl reload". Then have a look at the netstat -an output
for any strange bgpd sockets.
--
:wq Claudio
Index: buffer.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/buffer.c,v
retrieving revision 1.27
diff -u -p -r1.27 buffer.c
--- buffer.c 14 Mar 2005 11:59:13 -0000 1.27
+++ buffer.c 17 Mar 2005 17:48:28 -0000
@@ -151,8 +151,6 @@ msgbuf_write(struct msgbuf *msgbuf)
TAILQ_FOREACH(buf, &msgbuf->bufs, entry) {
if (i >= IOV_MAX)
break;
- if (i != 0 && buf->fd != -1) /* fds on their own */
- break;
iov[i].iov_base = buf->buf + buf->rpos;
iov[i].iov_len = buf->size - buf->rpos;
i++;
@@ -185,6 +183,15 @@ msgbuf_write(struct msgbuf *msgbuf)
return (-2);
}
+ /*
+ * assumption: fd got sent if sendmsg sent anything
+ * this works because fds are passed one at a time
+ */
+ if (buf != NULL && buf->fd != -1) {
+ close(buf->fd);
+ buf->fd = -1;
+ }
+
for (buf = TAILQ_FIRST(&msgbuf->bufs); buf != NULL && n > 0;
buf = next) {
next = TAILQ_NEXT(buf, entry);
@@ -194,11 +201,6 @@ msgbuf_write(struct msgbuf *msgbuf)
} else {
buf->rpos += n;
n = 0;
- /* assumption: fd got sent if sendmsg sent anything */
- if (buf->fd != -1) {
- close(buf->fd);
- buf->fd = -1;
- }
}
}
Visit your host, monkey.org