Skip to content

Commit

Permalink
Merge branch 'net-sched-fixes-for-sch_ingress-and-sch_clsact'
Browse files Browse the repository at this point in the history
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/[email protected]/
Link to v4: https://lore.kernel.org/r/[email protected]/
Link to v3 (incomplete): https://lore.kernel.org/r/[email protected]/
Link to v2: https://lore.kernel.org/r/[email protected]/
Link to v1: https://lore.kernel.org/r/[email protected]/
====================

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
kuba-moo committed May 31, 2023
2 parents 7ba0732 + 9de95df commit bb50f12
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
12 changes: 11 additions & 1 deletion net/sched/sch_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,12 @@ static struct Qdisc *qdisc_create(struct net_device *dev,
sch->parent = parent;

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);
} else {
if (handle == 0) {
Expand Down Expand Up @@ -1591,6 +1596,11 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n,
NL_SET_ERR_MSG(extack, "Invalid qdisc name");
return -EINVAL;
}
if (q->flags & TCQ_F_INGRESS) {
NL_SET_ERR_MSG(extack,
"Cannot regraft ingress or clsact Qdiscs");
return -EINVAL;
}
if (q == p ||
(p && check_loop(q, p, 0))) {
NL_SET_ERR_MSG(extack, "Qdisc parent/child loop detected");
Expand Down
16 changes: 14 additions & 2 deletions net/sched/sch_ingress.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ static int ingress_init(struct Qdisc *sch, struct nlattr *opt,
struct net_device *dev = qdisc_dev(sch);
int err;

if (sch->parent != TC_H_INGRESS)
return -EOPNOTSUPP;

net_inc_ingress_queue();

mini_qdisc_pair_init(&q->miniqp, sch, &dev->miniq_ingress);
Expand All @@ -101,6 +104,9 @@ static void ingress_destroy(struct Qdisc *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);
net_dec_ingress_queue();
}
Expand Down Expand Up @@ -134,7 +140,7 @@ static struct Qdisc_ops ingress_qdisc_ops __read_mostly = {
.cl_ops = &ingress_class_ops,
.id = "ingress",
.priv_size = sizeof(struct ingress_sched_data),
.static_flags = TCQ_F_CPUSTATS,
.static_flags = TCQ_F_INGRESS | TCQ_F_CPUSTATS,
.init = ingress_init,
.destroy = ingress_destroy,
.dump = ingress_dump,
Expand Down Expand Up @@ -219,6 +225,9 @@ static int clsact_init(struct Qdisc *sch, struct nlattr *opt,
struct net_device *dev = qdisc_dev(sch);
int err;

if (sch->parent != TC_H_CLSACT)
return -EOPNOTSUPP;

net_inc_ingress_queue();
net_inc_egress_queue();

Expand Down Expand Up @@ -248,6 +257,9 @@ static void clsact_destroy(struct Qdisc *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->ingress_block, sch, &q->ingress_block_info);

Expand All @@ -269,7 +281,7 @@ static struct Qdisc_ops clsact_qdisc_ops __read_mostly = {
.cl_ops = &clsact_class_ops,
.id = "clsact",
.priv_size = sizeof(struct clsact_sched_data),
.static_flags = TCQ_F_CPUSTATS,
.static_flags = TCQ_F_INGRESS | TCQ_F_CPUSTATS,
.init = clsact_init,
.destroy = clsact_destroy,
.dump = ingress_dump,
Expand Down

0 comments on commit bb50f12

Please sign in to comment.