aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/sch_red.c
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2008-01-23 01:11:17 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:11:10 -0500
commit1e90474c377e92db7262a8968a45c1dd980ca9e5 (patch)
tree645af56dcb17cf1a76fd3b7f1a8b833a3fffc3d7 /net/sched/sch_red.c
parent01480e1cf5e2118eba8a8968239f3242072f9563 (diff)
[NET_SCHED]: Convert packet schedulers from rtnetlink to new netlink API
Convert packet schedulers to use the netlink API. Unfortunately a gradual conversion is not possible without breaking compilation in the middle or adding lots of casts, so this patch converts them all in one step. The patch has been mostly generated automatically with some minor edits to at least allow seperate conversion of classifiers and actions. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/sch_red.c')
-rw-r--r--net/sched/sch_red.c52
1 files changed, 27 insertions, 25 deletions
diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c
index f1e9647f7db7..6ce8da5aca0b 100644
--- a/net/sched/sch_red.c
+++ b/net/sched/sch_red.c
@@ -177,21 +177,21 @@ static void red_destroy(struct Qdisc *sch)
177static struct Qdisc *red_create_dflt(struct Qdisc *sch, u32 limit) 177static struct Qdisc *red_create_dflt(struct Qdisc *sch, u32 limit)
178{ 178{
179 struct Qdisc *q; 179 struct Qdisc *q;
180 struct rtattr *rta; 180 struct nlattr *nla;
181 int ret; 181 int ret;
182 182
183 q = qdisc_create_dflt(sch->dev, &bfifo_qdisc_ops, 183 q = qdisc_create_dflt(sch->dev, &bfifo_qdisc_ops,
184 TC_H_MAKE(sch->handle, 1)); 184 TC_H_MAKE(sch->handle, 1));
185 if (q) { 185 if (q) {
186 rta = kmalloc(RTA_LENGTH(sizeof(struct tc_fifo_qopt)), 186 nla = kmalloc(nla_attr_size(sizeof(struct tc_fifo_qopt)),
187 GFP_KERNEL); 187 GFP_KERNEL);
188 if (rta) { 188 if (nla) {
189 rta->rta_type = RTM_NEWQDISC; 189 nla->nla_type = RTM_NEWQDISC;
190 rta->rta_len = RTA_LENGTH(sizeof(struct tc_fifo_qopt)); 190 nla->nla_len = nla_attr_size(sizeof(struct tc_fifo_qopt));
191 ((struct tc_fifo_qopt *)RTA_DATA(rta))->limit = limit; 191 ((struct tc_fifo_qopt *)nla_data(nla))->limit = limit;
192 192
193 ret = q->ops->change(q, rta); 193 ret = q->ops->change(q, nla);
194 kfree(rta); 194 kfree(nla);
195 195
196 if (ret == 0) 196 if (ret == 0)
197 return q; 197 return q;
@@ -201,23 +201,23 @@ static struct Qdisc *red_create_dflt(struct Qdisc *sch, u32 limit)
201 return NULL; 201 return NULL;
202} 202}
203 203
204static int red_change(struct Qdisc *sch, struct rtattr *opt) 204static int red_change(struct Qdisc *sch, struct nlattr *opt)
205{ 205{
206 struct red_sched_data *q = qdisc_priv(sch); 206 struct red_sched_data *q = qdisc_priv(sch);
207 struct rtattr *tb[TCA_RED_MAX]; 207 struct nlattr *tb[TCA_RED_MAX + 1];
208 struct tc_red_qopt *ctl; 208 struct tc_red_qopt *ctl;
209 struct Qdisc *child = NULL; 209 struct Qdisc *child = NULL;
210 210
211 if (opt == NULL || rtattr_parse_nested(tb, TCA_RED_MAX, opt)) 211 if (opt == NULL || nla_parse_nested(tb, TCA_RED_MAX, opt, NULL))
212 return -EINVAL; 212 return -EINVAL;
213 213
214 if (tb[TCA_RED_PARMS-1] == NULL || 214 if (tb[TCA_RED_PARMS] == NULL ||
215 RTA_PAYLOAD(tb[TCA_RED_PARMS-1]) < sizeof(*ctl) || 215 nla_len(tb[TCA_RED_PARMS]) < sizeof(*ctl) ||
216 tb[TCA_RED_STAB-1] == NULL || 216 tb[TCA_RED_STAB] == NULL ||
217 RTA_PAYLOAD(tb[TCA_RED_STAB-1]) < RED_STAB_SIZE) 217 nla_len(tb[TCA_RED_STAB]) < RED_STAB_SIZE)
218 return -EINVAL; 218 return -EINVAL;
219 219
220 ctl = RTA_DATA(tb[TCA_RED_PARMS-1]); 220 ctl = nla_data(tb[TCA_RED_PARMS]);
221 221
222 if (ctl->limit > 0) { 222 if (ctl->limit > 0) {
223 child = red_create_dflt(sch, ctl->limit); 223 child = red_create_dflt(sch, ctl->limit);
@@ -235,7 +235,7 @@ static int red_change(struct Qdisc *sch, struct rtattr *opt)
235 235
236 red_set_parms(&q->parms, ctl->qth_min, ctl->qth_max, ctl->Wlog, 236 red_set_parms(&q->parms, ctl->qth_min, ctl->qth_max, ctl->Wlog,
237 ctl->Plog, ctl->Scell_log, 237 ctl->Plog, ctl->Scell_log,
238 RTA_DATA(tb[TCA_RED_STAB-1])); 238 nla_data(tb[TCA_RED_STAB]));
239 239
240 if (skb_queue_empty(&sch->q)) 240 if (skb_queue_empty(&sch->q))
241 red_end_of_idle_period(&q->parms); 241 red_end_of_idle_period(&q->parms);
@@ -244,7 +244,7 @@ static int red_change(struct Qdisc *sch, struct rtattr *opt)
244 return 0; 244 return 0;
245} 245}
246 246
247static int red_init(struct Qdisc* sch, struct rtattr *opt) 247static int red_init(struct Qdisc* sch, struct nlattr *opt)
248{ 248{
249 struct red_sched_data *q = qdisc_priv(sch); 249 struct red_sched_data *q = qdisc_priv(sch);
250 250
@@ -255,7 +255,7 @@ static int red_init(struct Qdisc* sch, struct rtattr *opt)
255static int red_dump(struct Qdisc *sch, struct sk_buff *skb) 255static int red_dump(struct Qdisc *sch, struct sk_buff *skb)
256{ 256{
257 struct red_sched_data *q = qdisc_priv(sch); 257 struct red_sched_data *q = qdisc_priv(sch);
258 struct rtattr *opts = NULL; 258 struct nlattr *opts = NULL;
259 struct tc_red_qopt opt = { 259 struct tc_red_qopt opt = {
260 .limit = q->limit, 260 .limit = q->limit,
261 .flags = q->flags, 261 .flags = q->flags,
@@ -266,12 +266,14 @@ static int red_dump(struct Qdisc *sch, struct sk_buff *skb)
266 .Scell_log = q->parms.Scell_log, 266 .Scell_log = q->parms.Scell_log,
267 }; 267 };
268 268
269 opts = RTA_NEST(skb, TCA_OPTIONS); 269 opts = nla_nest_start(skb, TCA_OPTIONS);
270 RTA_PUT(skb, TCA_RED_PARMS, sizeof(opt), &opt); 270 if (opts == NULL)
271 return RTA_NEST_END(skb, opts); 271 goto nla_put_failure;
272 NLA_PUT(skb, TCA_RED_PARMS, sizeof(opt), &opt);
273 return nla_nest_end(skb, opts);
272 274
273rtattr_failure: 275nla_put_failure:
274 return RTA_NEST_CANCEL(skb, opts); 276 return nla_nest_cancel(skb, opts);
275} 277}
276 278
277static int red_dump_stats(struct Qdisc *sch, struct gnet_dump *d) 279static int red_dump_stats(struct Qdisc *sch, struct gnet_dump *d)
@@ -332,7 +334,7 @@ static void red_put(struct Qdisc *sch, unsigned long arg)
332} 334}
333 335
334static int red_change_class(struct Qdisc *sch, u32 classid, u32 parentid, 336static int red_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
335 struct rtattr **tca, unsigned long *arg) 337 struct nlattr **tca, unsigned long *arg)
336{ 338{
337 return -ENOSYS; 339 return -ENOSYS;
338} 340}