hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/net/sched/cls_cgroup.c
....@@ -1,10 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * net/sched/cls_cgroup.c Control Group Classifier
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: Thomas Graf <tgraf@suug.ch>
106 */
....@@ -32,6 +28,8 @@
3228 struct cls_cgroup_head *head = rcu_dereference_bh(tp->root);
3329 u32 classid = task_get_classid(skb);
3430
31
+ if (unlikely(!head))
32
+ return -1;
3533 if (!classid)
3634 return -1;
3735 if (!tcf_em_tree_match(skb, &head->ematches, NULL))
....@@ -78,7 +76,7 @@
7876 static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb,
7977 struct tcf_proto *tp, unsigned long base,
8078 u32 handle, struct nlattr **tca,
81
- void **arg, bool ovr,
79
+ void **arg, bool ovr, bool rtnl_held,
8280 struct netlink_ext_ack *extack)
8381 {
8482 struct nlattr *tb[TCA_CGROUP_MAX + 1];
....@@ -99,18 +97,19 @@
9997 if (!new)
10098 return -ENOBUFS;
10199
102
- err = tcf_exts_init(&new->exts, TCA_CGROUP_ACT, TCA_CGROUP_POLICE);
100
+ err = tcf_exts_init(&new->exts, net, TCA_CGROUP_ACT, TCA_CGROUP_POLICE);
103101 if (err < 0)
104102 goto errout;
105103 new->handle = handle;
106104 new->tp = tp;
107
- err = nla_parse_nested(tb, TCA_CGROUP_MAX, tca[TCA_OPTIONS],
108
- cgroup_policy, NULL);
105
+ err = nla_parse_nested_deprecated(tb, TCA_CGROUP_MAX,
106
+ tca[TCA_OPTIONS], cgroup_policy,
107
+ NULL);
109108 if (err < 0)
110109 goto errout;
111110
112111 err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &new->exts, ovr,
113
- extack);
112
+ true, extack);
114113 if (err < 0)
115114 goto errout;
116115
....@@ -130,7 +129,7 @@
130129 return err;
131130 }
132131
133
-static void cls_cgroup_destroy(struct tcf_proto *tp,
132
+static void cls_cgroup_destroy(struct tcf_proto *tp, bool rtnl_held,
134133 struct netlink_ext_ack *extack)
135134 {
136135 struct cls_cgroup_head *head = rtnl_dereference(tp->root);
....@@ -145,18 +144,21 @@
145144 }
146145
147146 static int cls_cgroup_delete(struct tcf_proto *tp, void *arg, bool *last,
148
- struct netlink_ext_ack *extack)
147
+ bool rtnl_held, struct netlink_ext_ack *extack)
149148 {
150149 return -EOPNOTSUPP;
151150 }
152151
153
-static void cls_cgroup_walk(struct tcf_proto *tp, struct tcf_walker *arg)
152
+static void cls_cgroup_walk(struct tcf_proto *tp, struct tcf_walker *arg,
153
+ bool rtnl_held)
154154 {
155155 struct cls_cgroup_head *head = rtnl_dereference(tp->root);
156156
157157 if (arg->count < arg->skip)
158158 goto skip;
159159
160
+ if (!head)
161
+ return;
160162 if (arg->fn(tp, head, arg) < 0) {
161163 arg->stop = 1;
162164 return;
....@@ -166,14 +168,14 @@
166168 }
167169
168170 static int cls_cgroup_dump(struct net *net, struct tcf_proto *tp, void *fh,
169
- struct sk_buff *skb, struct tcmsg *t)
171
+ struct sk_buff *skb, struct tcmsg *t, bool rtnl_held)
170172 {
171173 struct cls_cgroup_head *head = rtnl_dereference(tp->root);
172174 struct nlattr *nest;
173175
174176 t->tcm_handle = head->handle;
175177
176
- nest = nla_nest_start(skb, TCA_OPTIONS);
178
+ nest = nla_nest_start_noflag(skb, TCA_OPTIONS);
177179 if (nest == NULL)
178180 goto nla_put_failure;
179181