]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
pkt_sched: Fix return value corruption in HTB and TBF.
authorDavid S. Miller <davem@davemloft.net>
Thu, 28 Aug 2008 05:35:56 +0000 (22:35 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 8 Sep 2008 11:44:23 +0000 (04:44 -0700)
[ Upstream commit 69747650c814a8a79fef412c7416adf823293a3e ]

Based upon a bug report by Josip Rodin.

Packet schedulers should only return NET_XMIT_DROP iff
the packet really was dropped.  If the packet does reach
the device after we return NET_XMIT_DROP then TCP can
crash because it depends upon the enqueue path return
values being accurate.

Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
net/sched/sch_htb.c
net/sched/sch_tbf.c

index 3fb58f428f724ca9a8fd8c6cd9a41450df567c4d..51c3f6869691558bd0c9b60199d0d3cc97752da4 100644 (file)
@@ -595,11 +595,13 @@ static int htb_enqueue(struct sk_buff *skb, struct Qdisc *sch)
                kfree_skb(skb);
                return ret;
 #endif
-       } else if (cl->un.leaf.q->enqueue(skb, cl->un.leaf.q) !=
+       } else if ((ret = cl->un.leaf.q->enqueue(skb, cl->un.leaf.q)) !=
                   NET_XMIT_SUCCESS) {
-               sch->qstats.drops++;
-               cl->qstats.drops++;
-               return NET_XMIT_DROP;
+               if (ret == NET_XMIT_DROP) {
+                       sch->qstats.drops++;
+                       cl->qstats.drops++;
+               }
+               return ret;
        } else {
                cl->bstats.packets +=
                        skb_is_gso(skb)?skb_shinfo(skb)->gso_segs:1;
@@ -639,11 +641,13 @@ static int htb_requeue(struct sk_buff *skb, struct Qdisc *sch)
                kfree_skb(skb);
                return ret;
 #endif
-       } else if (cl->un.leaf.q->ops->requeue(skb, cl->un.leaf.q) !=
+       } else if ((ret = cl->un.leaf.q->ops->requeue(skb, cl->un.leaf.q)) !=
                   NET_XMIT_SUCCESS) {
-               sch->qstats.drops++;
-               cl->qstats.drops++;
-               return NET_XMIT_DROP;
+               if (ret == NET_XMIT_DROP) {
+                       sch->qstats.drops++;
+                       cl->qstats.drops++;
+               }
+               return ret;
        } else
                htb_activate(q, cl);
 
index 0b7d78f59d8cb727c1ac0506a5cbdf8cd36f153f..fc6f8f33ac6493286f52ce3926191d29ceb92202 100644 (file)
@@ -123,15 +123,8 @@ static int tbf_enqueue(struct sk_buff *skb, struct Qdisc* sch)
        struct tbf_sched_data *q = qdisc_priv(sch);
        int ret;
 
-       if (skb->len > q->max_size) {
-               sch->qstats.drops++;
-#ifdef CONFIG_NET_CLS_ACT
-               if (sch->reshape_fail == NULL || sch->reshape_fail(skb, sch))
-#endif
-                       kfree_skb(skb);
-
-               return NET_XMIT_DROP;
-       }
+       if (skb->len > q->max_size)
+               return qdisc_reshape_fail(skb, sch);
 
        if ((ret = q->qdisc->enqueue(skb, q->qdisc)) != 0) {
                sch->qstats.drops++;