diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/net/inet_common.h | 1 | ||||
-rw-r--r-- | include/net/ipv6.h | 1 | ||||
-rw-r--r-- | include/net/sock.h | 32 | ||||
-rw-r--r-- | include/net/tcp.h | 2 |
4 files changed, 32 insertions, 4 deletions
diff --git a/include/net/inet_common.h b/include/net/inet_common.h index fbc1f4d140d8..1fbd94d8a316 100644 --- a/include/net/inet_common.h +++ b/include/net/inet_common.h | |||
@@ -29,7 +29,6 @@ extern unsigned int inet_poll(struct file * file, struct socket *sock, struct p | |||
29 | extern int inet_listen(struct socket *sock, int backlog); | 29 | extern int inet_listen(struct socket *sock, int backlog); |
30 | 30 | ||
31 | extern void inet_sock_destruct(struct sock *sk); | 31 | extern void inet_sock_destruct(struct sock *sk); |
32 | extern atomic_t inet_sock_nr; | ||
33 | 32 | ||
34 | extern int inet_bind(struct socket *sock, | 33 | extern int inet_bind(struct socket *sock, |
35 | struct sockaddr *uaddr, int addr_len); | 34 | struct sockaddr *uaddr, int addr_len); |
diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 533fc074ed90..c5a02ddc594a 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h | |||
@@ -145,7 +145,6 @@ DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6); | |||
145 | #define UDP6_INC_STATS(field) SNMP_INC_STATS(udp_stats_in6, field) | 145 | #define UDP6_INC_STATS(field) SNMP_INC_STATS(udp_stats_in6, field) |
146 | #define UDP6_INC_STATS_BH(field) SNMP_INC_STATS_BH(udp_stats_in6, field) | 146 | #define UDP6_INC_STATS_BH(field) SNMP_INC_STATS_BH(udp_stats_in6, field) |
147 | #define UDP6_INC_STATS_USER(field) SNMP_INC_STATS_USER(udp_stats_in6, field) | 147 | #define UDP6_INC_STATS_USER(field) SNMP_INC_STATS_USER(udp_stats_in6, field) |
148 | extern atomic_t inet6_sock_nr; | ||
149 | 148 | ||
150 | int snmp6_register_dev(struct inet6_dev *idev); | 149 | int snmp6_register_dev(struct inet6_dev *idev); |
151 | int snmp6_unregister_dev(struct inet6_dev *idev); | 150 | int snmp6_unregister_dev(struct inet6_dev *idev); |
diff --git a/include/net/sock.h b/include/net/sock.h index e9b1dbab90d0..11b81551041e 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -491,6 +491,9 @@ extern int sk_wait_data(struct sock *sk, long *timeo); | |||
491 | 491 | ||
492 | struct request_sock_ops; | 492 | struct request_sock_ops; |
493 | 493 | ||
494 | /* Here is the right place to enable sock refcounting debugging */ | ||
495 | #define SOCK_REFCNT_DEBUG | ||
496 | |||
494 | /* Networking protocol blocks we attach to sockets. | 497 | /* Networking protocol blocks we attach to sockets. |
495 | * socket layer -> transport layer interface | 498 | * socket layer -> transport layer interface |
496 | * transport -> network interface is defined by struct inet_proto | 499 | * transport -> network interface is defined by struct inet_proto |
@@ -561,7 +564,9 @@ struct proto { | |||
561 | char name[32]; | 564 | char name[32]; |
562 | 565 | ||
563 | struct list_head node; | 566 | struct list_head node; |
564 | 567 | #ifdef SOCK_REFCNT_DEBUG | |
568 | atomic_t socks; | ||
569 | #endif | ||
565 | struct { | 570 | struct { |
566 | int inuse; | 571 | int inuse; |
567 | u8 __pad[SMP_CACHE_BYTES - sizeof(int)]; | 572 | u8 __pad[SMP_CACHE_BYTES - sizeof(int)]; |
@@ -571,6 +576,31 @@ struct proto { | |||
571 | extern int proto_register(struct proto *prot, int alloc_slab); | 576 | extern int proto_register(struct proto *prot, int alloc_slab); |
572 | extern void proto_unregister(struct proto *prot); | 577 | extern void proto_unregister(struct proto *prot); |
573 | 578 | ||
579 | #ifdef SOCK_REFCNT_DEBUG | ||
580 | static inline void sk_refcnt_debug_inc(struct sock *sk) | ||
581 | { | ||
582 | atomic_inc(&sk->sk_prot->socks); | ||
583 | } | ||
584 | |||
585 | static inline void sk_refcnt_debug_dec(struct sock *sk) | ||
586 | { | ||
587 | atomic_dec(&sk->sk_prot->socks); | ||
588 | printk(KERN_DEBUG "%s socket %p released, %d are still alive\n", | ||
589 | sk->sk_prot->name, sk, atomic_read(&sk->sk_prot->socks)); | ||
590 | } | ||
591 | |||
592 | static inline void sk_refcnt_debug_release(const struct sock *sk) | ||
593 | { | ||
594 | if (atomic_read(&sk->sk_refcnt) != 1) | ||
595 | printk(KERN_DEBUG "Destruction of the %s socket %p delayed, refcnt=%d\n", | ||
596 | sk->sk_prot->name, sk, atomic_read(&sk->sk_refcnt)); | ||
597 | } | ||
598 | #else /* SOCK_REFCNT_DEBUG */ | ||
599 | #define sk_refcnt_debug_inc(sk) do { } while (0) | ||
600 | #define sk_refcnt_debug_dec(sk) do { } while (0) | ||
601 | #define sk_refcnt_debug_release(sk) do { } while (0) | ||
602 | #endif /* SOCK_REFCNT_DEBUG */ | ||
603 | |||
574 | /* Called with local bh disabled */ | 604 | /* Called with local bh disabled */ |
575 | static __inline__ void sock_prot_inc_use(struct proto *prot) | 605 | static __inline__ void sock_prot_inc_use(struct proto *prot) |
576 | { | 606 | { |
diff --git a/include/net/tcp.h b/include/net/tcp.h index 5010f0c5a56e..31984733777b 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
@@ -306,7 +306,7 @@ extern kmem_cache_t *tcp_timewait_cachep; | |||
306 | static inline void tcp_tw_put(struct tcp_tw_bucket *tw) | 306 | static inline void tcp_tw_put(struct tcp_tw_bucket *tw) |
307 | { | 307 | { |
308 | if (atomic_dec_and_test(&tw->tw_refcnt)) { | 308 | if (atomic_dec_and_test(&tw->tw_refcnt)) { |
309 | #ifdef INET_REFCNT_DEBUG | 309 | #ifdef SOCK_REFCNT_DEBUG |
310 | printk(KERN_DEBUG "tw_bucket %p released\n", tw); | 310 | printk(KERN_DEBUG "tw_bucket %p released\n", tw); |
311 | #endif | 311 | #endif |
312 | kmem_cache_free(tcp_timewait_cachep, tw); | 312 | kmem_cache_free(tcp_timewait_cachep, tw); |