From owner-freebsd-ports-bugs@FreeBSD.ORG Sat Dec 18 20:20:07 2010 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7E3851065672 for ; Sat, 18 Dec 2010 20:20:07 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 40E218FC0A for ; Sat, 18 Dec 2010 20:20:07 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id oBIKK7Np046030 for ; Sat, 18 Dec 2010 20:20:07 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id oBIKK62x046029; Sat, 18 Dec 2010 20:20:06 GMT (envelope-from gnats) Resent-Date: Sat, 18 Dec 2010 20:20:06 GMT Resent-Message-Id: <201012182020.oBIKK62x046029@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Craig Leres Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 622B9106566B for ; Sat, 18 Dec 2010 20:17:50 +0000 (UTC) (envelope-from leres@ee.lbl.gov) Received: from fun.ee.lbl.gov (fun.ee.lbl.gov [IPv6:2001:400:610:102::ca]) by mx1.freebsd.org (Postfix) with ESMTP id 47AF08FC0A for ; Sat, 18 Dec 2010 20:17:50 +0000 (UTC) Received: from ice.ee.lbl.gov (ice.ee.lbl.gov [131.243.2.213]) (authenticated bits=0) by fun.ee.lbl.gov (8.14.4/8.14.4) with ESMTP id oBIKHmtl011905 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 18 Dec 2010 12:17:48 -0800 (PST) Message-Id: <4D0D16EC.2090302@ee.lbl.gov> Date: Sat, 18 Dec 2010 12:17:48 -0800 From: Craig Leres To: freebsd-gnats-submit@FreeBSD.org Cc: Jon Dugan , Cedric Hui Subject: ports/153278: [PATCH] net/beacon: Fix udp socket buffer sizes X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Dec 2010 20:20:07 -0000 >Number: 153278 >Category: ports >Synopsis: [PATCH] net/beacon: Fix udp socket buffer sizes >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Dec 18 20:20:06 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Craig Leres >Release: FreeBSD 7.2-RELEASE amd64 >Organization: Lawrence Berkeley National Laboratory >Environment: FreeBSD mon.lbl.gov 7.2-RELEASE FreeBSD 7.2-RELEASE #0 r105: Mon Dec 13 14:35:39 PST 2010 leres@fun.ee.lbl.gov:/home/fun/u2/src/7.2-RELEASE/sys/amd64/compile/GENERIC amd64 >Description: Although beacon has code to set the SO_SNDBUF and SO_RCVBUF buffer sizes, it is only executed if socket() *fails*. If you fix this then beacon fails to run because the sizes that it is attempting to be set are larger than system defaults allow. >How-To-Repeat: Check the udp section of netstat -s after running beacon for a few minutes and notice "dropped due to full socket buffers" is increasing. >Fix: Add a routine that sets the buffer sizes as high as the OS default allows; see attached patch. Note that with the FreeBSD default of 256KB you will still see udp full socket buffer drops but at least you'll have the option to raise kern.ipc.maxsockbuf so that beacon can get the 1MB buffers it wants. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0NFuwACgkQWxlAhAje3JsrwgCfSp3S07sHDH8VIJAdNtGhicJ/ 0rQAn1AEpSxIfkKCsg7z/UsJJQn01Q7m =weeU -----END PGP SIGNATURE----- --------------020202000407000805010102 Content-Type: text/plain; name="patch-patch-common-beacon.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch-patch-common-beacon.patch" --- files/patch-common-beacon.patch.orig 2010-12-15 14:44:42.000000000 -0800 +++ files/patch-common-beacon.patch 2010-12-18 12:10:52.000000000 -0800 @@ -1,11 +1,32 @@ --- common-beacon.patch.orig 2005-06-15 18:46:40.000000000 -0700 -+++ common-beacon.patch 2010-07-30 17:34:45.000000000 -0700 -@@ -46,3 +46,15 @@ ++++ common-beacon.patch 2010-12-18 12:10:48.000000000 -0800 +@@ -1,6 +1,5 @@ +-diff -u -p -w common/src/rtp.c common-beacon/src/rtp.c +---- common/src/rtp.c 2002-04-15 17:40:05.000000000 -0500 +-+++ common-beacon/src/rtp.c 2005-02-11 13:20:37.000000000 -0600 ++--- common.orig/src/rtp.c 2002-04-15 15:40:05.000000000 -0700 +++++ common/src/rtp.c 2010-12-18 10:54:33.000000000 -0800 + @@ -180,6 +180,7 @@ typedef struct _source { + int probation; + uint32_t jitter; +@@ -34,9 +33,8 @@ + if (s->sender) { + /* Much of this is taken from A.3 of draft-ietf-avt-rtp-new-01.txt */ + int extended_max = s->cycles + s->max_seq; +-diff -u -p -w common/src/rtp.h common-beacon/src/rtp.h +---- common/src/rtp.h 2002-04-15 17:40:05.000000000 -0500 +-+++ common-beacon/src/rtp.h 2005-02-11 13:22:50.000000000 -0600 ++--- common.orig/src/rtp.h 2002-04-15 15:40:05.000000000 -0700 +++++ common/src/rtp.h 2010-12-18 10:54:33.000000000 -0800 + @@ -41,7 +41,7 @@ + + #define RTP_VERSION 2 +@@ -46,3 +44,82 @@ #if !defined(WORDS_BIGENDIAN) && !defined(WORDS_SMALLENDIAN) #error RTP library requires WORDS_BIGENDIAN or WORDS_SMALLENDIAN to be defined. -+--- common/src/net_udp.c 2004-06-29 09:21:37.000000000 -0700 -++++ common-beacon/src/net_udp.c 2010-07-30 17:28:06.000000000 -0700 ++--- common.orig/src/net_udp.c 2004-06-29 09:21:37.000000000 -0700 +++++ common/src/net_udp.c 2010-12-18 12:10:46.000000000 -0800 +@@ -44,7 +44,9 @@ + #include "debug.h" + #include "memory.h" @@ -16,3 +37,70 @@ + #include "vsnprintf.h" + #include "net_udp.h" + ++@@ -117,8 +119,10 @@ struct _socket_udp { ++ * compatibility for Winsock 1. ++ */ ++ #define SETSOCKOPT winsock_versions_setsockopt +++#define GETSOCKOPT winsock_versions_getsockopt ++ #else ++ #define SETSOCKOPT setsockopt +++#define GETSOCKOPT getsockopt ++ #endif /* WIN32 */ ++ ++ /*****************************************************************************/ ++@@ -166,6 +170,36 @@ socket_error(const char *msg, ...) ++ #endif ++ } ++ +++/* Set the socket buffer size as close to the desired as the OS allows */ +++static int +++setsockbufsize(int fd, int opt, const char *what, int size) +++{ +++ int try, def; +++ socklen_t len; +++ +++ printf("setsockbufsize: desired %s %d", what, size); +++ def = 0; +++ len = sizeof(def); +++ if (GETSOCKOPT(fd, SOL_SOCKET, opt, (void *)&def, (void *)&len) < 0) { +++ printf("\n"); +++ socket_error("getsockopt %s", what); +++ return (-1); +++ } +++ printf(", default %d", def); +++ +++ /* Work from the desired size down to the default */ +++ for (try = size; try > def; try -= 1024) { +++ if (SETSOCKOPT(fd, SOL_SOCKET, opt, +++ (void *)&try, sizeof(try)) >= 0) { +++ printf(", new %d\n", try); +++ return (0); +++ } +++ } +++ printf("\n"); +++ socket_error("setsockopt %s", what); +++ return (-1); +++} +++ ++ #ifdef WIN32 ++ /* ws2tcpip.h defines these constants with different values from ++ * winsock.h so files that use winsock 2 values but try to use ++@@ -290,16 +324,12 @@ static socket_udp *udp_init4(const char ++ s->fd = socket(AF_INET, SOCK_DGRAM, 0); ++ if (s->fd < 0) { ++ socket_error("socket"); ++- if (SETSOCKOPT(s->fd, SOL_SOCKET, SO_SNDBUF, (char *) &udpbufsize, sizeof(udpbufsize)) != 0) { ++- socket_error("setsockopt SO_SNDBUF"); ++ return NULL; ++ } ++- if (SETSOCKOPT(s->fd, SOL_SOCKET, SO_RCVBUF, (char *) &udpbufsize, sizeof(udpbufsize)) != 0) { ++- socket_error("setsockopt SO_RCVBUF"); +++ if (setsockbufsize(s->fd, SO_SNDBUF, "SO_SNDBUF", udpbufsize) < 0) ++ return NULL; ++- } +++ if (setsockbufsize(s->fd, SO_RCVBUF, "SO_RCVBUF", udpbufsize) < 0) ++ return NULL; ++- } ++ if (SETSOCKOPT(s->fd, SOL_SOCKET, SO_REUSEADDR, (char *) &reuse, sizeof(reuse)) != 0) { ++ socket_error("setsockopt SO_REUSEADDR"); ++ return NULL; --------------020202000407000805010102 Content-Type: application/octet-stream; name="patch-patch-common-beacon.patch.sig" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="patch-patch-common-beacon.patch.sig" iEYEABECAAYFAk0NFuwACgkQWxlAhAje3JvOJQCeMH/CJoii7thoinksWHZVwFuFdwgAnjZm qIE+TGGeGqk6OcbzFmef+P/D --------------020202000407000805010102-- >Release-Note: >Audit-Trail: >Unformatted: This is a multi-part message in MIME format. --------------020202000407000805010102 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1