From vfom@narod.ru  Mon Sep  2 20:37:27 2002
Return-Path: <vfom@narod.ru>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 2608D37B400
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  2 Sep 2002 20:37:27 -0700 (PDT)
Received: from soapbox.yandex.ru (soapbox.yandex.ru [213.180.193.40])
	by mx1.FreeBSD.org (Postfix) with ESMTP id D80C543E6A
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  2 Sep 2002 20:37:25 -0700 (PDT)
	(envelope-from vfom@narod.ru)
Received: from YAMAIL (soapbox.yandex.ru) by mail.yandex.ru
	id <S1156978AbSICDhR>; Tue, 3 Sep 2002 07:37:17 +0400
Message-Id: <3D742E6D.00000A.02440@soapbox.yandex.ru>
Date: Tue, 3 Sep 2002 07:37:17 +0400 (MSD)
From: "vfom" <vfom@narod.ru>
Sender: vfom@narod.ru
Reply-To: vfom@narod.ru
To: FreeBSD-gnats-submit@freebsd.org
Subject: Impossible to set RCV timeout on a socket to 33 sec, with "option HZ=1000" in ke

>Number:         42352
>Category:       kern
>Synopsis:       Impossible to set RCV timeout on a socket to 33 sec, with "option HZ=1000" in kernel
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    glebius
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 02 20:40:01 PDT 2002
>Closed-Date:    Tue Nov 16 08:17:24 GMT 2004
>Last-Modified:  Tue Nov 16 08:17:24 GMT 2004
>Originator:     Viktor Fomichev
>Release:        FreeBSD 4.6.2-RELEASE i386
>Organization:
home-user
>Environment:
System: FreeBSD shark.office.sice.ru 4.6.2-RELEASE FreeBSD 4.6.2-RELEASE #0: Wed Aug 28 12:20:43 NOVST 2002 root@gog:/usr/src/sys/compile/GROM.ipsec.tap i386

	
>Description:
	
Impossible to set receive and send timeout on a socket to more then 33 secs.
when kernel compiled with  "option	HZ=1000"
It recomended for network device polling. (man 4 polling)  
"Setsockopt" returns with error: Numerical argument out of domain.

>How-To-Repeat:
Compile new kernel with  "option HZ=1000". Install new kernel and reboot.
Compile and run following program. Output looks like:    

# ./test_sockopt                                              
recv 32...                                                    
test_sockopt: recv: Resource temporarily unavailable          
test_sockopt: setsockopt: Numerical argument out of domain        
#

test_sockopt.c:

# include <sys/types.h>
# include <sys/socket.h>
# include <sys/time.h>
# include <stdio.h>
# include <errno.h>
# include <string.h>
# include <err.h>
# include <netinet/in.h>

int
main(int argc, char *argv[])
{
	int s;
	struct timeval tv;
	struct sockaddr_in sin;
	u_char buf[1000];

	if ((s = socket(PF_INET, SOCK_DGRAM, 0)) == -1)
		err(1, "socket");

	sin.sin_len = sizeof(sin);
	sin.sin_family = AF_INET;
	sin.sin_port = htons(10000);
	sin.sin_addr.s_addr = INADDR_ANY;
	if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) == -1)
		err(1, "bind");

	tv.tv_sec = 32;
	tv.tv_usec = 0;
	if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1)
		err(1, "setsockopt");

	printf("recv 32...\n");
	if (recv(s, buf, sizeof(buf), 0) == -1)
		warn("recv");

	tv.tv_sec = 33;
	tv.tv_usec = 0;
	if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1)
		err(1, "setsockopt");

	printf("recv 33...\n");
	if (recv(s, buf, sizeof(buf), 0) == -1)
		warn("recv");

	return (0);
}
	
>Fix:
Not known.
It seems to me, we have to change  "socket" structure definition
in "sys/socketvar.h", in substructure  "sockbuf" - sb_timeo must be
at least 4 byte integer, or long - to forget the problem forever.
	


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->glebius 
Responsible-Changed-By: glebius 
Responsible-Changed-When: Tue Nov 9 13:59:15 GMT 2004 
Responsible-Changed-Why:  
Take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=42352 
State-Changed-From-To: open->closed 
State-Changed-By: glebius 
State-Changed-When: Tue Nov 16 08:15:52 GMT 2004 
State-Changed-Why:  
Fixed in HEAD and RELENG_5. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=42352 
>Unformatted:
 X-send-pr-version: 3.113
 X-GNATS-Notify: 
 
 
