Currently if we add a filter to the ingress qdisc (e.g matchall) the filter data are reported even in the egress path. The issue can be triggered with the following reproducer:
$tc qdisc add dev lo ingress $tc filter add dev lo ingress matchall action ok $tc filter show dev lo ingress filter protocol all pref 49152 matchall chain 0 filter protocol all pref 49152 matchall chain 0 handle 0x1 not_in_hw action order 1: gact action pass random type none pass val 0 index 1 ref 1 bind 1 $tc filter show dev lo egress filter protocol all pref 49152 matchall chain 0 filter protocol all pref 49152 matchall chain 0 handle 0x1 not_in_hw action order 1: gact action pass random type none pass val 0 index 1 ref 1 bind 1 Fix it reporting NULL for non-ingress filters in ingress_tcf_block routine Fixes: 6529eaba33f0 ("net: sched: introduce tcf block infrastructure") Signed-off-by: Lorenzo Bianconi <lorenzo.bianc...@redhat.com> --- net/sched/sch_ingress.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c index 0bac926b46c7..1825347fed3a 100644 --- a/net/sched/sch_ingress.c +++ b/net/sched/sch_ingress.c @@ -31,7 +31,7 @@ static struct Qdisc *ingress_leaf(struct Qdisc *sch, unsigned long arg) static unsigned long ingress_find(struct Qdisc *sch, u32 classid) { - return TC_H_MIN(classid) + 1; + return TC_H_MIN(classid); } static unsigned long ingress_bind_filter(struct Qdisc *sch, @@ -53,7 +53,12 @@ static struct tcf_block *ingress_tcf_block(struct Qdisc *sch, unsigned long cl, { struct ingress_sched_data *q = qdisc_priv(sch); - return q->block; + switch (cl) { + case TC_H_MIN(TC_H_MIN_INGRESS): + return q->block; + default: + return NULL; + } } static void clsact_chain_head_change(struct tcf_proto *tp_head, void *priv) -- 2.20.1