From leres@ee.lbl.gov  Sat Dec 18 20:17:50 2010
Return-Path: <leres@ee.lbl.gov>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 622B9106566B
	for <freebsd-gnats-submit@freebsd.org>; 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 <freebsd-gnats-submit@freebsd.org>; 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 <leres@ee.lbl.gov>
To: freebsd-gnats-submit@freebsd.org
Cc: Cedric Hui <chui@lbl.gov>, Jon Dugan <jdugan@es.net>
Subject: [PATCH] net/beacon: Fix udp socket buffer sizes

>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:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Dec 18 20:20:06 UTC 2010
>Closed-Date:    Sat Feb 05 20:08:59 UTC 2011
>Last-Modified:  Sat Feb 05 20:08:59 UTC 2011
>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:
State-Changed-From-To: open->feedback 
State-Changed-By: edwin 
State-Changed-When: Sat Dec 18 20:20:12 UTC 2010 
State-Changed-Why:  
Awaiting maintainers feedback (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=153278 

From: Edwin Groothuis <edwin@FreeBSD.org>
To: janos.mohacsi@bsd.hu
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/153278: [PATCH] net/beacon: Fix udp socket buffer sizes
Date: Sat, 18 Dec 2010 20:20:10 UT

 Maintainer of net/beacon,
 
 Please note that PR ports/153278 has just been submitted.
 
 If it contains a patch for an upgrade, an enhancement or a bug fix
 you agree on, reply to this email stating that you approve the patch
 and a committer will take care of it.
 
 The full text of the PR can be found at:
     http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/153278
 
 -- 
 Edwin Groothuis via the GNATS Auto Assign Tool
 edwin@FreeBSD.org

From: Craig Leres <leres@ee.lbl.gov>
To: FreeBSD-gnats-submit@FreeBSD.org, freebsd-ports-bugs@FreeBSD.org
Cc:  
Subject: Re: ports/153278: [PATCH] net/beacon: Fix udp socket buffer sizes
Date: Fri, 04 Feb 2011 21:41:40 -0800

 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
 Please close this PR; it has been subsumed by version 1.4 and this PR:
 
     http://www.freebsd.org/cgi/query-pr.cgi?pr=154519
 
 Thanks!
 
 		Craig
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.9 (MingW32)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
 
 iEYEARECAAYFAk1M4xQACgkQWxlAhAje3JszSgCfRucgqyceukAkvmFmEYf0CRAN
 prAAn3zXcc4GAgXs3fB84aEerCPT4ix4
 =0Oew
 -----END PGP SIGNATURE-----
State-Changed-From-To: feedback->closed 
State-Changed-By: linimon 
State-Changed-When: Sat Feb 5 20:08:35 UTC 2011 
State-Changed-Why:  
Superseded by ports/154519. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=153278 
>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
 
