Commit bb50f12c authored by Jakub Kicinski's avatar Jakub Kicinski

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.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 7ba0732c 9de95df5
...@@ -1252,7 +1252,12 @@ static struct Qdisc *qdisc_create(struct net_device *dev, ...@@ -1252,7 +1252,12 @@ static struct Qdisc *qdisc_create(struct net_device *dev,
sch->parent = parent; sch->parent = parent;
if (handle == TC_H_INGRESS) { if (handle == TC_H_INGRESS) {
sch->flags |= TCQ_F_INGRESS; if (!(sch->flags & TCQ_F_INGRESS)) {
NL_SET_ERR_MSG(extack,
"Specified parent ID is reserved for ingress and clsact Qdiscs");
err = -EINVAL;
goto err_out3;
}
handle = TC_H_MAKE(TC_H_INGRESS, 0); handle = TC_H_MAKE(TC_H_INGRESS, 0);
} else { } else {
if (handle == 0) { if (handle == 0) {
...@@ -1591,6 +1596,11 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n, ...@@ -1591,6 +1596,11 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n,
NL_SET_ERR_MSG(extack, "Invalid qdisc name"); NL_SET_ERR_MSG(extack, "Invalid qdisc name");
return -EINVAL; return -EINVAL;
} }
if (q->flags & TCQ_F_INGRESS) {
NL_SET_ERR_MSG(extack,
"Cannot regraft ingress or clsact Qdiscs");
return -EINVAL;
}
if (q == p || if (q == p ||
(p && check_loop(q, p, 0))) { (p && check_loop(q, p, 0))) {
NL_SET_ERR_MSG(extack, "Qdisc parent/child loop detected"); NL_SET_ERR_MSG(extack, "Qdisc parent/child loop detected");
......
...@@ -80,6 +80,9 @@ static int ingress_init(struct Qdisc *sch, struct nlattr *opt, ...@@ -80,6 +80,9 @@ static int ingress_init(struct Qdisc *sch, struct nlattr *opt,
struct net_device *dev = qdisc_dev(sch); struct net_device *dev = qdisc_dev(sch);
int err; int err;
if (sch->parent != TC_H_INGRESS)
return -EOPNOTSUPP;
net_inc_ingress_queue(); net_inc_ingress_queue();
mini_qdisc_pair_init(&q->miniqp, sch, &dev->miniq_ingress); mini_qdisc_pair_init(&q->miniqp, sch, &dev->miniq_ingress);
...@@ -101,6 +104,9 @@ static void ingress_destroy(struct Qdisc *sch) ...@@ -101,6 +104,9 @@ static void ingress_destroy(struct Qdisc *sch)
{ {
struct ingress_sched_data *q = qdisc_priv(sch); struct ingress_sched_data *q = qdisc_priv(sch);
if (sch->parent != TC_H_INGRESS)
return;
tcf_block_put_ext(q->block, sch, &q->block_info); tcf_block_put_ext(q->block, sch, &q->block_info);
net_dec_ingress_queue(); net_dec_ingress_queue();
} }
...@@ -134,7 +140,7 @@ static struct Qdisc_ops ingress_qdisc_ops __read_mostly = { ...@@ -134,7 +140,7 @@ static struct Qdisc_ops ingress_qdisc_ops __read_mostly = {
.cl_ops = &ingress_class_ops, .cl_ops = &ingress_class_ops,
.id = "ingress", .id = "ingress",
.priv_size = sizeof(struct ingress_sched_data), .priv_size = sizeof(struct ingress_sched_data),
.static_flags = TCQ_F_CPUSTATS, .static_flags = TCQ_F_INGRESS | TCQ_F_CPUSTATS,
.init = ingress_init, .init = ingress_init,
.destroy = ingress_destroy, .destroy = ingress_destroy,
.dump = ingress_dump, .dump = ingress_dump,
...@@ -219,6 +225,9 @@ static int clsact_init(struct Qdisc *sch, struct nlattr *opt, ...@@ -219,6 +225,9 @@ static int clsact_init(struct Qdisc *sch, struct nlattr *opt,
struct net_device *dev = qdisc_dev(sch); struct net_device *dev = qdisc_dev(sch);
int err; int err;
if (sch->parent != TC_H_CLSACT)
return -EOPNOTSUPP;
net_inc_ingress_queue(); net_inc_ingress_queue();
net_inc_egress_queue(); net_inc_egress_queue();
...@@ -248,6 +257,9 @@ static void clsact_destroy(struct Qdisc *sch) ...@@ -248,6 +257,9 @@ static void clsact_destroy(struct Qdisc *sch)
{ {
struct clsact_sched_data *q = qdisc_priv(sch); struct clsact_sched_data *q = qdisc_priv(sch);
if (sch->parent != TC_H_CLSACT)
return;
tcf_block_put_ext(q->egress_block, sch, &q->egress_block_info); tcf_block_put_ext(q->egress_block, sch, &q->egress_block_info);
tcf_block_put_ext(q->ingress_block, sch, &q->ingress_block_info); tcf_block_put_ext(q->ingress_block, sch, &q->ingress_block_info);
...@@ -269,7 +281,7 @@ static struct Qdisc_ops clsact_qdisc_ops __read_mostly = { ...@@ -269,7 +281,7 @@ static struct Qdisc_ops clsact_qdisc_ops __read_mostly = {
.cl_ops = &clsact_class_ops, .cl_ops = &clsact_class_ops,
.id = "clsact", .id = "clsact",
.priv_size = sizeof(struct clsact_sched_data), .priv_size = sizeof(struct clsact_sched_data),
.static_flags = TCQ_F_CPUSTATS, .static_flags = TCQ_F_INGRESS | TCQ_F_CPUSTATS,
.init = clsact_init, .init = clsact_init,
.destroy = clsact_destroy, .destroy = clsact_destroy,
.dump = ingress_dump, .dump = ingress_dump,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment