Skip to content

Commit 9de95df

Browse files
peilin-yekuba-moo
authored andcommitted
net/sched: Prohibit regrafting ingress or clsact Qdiscs
Currently, after creating an ingress (or clsact) Qdisc and grafting it under TC_H_INGRESS (TC_H_CLSACT), it is possible to graft it again under e.g. a TBF Qdisc: $ ip link add ifb0 type ifb $ tc qdisc add dev ifb0 handle 1: root tbf rate 20kbit buffer 1600 limit 3000 $ tc qdisc add dev ifb0 clsact $ tc qdisc link dev ifb0 handle ffff: parent 1:1 $ tc qdisc show dev ifb0 qdisc tbf 1: root refcnt 2 rate 20Kbit burst 1600b lat 560.0ms qdisc clsact ffff: parent ffff:fff1 refcnt 2 ^^^^^^^^ clsact's refcount has increased: it is now grafted under both TC_H_CLSACT and 1:1. ingress and clsact Qdiscs should only be used under TC_H_INGRESS (TC_H_CLSACT). Prohibit regrafting them. Fixes: 1da177e ("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 f85fa45 commit 9de95df

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

net/sched/sch_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,6 +1596,11 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n,
15961596
NL_SET_ERR_MSG(extack, "Invalid qdisc name");
15971597
return -EINVAL;
15981598
}
1599+
if (q->flags & TCQ_F_INGRESS) {
1600+
NL_SET_ERR_MSG(extack,
1601+
"Cannot regraft ingress or clsact Qdiscs");
1602+
return -EINVAL;
1603+
}
15991604
if (q == p ||
16001605
(p && check_loop(q, p, 0))) {
16011606
NL_SET_ERR_MSG(extack, "Qdisc parent/child loop detected");

0 commit comments

Comments
 (0)