aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@ghostprotocols.net>2005-08-09 22:45:38 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2005-08-29 18:37:29 -0400
commite6848976b721eeb5551cd94673faafeef78d9f35 (patch)
tree6c78b0eb52614ff6386b603ca64091b5aefaa418 /net/ipv6
parentd13964f4490157b8a290903362bfbc54f750a6bc (diff)
[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>
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/af_inet6.c31
-rw-r--r--net/ipv6/ipv6_sockglue.c15
-rw-r--r--net/ipv6/tcp_ipv6.c18
3 files changed, 32 insertions, 32 deletions
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 574047353628..7df2ccb380d9 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -86,26 +86,12 @@ extern void if6_proc_exit(void);
86 86
87int sysctl_ipv6_bindv6only; 87int sysctl_ipv6_bindv6only;
88 88
89#ifdef INET_REFCNT_DEBUG
90atomic_t inet6_sock_nr;
91EXPORT_SYMBOL(inet6_sock_nr);
92#endif
93
94/* The inetsw table contains everything that inet_create needs to 89/* The inetsw table contains everything that inet_create needs to
95 * build a new socket. 90 * build a new socket.
96 */ 91 */
97static struct list_head inetsw6[SOCK_MAX]; 92static struct list_head inetsw6[SOCK_MAX];
98static DEFINE_SPINLOCK(inetsw6_lock); 93static DEFINE_SPINLOCK(inetsw6_lock);
99 94
100static void inet6_sock_destruct(struct sock *sk)
101{
102 inet_sock_destruct(sk);
103
104#ifdef INET_REFCNT_DEBUG
105 atomic_dec(&inet6_sock_nr);
106#endif
107}
108
109static __inline__ struct ipv6_pinfo *inet6_sk_generic(struct sock *sk) 95static __inline__ struct ipv6_pinfo *inet6_sk_generic(struct sock *sk)
110{ 96{
111 const int offset = sk->sk_prot->obj_size - sizeof(struct ipv6_pinfo); 97 const int offset = sk->sk_prot->obj_size - sizeof(struct ipv6_pinfo);
@@ -186,7 +172,7 @@ static int inet6_create(struct socket *sock, int protocol)
186 inet->hdrincl = 1; 172 inet->hdrincl = 1;
187 } 173 }
188 174
189 sk->sk_destruct = inet6_sock_destruct; 175 sk->sk_destruct = inet_sock_destruct;
190 sk->sk_family = PF_INET6; 176 sk->sk_family = PF_INET6;
191 sk->sk_protocol = protocol; 177 sk->sk_protocol = protocol;
192 178
@@ -213,12 +199,17 @@ static int inet6_create(struct socket *sock, int protocol)
213 inet->pmtudisc = IP_PMTUDISC_DONT; 199 inet->pmtudisc = IP_PMTUDISC_DONT;
214 else 200 else
215 inet->pmtudisc = IP_PMTUDISC_WANT; 201 inet->pmtudisc = IP_PMTUDISC_WANT;
202 /*
203 * Increment only the relevant sk_prot->socks debug field, this changes
204 * the previous behaviour of incrementing both the equivalent to
205 * answer->prot->socks (inet6_sock_nr) and inet_sock_nr.
206 *
207 * This allows better debug granularity as we'll know exactly how many
208 * UDPv6, TCPv6, etc socks were allocated, not the sum of all IPv6
209 * transport protocol socks. -acme
210 */
211 sk_refcnt_debug_inc(sk);
216 212
217
218#ifdef INET_REFCNT_DEBUG
219 atomic_inc(&inet6_sock_nr);
220 atomic_inc(&inet_sock_nr);
221#endif
222 if (inet->num) { 213 if (inet->num) {
223 /* It assumes that any protocol which allows 214 /* It assumes that any protocol which allows
224 * the user to assign a number at socket 215 * the user to assign a number at socket
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 3bc144a79fa5..76fe23925d77 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -163,6 +163,13 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname,
163 fl6_free_socklist(sk); 163 fl6_free_socklist(sk);
164 ipv6_sock_mc_close(sk); 164 ipv6_sock_mc_close(sk);
165 165
166 /*
167 * Sock is moving from IPv6 to IPv4 (sk_prot), so
168 * remove it from the refcnt debug socks count in the
169 * original family...
170 */
171 sk_refcnt_debug_dec(sk);
172
166 if (sk->sk_protocol == IPPROTO_TCP) { 173 if (sk->sk_protocol == IPPROTO_TCP) {
167 struct tcp_sock *tp = tcp_sk(sk); 174 struct tcp_sock *tp = tcp_sk(sk);
168 175
@@ -192,9 +199,11 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname,
192 kfree_skb(pktopt); 199 kfree_skb(pktopt);
193 200
194 sk->sk_destruct = inet_sock_destruct; 201 sk->sk_destruct = inet_sock_destruct;
195#ifdef INET_REFCNT_DEBUG 202 /*
196 atomic_dec(&inet6_sock_nr); 203 * ... and add it to the refcnt debug socks count
197#endif 204 * in the new family. -acme
205 */
206 sk_refcnt_debug_inc(sk);
198 module_put(THIS_MODULE); 207 module_put(THIS_MODULE);
199 retv = 0; 208 retv = 0;
200 break; 209 break;
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index ef29cfd936d3..885e05bd99f6 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1407,12 +1407,11 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1407 newnp->mcast_oif = tcp_v6_iif(skb); 1407 newnp->mcast_oif = tcp_v6_iif(skb);
1408 newnp->mcast_hops = skb->nh.ipv6h->hop_limit; 1408 newnp->mcast_hops = skb->nh.ipv6h->hop_limit;
1409 1409
1410 /* Charge newly allocated IPv6 socket. Though it is mapped, 1410 /*
1411 * it is IPv6 yet. 1411 * No need to charge this sock to the relevant IPv6 refcnt debug socks count
1412 * here, tcp_create_openreq_child now does this for us, see the comment in
1413 * that function for the gory details. -acme
1412 */ 1414 */
1413#ifdef INET_REFCNT_DEBUG
1414 atomic_inc(&inet6_sock_nr);
1415#endif
1416 1415
1417 /* It is tricky place. Until this moment IPv4 tcp 1416 /* It is tricky place. Until this moment IPv4 tcp
1418 worked with IPv6 af_tcp.af_specific. 1417 worked with IPv6 af_tcp.af_specific.
@@ -1467,10 +1466,11 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1467 if (newsk == NULL) 1466 if (newsk == NULL)
1468 goto out; 1467 goto out;
1469 1468
1470 /* Charge newly allocated IPv6 socket */ 1469 /*
1471#ifdef INET_REFCNT_DEBUG 1470 * No need to charge this sock to the relevant IPv6 refcnt debug socks
1472 atomic_inc(&inet6_sock_nr); 1471 * count here, tcp_create_openreq_child now does this for us, see the
1473#endif 1472 * comment in that function for the gory details. -acme
1473 */
1474 1474
1475 ip6_dst_store(newsk, dst, NULL); 1475 ip6_dst_store(newsk, dst, NULL);
1476 newsk->sk_route_caps = dst->dev->features & 1476 newsk->sk_route_caps = dst->dev->features &