Don't use sk_protinfo + private sock slab cache
Subsystems (2)
PATCH 3/12 Don't use sk_protinfo + private sock slab cache
Hi David/Patrick,
Please see the log in the patch.
Best Regards,
- Arnaldo
===================================================================
[email protected], 2005-01-20 20:36:07-02:00, [email protected]
[DECNET] Don't use sk_protinfo + private sock slab cache
DecNET already uses a private sock slab cache, but initializes sk->sk_protinfo, pointing to (sk + 1), this is wrong because at sk_free time we call sk->sk_destruct, that by default points to sock_def_destruct, that does a kfree on sk->sk_protinfo, since it was initialized at net_proto_family->create() time (dn_create), but in decnet sk_protinfo was not kmalloced, it was allocated piggybacked to struct sock.
This doesn't causes problems because decnet sets sk->sk_destruct to a custom function that doesn't calls kfree(sk->sk_protinfo), but to reach a long time goal of killing sk_protinfo lets just make DN_SK return sk + 1.
I left merging dn_scp with dn_sock for later, as the current state suits my needs to introduce connection_sock.
include/net/dn.h | 6 +++++- net/decnet/af_decnet.c | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-)
include/net/dn.h +5 -1
@@ -2,6 +2,7 @@#define _NET_DN_H#include <linux/dn.h> +#include <net/sock.h> #include <asm/byteorder.h> typedef unsigned short dn_address ;
@@ -133,7 +134,10 @@ }; -#define DN_SK (__sk) ((struct dn_scp *)(__sk)->sk_protinfo) +static inline struct dn_scp *DN_SK (struct sock *sk) +{ +return (struct dn_scp *)(sk +1 ); +}/* * src,dst : Source and Destination DECnet addresses
net/decnet/af_decnet.c +1 -2
@@ -456,8 +456,6 @@if (!sk) goto out; - sk->sk_protinfo = scp = (struct dn_scp *)(sk +1 ); -if (sock) sock->ops = &dn_proto_ops;sock_init_data (sock, sk);
@@ -471,6 +469,7 @@ sk->sk_allocation = gfp;/* Initialization of DECnet Session Control Port */ + scp =DN_SK (sk); scp->state =DN_O ;/* Open */ scp->numdat =1 ;/* Next data seg to tx */ scp->numoth =1 ;/* Next oth data to tx */