17 #include <linux/module.h>
18 #include <linux/types.h>
19 #include <linux/kernel.h>
20 #include <linux/string.h>
21 #include <linux/errno.h>
25 #include <linux/netlink.h>
27 #include <linux/slab.h>
49 for (t = tcf_proto_base;
t; t = t->
next) {
51 if (!try_module_get(t->
owner))
69 for (tp = &tcf_proto_base; (t = *tp) !=
NULL; tp = &t->
next)
88 for (tp = &tcf_proto_base; (t = *tp) !=
NULL; tp = &t->
next)
102 static int tfilter_notify(
struct net *
net,
struct sk_buff *oskb,
104 unsigned long fh,
int event);
114 first = tp->
prio - 1;
123 struct net *
net = sock_net(skb->
sk);
165 err = nlmsg_parse(n,
sizeof(*t), tca,
TCA_MAX,
NULL);
180 cops = q->
ops->cl_ops;
189 cl = cops->
get(q, parent);
201 for (back = chain; (tp = *back) !=
NULL; back = &tp->
next) {
202 if (tp->
prio >= prio) {
203 if (tp->
prio == prio) {
205 (tp->
protocol != protocol && protocol))
213 root_lock = qdisc_root_sleeping_lock(q);
234 tp_ops = tcf_proto_lookup_ops(tca[
TCA_KIND]);
235 if (tp_ops ==
NULL) {
236 #ifdef CONFIG_MODULES
243 request_module(
"cls_%s", name);
245 tp_ops = tcf_proto_lookup_ops(kind);
252 if (tp_ops !=
NULL) {
253 module_put(tp_ops->
owner);
268 err = tp_ops->
init(tp);
270 module_put(tp_ops->
owner);
284 spin_lock_bh(root_lock);
286 spin_unlock_bh(root_lock);
309 err = tp->
ops->delete(tp, fh);
325 spin_lock_bh(root_lock);
328 spin_unlock_bh(root_lock);
350 unsigned char *
b = skb_tail_pointer(skb);
352 nlh = nlmsg_put(skb, portid, seq, event,
sizeof(*tcm), flags);
355 tcm = nlmsg_data(nlh);
362 if (nla_put_string(skb, TCA_KIND, tp->
ops->kind))
363 goto nla_put_failure;
367 if (tp->
ops->dump && tp->
ops->dump(tp, fh, skb, tcm) < 0)
368 goto nla_put_failure;
379 static int tfilter_notify(
struct net *net,
struct sk_buff *oskb,
381 unsigned long fh,
int event)
390 if (tcf_fill_node(skb, tp, fh, portid, n->
nlmsg_seq, 0, event) <= 0) {
405 static int tcf_node_dump(
struct tcf_proto *tp,
unsigned long n,
417 struct net *net = sock_net(skb->
sk);
423 struct tcmsg *tcm = nlmsg_data(cb->
nlh);
424 unsigned long cl = 0;
440 cops = q->
ops->cl_ops;
456 for (tp = *chain, t = 0; tp; tp = tp->
next, t++) {
467 if (cb->
args[1] == 0) {
477 arg.w.fn = tcf_node_dump;
481 arg.w.skip = cb->
args[1] - 1;
483 tp->
ops->walk(tp, &arg.w);
484 cb->
args[1] = arg.w.count + 1;
500 #ifdef CONFIG_NET_CLS_ACT
513 memset(exts, 0,
sizeof(*exts));
515 #ifdef CONFIG_NET_CLS_ACT
517 struct tc_action *act;
550 #ifdef CONFIG_NET_CLS_ACT
552 struct tc_action *act;
555 dst->action = src->action;
567 #ifdef CONFIG_NET_CLS_ACT
568 if (map->
action && exts->action) {
577 nest = nla_nest_start(skb, map->
action);
579 goto nla_put_failure;
581 goto nla_put_failure;
582 nla_nest_end(skb, nest);
584 nest = nla_nest_start(skb, map->
police);
586 goto nla_put_failure;
588 goto nla_put_failure;
589 nla_nest_end(skb, nest);
603 #ifdef CONFIG_NET_CLS_ACT
606 goto nla_put_failure;
614 static int __init tc_filter_init(
void)
619 tc_dump_tfilter,
NULL);