aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/inet_timewait_sock.h
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@ghostprotocols.net>2005-10-11 00:25:23 -0400
committerDavid S. Miller <davem@davemloft.net>2005-10-11 00:25:23 -0400
commiteeb2b8560676e454ad37ee30b49bc7d897edc9be (patch)
tree60b316e93b880aa1ba01a9c5496c8269a48b4de9 /include/net/inet_timewait_sock.h
parent2a9bc9bb4d3a4570a8a48aadf071b91e657adb89 (diff)
[TWSK]: Grab the module refcount for timewait sockets
This is required to avoid unloading a module that has active timewait sockets, such as DCCP. Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/inet_timewait_sock.h')
-rw-r--r--include/net/inet_timewait_sock.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h
index 4ade56ef3a4d..28f7b2103505 100644
--- a/include/net/inet_timewait_sock.h
+++ b/include/net/inet_timewait_sock.h
@@ -19,6 +19,7 @@
19 19
20#include <linux/ip.h> 20#include <linux/ip.h>
21#include <linux/list.h> 21#include <linux/list.h>
22#include <linux/module.h>
22#include <linux/timer.h> 23#include <linux/timer.h>
23#include <linux/types.h> 24#include <linux/types.h>
24#include <linux/workqueue.h> 25#include <linux/workqueue.h>
@@ -193,11 +194,13 @@ static inline u32 inet_rcv_saddr(const struct sock *sk)
193static inline void inet_twsk_put(struct inet_timewait_sock *tw) 194static inline void inet_twsk_put(struct inet_timewait_sock *tw)
194{ 195{
195 if (atomic_dec_and_test(&tw->tw_refcnt)) { 196 if (atomic_dec_and_test(&tw->tw_refcnt)) {
197 struct module *owner = tw->tw_prot->owner;
196#ifdef SOCK_REFCNT_DEBUG 198#ifdef SOCK_REFCNT_DEBUG
197 printk(KERN_DEBUG "%s timewait_sock %p released\n", 199 printk(KERN_DEBUG "%s timewait_sock %p released\n",
198 tw->tw_prot->name, tw); 200 tw->tw_prot->name, tw);
199#endif 201#endif
200 kmem_cache_free(tw->tw_prot->twsk_slab, tw); 202 kmem_cache_free(tw->tw_prot->twsk_slab, tw);
203 module_put(owner);
201 } 204 }
202} 205}
203 206