Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Jan 2002 00:14:11 -0500
From:      Florent Parent <Florent.Parent@viagenie.qc.ca>
To:        freebsd-net@freebsd.org
Cc:        "Rogier R. Mulhuijzen" <drwilco@drwilco.net>
Subject:   Re: netgraph: how to setsockopt on ksocket node ?
Message-ID:  <26540000.1011417251@blues.viagenie.qc.ca>

next in thread | raw e-mail | index | archive | help


--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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?26540000.1011417251>