hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/net/sched/sch_ingress.c
....@@ -1,9 +1,5 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* net/sched/sch_ingress.c - Ingress and clsact qdisc
2
- *
3
- * This program is free software; you can redistribute it and/or
4
- * modify it under the terms of the GNU General Public License
5
- * as published by the Free Software Foundation; either version
6
- * 2 of the License, or (at your option) any later version.
73 *
84 * Authors: Jamal Hadi Salim 1999
95 */
....@@ -82,21 +78,34 @@
8278 {
8379 struct ingress_sched_data *q = qdisc_priv(sch);
8480 struct net_device *dev = qdisc_dev(sch);
81
+ int err;
82
+
83
+ if (sch->parent != TC_H_INGRESS)
84
+ return -EOPNOTSUPP;
8585
8686 net_inc_ingress_queue();
8787
8888 mini_qdisc_pair_init(&q->miniqp, sch, &dev->miniq_ingress);
8989
90
- q->block_info.binder_type = TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS;
90
+ q->block_info.binder_type = FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS;
9191 q->block_info.chain_head_change = clsact_chain_head_change;
9292 q->block_info.chain_head_change_priv = &q->miniqp;
9393
94
- return tcf_block_get_ext(&q->block, sch, &q->block_info, extack);
94
+ err = tcf_block_get_ext(&q->block, sch, &q->block_info, extack);
95
+ if (err)
96
+ return err;
97
+
98
+ mini_qdisc_pair_block_init(&q->miniqp, q->block);
99
+
100
+ return 0;
95101 }
96102
97103 static void ingress_destroy(struct Qdisc *sch)
98104 {
99105 struct ingress_sched_data *q = qdisc_priv(sch);
106
+
107
+ if (sch->parent != TC_H_INGRESS)
108
+ return;
100109
101110 tcf_block_put_ext(q->block, sch, &q->block_info);
102111 net_dec_ingress_queue();
....@@ -106,7 +115,7 @@
106115 {
107116 struct nlattr *nest;
108117
109
- nest = nla_nest_start(skb, TCA_OPTIONS);
118
+ nest = nla_nest_start_noflag(skb, TCA_OPTIONS);
110119 if (nest == NULL)
111120 goto nla_put_failure;
112121
....@@ -118,6 +127,7 @@
118127 }
119128
120129 static const struct Qdisc_class_ops ingress_class_ops = {
130
+ .flags = QDISC_CLASS_OPS_DOIT_UNLOCKED,
121131 .leaf = ingress_leaf,
122132 .find = ingress_find,
123133 .walk = ingress_walk,
....@@ -130,7 +140,7 @@
130140 .cl_ops = &ingress_class_ops,
131141 .id = "ingress",
132142 .priv_size = sizeof(struct ingress_sched_data),
133
- .static_flags = TCQ_F_CPUSTATS,
143
+ .static_flags = TCQ_F_INGRESS | TCQ_F_CPUSTATS,
134144 .init = ingress_init,
135145 .destroy = ingress_destroy,
136146 .dump = ingress_dump,
....@@ -215,12 +225,15 @@
215225 struct net_device *dev = qdisc_dev(sch);
216226 int err;
217227
228
+ if (sch->parent != TC_H_CLSACT)
229
+ return -EOPNOTSUPP;
230
+
218231 net_inc_ingress_queue();
219232 net_inc_egress_queue();
220233
221234 mini_qdisc_pair_init(&q->miniqp_ingress, sch, &dev->miniq_ingress);
222235
223
- q->ingress_block_info.binder_type = TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS;
236
+ q->ingress_block_info.binder_type = FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS;
224237 q->ingress_block_info.chain_head_change = clsact_chain_head_change;
225238 q->ingress_block_info.chain_head_change_priv = &q->miniqp_ingress;
226239
....@@ -229,9 +242,11 @@
229242 if (err)
230243 return err;
231244
245
+ mini_qdisc_pair_block_init(&q->miniqp_ingress, q->ingress_block);
246
+
232247 mini_qdisc_pair_init(&q->miniqp_egress, sch, &dev->miniq_egress);
233248
234
- q->egress_block_info.binder_type = TCF_BLOCK_BINDER_TYPE_CLSACT_EGRESS;
249
+ q->egress_block_info.binder_type = FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS;
235250 q->egress_block_info.chain_head_change = clsact_chain_head_change;
236251 q->egress_block_info.chain_head_change_priv = &q->miniqp_egress;
237252
....@@ -242,6 +257,9 @@
242257 {
243258 struct clsact_sched_data *q = qdisc_priv(sch);
244259
260
+ if (sch->parent != TC_H_CLSACT)
261
+ return;
262
+
245263 tcf_block_put_ext(q->egress_block, sch, &q->egress_block_info);
246264 tcf_block_put_ext(q->ingress_block, sch, &q->ingress_block_info);
247265
....@@ -250,6 +268,7 @@
250268 }
251269
252270 static const struct Qdisc_class_ops clsact_class_ops = {
271
+ .flags = QDISC_CLASS_OPS_DOIT_UNLOCKED,
253272 .leaf = ingress_leaf,
254273 .find = clsact_find,
255274 .walk = ingress_walk,
....@@ -262,7 +281,7 @@
262281 .cl_ops = &clsact_class_ops,
263282 .id = "clsact",
264283 .priv_size = sizeof(struct clsact_sched_data),
265
- .static_flags = TCQ_F_CPUSTATS,
284
+ .static_flags = TCQ_F_INGRESS | TCQ_F_CPUSTATS,
266285 .init = clsact_init,
267286 .destroy = clsact_destroy,
268287 .dump = ingress_dump,