netdev
[Top] [All Lists]

Re: sk->user_data

To: Henner Eisen <eis@xxxxxxxxxxxxx>
Subject: Re: sk->user_data
From: Ben Greear <greearb@xxxxxxxxxxxxxxx>
Date: Wed, 22 Nov 2000 18:03:27 -0700
Cc: netdev@xxxxxxxxxxx
Organization: Candela Technologies
References: <200011212222.XAA03012@xxxxxxxxxxxxx>
Sender: owner-netdev@xxxxxxxxxxx
Henner Eisen wrote:
> 
> Hi,
> 
> 2.4.0 struct sock contains a member
> 
>         void                    *user_data;
> 
> which is currently only used for pointing to an in-kernel RPC layer
> control block.
> 
> Is it o.k. to use this pointer for alternative upper layer or would that
> be a bad idea?

I've been thinking that if we used unions instead of all the void*,
then it might be more obvious what the use of the variable is (in
the using code), and could be (when looking at net_dev.h).

As long as the data types are all pointers,
the space used in the struct containing the union is the same, right?

Either way, comments are a good idea.

> 
> Rationale:
> 
> I have implemented a framework that allows tunneling of PPP and IP over
> PF_X25 socket connections. For this I need a pointer to a socket tunnel
> structure which I currently maintain in the private x25 protocol block.
> As this code is generic (it is not x25 specific and aims at being
> re-usable for tunneling over other linux network protocol stacks), it
> makes sense to maintain the pointer in a protocol-independent area of
> struct sock.
> RPC already uses the sk->user_data field to point to an upper layer
> control structure. My tunnel scenario is similar: it is also an alternative
> (not a struct socket) in-kernel upper layer.
> 
> As the type is void*, it seems to me that it was intended for such use.
> And there won't be any conflicts with RPC because a socket attached to
> in-kernel RPC won't be simultaneously used for tunneling.
> Thus, if it's o.k to re-use sk->user_data, I'd like to document this in
> the source by means of the following patch.
> 
> Henner
> 
> --- sktn/include/net/sock.h.old Mon Nov 20 22:45:24 2000
> +++ sktn/include/net/sock.h     Tue Nov 21 22:38:14 2000
> @@ -651,7 +651,7 @@
>         /* Identd and reporting IO signals */
>         struct socket           *socket;
> 
> -       /* RPC layer private data */
> +       /* Private data for non-socket upper layer (e.g. in-kernel RPC) */
>         void                    *user_data;
> 
>         /* Callbacks */

-- 
Ben Greear (greearb@xxxxxxxxxxxxxxx)  http://www.candelatech.com
Author of ScryMUD:  scry.wanfear.com 4444        (Released under GPL)
http://scry.wanfear.com               http://scry.wanfear.com/~greear

<Prev in Thread] Current Thread [Next in Thread>