summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2005-03-15 10:18:40 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2005-03-15 10:18:40 +0000
commitfbf084345fc1d6199947237fbe7e52d75028bb2a (patch)
treecb8df3fe708ee067ad864922c2c746f47cf0aed2
parent9121d83d2238494348f499f0c93ceb63a8fc11e1 (diff)
grow the receive buffer on the routing socket, pointed out by markus,
ok markus claudio
-rw-r--r--usr.sbin/bgpd/bgpd.h3
-rw-r--r--usr.sbin/bgpd/kroute.c18
2 files changed, 18 insertions, 3 deletions
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h
index b03e88f7501..9c08c74af0d 100644
--- a/usr.sbin/bgpd/bgpd.h
+++ b/usr.sbin/bgpd/bgpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.h,v 1.158 2005/03/14 17:32:04 claudio Exp $ */
+/* $OpenBSD: bgpd.h,v 1.159 2005/03/15 10:18:39 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -43,6 +43,7 @@
#define MIN_HOLDTIME 3
#define READ_BUF_SIZE 65535
#define RT_BUF_SIZE 16384
+#define MAX_RTSOCK_BUF 128 * 1024
#define BGPD_OPT_VERBOSE 0x0001
#define BGPD_OPT_VERBOSE2 0x0002
diff --git a/usr.sbin/bgpd/kroute.c b/usr.sbin/bgpd/kroute.c
index 84608dd7bb7..af39bd1bc53 100644
--- a/usr.sbin/bgpd/kroute.c
+++ b/usr.sbin/bgpd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.116 2005/03/14 12:25:50 henning Exp $ */
+/* $OpenBSD: kroute.c,v 1.117 2005/03/15 10:18:39 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -138,7 +138,8 @@ RB_GENERATE(kif_tree, kif_node, entry, kif_compare)
int
kr_init(int fs)
{
- int opt = 0;
+ int opt = 0, rcvbuf, default_rcvbuf;
+ socklen_t optlen;
kr_state.fib_sync = fs;
@@ -152,6 +153,19 @@ kr_init(int fs)
&opt, sizeof(opt)) == -1)
log_warn("kr_init: setsockopt"); /* not fatal */
+ /* grow receive buffer, don't wanna miss messages */
+ optlen = sizeof(default_rcvbuf);
+ if (getsockopt(kr_state.fd, SOL_SOCKET, SO_RCVBUF,
+ &default_rcvbuf, &optlen) == -1)
+ log_warn("kr_init getsockopt SOL_SOCKET SO_RCVBUF");
+ else
+ for (rcvbuf = MAX_RTSOCK_BUF;
+ rcvbuf > default_rcvbuf &&
+ setsockopt(kr_state.fd, SOL_SOCKET, SO_RCVBUF,
+ &rcvbuf, sizeof(rcvbuf)) == -1 && errno == ENOBUFS;
+ rcvbuf /= 2)
+ ; /* nothing */
+
kr_state.pid = getpid();
kr_state.rtseq = 1;