aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2008-01-23 23:35:03 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:11:21 -0500
commit1587bac49f8491b5006a78f8d726111b71757941 (patch)
tree753e9fb452917efd9da6751fa4c6a45442c9fb8d /net/sched
parent24beeab539c6f42c4a93e2ff7c3b5f272e60da45 (diff)
[NET_SCHED]: Use typeful attribute parsing helpers
Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched')
-rw-r--r--net/sched/act_api.c2
-rw-r--r--net/sched/act_ipt.c4
-rw-r--r--net/sched/act_police.c5
-rw-r--r--net/sched/cls_basic.c2
-rw-r--r--net/sched/cls_fw.c6
-rw-r--r--net/sched/cls_route.c8
-rw-r--r--net/sched/cls_rsvp.h4
-rw-r--r--net/sched/cls_tcindex.c11
-rw-r--r--net/sched/cls_u32.c8
-rw-r--r--net/sched/em_meta.c2
-rw-r--r--net/sched/sch_atm.c4
11 files changed, 27 insertions, 29 deletions
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 41fbd496abac..0b8eb235bc13 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -690,7 +690,7 @@ tcf_action_get_1(struct nlattr *nla, struct nlmsghdr *n, u32 pid)
690 if (tb[TCA_ACT_INDEX] == NULL || 690 if (tb[TCA_ACT_INDEX] == NULL ||
691 nla_len(tb[TCA_ACT_INDEX]) < sizeof(index)) 691 nla_len(tb[TCA_ACT_INDEX]) < sizeof(index))
692 goto err_out; 692 goto err_out;
693 index = *(int *)nla_data(tb[TCA_ACT_INDEX]); 693 index = nla_get_u32(tb[TCA_ACT_INDEX]);
694 694
695 err = -ENOMEM; 695 err = -ENOMEM;
696 a = kzalloc(sizeof(struct tc_action), GFP_KERNEL); 696 a = kzalloc(sizeof(struct tc_action), GFP_KERNEL);
diff --git a/net/sched/act_ipt.c b/net/sched/act_ipt.c
index 5dd701a7bc56..7ab2419b44ec 100644
--- a/net/sched/act_ipt.c
+++ b/net/sched/act_ipt.c
@@ -123,7 +123,7 @@ static int tcf_ipt_init(struct nlattr *nla, struct nlattr *est,
123 123
124 if (tb[TCA_IPT_INDEX] != NULL && 124 if (tb[TCA_IPT_INDEX] != NULL &&
125 nla_len(tb[TCA_IPT_INDEX]) >= sizeof(u32)) 125 nla_len(tb[TCA_IPT_INDEX]) >= sizeof(u32))
126 index = *(u32 *)nla_data(tb[TCA_IPT_INDEX]); 126 index = nla_get_u32(tb[TCA_IPT_INDEX]);
127 127
128 pc = tcf_hash_check(index, a, bind, &ipt_hash_info); 128 pc = tcf_hash_check(index, a, bind, &ipt_hash_info);
129 if (!pc) { 129 if (!pc) {
@@ -140,7 +140,7 @@ static int tcf_ipt_init(struct nlattr *nla, struct nlattr *est,
140 } 140 }
141 ipt = to_ipt(pc); 141 ipt = to_ipt(pc);
142 142
143 hook = *(u32 *)nla_data(tb[TCA_IPT_HOOK]); 143 hook = nla_get_u32(tb[TCA_IPT_HOOK]);
144 144
145 err = -ENOMEM; 145 err = -ENOMEM;
146 tname = kmalloc(IFNAMSIZ, GFP_KERNEL); 146 tname = kmalloc(IFNAMSIZ, GFP_KERNEL);
diff --git a/net/sched/act_police.c b/net/sched/act_police.c
index 79db6bb8a5fd..62de806af3af 100644
--- a/net/sched/act_police.c
+++ b/net/sched/act_police.c
@@ -203,7 +203,7 @@ override:
203 } 203 }
204 204
205 if (tb[TCA_POLICE_RESULT]) 205 if (tb[TCA_POLICE_RESULT])
206 police->tcfp_result = *(u32*)nla_data(tb[TCA_POLICE_RESULT]); 206 police->tcfp_result = nla_get_u32(tb[TCA_POLICE_RESULT]);
207 police->tcfp_toks = police->tcfp_burst = parm->burst; 207 police->tcfp_toks = police->tcfp_burst = parm->burst;
208 police->tcfp_mtu = parm->mtu; 208 police->tcfp_mtu = parm->mtu;
209 if (police->tcfp_mtu == 0) { 209 if (police->tcfp_mtu == 0) {
@@ -216,8 +216,7 @@ override:
216 police->tcf_action = parm->action; 216 police->tcf_action = parm->action;
217 217
218 if (tb[TCA_POLICE_AVRATE]) 218 if (tb[TCA_POLICE_AVRATE])
219 police->tcfp_ewma_rate = 219 police->tcfp_ewma_rate = nla_get_u32(tb[TCA_POLICE_AVRATE]);
220 *(u32*)nla_data(tb[TCA_POLICE_AVRATE]);
221 if (est) 220 if (est)
222 gen_replace_estimator(&police->tcf_bstats, 221 gen_replace_estimator(&police->tcf_bstats,
223 &police->tcf_rate_est, 222 &police->tcf_rate_est,
diff --git a/net/sched/cls_basic.c b/net/sched/cls_basic.c
index 58444fedf06e..0c872a76c4b0 100644
--- a/net/sched/cls_basic.c
+++ b/net/sched/cls_basic.c
@@ -150,7 +150,7 @@ static inline int basic_set_parms(struct tcf_proto *tp, struct basic_filter *f,
150 goto errout; 150 goto errout;
151 151
152 if (tb[TCA_BASIC_CLASSID]) { 152 if (tb[TCA_BASIC_CLASSID]) {
153 f->res.classid = *(u32*)nla_data(tb[TCA_BASIC_CLASSID]); 153 f->res.classid = nla_get_u32(tb[TCA_BASIC_CLASSID]);
154 tcf_bind_filter(tp, &f->res, base); 154 tcf_bind_filter(tp, &f->res, base);
155 } 155 }
156 156
diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c
index 61ebe25e5f77..b75696d67ec2 100644
--- a/net/sched/cls_fw.c
+++ b/net/sched/cls_fw.c
@@ -203,7 +203,7 @@ fw_change_attrs(struct tcf_proto *tp, struct fw_filter *f,
203 if (tb[TCA_FW_CLASSID]) { 203 if (tb[TCA_FW_CLASSID]) {
204 if (nla_len(tb[TCA_FW_CLASSID]) != sizeof(u32)) 204 if (nla_len(tb[TCA_FW_CLASSID]) != sizeof(u32))
205 goto errout; 205 goto errout;
206 f->res.classid = *(u32*)nla_data(tb[TCA_FW_CLASSID]); 206 f->res.classid = nla_get_u32(tb[TCA_FW_CLASSID]);
207 tcf_bind_filter(tp, &f->res, base); 207 tcf_bind_filter(tp, &f->res, base);
208 } 208 }
209 209
@@ -218,7 +218,7 @@ fw_change_attrs(struct tcf_proto *tp, struct fw_filter *f,
218 if (tb[TCA_FW_MASK]) { 218 if (tb[TCA_FW_MASK]) {
219 if (nla_len(tb[TCA_FW_MASK]) != sizeof(u32)) 219 if (nla_len(tb[TCA_FW_MASK]) != sizeof(u32))
220 goto errout; 220 goto errout;
221 mask = *(u32*)nla_data(tb[TCA_FW_MASK]); 221 mask = nla_get_u32(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)
@@ -264,7 +264,7 @@ static int fw_change(struct tcf_proto *tp, unsigned long base,
264 if (tb[TCA_FW_MASK]) { 264 if (tb[TCA_FW_MASK]) {
265 if (nla_len(tb[TCA_FW_MASK]) != sizeof(u32)) 265 if (nla_len(tb[TCA_FW_MASK]) != sizeof(u32))
266 return -EINVAL; 266 return -EINVAL;
267 mask = *(u32*)nla_data(tb[TCA_FW_MASK]); 267 mask = nla_get_u32(tb[TCA_FW_MASK]);
268 } 268 }
269 269
270 head = kzalloc(sizeof(struct fw_head), GFP_KERNEL); 270 head = kzalloc(sizeof(struct fw_head), GFP_KERNEL);
diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c
index 7752586e918d..ae97238c57ad 100644
--- a/net/sched/cls_route.c
+++ b/net/sched/cls_route.c
@@ -348,7 +348,7 @@ static int route4_set_parms(struct tcf_proto *tp, unsigned long base,
348 goto errout; 348 goto errout;
349 if (nla_len(tb[TCA_ROUTE4_TO]) < sizeof(u32)) 349 if (nla_len(tb[TCA_ROUTE4_TO]) < sizeof(u32))
350 goto errout; 350 goto errout;
351 to = *(u32*)nla_data(tb[TCA_ROUTE4_TO]); 351 to = nla_get_u32(tb[TCA_ROUTE4_TO]);
352 if (to > 0xFF) 352 if (to > 0xFF)
353 goto errout; 353 goto errout;
354 nhandle = to; 354 nhandle = to;
@@ -359,14 +359,14 @@ static int route4_set_parms(struct tcf_proto *tp, unsigned long base,
359 goto errout; 359 goto errout;
360 if (nla_len(tb[TCA_ROUTE4_FROM]) < sizeof(u32)) 360 if (nla_len(tb[TCA_ROUTE4_FROM]) < sizeof(u32))
361 goto errout; 361 goto errout;
362 id = *(u32*)nla_data(tb[TCA_ROUTE4_FROM]); 362 id = nla_get_u32(tb[TCA_ROUTE4_FROM]);
363 if (id > 0xFF) 363 if (id > 0xFF)
364 goto errout; 364 goto errout;
365 nhandle |= id << 16; 365 nhandle |= id << 16;
366 } else if (tb[TCA_ROUTE4_IIF]) { 366 } else if (tb[TCA_ROUTE4_IIF]) {
367 if (nla_len(tb[TCA_ROUTE4_IIF]) < sizeof(u32)) 367 if (nla_len(tb[TCA_ROUTE4_IIF]) < sizeof(u32))
368 goto errout; 368 goto errout;
369 id = *(u32*)nla_data(tb[TCA_ROUTE4_IIF]); 369 id = nla_get_u32(tb[TCA_ROUTE4_IIF]);
370 if (id > 0x7FFF) 370 if (id > 0x7FFF)
371 goto errout; 371 goto errout;
372 nhandle |= (id | 0x8000) << 16; 372 nhandle |= (id | 0x8000) << 16;
@@ -411,7 +411,7 @@ static int route4_set_parms(struct tcf_proto *tp, unsigned long base,
411 tcf_tree_unlock(tp); 411 tcf_tree_unlock(tp);
412 412
413 if (tb[TCA_ROUTE4_CLASSID]) { 413 if (tb[TCA_ROUTE4_CLASSID]) {
414 f->res.classid = *(u32*)nla_data(tb[TCA_ROUTE4_CLASSID]); 414 f->res.classid = nla_get_u32(tb[TCA_ROUTE4_CLASSID]);
415 tcf_bind_filter(tp, &f->res, base); 415 tcf_bind_filter(tp, &f->res, base);
416 } 416 }
417 417
diff --git a/net/sched/cls_rsvp.h b/net/sched/cls_rsvp.h
index 838a3ff5a2cc..61286a0f7a3e 100644
--- a/net/sched/cls_rsvp.h
+++ b/net/sched/cls_rsvp.h
@@ -430,7 +430,7 @@ static int rsvp_change(struct tcf_proto *tp, unsigned long base,
430 if (f->handle != handle && handle) 430 if (f->handle != handle && handle)
431 goto errout2; 431 goto errout2;
432 if (tb[TCA_RSVP_CLASSID-1]) { 432 if (tb[TCA_RSVP_CLASSID-1]) {
433 f->res.classid = *(u32*)nla_data(tb[TCA_RSVP_CLASSID-1]); 433 f->res.classid = nla_get_u32(tb[TCA_RSVP_CLASSID-1]);
434 tcf_bind_filter(tp, &f->res, base); 434 tcf_bind_filter(tp, &f->res, base);
435 } 435 }
436 436
@@ -470,7 +470,7 @@ static int rsvp_change(struct tcf_proto *tp, unsigned long base,
470 err = -EINVAL; 470 err = -EINVAL;
471 if (nla_len(tb[TCA_RSVP_CLASSID-1]) != 4) 471 if (nla_len(tb[TCA_RSVP_CLASSID-1]) != 4)
472 goto errout; 472 goto errout;
473 f->res.classid = *(u32*)nla_data(tb[TCA_RSVP_CLASSID-1]); 473 f->res.classid = nla_get_u32(tb[TCA_RSVP_CLASSID-1]);
474 } 474 }
475 475
476 err = -EINVAL; 476 err = -EINVAL;
diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c
index 7d46df7eac09..28098564b4d7 100644
--- a/net/sched/cls_tcindex.c
+++ b/net/sched/cls_tcindex.c
@@ -221,19 +221,19 @@ tcindex_set_parms(struct tcf_proto *tp, unsigned long base, u32 handle,
221 if (tb[TCA_TCINDEX_HASH]) { 221 if (tb[TCA_TCINDEX_HASH]) {
222 if (nla_len(tb[TCA_TCINDEX_HASH]) < sizeof(u32)) 222 if (nla_len(tb[TCA_TCINDEX_HASH]) < sizeof(u32))
223 goto errout; 223 goto errout;
224 cp.hash = *(u32 *) nla_data(tb[TCA_TCINDEX_HASH]); 224 cp.hash = nla_get_u32(tb[TCA_TCINDEX_HASH]);
225 } 225 }
226 226
227 if (tb[TCA_TCINDEX_MASK]) { 227 if (tb[TCA_TCINDEX_MASK]) {
228 if (nla_len(tb[TCA_TCINDEX_MASK]) < sizeof(u16)) 228 if (nla_len(tb[TCA_TCINDEX_MASK]) < sizeof(u16))
229 goto errout; 229 goto errout;
230 cp.mask = *(u16 *) nla_data(tb[TCA_TCINDEX_MASK]); 230 cp.mask = nla_get_u16(tb[TCA_TCINDEX_MASK]);
231 } 231 }
232 232
233 if (tb[TCA_TCINDEX_SHIFT]) { 233 if (tb[TCA_TCINDEX_SHIFT]) {
234 if (nla_len(tb[TCA_TCINDEX_SHIFT]) < sizeof(int)) 234 if (nla_len(tb[TCA_TCINDEX_SHIFT]) < sizeof(int))
235 goto errout; 235 goto errout;
236 cp.shift = *(int *) nla_data(tb[TCA_TCINDEX_SHIFT]); 236 cp.shift = nla_get_u32(tb[TCA_TCINDEX_SHIFT]);
237 } 237 }
238 238
239 err = -EBUSY; 239 err = -EBUSY;
@@ -251,8 +251,7 @@ tcindex_set_parms(struct tcf_proto *tp, unsigned long base, u32 handle,
251 if (tb[TCA_TCINDEX_FALL_THROUGH]) { 251 if (tb[TCA_TCINDEX_FALL_THROUGH]) {
252 if (nla_len(tb[TCA_TCINDEX_FALL_THROUGH]) < sizeof(u32)) 252 if (nla_len(tb[TCA_TCINDEX_FALL_THROUGH]) < sizeof(u32))
253 goto errout; 253 goto errout;
254 cp.fall_through = 254 cp.fall_through = nla_get_u32(tb[TCA_TCINDEX_FALL_THROUGH]);
255 *(u32 *) nla_data(tb[TCA_TCINDEX_FALL_THROUGH]);
256 } 255 }
257 256
258 if (!cp.hash) { 257 if (!cp.hash) {
@@ -305,7 +304,7 @@ tcindex_set_parms(struct tcf_proto *tp, unsigned long base, u32 handle,
305 } 304 }
306 305
307 if (tb[TCA_TCINDEX_CLASSID]) { 306 if (tb[TCA_TCINDEX_CLASSID]) {
308 cr.res.classid = *(u32 *) nla_data(tb[TCA_TCINDEX_CLASSID]); 307 cr.res.classid = nla_get_u32(tb[TCA_TCINDEX_CLASSID]);
309 tcf_bind_filter(tp, &cr.res, base); 308 tcf_bind_filter(tp, &cr.res, base);
310 } 309 }
311 310
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index 326711eb593c..a4e72e8a882f 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -474,7 +474,7 @@ static int u32_set_parms(struct tcf_proto *tp, unsigned long base,
474 474
475 err = -EINVAL; 475 err = -EINVAL;
476 if (tb[TCA_U32_LINK]) { 476 if (tb[TCA_U32_LINK]) {
477 u32 handle = *(u32*)nla_data(tb[TCA_U32_LINK]); 477 u32 handle = nla_get_u32(tb[TCA_U32_LINK]);
478 struct tc_u_hnode *ht_down = NULL; 478 struct tc_u_hnode *ht_down = NULL;
479 479
480 if (TC_U32_KEY(handle)) 480 if (TC_U32_KEY(handle))
@@ -496,7 +496,7 @@ static int u32_set_parms(struct tcf_proto *tp, unsigned long base,
496 ht_down->refcnt--; 496 ht_down->refcnt--;
497 } 497 }
498 if (tb[TCA_U32_CLASSID]) { 498 if (tb[TCA_U32_CLASSID]) {
499 n->res.classid = *(u32*)nla_data(tb[TCA_U32_CLASSID]); 499 n->res.classid = nla_get_u32(tb[TCA_U32_CLASSID]);
500 tcf_bind_filter(tp, &n->res, base); 500 tcf_bind_filter(tp, &n->res, base);
501 } 501 }
502 502
@@ -543,7 +543,7 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle,
543 } 543 }
544 544
545 if (tb[TCA_U32_DIVISOR]) { 545 if (tb[TCA_U32_DIVISOR]) {
546 unsigned divisor = *(unsigned*)nla_data(tb[TCA_U32_DIVISOR]); 546 unsigned divisor = nla_get_u32(tb[TCA_U32_DIVISOR]);
547 547
548 if (--divisor > 0x100) 548 if (--divisor > 0x100)
549 return -EINVAL; 549 return -EINVAL;
@@ -569,7 +569,7 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle,
569 } 569 }
570 570
571 if (tb[TCA_U32_HASH]) { 571 if (tb[TCA_U32_HASH]) {
572 htid = *(unsigned*)nla_data(tb[TCA_U32_HASH]); 572 htid = nla_get_u32(tb[TCA_U32_HASH]);
573 if (TC_U32_HTID(htid) == TC_U32_ROOT) { 573 if (TC_U32_HTID(htid) == TC_U32_ROOT) {
574 ht = tp->root; 574 ht = tp->root;
575 htid = ht->handle; 575 htid = ht->handle;
diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c
index 63ae6a230c4f..d9f487d813c4 100644
--- a/net/sched/em_meta.c
+++ b/net/sched/em_meta.c
@@ -600,7 +600,7 @@ static int meta_int_change(struct meta_value *dst, struct nlattr *nla)
600 dst->val = *(unsigned long *) nla_data(nla); 600 dst->val = *(unsigned long *) nla_data(nla);
601 dst->len = sizeof(unsigned long); 601 dst->len = sizeof(unsigned long);
602 } else if (nla_len(nla) == sizeof(u32)) { 602 } else if (nla_len(nla) == sizeof(u32)) {
603 dst->val = *(u32 *) nla_data(nla); 603 dst->val = nla_get_u32(nla);
604 dst->len = sizeof(u32); 604 dst->len = sizeof(u32);
605 } else 605 } else
606 return -EINVAL; 606 return -EINVAL;
diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c
index 4d876598d7df..0c71f2eb96bc 100644
--- a/net/sched/sch_atm.c
+++ b/net/sched/sch_atm.c
@@ -231,7 +231,7 @@ static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent,
231 231
232 if (!tb[TCA_ATM_FD] || nla_len(tb[TCA_ATM_FD]) < sizeof(fd)) 232 if (!tb[TCA_ATM_FD] || nla_len(tb[TCA_ATM_FD]) < sizeof(fd))
233 return -EINVAL; 233 return -EINVAL;
234 fd = *(int *)nla_data(tb[TCA_ATM_FD]); 234 fd = nla_get_u32(tb[TCA_ATM_FD]);
235 pr_debug("atm_tc_change: fd %d\n", fd); 235 pr_debug("atm_tc_change: fd %d\n", fd);
236 if (tb[TCA_ATM_HDR]) { 236 if (tb[TCA_ATM_HDR]) {
237 hdr_len = nla_len(tb[TCA_ATM_HDR]); 237 hdr_len = nla_len(tb[TCA_ATM_HDR]);
@@ -246,7 +246,7 @@ static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent,
246 if (nla_len(tb[TCA_ATM_EXCESS]) != sizeof(u32)) 246 if (nla_len(tb[TCA_ATM_EXCESS]) != sizeof(u32))
247 return -EINVAL; 247 return -EINVAL;
248 excess = (struct atm_flow_data *) 248 excess = (struct atm_flow_data *)
249 atm_tc_get(sch, *(u32 *)nla_data(tb[TCA_ATM_EXCESS])); 249 atm_tc_get(sch, nla_get_u32(tb[TCA_ATM_EXCESS]));
250 if (!excess) 250 if (!excess)
251 return -ENOENT; 251 return -ENOENT;
252 } 252 }