From owner-freebsd-net Fri Jan 18 21:14:28 2002 Delivered-To: freebsd-net@freebsd.org Received: from blues.viagenie.qc.ca (modemcable114.39-130-66.mtl.mc.videotron.ca [66.130.39.114]) by hub.freebsd.org (Postfix) with ESMTP id 1F31A37B402 for ; Fri, 18 Jan 2002 21:14:25 -0800 (PST) Received: from blues.viagenie.qc.ca (blues-local [127.0.0.1]) by blues.viagenie.qc.ca (8.11.6/8.11.3) with ESMTP id g0J5EN801863; Sat, 19 Jan 2002 00:14:23 -0500 (EST) (envelope-from Florent.Parent@viagenie.qc.ca) Date: Sat, 19 Jan 2002 00:14:11 -0500 From: Florent Parent To: freebsd-net@freebsd.org Cc: "Rogier R. Mulhuijzen" Subject: Re: netgraph: how to setsockopt on ksocket node ? Message-ID: <26540000.1011417251@blues.viagenie.qc.ca> X-Mailer: Mulberry/2.1.2 (Linux/x86) X-PGP-Fingerprint: B718 4543 977C BE73 2BCC 23D5 3E20 4FC9 2A90 872C MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org --On 2002-01-18 11:55:09 +0100 drwilco@drwilco.net wrote: > But socket options (on this level) are a predefined struct. Here's an > example from some code I am working on: > > struct sockopt sopt; > > /* some code removed */ > > bzero(&sopt, sizeof(sopt)); > sopt.sopt_level = SOL_SOCKET; > sopt.sopt_name = SO_SNDBUF; > bufsiz = 128 * 1024; /* XXX */ > sopt.sopt_val = &bufsiz; > sopt.sopt_valsize = sizeof(bufsiz); > > Hope this clears a few things up =) (BTW, I'm not using netgraph after > this code, but I know from reading the netgraph source that this struct > sockopt is what is used). > > Doc Hi, However I need to use the netgraph interface to access the socket. I cannot use the struct sockopt directly. struct sockopt is set in ng_ksocket_rcvmsg(). Poking around sosetopt(): sopt.sopt_p is used to determine whether copyin() or bcopy() will be used to copy data from sopt.sopt_val. The struct sockopt and the sopt_p member is set inside ng_ksocket_rcvmsg(). I commented out the sopt_p definition to force the use of bcopy() instead of copyin() and now my code now works ok. Could it be that sopt_val points to kernel space instead of user space and causes copyin() to fail with EFAULT ? Florent. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message