From owner-freebsd-net@FreeBSD.ORG Tue Jan 6 23:05:46 2004 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E72A116A4CE for ; Tue, 6 Jan 2004 23:05:45 -0800 (PST) Received: from mailgw.servicefactory.se (mailgw.servicefactory.se [192.71.33.33]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9BE5B43D53 for ; Tue, 6 Jan 2004 23:05:43 -0800 (PST) (envelope-from xfree@bulow.mine.nu) Received: from ark.servicefactory.se (ark.servicefactory.se [192.71.33.5]) i0775fw26225; Wed, 7 Jan 2004 08:05:41 +0100 (CET) Received: from bulow.mine.nu (ark.servicefactory.se [192.71.33.5]) by ark.servicefactory.se (8.12.9/8.12.6) with ESMTP id i0774hmP015185; Wed, 7 Jan 2004 08:04:43 +0100 (CET) (envelope-from xfree@bulow.mine.nu) Message-ID: <3FFBAFB9.5060708@bulow.mine.nu> Date: Wed, 07 Jan 2004 08:05:29 +0100 From: Jonas Bulow User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.6b) Gecko/20031218 X-Accept-Language: en-us, en, sv MIME-Version: 1.0 To: Julian Elischer References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit cc: freebsd-net@freebsd.org Subject: Re: netgraph and kqueue together - socket problems X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Jan 2004 07:05:46 -0000 Hi, Julian Elischer wrote: >On Wed, 7 Jan 2004, Jonas Bulow wrote: > > > >>Hi, >> >>I'm trying to use netgraph and kqueue together and ran into some >>problems. I hope someone can enligthen me what I'm missing. >> >> > >I'm not sure that anyone has ever looked at netgraph and kqueue as a >pair. > > > > > >>I register EVFILT_READ and EVFILT_WRITE on a netgraph-socket connected >>to a netgraph echo-node. The EVFILT_WRITE-filter returns immediately >>from the kevent call saying there is 20480 bytes remaining in the write >>buffer (in the event data field). Then I write 20480 using NgSendData. >>NgSendData encounters an error: "No buffer space available". >> >> > > > >WHat does it mean "write buffer"? > > I guess it is struct sockbuf sn_snd in struckt socket. >The netgraph socket will pass th edat adirectly to whatever is >connected. There is no buffer. >The echo node in turn passes it back to the socket node (though there >maybe a lock.. not sure) so eventually the data will be put in the >receive buffer, so for this case the receive buffer is the send buffer >but the socket can not know this.. > > > > > > > >>When I write fewer but smaller chunks of data, say ~3000 bytes, the next >>call to kevent returns the same amount of remaining space in the write >>buffer. The kqueue event data field never change from 20480 for the >>EVFILT_WRITE-filter. >> >> > >No it is returning some default value.. >I doubt it is related in any way to much of importance. > > > >tell me, does a write of 20479 bytes work? > > No, but 20473 works. The next call to kevent returns the constans 20480 again and the following NgSendData fails with the error above. > > > >>Now I understand that there are some overhead in the NgSendData. It's >>not just my data that are written through the socket. The addressing >>data adds some data when NgSendData calls sendto. Right? >> >> >> > >nope. >that is out of band data.. I don't count that.. (I don't count anything >really.). > > > > >>But, how do I calculate the true amount of remaining buffer space >>available for me when I call NgSendData? >> >> > >you can't.. there is no transmit buffer.. that is a reponsibility of the >node that eventually decides to queue the data (maybe never). > > > >>And, why does kevent EVFILT_WRITE always say 20480 on repeated calls to >>kevent on a netgraph-socket, even if I have successfully written some >>data between the calls to kevent? >> >> > >probably some default value. > > It seems to get it's value in kern/uipc_socket.c:filt_sowrite: ( -stable) kn->kn_data = sbspace(&so->so_snd); > > > >>The netgraph-node the programming is talking to is a echo-node set up with: >> >>#ngctl mkpeer echo dummy foo >> >> >> > >I suggest 'following' the data in the source code... > >starting in ng_socket.c >start at: > http://snapshots.jp.freebsd.org/tour/current/kernel/S/3328.html#338 >for -current and: > http://snapshots.jp.freebsd.org/tour/releng4/kernel/S/2566.html#182 >for -stable. > > Ok, I will do that. Isn't it kern/uipc_socket .c in sosend who is responsible for returning ENOBUFS in the first place when using the sendto that NgSendData uses? /j > > > > > >>Regards, >> Jonas >>_______________________________________________ >>freebsd-net@freebsd.org mailing list >>http://lists.freebsd.org/mailman/listinfo/freebsd-net >>To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org" >> >> >> > > >