This patch cleans up include/net/sock.h, starting to move protocol
specific stuff out of this header, with it struct sock protinfo member
turns into this:
struct unix_opt af_unix;
#if defined(CONFIG_INET) || defined (CONFIG_INET_MODULE)
struct inet_opt af_inet;
Where it previously had one entry per protocol, surrounded by #ifdef.
The approach I used was to overload destruct_hook so that it serves the
same purpose of struct inode u.generic_ip field. Please note that most of
the protocols in protinfo (without this patch) already uses pointers to
private structs allocated at proto_create time and destroyed after the
sk->refcnt hits zero, with kfree or with a special function registered in
sk->destruct, which most of the protocols touched by this patch were
The original idea, discussed privately with some of the net stack
maintainers was to have a big fat union as struct inode now has, but after
reading the discussion about struct inode where it was said that the
filesystems would migrate to use u.generic_ip I changed my mind and decided
to hack this first proposal to see what people think.
I've been using this approach with the LLC and NetBEUI stacks that I'm
working on, no problems, as expected 8)
If this is accepted I'll do the same for sk->tp_pinfo and remove the SPX
bits from sock.h, making sk->destruct look at sk->tp_pinfo.generic and
freeing it if non null, just like it works now for
IMHO, if this is accepted we should make sk->protinfo and sk->tp_pinfo be
just void * pointers 8)
The patch is against 2.4.16 but I'll of course submit it for 2.5 if the
patch looks ok for the net maintainers.
Please take a look and lemme know what you think.
Ah, while working on this I noticed that netrom oopses on rmmod, not sure
if this is a bug introduced by this patch, will certainly check.
David, if you don't like it, I'll happily switch to the big fat union idea,
but I think that this is more clean and will avoid us having to patch
sock.h every time a new net stack is added to the kernel.
Patch available at: