Re: [GIT]: Networking

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Eric Dumazet
Date: Tuesday, June 16, 2009 - 7:19 am

Eric Dumazet a écrit :

Here is first patch to take into account this initial offset in sk_wmem_alloc

(Only compiled, not tested)

A second patch will follow to correct /prov/net/udp and other PROC_FS files, and
also SIOCOUTQ/TIOCOUTQ, as we currently give off-by-one values, it certainly can
break some apps.

Thank you

[PATCH] net: sk_wmem_alloc has initial value of one, not zero

commit 2b85a34e911bf483c27cfdd124aeb1605145dc80 
(net: No more expensive sock_hold()/sock_put() on each tx)
changed initial sk_wmem_alloc value.

Some protocols check sk_wmem_alloc value to determine if a timer
must delay socket deallocation. We must take care of the sk_wmem_alloc
value being one instead of zero.

Reported by Ingo Molnar, and full diagnostic from David Miller.

Reported-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
 net/appletalk/ddp.c    |    4 ++--
 net/ax25/af_ax25.c     |    2 +-
 net/econet/af_econet.c |    4 ++--
 net/netrom/af_netrom.c |    2 +-
 net/rose/af_rose.c     |    2 +-
 net/x25/af_x25.c       |    2 +-
 6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index b603cba..048cfd0 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -162,7 +162,7 @@ static void atalk_destroy_timer(unsigned long data)
 {
 	struct sock *sk = (struct sock *)data;
 
-	if (atomic_read(&sk->sk_wmem_alloc) ||
+	if (atomic_read(&sk->sk_wmem_alloc) > 1 ||
 	    atomic_read(&sk->sk_rmem_alloc)) {
 		sk->sk_timer.expires = jiffies + SOCK_DESTROY_TIME;
 		add_timer(&sk->sk_timer);
@@ -175,7 +175,7 @@ static inline void atalk_destroy_socket(struct sock *sk)
 	atalk_remove_socket(sk);
 	skb_queue_purge(&sk->sk_receive_queue);
 
-	if (atomic_read(&sk->sk_wmem_alloc) ||
+	if (atomic_read(&sk->sk_wmem_alloc) > 1 ||
 	    atomic_read(&sk->sk_rmem_alloc)) {
 		setup_timer(&sk->sk_timer, atalk_destroy_timer,
 				(unsigned long)sk);
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index fd9d06f..2e81b1d 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -330,7 +330,7 @@ void ax25_destroy_socket(ax25_cb *ax25)
 	}
 
 	if (ax25->sk != NULL) {
-		if (atomic_read(&ax25->sk->sk_wmem_alloc) ||
+		if (atomic_read(&ax25->sk->sk_wmem_alloc) > 1 ||
 		    atomic_read(&ax25->sk->sk_rmem_alloc)) {
 			/* Defer: outstanding buffers */
 			setup_timer(&ax25->dtimer, ax25_destroy_timer,
diff --git a/net/econet/af_econet.c b/net/econet/af_econet.c
index 8121bf0..051dcb6 100644
--- a/net/econet/af_econet.c
+++ b/net/econet/af_econet.c
@@ -540,7 +540,7 @@ static void econet_destroy_timer(unsigned long data)
 {
 	struct sock *sk=(struct sock *)data;
 
-	if (!atomic_read(&sk->sk_wmem_alloc) &&
+	if (atomic_read(&sk->sk_wmem_alloc) <= 1 &&
 	    !atomic_read(&sk->sk_rmem_alloc)) {
 		sk_free(sk);
 		return;
@@ -580,7 +580,7 @@ static int econet_release(struct socket *sock)
 	skb_queue_purge(&sk->sk_receive_queue);
 
 	if (atomic_read(&sk->sk_rmem_alloc) ||
-	    atomic_read(&sk->sk_wmem_alloc)) {
+	    atomic_read(&sk->sk_wmem_alloc) > 1) {
 		sk->sk_timer.data     = (unsigned long)sk;
 		sk->sk_timer.expires  = jiffies + HZ;
 		sk->sk_timer.function = econet_destroy_timer;
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
index 3be0e01..8126bd4 100644
--- a/net/netrom/af_netrom.c
+++ b/net/netrom/af_netrom.c
@@ -286,7 +286,7 @@ void nr_destroy_socket(struct sock *sk)
 		kfree_skb(skb);
 	}
 
-	if (atomic_read(&sk->sk_wmem_alloc) ||
+	if (atomic_read(&sk->sk_wmem_alloc) > 1 ||
 	    atomic_read(&sk->sk_rmem_alloc)) {
 		/* Defer: outstanding buffers */
 		sk->sk_timer.function = nr_destroy_timer;
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index 877a7f6..0ab0f4d 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -356,7 +356,7 @@ void rose_destroy_socket(struct sock *sk)
 		kfree_skb(skb);
 	}
 
-	if (atomic_read(&sk->sk_wmem_alloc) ||
+	if (atomic_read(&sk->sk_wmem_alloc) > 1 ||
 	    atomic_read(&sk->sk_rmem_alloc)) {
 		/* Defer: outstanding buffers */
 		setup_timer(&sk->sk_timer, rose_destroy_timer,
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index c51f309..57dd5d3 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -372,7 +372,7 @@ static void __x25_destroy_socket(struct sock *sk)
 		kfree_skb(skb);
 	}
 
-	if (atomic_read(&sk->sk_wmem_alloc) ||
+	if (atomic_read(&sk->sk_wmem_alloc) > 1 ||
 	    atomic_read(&sk->sk_rmem_alloc)) {
 		/* Defer: outstanding buffers */
 		sk->sk_timer.expires  = jiffies + 10 * HZ;
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[GIT]: Networking, David Miller, (Mon Jun 15, 5:04 am)
Re: [GIT]: Networking, Ingo Molnar, (Tue Jun 16, 2:15 am)
Re: [GIT]: Networking, David Miller, (Tue Jun 16, 2:19 am)
Re: [GIT]: Networking, David Miller, (Tue Jun 16, 2:21 am)
Re: [GIT]: Networking, Ingo Molnar, (Tue Jun 16, 2:26 am)
Re: [GIT]: Networking, Ingo Molnar, (Tue Jun 16, 2:33 am)
Re: [GIT]: Networking, Alan Cox, (Tue Jun 16, 2:44 am)
Re: [GIT]: Networking, Ingo Molnar, (Tue Jun 16, 2:44 am)
Re: [GIT]: Networking, Ingo Molnar, (Tue Jun 16, 2:48 am)
Re: [GIT]: Networking, David Miller, (Tue Jun 16, 2:56 am)
Re: [GIT]: Networking, Ingo Molnar, (Tue Jun 16, 3:11 am)
Re: [GIT]: Networking, David Miller, (Tue Jun 16, 3:35 am)
Re: [GIT]: Networking, David Miller, (Tue Jun 16, 3:47 am)
Re: [GIT]: Networking, Ingo Molnar, (Tue Jun 16, 3:53 am)
Re: [GIT]: Networking, Ingo Molnar, (Tue Jun 16, 5:24 am)
Re: [GIT]: Networking, David Miller, (Tue Jun 16, 5:39 am)
Re: [GIT]: Networking, Eric Dumazet, (Tue Jun 16, 6:38 am)
Re: [GIT]: Networking, Eric Dumazet, (Tue Jun 16, 7:19 am)
Re: [GIT]: Networking, Linus Torvalds, (Tue Jun 16, 11:59 am)
Re: [GIT]: Networking, David Miller, (Tue Jun 16, 12:08 pm)
Re: [GIT]: Networking, Eric Dumazet, (Tue Jun 16, 12:37 pm)
Re: [GIT]: Networking, Eric Dumazet, (Tue Jun 16, 1:12 pm)
[PATCH] net: correct off-by-one write allocations reports, Eric Dumazet, (Tue Jun 16, 11:41 pm)
[PATCH] atm: sk_wmem_alloc initial value is one, Eric Dumazet, (Wed Jun 17, 4:31 am)
Re: [GIT]: Networking, David Miller, (Wed Jun 17, 4:32 am)
Re: [PATCH] atm: sk_wmem_alloc initial value is one, David Miller, (Wed Jun 17, 7:06 pm)
Re: [bug] __nf_ct_refresh_acct(): WARNING: at lib/list_deb ..., Pablo Neira Ayuso, (Thu Jun 18, 9:13 am)
[PATCH] netfilter: conntrack: death_by_timeout() fix, Eric Dumazet, (Thu Jun 18, 3:46 pm)
Re: [GIT]: Networking, Tilman Schmidt, (Thu Jun 18, 4:18 pm)
Re: [GIT]: Networking, David Miller, (Thu Jun 18, 8:36 pm)
Re: [PATCH] netfilter: conntrack: death_by_timeout() fix, Patrick McHardy, (Fri Jun 19, 4:15 am)