Commit 42b6785eeb40fe3e9dab9981b6e3231a77c7c2f6

Authored by YOSHIFUJI Hideaki
Committed by David S. Miller
1 parent 9469c7b4aa

[NET]: Introduce protocol-specific destructor for time-wait sockets.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 2 changed files with 8 additions and 0 deletions Side-by-side Diff

include/net/inet_timewait_sock.h
... ... @@ -196,6 +196,7 @@
196 196 {
197 197 if (atomic_dec_and_test(&tw->tw_refcnt)) {
198 198 struct module *owner = tw->tw_prot->owner;
  199 + twsk_destructor((struct sock *)tw);
199 200 #ifdef SOCK_REFCNT_DEBUG
200 201 printk(KERN_DEBUG "%s timewait_sock %p released\n",
201 202 tw->tw_prot->name, tw);
include/net/timewait_sock.h
... ... @@ -19,6 +19,7 @@
19 19 unsigned int twsk_obj_size;
20 20 int (*twsk_unique)(struct sock *sk,
21 21 struct sock *sktw, void *twp);
  22 + void (*twsk_destructor)(struct sock *sk);
22 23 };
23 24  
24 25 static inline int twsk_unique(struct sock *sk, struct sock *sktw, void *twp)
... ... @@ -26,6 +27,12 @@
26 27 if (sk->sk_prot->twsk_prot->twsk_unique != NULL)
27 28 return sk->sk_prot->twsk_prot->twsk_unique(sk, sktw, twp);
28 29 return 0;
  30 +}
  31 +
  32 +static inline void twsk_destructor(struct sock *sk)
  33 +{
  34 + if (sk->sk_prot->twsk_prot->twsk_destructor != NULL)
  35 + sk->sk_prot->twsk_prot->twsk_destructor(sk);
29 36 }
30 37  
31 38 #endif /* _TIMEWAIT_SOCK_H */