: Fix prio/ingress classification logic error
Subsystems (3)
This is the final fix for the problem Peter reported. Turns out most other schedulers get it right, the only other case is ingress setting skb->tc_index to the uninitialized value of res.classid.
[NET_SCHED]: Fix prio/ingress classification logic error
Fix handling of empty or completely non-matching filter chains. In that case -1 is returned and tcf_result is uninitialized, the qdisc should fall back to default classification in that case.
Noticed by PJ Waskiewicz <[email protected]>.
---
commit c98436c161ff45850346b08f89cfb444be7c7817
tree 07e3ea0f508243f41e70645b6c358e23244ea0b4
parent e4903fb59590f86190280a549420f6cb85bd7f7e
author Patrick McHardy <[email protected]> Thu, 26 Jul 2007 13:32:26 +0200 committer Patrick McHardy <[email protected]> Thu, 26 Jul 2007 13:32:26 +0200
net/sched/sch_ingress.c | 3 +-- net/sched/sch_prio.c | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-)
net/sched/sch_ingress.c +1 -2
@@ -158,9 +158,8 @@ static int ingress_enqueue(struct sk_buff *skb,struct Qdisc *sch)break ;case TC_ACT_RECLASSIFY :case TC_ACT_OK : -case TC_ACT_UNSPEC : -default : skb->tc_index =TC_H_MIN (res.classid); +default : result =TC_ACT_OK ;break ; }
net/sched/sch_prio.c +3 -4
@@ -38,9 +38,11 @@ prio_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr)struct prio_sched_data *q =qdisc_priv (sch);u32 band = skb->priority;struct tcf_result res; +int err; *qerr =NET_XMIT_BYPASS ;if (TC_H_MAJ (skb->priority) != sch->handle) { + err =tc_classify (skb, q->filter_list, &res);#ifdef CONFIG_NET_CLS_ACT switch (tc_classify (skb, q->filter_list, &res)) {case TC_ACT_STOLEN :
@@ -49,11 +51,8 @@ prio_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr)case TC_ACT_SHOT : return NULL; } - -if (!q->filter_list ) { -#else -if (!q->filter_list ||tc_classify (skb, q->filter_list, &res)) {#endif +if (!q->filter_list || err <0 ) {if (TC_H_MAJ (band)) band =0 ; band = q->prio2band[band&TC_PRIO_MAX ];
Quoted 4 lines
This is the final fix for the problem Peter reported. Turns out most other schedulers get it right, the only other case is ingress setting
skb->tc_indexto the uninitialized value of res.classid.
I've applied this and tested prio and rr, and everything is happy again. Thanks for finding this and putting the patch together.
I got lost in looking for the bug in the u32_classify() code, and missed the easier defect...
Thanks again Patrick,
-PJ Waskiewicz