aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/cls_api.c
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@vyatta.com>2008-01-21 05:26:41 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:08:42 -0500
commitaa767bfea4828936fffb7800204294ba4c8ba283 (patch)
tree22108dfc08b78a928774bc099436f0300092332e /net/sched/cls_api.c
parent786a90366f7571b5755d0e2773be9fe4cde80871 (diff)
[PKT_SCHED] net classifier: style cleanup's
Classifier code cleanup. Get rid of printk wrapper, and fix whitespace and other style stuff reported by checkpatch Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/cls_api.c')
-rw-r--r--net/sched/cls_api.c100
1 files changed, 49 insertions, 51 deletions
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 80dccac769d0..e53773612bc7 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -29,12 +29,6 @@
29#include <net/pkt_sched.h> 29#include <net/pkt_sched.h>
30#include <net/pkt_cls.h> 30#include <net/pkt_cls.h>
31 31
32#if 0 /* control */
33#define DPRINTK(format,args...) printk(KERN_DEBUG format,##args)
34#else
35#define DPRINTK(format,args...)
36#endif
37
38/* The list of all installed classifier types */ 32/* The list of all installed classifier types */
39 33
40static struct tcf_proto_ops *tcf_proto_base; 34static struct tcf_proto_ops *tcf_proto_base;
@@ -44,7 +38,7 @@ static DEFINE_RWLOCK(cls_mod_lock);
44 38
45/* Find classifier type by string name */ 39/* Find classifier type by string name */
46 40
47static struct tcf_proto_ops * tcf_proto_lookup_ops(struct rtattr *kind) 41static struct tcf_proto_ops *tcf_proto_lookup_ops(struct rtattr *kind)
48{ 42{
49 struct tcf_proto_ops *t = NULL; 43 struct tcf_proto_ops *t = NULL;
50 44
@@ -81,6 +75,7 @@ out:
81 write_unlock(&cls_mod_lock); 75 write_unlock(&cls_mod_lock);
82 return rc; 76 return rc;
83} 77}
78EXPORT_SYMBOL(register_tcf_proto_ops);
84 79
85int unregister_tcf_proto_ops(struct tcf_proto_ops *ops) 80int unregister_tcf_proto_ops(struct tcf_proto_ops *ops)
86{ 81{
@@ -100,6 +95,7 @@ out:
100 write_unlock(&cls_mod_lock); 95 write_unlock(&cls_mod_lock);
101 return rc; 96 return rc;
102} 97}
98EXPORT_SYMBOL(unregister_tcf_proto_ops);
103 99
104static int tfilter_notify(struct sk_buff *oskb, struct nlmsghdr *n, 100static int tfilter_notify(struct sk_buff *oskb, struct nlmsghdr *n,
105 struct tcf_proto *tp, unsigned long fh, int event); 101 struct tcf_proto *tp, unsigned long fh, int event);
@@ -107,9 +103,9 @@ static int tfilter_notify(struct sk_buff *oskb, struct nlmsghdr *n,
107 103
108/* Select new prio value from the range, managed by kernel. */ 104/* Select new prio value from the range, managed by kernel. */
109 105
110static __inline__ u32 tcf_auto_prio(struct tcf_proto *tp) 106static inline u32 tcf_auto_prio(struct tcf_proto *tp)
111{ 107{
112 u32 first = TC_H_MAKE(0xC0000000U,0U); 108 u32 first = TC_H_MAKE(0xC0000000U, 0U);
113 109
114 if (tp) 110 if (tp)
115 first = tp->prio-1; 111 first = tp->prio-1;
@@ -154,21 +150,25 @@ replay:
154 /* If no priority is given, user wants we allocated it. */ 150 /* If no priority is given, user wants we allocated it. */
155 if (n->nlmsg_type != RTM_NEWTFILTER || !(n->nlmsg_flags&NLM_F_CREATE)) 151 if (n->nlmsg_type != RTM_NEWTFILTER || !(n->nlmsg_flags&NLM_F_CREATE))
156 return -ENOENT; 152 return -ENOENT;
157 prio = TC_H_MAKE(0x80000000U,0U); 153 prio = TC_H_MAKE(0x80000000U, 0U);
158 } 154 }
159 155
160 /* Find head of filter chain. */ 156 /* Find head of filter chain. */
161 157
162 /* Find link */ 158 /* Find link */
163 if ((dev = __dev_get_by_index(&init_net, t->tcm_ifindex)) == NULL) 159 dev = __dev_get_by_index(&init_net, t->tcm_ifindex);
160 if (dev == NULL)
164 return -ENODEV; 161 return -ENODEV;
165 162
166 /* Find qdisc */ 163 /* Find qdisc */
167 if (!parent) { 164 if (!parent) {
168 q = dev->qdisc_sleeping; 165 q = dev->qdisc_sleeping;
169 parent = q->handle; 166 parent = q->handle;
170 } else if ((q = qdisc_lookup(dev, TC_H_MAJ(t->tcm_parent))) == NULL) 167 } else {
171 return -EINVAL; 168 q = qdisc_lookup(dev, TC_H_MAJ(t->tcm_parent));
169 if (q == NULL)
170 return -EINVAL;
171 }
172 172
173 /* Is it classful? */ 173 /* Is it classful? */
174 if ((cops = q->ops->cl_ops) == NULL) 174 if ((cops = q->ops->cl_ops) == NULL)
@@ -213,7 +213,8 @@ replay:
213 /* Create new proto tcf */ 213 /* Create new proto tcf */
214 214
215 err = -ENOBUFS; 215 err = -ENOBUFS;
216 if ((tp = kzalloc(sizeof(*tp), GFP_KERNEL)) == NULL) 216 tp = kzalloc(sizeof(*tp), GFP_KERNEL);
217 if (tp == NULL)
217 goto errout; 218 goto errout;
218 err = -EINVAL; 219 err = -EINVAL;
219 tp_ops = tcf_proto_lookup_ops(tca[TCA_KIND-1]); 220 tp_ops = tcf_proto_lookup_ops(tca[TCA_KIND-1]);
@@ -249,7 +250,9 @@ replay:
249 tp->q = q; 250 tp->q = q;
250 tp->classify = tp_ops->classify; 251 tp->classify = tp_ops->classify;
251 tp->classid = parent; 252 tp->classid = parent;
252 if ((err = tp_ops->init(tp)) != 0) { 253
254 err = tp_ops->init(tp);
255 if (err != 0) {
253 module_put(tp_ops->owner); 256 module_put(tp_ops->owner);
254 kfree(tp); 257 kfree(tp);
255 goto errout; 258 goto errout;
@@ -278,13 +281,14 @@ replay:
278 } 281 }
279 282
280 err = -ENOENT; 283 err = -ENOENT;
281 if (n->nlmsg_type != RTM_NEWTFILTER || !(n->nlmsg_flags&NLM_F_CREATE)) 284 if (n->nlmsg_type != RTM_NEWTFILTER ||
285 !(n->nlmsg_flags & NLM_F_CREATE))
282 goto errout; 286 goto errout;
283 } else { 287 } else {
284 switch (n->nlmsg_type) { 288 switch (n->nlmsg_type) {
285 case RTM_NEWTFILTER: 289 case RTM_NEWTFILTER:
286 err = -EEXIST; 290 err = -EEXIST;
287 if (n->nlmsg_flags&NLM_F_EXCL) 291 if (n->nlmsg_flags & NLM_F_EXCL)
288 goto errout; 292 goto errout;
289 break; 293 break;
290 case RTM_DELTFILTER: 294 case RTM_DELTFILTER:
@@ -314,9 +318,8 @@ errout:
314 return err; 318 return err;
315} 319}
316 320
317static int 321static int tcf_fill_node(struct sk_buff *skb, struct tcf_proto *tp,
318tcf_fill_node(struct sk_buff *skb, struct tcf_proto *tp, unsigned long fh, 322 unsigned long fh, u32 pid, u32 seq, u16 flags, int event)
319 u32 pid, u32 seq, u16 flags, int event)
320{ 323{
321 struct tcmsg *tcm; 324 struct tcmsg *tcm;
322 struct nlmsghdr *nlh; 325 struct nlmsghdr *nlh;
@@ -361,19 +364,20 @@ static int tfilter_notify(struct sk_buff *oskb, struct nlmsghdr *n,
361 return -EINVAL; 364 return -EINVAL;
362 } 365 }
363 366
364 return rtnetlink_send(skb, &init_net, pid, RTNLGRP_TC, n->nlmsg_flags&NLM_F_ECHO); 367 return rtnetlink_send(skb, &init_net, pid, RTNLGRP_TC,
368 n->nlmsg_flags & NLM_F_ECHO);
365} 369}
366 370
367struct tcf_dump_args 371struct tcf_dump_args {
368{
369 struct tcf_walker w; 372 struct tcf_walker w;
370 struct sk_buff *skb; 373 struct sk_buff *skb;
371 struct netlink_callback *cb; 374 struct netlink_callback *cb;
372}; 375};
373 376
374static int tcf_node_dump(struct tcf_proto *tp, unsigned long n, struct tcf_walker *arg) 377static int tcf_node_dump(struct tcf_proto *tp, unsigned long n,
378 struct tcf_walker *arg)
375{ 379{
376 struct tcf_dump_args *a = (void*)arg; 380 struct tcf_dump_args *a = (void *)arg;
377 381
378 return tcf_fill_node(a->skb, tp, n, NETLINK_CB(a->cb->skb).pid, 382 return tcf_fill_node(a->skb, tp, n, NETLINK_CB(a->cb->skb).pid,
379 a->cb->nlh->nlmsg_seq, NLM_F_MULTI, RTM_NEWTFILTER); 383 a->cb->nlh->nlmsg_seq, NLM_F_MULTI, RTM_NEWTFILTER);
@@ -387,7 +391,7 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)
387 struct net_device *dev; 391 struct net_device *dev;
388 struct Qdisc *q; 392 struct Qdisc *q;
389 struct tcf_proto *tp, **chain; 393 struct tcf_proto *tp, **chain;
390 struct tcmsg *tcm = (struct tcmsg*)NLMSG_DATA(cb->nlh); 394 struct tcmsg *tcm = (struct tcmsg *)NLMSG_DATA(cb->nlh);
391 unsigned long cl = 0; 395 unsigned long cl = 0;
392 const struct Qdisc_class_ops *cops; 396 const struct Qdisc_class_ops *cops;
393 struct tcf_dump_args arg; 397 struct tcf_dump_args arg;
@@ -431,9 +435,10 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)
431 memset(&cb->args[1], 0, sizeof(cb->args)-sizeof(cb->args[0])); 435 memset(&cb->args[1], 0, sizeof(cb->args)-sizeof(cb->args[0]));
432 if (cb->args[1] == 0) { 436 if (cb->args[1] == 0) {
433 if (tcf_fill_node(skb, tp, 0, NETLINK_CB(cb->skb).pid, 437 if (tcf_fill_node(skb, tp, 0, NETLINK_CB(cb->skb).pid,
434 cb->nlh->nlmsg_seq, NLM_F_MULTI, RTM_NEWTFILTER) <= 0) { 438 cb->nlh->nlmsg_seq, NLM_F_MULTI,
439 RTM_NEWTFILTER) <= 0)
435 break; 440 break;
436 } 441
437 cb->args[1] = 1; 442 cb->args[1] = 1;
438 } 443 }
439 if (tp->ops->walk == NULL) 444 if (tp->ops->walk == NULL)
@@ -460,8 +465,7 @@ out:
460 return skb->len; 465 return skb->len;
461} 466}
462 467
463void 468void tcf_exts_destroy(struct tcf_proto *tp, struct tcf_exts *exts)
464tcf_exts_destroy(struct tcf_proto *tp, struct tcf_exts *exts)
465{ 469{
466#ifdef CONFIG_NET_CLS_ACT 470#ifdef CONFIG_NET_CLS_ACT
467 if (exts->action) { 471 if (exts->action) {
@@ -470,10 +474,9 @@ tcf_exts_destroy(struct tcf_proto *tp, struct tcf_exts *exts)
470 } 474 }
471#endif 475#endif
472} 476}
477EXPORT_SYMBOL(tcf_exts_destroy);
473 478
474 479int tcf_exts_validate(struct tcf_proto *tp, struct rtattr **tb,
475int
476tcf_exts_validate(struct tcf_proto *tp, struct rtattr **tb,
477 struct rtattr *rate_tlv, struct tcf_exts *exts, 480 struct rtattr *rate_tlv, struct tcf_exts *exts,
478 struct tcf_ext_map *map) 481 struct tcf_ext_map *map)
479{ 482{
@@ -485,8 +488,9 @@ tcf_exts_validate(struct tcf_proto *tp, struct rtattr **tb,
485 struct tc_action *act; 488 struct tc_action *act;
486 489
487 if (map->police && tb[map->police-1]) { 490 if (map->police && tb[map->police-1]) {
488 act = tcf_action_init_1(tb[map->police-1], rate_tlv, "police", 491 act = tcf_action_init_1(tb[map->police-1], rate_tlv,
489 TCA_ACT_NOREPLACE, TCA_ACT_BIND, &err); 492 "police", TCA_ACT_NOREPLACE,
493 TCA_ACT_BIND, &err);
490 if (act == NULL) 494 if (act == NULL)
491 return err; 495 return err;
492 496
@@ -509,10 +513,10 @@ tcf_exts_validate(struct tcf_proto *tp, struct rtattr **tb,
509 513
510 return 0; 514 return 0;
511} 515}
516EXPORT_SYMBOL(tcf_exts_validate);
512 517
513void 518void tcf_exts_change(struct tcf_proto *tp, struct tcf_exts *dst,
514tcf_exts_change(struct tcf_proto *tp, struct tcf_exts *dst, 519 struct tcf_exts *src)
515 struct tcf_exts *src)
516{ 520{
517#ifdef CONFIG_NET_CLS_ACT 521#ifdef CONFIG_NET_CLS_ACT
518 if (src->action) { 522 if (src->action) {
@@ -525,9 +529,9 @@ tcf_exts_change(struct tcf_proto *tp, struct tcf_exts *dst,
525 } 529 }
526#endif 530#endif
527} 531}
532EXPORT_SYMBOL(tcf_exts_change);
528 533
529int 534int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts,
530tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts,
531 struct tcf_ext_map *map) 535 struct tcf_ext_map *map)
532{ 536{
533#ifdef CONFIG_NET_CLS_ACT 537#ifdef CONFIG_NET_CLS_ACT
@@ -556,10 +560,11 @@ tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts,
556rtattr_failure: __attribute__ ((unused)) 560rtattr_failure: __attribute__ ((unused))
557 return -1; 561 return -1;
558} 562}
563EXPORT_SYMBOL(tcf_exts_dump);
559 564
560int 565
561tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts, 566int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts,
562 struct tcf_ext_map *map) 567 struct tcf_ext_map *map)
563{ 568{
564#ifdef CONFIG_NET_CLS_ACT 569#ifdef CONFIG_NET_CLS_ACT
565 if (exts->action) 570 if (exts->action)
@@ -570,6 +575,7 @@ tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts,
570rtattr_failure: __attribute__ ((unused)) 575rtattr_failure: __attribute__ ((unused))
571 return -1; 576 return -1;
572} 577}
578EXPORT_SYMBOL(tcf_exts_dump_stats);
573 579
574static int __init tc_filter_init(void) 580static int __init tc_filter_init(void)
575{ 581{
@@ -582,11 +588,3 @@ static int __init tc_filter_init(void)
582} 588}
583 589
584subsys_initcall(tc_filter_init); 590subsys_initcall(tc_filter_init);
585
586EXPORT_SYMBOL(register_tcf_proto_ops);
587EXPORT_SYMBOL(unregister_tcf_proto_ops);
588EXPORT_SYMBOL(tcf_exts_validate);
589EXPORT_SYMBOL(tcf_exts_destroy);
590EXPORT_SYMBOL(tcf_exts_change);
591EXPORT_SYMBOL(tcf_exts_dump);
592EXPORT_SYMBOL(tcf_exts_dump_stats);