From owner-freebsd-bugs Mon Sep 17 10:40:12 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 452DE37B407 for ; Mon, 17 Sep 2001 10:40:04 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id f8HHe4d02398; Mon, 17 Sep 2001 10:40:04 -0700 (PDT) (envelope-from gnats) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id CD45F37B406 for ; Mon, 17 Sep 2001 10:30:56 -0700 (PDT) Received: (from nobody@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id f8HHUub00713; Mon, 17 Sep 2001 10:30:56 -0700 (PDT) (envelope-from nobody) Message-Id: <200109171730.f8HHUub00713@freefall.freebsd.org> Date: Mon, 17 Sep 2001 10:30:56 -0700 (PDT) From: Brad Knotwell To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-1.0 Subject: kern/30634: kevent.data value incorrect for UDP sockets Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 30634 >Category: kern >Synopsis: kevent.data value incorrect for UDP sockets >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Sep 17 10:40:03 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Brad Knotwell >Release: 4.2 >Organization: home >Environment: FreeBSD freebsd 4.2-RELEASE FreeBSD 4.2-RELEASE #3: Thu Jul 19 root@freebsd:/usr/src/sys/compile/ALPHA-SVR i386 >Description: When kevent returns a read event for a UDP socket, the data field (AKA the number of bytes to be read) is 16 bytes too long. NOTE: the problem exists in 4.3 release as well. >How-To-Repeat: 1) Compile up the following discard server 2) Run nc -u 127.0.0.1 6060 3) Send data to netcat and watch the server's output It should be consistently off by sixteen bytes. NOTE: this may be a documentation bug and "the number of bytes in the socket buffer" needs to be explained further. #include #include #include #include #include #include #include #include /* loopback discardserver on port 6060 */ int main(void) { int queue,sock; struct sockaddr_in saddr; struct kevent evt; memset(&saddr,0,sizeof(struct sockaddr_in)); saddr.sin_family = AF_INET; saddr.sin_port = htons(6060); saddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); memset(&evt,0,sizeof(struct kevent)); evt.filter = EVFILT_READ; evt.flags = EV_ADD; if(((queue = kqueue()) == -1) || ((evt.ident = (sock = socket(AF_INET,SOCK_DGRAM,0))) == -1) || (bind(sock,(struct sockaddr *)&saddr,sizeof saddr)) || (kevent(queue,&evt,1,NULL,0,NULL))) return(fprintf(stderr,"bad setup\n"),EXIT_FAILURE); while(1){ char *buf; if((kevent(queue,NULL,0,&evt,1,NULL) == -1) || (!evt.data)) break; if((buf = malloc(evt.data)) == NULL) continue; recv(sock,buf,evt.data,0); printf("size to read(%d) : data : %s\n",evt.data,buf); free(buf); } return(EXIT_SUCCESS); } >Fix: >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message