Skip to content

Commit bb50f12

Browse files
committed
Merge branch 'net-sched-fixes-for-sch_ingress-and-sch_clsact'
Peilin Ye says: ==================== net/sched: Fixes for sch_ingress and sch_clsact These are v6 fixes for ingress and clsact Qdiscs, including only first 4 patches (already tested and reviewed) from v5. Patch 5 and 6 from previous versions are still under discussion and will be sent separately. [a] https://syzkaller.appspot.com/bug?extid=b53a9c0d1ea4ad62da8b Link to v5: https://lore.kernel.org/r/cover.1684887977.git.peilin.ye@bytedance.com/ Link to v4: https://lore.kernel.org/r/cover.1684825171.git.peilin.ye@bytedance.com/ Link to v3 (incomplete): https://lore.kernel.org/r/cover.1684821877.git.peilin.ye@bytedance.com/ Link to v2: https://lore.kernel.org/r/cover.1684796705.git.peilin.ye@bytedance.com/ Link to v1: https://lore.kernel.org/r/cover.1683326865.git.peilin.ye@bytedance.com/ ==================== Link: https://lore.kernel.org/r/cover.1685388545.git.peilin.ye@bytedance.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 7ba0732 + 9de95df commit bb50f12

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

net/sched/sch_api.c

Lines changed: 11 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) {
@@ -1591,6 +1596,11 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n,
15911596
NL_SET_ERR_MSG(extack, "Invalid qdisc name");
15921597
return -EINVAL;
15931598
}
1599+
if (q->flags & TCQ_F_INGRESS) {
1600+
NL_SET_ERR_MSG(extack,
1601+
"Cannot regraft ingress or clsact Qdiscs");
1602+
return -EINVAL;
1603+
}
15941604
if (q == p ||
15951605
(p && check_loop(q, p, 0))) {
15961606
NL_SET_ERR_MSG(extack, "Qdisc parent/child loop detected");

net/sched/sch_ingress.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ static int ingress_init(struct Qdisc *sch, struct nlattr *opt,
8080
struct net_device *dev = qdisc_dev(sch);
8181
int err;
8282

83+
if (sch->parent != TC_H_INGRESS)
84+
return -EOPNOTSUPP;
85+
8386
net_inc_ingress_queue();
8487

8588
mini_qdisc_pair_init(&q->miniqp, sch, &dev->miniq_ingress);
@@ -101,6 +104,9 @@ static void ingress_destroy(struct Qdisc *sch)
101104
{
102105
struct ingress_sched_data *q = qdisc_priv(sch);
103106

107+
if (sch->parent != TC_H_INGRESS)
108+
return;
109+
104110
tcf_block_put_ext(q->block, sch, &q->block_info);
105111
net_dec_ingress_queue();
106112
}
@@ -134,7 +140,7 @@ static struct Qdisc_ops ingress_qdisc_ops __read_mostly = {
134140
.cl_ops = &ingress_class_ops,
135141
.id = "ingress",
136142
.priv_size = sizeof(struct ingress_sched_data),
137-
.static_flags = TCQ_F_CPUSTATS,
143+
.static_flags = TCQ_F_INGRESS | TCQ_F_CPUSTATS,
138144
.init = ingress_init,
139145
.destroy = ingress_destroy,
140146
.dump = ingress_dump,
@@ -219,6 +225,9 @@ static int clsact_init(struct Qdisc *sch, struct nlattr *opt,
219225
struct net_device *dev = qdisc_dev(sch);
220226
int err;
221227

228+
if (sch->parent != TC_H_CLSACT)
229+
return -EOPNOTSUPP;
230+
222231
net_inc_ingress_queue();
223232
net_inc_egress_queue();
224233

@@ -248,6 +257,9 @@ static void clsact_destroy(struct Qdisc *sch)
248257
{
249258
struct clsact_sched_data *q = qdisc_priv(sch);
250259

260+
if (sch->parent != TC_H_CLSACT)
261+
return;
262+
251263
tcf_block_put_ext(q->egress_block, sch, &q->egress_block_info);
252264
tcf_block_put_ext(q->ingress_block, sch, &q->ingress_block_info);
253265

@@ -269,7 +281,7 @@ static struct Qdisc_ops clsact_qdisc_ops __read_mostly = {
269281
.cl_ops = &clsact_class_ops,
270282
.id = "clsact",
271283
.priv_size = sizeof(struct clsact_sched_data),
272-
.static_flags = TCQ_F_CPUSTATS,
284+
.static_flags = TCQ_F_INGRESS | TCQ_F_CPUSTATS,
273285
.init = clsact_init,
274286
.destroy = clsact_destroy,
275287
.dump = ingress_dump,

0 commit comments

Comments
 (0)