Unix Technical Forum

bgpd listener fix

This is a discussion on bgpd listener fix within the lucky.openbsd.tech forums, part of the OpenBSD category; --> Hey bgpd users, this diff needs your attention. There is a major bug in the fd passing code that ...


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > lucky.openbsd.tech

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-22-2008, 11:20 AM
Claudio Jeker
 
Posts: n/a
Default bgpd listener fix

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;
- }
}
}

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:04 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com