From fbf084345fc1d6199947237fbe7e52d75028bb2a Mon Sep 17 00:00:00 2001 From: Henning Brauer Date: Tue, 15 Mar 2005 10:18:40 +0000 Subject: grow the receive buffer on the routing socket, pointed out by markus, ok markus claudio --- usr.sbin/bgpd/bgpd.h | 3 ++- usr.sbin/bgpd/kroute.c | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'usr.sbin') 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 @@ -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 @@ -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; -- cgit v1.2.3