[PATCH] net: trap attempts to modify noop qdisc

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: David Miller <davem@...>
Cc: <kaber@...>, <netdev@...>
Date: Thursday, August 7, 2008 - 2:08 am

Since noop qdisc is a singleton, it shouldn't end up with any other
qdisc's on it's list, and it shouldn't be deleted.

Dave, this should help you find the bug.  Any change to root qdisc causes
this to trigger.  I.e doing:
  tc qdisc add dev eth0 root pfifo
causes pfifo to end up on the noop_qdisc->list, which later causes problems.

diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 4840aff..57b778f 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -792,8 +792,10 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue,
 				goto err_out3;
 			}
 		}
-		if (parent && !(sch->flags & TCQ_F_INGRESS))
+		if (parent && !(sch->flags & TCQ_F_INGRESS)) {
+			BUG_ON(dev_queue->qdisc == &noop_qdisc);
 			list_add_tail(&sch->list, &dev_queue->qdisc->list);
+		}
 
 		return sch;
 	}
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 7cf83b3..5988863 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -547,6 +547,8 @@ static void __qdisc_destroy(struct rcu_head *head)
 
 void qdisc_destroy(struct Qdisc *qdisc)
 {
+	BUG_ON(qdisc == &noop_qdisc);
+
 	if (qdisc->flags & TCQ_F_BUILTIN ||
 	    !atomic_dec_and_test(&qdisc->refcnt))
 		return;
-- 
1.5.4.3

--
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:
sfq dump broken in 2.6.27-rc1, Stephen Hemminger, (Wed Aug 6, 9:02 pm)
Re: sfq dump broken in 2.6.27-rc1, David Miller, (Wed Aug 6, 9:13 pm)
Re: sfq dump broken in 2.6.27-rc1, Stephen Hemminger, (Wed Aug 6, 11:20 pm)
Re: sfq dump broken in 2.6.27-rc1, David Miller, (Wed Aug 6, 11:22 pm)
[PATCH] net: trap attempts to modify noop qdisc, Stephen Hemminger, (Thu Aug 7, 2:08 am)
Re: [PATCH] net: trap attempts to modify noop qdisc, David Miller, (Thu Aug 7, 2:11 am)
Re: [PATCH] net: trap attempts to modify noop qdisc, Stephen Hemminger, (Thu Aug 7, 2:15 am)
Re: [PATCH] net: trap attempts to modify noop qdisc, David Miller, (Thu Aug 7, 2:37 am)
Re: [PATCH] net: trap attempts to modify noop qdisc, Stephen Hemminger, (Thu Aug 7, 1:22 pm)
Re: [PATCH] net: trap attempts to modify noop qdisc, David Miller, (Thu Aug 7, 2:18 am)