Subject: [PATCH] pkt_sched: Fix qdisc state in net_tx_action()

From: Jarek Poplawski <[email-masked]>
Date: Fri, 5 Sep 2008 08:29:15 +0000

On 05-09-2008 00:43, Denys Fedoryshchenko wrote:
> I catch it!!!! And it is not ppp seems.
...
> Here is command that stuck. ifconfig, tc doesn't work, and seems 
> even sockets cannot be created (i cannot open new ssh connection 
> from this router, but i can ssh to existing socket).
> 
> I trigger this bug on latest git too.
> 
> 
>   PID  PPID USER     STAT   VSZ %MEM %CPU COMMAND
> 11593     1 root     R     2048  0.1 47.5 tc qdisc del dev ifb0 root
...

Great!!!!

Alas these logs are not very clear, but while browsing the code I
think I found one of possible reasons around this (but I'm not sure
this is all...).

Thanks,
Jarek P.

------------>

pkt_sched: Fix qdisc state in net_tx_action()

net_tx_action() can skip __QDISC_STATE_SCHED bit clearing while qdisc
is neither ran nor rescheduled, which may cause endless loop in
dev_deactivate().

Reported-by: Denys Fedoryshchenko <[email-masked]>
Signed-off-by: Jarek Poplawski <[email-masked]>

---

 net/core/dev.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 60c51f7..e719ed2 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1991,8 +1991,13 @@ static void net_tx_action(struct softirq_action *h)
 				spin_unlock(root_lock);
 			} else {
 				if (!test_bit(__QDISC_STATE_DEACTIVATED,
-					      &q->state))
+					      &q->state)) {
 					__netif_reschedule(q);
+				} else {
+					smp_mb__before_clear_bit();
+					clear_bit(__QDISC_STATE_SCHED,
+						  &q->state);
+				}
 			}
 		}
 	}