Skip to content

Commit f85fa45

Browse files
peilin-yekuba-moo
authored andcommitted
net/sched: Reserve TC_H_INGRESS (TC_H_CLSACT) for ingress (clsact) Qdiscs
Currently it is possible to add e.g. an HTB Qdisc under ffff:fff1 (TC_H_INGRESS, TC_H_CLSACT): $ ip link add name ifb0 type ifb $ tc qdisc add dev ifb0 parent ffff:fff1 htb $ tc qdisc add dev ifb0 clsact Error: Exclusivity flag on, cannot modify. $ drgn ... >>> ifb0 = netdev_get_by_name(prog, "ifb0") >>> qdisc = ifb0.ingress_queue.qdisc_sleeping >>> print(qdisc.ops.id.string_().decode()) htb >>> qdisc.flags.value_() # TCQ_F_INGRESS 2 Only allow ingress and clsact Qdiscs under ffff:fff1. Return -EINVAL for everything else. Make TCQ_F_INGRESS a static flag of ingress and clsact Qdiscs. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Fixes: 1f211a1 ("net, sched: add clsact qdisc") Tested-by: Pedro Tammela <pctammela@mojatatu.com> Acked-by: Jamal Hadi Salim <jhs@mojatatu.com> Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com> Reviewed-by: Vlad Buslov <vladbu@nvidia.com> Signed-off-by: Peilin Ye <peilin.ye@bytedance.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 5eeebfe commit f85fa45

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

net/sched/sch_api.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,12 @@ static struct Qdisc *qdisc_create(struct net_device *dev,
12521252
sch->parent = parent;
12531253

12541254
if (handle == TC_H_INGRESS) {
1255-
sch->flags |= TCQ_F_INGRESS;
1255+
if (!(sch->flags & TCQ_F_INGRESS)) {
1256+
NL_SET_ERR_MSG(extack,
1257+
"Specified parent ID is reserved for ingress and clsact Qdiscs");
1258+
err = -EINVAL;
1259+
goto err_out3;
1260+
}
12561261
handle = TC_H_MAKE(TC_H_INGRESS, 0);
12571262
} else {
12581263
if (handle == 0) {

net/sched/sch_ingress.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static struct Qdisc_ops ingress_qdisc_ops __read_mostly = {
140140
.cl_ops = &ingress_class_ops,
141141
.id = "ingress",
142142
.priv_size = sizeof(struct ingress_sched_data),
143-
.static_flags = TCQ_F_CPUSTATS,
143+
.static_flags = TCQ_F_INGRESS | TCQ_F_CPUSTATS,
144144
.init = ingress_init,
145145
.destroy = ingress_destroy,
146146
.dump = ingress_dump,
@@ -281,7 +281,7 @@ static struct Qdisc_ops clsact_qdisc_ops __read_mostly = {
281281
.cl_ops = &clsact_class_ops,
282282
.id = "clsact",
283283
.priv_size = sizeof(struct clsact_sched_data),
284-
.static_flags = TCQ_F_CPUSTATS,
284+
.static_flags = TCQ_F_INGRESS | TCQ_F_CPUSTATS,
285285
.init = clsact_init,
286286
.destroy = clsact_destroy,
287287
.dump = ingress_dump,

0 commit comments

Comments
 (0)