summaryrefslogtreecommitdiff
path: root/include/net
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@conectiva.com.br>2003-05-02 20:57:58 -0300
committerArnaldo Carvalho de Melo <acme@conectiva.com.br>2003-05-02 20:57:58 -0300
commitcfc7551c0afe5c167eebf68be397c84e1fd3957f (patch)
tree8bbe92271fab807129a93c4e509161bb71eddce7 /include/net
parentf48b1d88fa6e2aa368202b77e5da3c4ea0979edb (diff)
o net: improve the current module infrastructure
As per discussions in netdev we'll probably be moving to a brand new scheme, but this set of changesets have been discussed and are an improvement to the current situation and were already done prior to this thread happening.
Diffstat (limited to 'include/net')
-rw-r--r--include/net/sock.h20
1 files changed, 19 insertions, 1 deletions
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)
{