summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/if_pppox.h5
-rw-r--r--include/linux/net.h9
-rw-r--r--include/net/sock.h20
3 files changed, 22 insertions, 12 deletions
diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
index 117357b14483..78ffd78ddb9e 100644
--- a/include/linux/if_pppox.h
+++ b/include/linux/if_pppox.h
@@ -140,8 +140,6 @@ struct pppox_proto {
int (*create)(struct socket *sock);
int (*ioctl)(struct socket *sock, unsigned int cmd,
unsigned long arg);
- int (*release)(struct socket *sock);
- void (*sk_free)(struct sock *sk);
struct module *owner;
};
@@ -150,9 +148,6 @@ extern void unregister_pppox_proto(int proto_num);
extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */
extern int pppox_channel_ioctl(struct ppp_channel *pc, unsigned int cmd,
unsigned long arg);
-extern struct sock *pppox_sk_alloc(struct socket *sock, int protocol,
- int priority, int zero_it,
- kmem_cache_t *slab);
/* PPPoX socket states */
enum {
diff --git a/include/linux/net.h b/include/linux/net.h
index 8b012430f49d..04bd681473db 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -89,9 +89,11 @@ struct page;
struct kiocb;
struct sockaddr;
struct msghdr;
+struct module;
struct proto_ops {
int family;
+ struct module *owner;
int (*release) (struct socket *sock);
int (*bind) (struct socket *sock,
struct sockaddr *umyaddr,
@@ -127,8 +129,6 @@ struct proto_ops {
int offset, size_t size, int flags);
};
-struct module;
-
struct net_proto_family {
int family;
int (*create)(struct socket *sock, int protocol);
@@ -140,9 +140,6 @@ struct net_proto_family {
struct module *owner;
};
-extern int net_family_get(int family);
-extern void net_family_put(int family);
-
struct iovec;
extern int sock_wake_async(struct socket *sk, int how, int band);
@@ -227,7 +224,7 @@ SOCKCALL_WRAP(name, mmap, (struct file *file, struct socket *sock, struct vm_are
\
static struct proto_ops name##_ops = { \
.family = fam, \
- \
+ .owner = THIS_MODULE, \
.release = __lock_##name##_release, \
.bind = __lock_##name##_bind, \
.connect = __lock_##name##_connect, \
diff --git a/include/net/sock.h b/include/net/sock.h
index 4f5b79f30880..53639300bc3c 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -43,7 +43,7 @@
#include <linux/config.h>
#include <linux/timer.h>
#include <linux/cache.h>
-
+#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/skbuff.h> /* struct sk_buff */
#include <linux/security.h>
@@ -197,6 +197,7 @@ struct sock {
void *user_data;
/* Callbacks */
+ struct module *owner;
void (*state_change)(struct sock *sk);
void (*data_ready)(struct sock *sk,int bytes);
void (*write_space)(struct sock *sk);
@@ -270,6 +271,23 @@ struct proto {
} stats[NR_CPUS];
};
+static __inline__ void sk_set_owner(struct sock *sk, struct module *owner)
+{
+ /*
+ * One should use sk_set_owner just once, after struct sock creation,
+ * be it shortly after sk_alloc or after a function that returns a new
+ * struct sock (and that down the call chain called sk_alloc), e.g. the
+ * IPv4 and IPv6 modules share tcp_create_openreq_child, so if
+ * tcp_create_openreq_child called sk_set_owner IPv6 would have to
+ * change the ownership of this struct sock, with one not needed
+ * transient sk_set_owner call.
+ */
+ if (unlikely(sk->owner != NULL))
+ BUG();
+ sk->owner = owner;
+ __module_get(owner);
+}
+
/* Called with local bh disabled */
static __inline__ void sock_prot_inc_use(struct proto *prot)
{