[NET]: Cleanup INET_REFCNT_DEBUG code
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
d13964f449
commit
e6848976b7
@@ -29,7 +29,6 @@ extern unsigned int inet_poll(struct file * file, struct socket *sock, struct p
|
||||
extern int inet_listen(struct socket *sock, int backlog);
|
||||
|
||||
extern void inet_sock_destruct(struct sock *sk);
|
||||
extern atomic_t inet_sock_nr;
|
||||
|
||||
extern int inet_bind(struct socket *sock,
|
||||
struct sockaddr *uaddr, int addr_len);
|
||||
|
@@ -145,7 +145,6 @@ DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6);
|
||||
#define UDP6_INC_STATS(field) SNMP_INC_STATS(udp_stats_in6, field)
|
||||
#define UDP6_INC_STATS_BH(field) SNMP_INC_STATS_BH(udp_stats_in6, field)
|
||||
#define UDP6_INC_STATS_USER(field) SNMP_INC_STATS_USER(udp_stats_in6, field)
|
||||
extern atomic_t inet6_sock_nr;
|
||||
|
||||
int snmp6_register_dev(struct inet6_dev *idev);
|
||||
int snmp6_unregister_dev(struct inet6_dev *idev);
|
||||
|
@@ -491,6 +491,9 @@ extern int sk_wait_data(struct sock *sk, long *timeo);
|
||||
|
||||
struct request_sock_ops;
|
||||
|
||||
/* Here is the right place to enable sock refcounting debugging */
|
||||
#define SOCK_REFCNT_DEBUG
|
||||
|
||||
/* Networking protocol blocks we attach to sockets.
|
||||
* socket layer -> transport layer interface
|
||||
* transport -> network interface is defined by struct inet_proto
|
||||
@@ -561,7 +564,9 @@ struct proto {
|
||||
char name[32];
|
||||
|
||||
struct list_head node;
|
||||
|
||||
#ifdef SOCK_REFCNT_DEBUG
|
||||
atomic_t socks;
|
||||
#endif
|
||||
struct {
|
||||
int inuse;
|
||||
u8 __pad[SMP_CACHE_BYTES - sizeof(int)];
|
||||
@@ -571,6 +576,31 @@ struct proto {
|
||||
extern int proto_register(struct proto *prot, int alloc_slab);
|
||||
extern void proto_unregister(struct proto *prot);
|
||||
|
||||
#ifdef SOCK_REFCNT_DEBUG
|
||||
static inline void sk_refcnt_debug_inc(struct sock *sk)
|
||||
{
|
||||
atomic_inc(&sk->sk_prot->socks);
|
||||
}
|
||||
|
||||
static inline void sk_refcnt_debug_dec(struct sock *sk)
|
||||
{
|
||||
atomic_dec(&sk->sk_prot->socks);
|
||||
printk(KERN_DEBUG "%s socket %p released, %d are still alive\n",
|
||||
sk->sk_prot->name, sk, atomic_read(&sk->sk_prot->socks));
|
||||
}
|
||||
|
||||
static inline void sk_refcnt_debug_release(const struct sock *sk)
|
||||
{
|
||||
if (atomic_read(&sk->sk_refcnt) != 1)
|
||||
printk(KERN_DEBUG "Destruction of the %s socket %p delayed, refcnt=%d\n",
|
||||
sk->sk_prot->name, sk, atomic_read(&sk->sk_refcnt));
|
||||
}
|
||||
#else /* SOCK_REFCNT_DEBUG */
|
||||
#define sk_refcnt_debug_inc(sk) do { } while (0)
|
||||
#define sk_refcnt_debug_dec(sk) do { } while (0)
|
||||
#define sk_refcnt_debug_release(sk) do { } while (0)
|
||||
#endif /* SOCK_REFCNT_DEBUG */
|
||||
|
||||
/* Called with local bh disabled */
|
||||
static __inline__ void sock_prot_inc_use(struct proto *prot)
|
||||
{
|
||||
|
@@ -306,7 +306,7 @@ extern kmem_cache_t *tcp_timewait_cachep;
|
||||
static inline void tcp_tw_put(struct tcp_tw_bucket *tw)
|
||||
{
|
||||
if (atomic_dec_and_test(&tw->tw_refcnt)) {
|
||||
#ifdef INET_REFCNT_DEBUG
|
||||
#ifdef SOCK_REFCNT_DEBUG
|
||||
printk(KERN_DEBUG "tw_bucket %p released\n", tw);
|
||||
#endif
|
||||
kmem_cache_free(tcp_timewait_cachep, tw);
|
||||
|
Reference in New Issue
Block a user