aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/cls_fw.c
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2008-01-23 01:11:33 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:11:11 -0500
commitadd93b610a4e66d36d0cf0b2596c3d3bcfdaee39 (patch)
tree073873879eb3b87981ee015f0f1ca48da8f1c696 /net/sched/cls_fw.c
parent1e90474c377e92db7262a8968a45c1dd980ca9e5 (diff)
[NET_SCHED]: Convert classifiers from rtnetlink to new netlink API
Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/cls_fw.c')
-rw-r--r--net/sched/cls_fw.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c
index b45038770e79..db6e90a37846 100644
--- a/net/sched/cls_fw.c
+++ b/net/sched/cls_fw.c
@@ -188,37 +188,37 @@ out:
188 188
189static int 189static int
190fw_change_attrs(struct tcf_proto *tp, struct fw_filter *f, 190fw_change_attrs(struct tcf_proto *tp, struct fw_filter *f,
191 struct rtattr **tb, struct rtattr **tca, unsigned long base) 191 struct nlattr **tb, struct nlattr **tca, unsigned long base)
192{ 192{
193 struct fw_head *head = (struct fw_head *)tp->root; 193 struct fw_head *head = (struct fw_head *)tp->root;
194 struct tcf_exts e; 194 struct tcf_exts e;
195 u32 mask; 195 u32 mask;
196 int err; 196 int err;
197 197
198 err = tcf_exts_validate(tp, tb, tca[TCA_RATE-1], &e, &fw_ext_map); 198 err = tcf_exts_validate(tp, tb, tca[TCA_RATE], &e, &fw_ext_map);
199 if (err < 0) 199 if (err < 0)
200 return err; 200 return err;
201 201
202 err = -EINVAL; 202 err = -EINVAL;
203 if (tb[TCA_FW_CLASSID-1]) { 203 if (tb[TCA_FW_CLASSID]) {
204 if (RTA_PAYLOAD(tb[TCA_FW_CLASSID-1]) != sizeof(u32)) 204 if (nla_len(tb[TCA_FW_CLASSID]) != sizeof(u32))
205 goto errout; 205 goto errout;
206 f->res.classid = *(u32*)RTA_DATA(tb[TCA_FW_CLASSID-1]); 206 f->res.classid = *(u32*)nla_data(tb[TCA_FW_CLASSID]);
207 tcf_bind_filter(tp, &f->res, base); 207 tcf_bind_filter(tp, &f->res, base);
208 } 208 }
209 209
210#ifdef CONFIG_NET_CLS_IND 210#ifdef CONFIG_NET_CLS_IND
211 if (tb[TCA_FW_INDEV-1]) { 211 if (tb[TCA_FW_INDEV]) {
212 err = tcf_change_indev(tp, f->indev, tb[TCA_FW_INDEV-1]); 212 err = tcf_change_indev(tp, f->indev, tb[TCA_FW_INDEV]);
213 if (err < 0) 213 if (err < 0)
214 goto errout; 214 goto errout;
215 } 215 }
216#endif /* CONFIG_NET_CLS_IND */ 216#endif /* CONFIG_NET_CLS_IND */
217 217
218 if (tb[TCA_FW_MASK-1]) { 218 if (tb[TCA_FW_MASK]) {
219 if (RTA_PAYLOAD(tb[TCA_FW_MASK-1]) != sizeof(u32)) 219 if (nla_len(tb[TCA_FW_MASK]) != sizeof(u32))
220 goto errout; 220 goto errout;
221 mask = *(u32*)RTA_DATA(tb[TCA_FW_MASK-1]); 221 mask = *(u32*)nla_data(tb[TCA_FW_MASK]);
222 if (mask != head->mask) 222 if (mask != head->mask)
223 goto errout; 223 goto errout;
224 } else if (head->mask != 0xFFFFFFFF) 224 } else if (head->mask != 0xFFFFFFFF)
@@ -234,19 +234,19 @@ errout:
234 234
235static int fw_change(struct tcf_proto *tp, unsigned long base, 235static int fw_change(struct tcf_proto *tp, unsigned long base,
236 u32 handle, 236 u32 handle,
237 struct rtattr **tca, 237 struct nlattr **tca,
238 unsigned long *arg) 238 unsigned long *arg)
239{ 239{
240 struct fw_head *head = (struct fw_head*)tp->root; 240 struct fw_head *head = (struct fw_head*)tp->root;
241 struct fw_filter *f = (struct fw_filter *) *arg; 241 struct fw_filter *f = (struct fw_filter *) *arg;
242 struct rtattr *opt = tca[TCA_OPTIONS-1]; 242 struct nlattr *opt = tca[TCA_OPTIONS];
243 struct rtattr *tb[TCA_FW_MAX]; 243 struct nlattr *tb[TCA_FW_MAX + 1];
244 int err; 244 int err;
245 245
246 if (!opt) 246 if (!opt)
247 return handle ? -EINVAL : 0; 247 return handle ? -EINVAL : 0;
248 248
249 if (rtattr_parse_nested(tb, TCA_FW_MAX, opt) < 0) 249 if (nla_parse_nested(tb, TCA_FW_MAX, opt, NULL) < 0)
250 return -EINVAL; 250 return -EINVAL;
251 251
252 if (f != NULL) { 252 if (f != NULL) {
@@ -260,10 +260,10 @@ static int fw_change(struct tcf_proto *tp, unsigned long base,
260 260
261 if (head == NULL) { 261 if (head == NULL) {
262 u32 mask = 0xFFFFFFFF; 262 u32 mask = 0xFFFFFFFF;
263 if (tb[TCA_FW_MASK-1]) { 263 if (tb[TCA_FW_MASK]) {
264 if (RTA_PAYLOAD(tb[TCA_FW_MASK-1]) != sizeof(u32)) 264 if (nla_len(tb[TCA_FW_MASK]) != sizeof(u32))
265 return -EINVAL; 265 return -EINVAL;
266 mask = *(u32*)RTA_DATA(tb[TCA_FW_MASK-1]); 266 mask = *(u32*)nla_data(tb[TCA_FW_MASK]);
267 } 267 }
268 268
269 head = kzalloc(sizeof(struct fw_head), GFP_KERNEL); 269 head = kzalloc(sizeof(struct fw_head), GFP_KERNEL);
@@ -333,7 +333,7 @@ static int fw_dump(struct tcf_proto *tp, unsigned long fh,
333 struct fw_head *head = (struct fw_head *)tp->root; 333 struct fw_head *head = (struct fw_head *)tp->root;
334 struct fw_filter *f = (struct fw_filter*)fh; 334 struct fw_filter *f = (struct fw_filter*)fh;
335 unsigned char *b = skb_tail_pointer(skb); 335 unsigned char *b = skb_tail_pointer(skb);
336 struct rtattr *rta; 336 struct nlattr *nla;
337 337
338 if (f == NULL) 338 if (f == NULL)
339 return skb->len; 339 return skb->len;
@@ -343,29 +343,29 @@ static int fw_dump(struct tcf_proto *tp, unsigned long fh,
343 if (!f->res.classid && !tcf_exts_is_available(&f->exts)) 343 if (!f->res.classid && !tcf_exts_is_available(&f->exts))
344 return skb->len; 344 return skb->len;
345 345
346 rta = (struct rtattr*)b; 346 nla = (struct nlattr*)b;
347 RTA_PUT(skb, TCA_OPTIONS, 0, NULL); 347 NLA_PUT(skb, TCA_OPTIONS, 0, NULL);
348 348
349 if (f->res.classid) 349 if (f->res.classid)
350 RTA_PUT(skb, TCA_FW_CLASSID, 4, &f->res.classid); 350 NLA_PUT(skb, TCA_FW_CLASSID, 4, &f->res.classid);
351#ifdef CONFIG_NET_CLS_IND 351#ifdef CONFIG_NET_CLS_IND
352 if (strlen(f->indev)) 352 if (strlen(f->indev))
353 RTA_PUT(skb, TCA_FW_INDEV, IFNAMSIZ, f->indev); 353 NLA_PUT(skb, TCA_FW_INDEV, IFNAMSIZ, f->indev);
354#endif /* CONFIG_NET_CLS_IND */ 354#endif /* CONFIG_NET_CLS_IND */
355 if (head->mask != 0xFFFFFFFF) 355 if (head->mask != 0xFFFFFFFF)
356 RTA_PUT(skb, TCA_FW_MASK, 4, &head->mask); 356 NLA_PUT(skb, TCA_FW_MASK, 4, &head->mask);
357 357
358 if (tcf_exts_dump(skb, &f->exts, &fw_ext_map) < 0) 358 if (tcf_exts_dump(skb, &f->exts, &fw_ext_map) < 0)
359 goto rtattr_failure; 359 goto nla_put_failure;
360 360
361 rta->rta_len = skb_tail_pointer(skb) - b; 361 nla->nla_len = skb_tail_pointer(skb) - b;
362 362
363 if (tcf_exts_dump_stats(skb, &f->exts, &fw_ext_map) < 0) 363 if (tcf_exts_dump_stats(skb, &f->exts, &fw_ext_map) < 0)
364 goto rtattr_failure; 364 goto nla_put_failure;
365 365
366 return skb->len; 366 return skb->len;
367 367
368rtattr_failure: 368nla_put_failure:
369 nlmsg_trim(skb, b); 369 nlmsg_trim(skb, b);
370 return -1; 370 return -1;
371} 371}