forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/net/sched/cls_fw.c
....@@ -1,10 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * net/sched/cls_fw.c Classifier mapping ipchains' fwmark to traffic class.
3
- *
4
- * This program is free software; you can redistribute it and/or
5
- * modify it under the terms of the GNU General Public License
6
- * as published by the Free Software Foundation; either version
7
- * 2 of the License, or (at your option) any later version.
84 *
95 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
106 *
....@@ -12,10 +8,6 @@
128 * Karlis Peisenieks <karlis@mt.lv> : 990415 : fw_walk off by one
139 * Karlis Peisenieks <karlis@mt.lv> : 990415 : fw_delete killed all the filter (and kernel).
1410 * Alex <alex@pilotsoft.com> : 2004xxyy: Added Action extension
15
- *
16
- * JHS: We should remove the CONFIG_NET_CLS_IND from here
17
- * eventually when the meta match extension is made available
18
- *
1911 */
2012
2113 #include <linux/module.h>
....@@ -42,9 +34,7 @@
4234 struct fw_filter __rcu *next;
4335 u32 id;
4436 struct tcf_result res;
45
-#ifdef CONFIG_NET_CLS_IND
4637 int ifindex;
47
-#endif /* CONFIG_NET_CLS_IND */
4838 struct tcf_exts exts;
4939 struct tcf_proto *tp;
5040 struct rcu_work rwork;
....@@ -72,10 +62,8 @@
7262 f = rcu_dereference_bh(f->next)) {
7363 if (f->id == id) {
7464 *res = f->res;
75
-#ifdef CONFIG_NET_CLS_IND
7665 if (!tcf_match_indev(skb, f->ifindex))
7766 continue;
78
-#endif /* CONFIG_NET_CLS_IND */
7967 r = tcf_exts_exec(skb, &f->exts, res);
8068 if (r < 0)
8169 continue;
....@@ -139,7 +127,8 @@
139127 rtnl_unlock();
140128 }
141129
142
-static void fw_destroy(struct tcf_proto *tp, struct netlink_ext_ack *extack)
130
+static void fw_destroy(struct tcf_proto *tp, bool rtnl_held,
131
+ struct netlink_ext_ack *extack)
143132 {
144133 struct fw_head *head = rtnl_dereference(tp->root);
145134 struct fw_filter *f;
....@@ -163,7 +152,7 @@
163152 }
164153
165154 static int fw_delete(struct tcf_proto *tp, void *arg, bool *last,
166
- struct netlink_ext_ack *extack)
155
+ bool rtnl_held, struct netlink_ext_ack *extack)
167156 {
168157 struct fw_head *head = rtnl_dereference(tp->root);
169158 struct fw_filter *f = arg;
....@@ -217,7 +206,7 @@
217206 int err;
218207
219208 err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &f->exts, ovr,
220
- extack);
209
+ true, extack);
221210 if (err < 0)
222211 return err;
223212
....@@ -226,7 +215,6 @@
226215 tcf_bind_filter(tp, &f->res, base);
227216 }
228217
229
-#ifdef CONFIG_NET_CLS_IND
230218 if (tb[TCA_FW_INDEV]) {
231219 int ret;
232220 ret = tcf_change_indev(net, tb[TCA_FW_INDEV], extack);
....@@ -234,7 +222,6 @@
234222 return ret;
235223 f->ifindex = ret;
236224 }
237
-#endif /* CONFIG_NET_CLS_IND */
238225
239226 err = -EINVAL;
240227 if (tb[TCA_FW_MASK]) {
....@@ -250,7 +237,8 @@
250237 static int fw_change(struct net *net, struct sk_buff *in_skb,
251238 struct tcf_proto *tp, unsigned long base,
252239 u32 handle, struct nlattr **tca, void **arg,
253
- bool ovr, struct netlink_ext_ack *extack)
240
+ bool ovr, bool rtnl_held,
241
+ struct netlink_ext_ack *extack)
254242 {
255243 struct fw_head *head = rtnl_dereference(tp->root);
256244 struct fw_filter *f = *arg;
....@@ -261,7 +249,8 @@
261249 if (!opt)
262250 return handle ? -EINVAL : 0; /* Succeed if it is old method. */
263251
264
- err = nla_parse_nested(tb, TCA_FW_MAX, opt, fw_policy, NULL);
252
+ err = nla_parse_nested_deprecated(tb, TCA_FW_MAX, opt, fw_policy,
253
+ NULL);
265254 if (err < 0)
266255 return err;
267256
....@@ -278,12 +267,11 @@
278267
279268 fnew->id = f->id;
280269 fnew->res = f->res;
281
-#ifdef CONFIG_NET_CLS_IND
282270 fnew->ifindex = f->ifindex;
283
-#endif /* CONFIG_NET_CLS_IND */
284271 fnew->tp = f->tp;
285272
286
- err = tcf_exts_init(&fnew->exts, TCA_FW_ACT, TCA_FW_POLICE);
273
+ err = tcf_exts_init(&fnew->exts, net, TCA_FW_ACT,
274
+ TCA_FW_POLICE);
287275 if (err < 0) {
288276 kfree(fnew);
289277 return err;
....@@ -332,7 +320,7 @@
332320 if (f == NULL)
333321 return -ENOBUFS;
334322
335
- err = tcf_exts_init(&f->exts, TCA_FW_ACT, TCA_FW_POLICE);
323
+ err = tcf_exts_init(&f->exts, net, TCA_FW_ACT, TCA_FW_POLICE);
336324 if (err < 0)
337325 goto errout;
338326 f->id = handle;
....@@ -354,7 +342,8 @@
354342 return err;
355343 }
356344
357
-static void fw_walk(struct tcf_proto *tp, struct tcf_walker *arg)
345
+static void fw_walk(struct tcf_proto *tp, struct tcf_walker *arg,
346
+ bool rtnl_held)
358347 {
359348 struct fw_head *head = rtnl_dereference(tp->root);
360349 int h;
....@@ -384,7 +373,7 @@
384373 }
385374
386375 static int fw_dump(struct net *net, struct tcf_proto *tp, void *fh,
387
- struct sk_buff *skb, struct tcmsg *t)
376
+ struct sk_buff *skb, struct tcmsg *t, bool rtnl_held)
388377 {
389378 struct fw_head *head = rtnl_dereference(tp->root);
390379 struct fw_filter *f = fh;
....@@ -398,21 +387,19 @@
398387 if (!f->res.classid && !tcf_exts_has_actions(&f->exts))
399388 return skb->len;
400389
401
- nest = nla_nest_start(skb, TCA_OPTIONS);
390
+ nest = nla_nest_start_noflag(skb, TCA_OPTIONS);
402391 if (nest == NULL)
403392 goto nla_put_failure;
404393
405394 if (f->res.classid &&
406395 nla_put_u32(skb, TCA_FW_CLASSID, f->res.classid))
407396 goto nla_put_failure;
408
-#ifdef CONFIG_NET_CLS_IND
409397 if (f->ifindex) {
410398 struct net_device *dev;
411399 dev = __dev_get_by_index(net, f->ifindex);
412400 if (dev && nla_put_string(skb, TCA_FW_INDEV, dev->name))
413401 goto nla_put_failure;
414402 }
415
-#endif /* CONFIG_NET_CLS_IND */
416403 if (head->mask != 0xFFFFFFFF &&
417404 nla_put_u32(skb, TCA_FW_MASK, head->mask))
418405 goto nla_put_failure;