2 * net/sched/act_api.c Packet action API.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * Author: Jamal Hadi Salim
14 #include <linux/types.h>
15 #include <linux/kernel.h>
16 #include <linux/string.h>
17 #include <linux/errno.h>
18 #include <linux/slab.h>
19 #include <linux/skbuff.h>
20 #include <linux/init.h>
21 #include <linux/kmod.h>
22 #include <linux/err.h>
23 #include <linux/module.h>
24 #include <net/net_namespace.h>
26 #include <net/sch_generic.h>
27 #include <net/act_api.h>
28 #include <net/netlink.h>
30 static void free_tcf(struct rcu_head *head)
32 struct tcf_common *p = container_of(head, struct tcf_common, tcfc_rcu);
34 free_percpu(p->cpu_bstats);
35 free_percpu(p->cpu_qstats);
39 static void tcf_hash_destroy(struct tcf_hashinfo *hinfo, struct tc_action *a)
41 struct tcf_common *p = a->priv;
43 spin_lock_bh(&hinfo->lock);
44 hlist_del(&p->tcfc_head);
45 spin_unlock_bh(&hinfo->lock);
46 gen_kill_estimator(&p->tcfc_bstats,
49 * gen_estimator est_timer() might access p->tcfc_lock
50 * or bstats, wait a RCU grace period before freeing p
52 call_rcu(&p->tcfc_rcu, free_tcf);
55 int __tcf_hash_release(struct tc_action *a, bool bind, bool strict)
57 struct tcf_common *p = a->priv;
63 else if (strict && p->tcfc_bindcnt > 0)
67 if (p->tcfc_bindcnt <= 0 && p->tcfc_refcnt <= 0) {
69 a->ops->cleanup(a, bind);
70 tcf_hash_destroy(a->hinfo, a);
77 EXPORT_SYMBOL(__tcf_hash_release);
79 static int tcf_dump_walker(struct tcf_hashinfo *hinfo, struct sk_buff *skb,
80 struct netlink_callback *cb, struct tc_action *a)
82 struct hlist_head *head;
84 int err = 0, index = -1, i = 0, s_i = 0, n_i = 0;
87 spin_lock_bh(&hinfo->lock);
91 for (i = 0; i < (hinfo->hmask + 1); i++) {
92 head = &hinfo->htab[tcf_hash(i, hinfo->hmask)];
94 hlist_for_each_entry_rcu(p, head, tcfc_head) {
101 nest = nla_nest_start(skb, a->order);
103 goto nla_put_failure;
104 err = tcf_action_dump_1(skb, a, 0, 0);
107 nlmsg_trim(skb, nest);
110 nla_nest_end(skb, nest);
112 if (n_i >= TCA_ACT_MAX_PRIO)
117 spin_unlock_bh(&hinfo->lock);
123 nla_nest_cancel(skb, nest);
127 static int tcf_del_walker(struct tcf_hashinfo *hinfo, struct sk_buff *skb,
130 struct hlist_head *head;
131 struct hlist_node *n;
132 struct tcf_common *p;
137 nest = nla_nest_start(skb, a->order);
139 goto nla_put_failure;
140 if (nla_put_string(skb, TCA_KIND, a->ops->kind))
141 goto nla_put_failure;
142 for (i = 0; i < (hinfo->hmask + 1); i++) {
143 head = &hinfo->htab[tcf_hash(i, hinfo->hmask)];
144 hlist_for_each_entry_safe(p, n, head, tcfc_head) {
146 ret = __tcf_hash_release(a, false, true);
147 if (ret == ACT_P_DELETED) {
148 module_put(a->ops->owner);
151 goto nla_put_failure;
154 if (nla_put_u32(skb, TCA_FCNT, n_i))
155 goto nla_put_failure;
156 nla_nest_end(skb, nest);
160 nla_nest_cancel(skb, nest);
164 int tcf_generic_walker(struct tc_action_net *tn, struct sk_buff *skb,
165 struct netlink_callback *cb, int type,
168 struct tcf_hashinfo *hinfo = tn->hinfo;
172 if (type == RTM_DELACTION) {
173 return tcf_del_walker(hinfo, skb, a);
174 } else if (type == RTM_GETACTION) {
175 return tcf_dump_walker(hinfo, skb, cb, a);
177 WARN(1, "tcf_generic_walker: unknown action %d\n", type);
181 EXPORT_SYMBOL(tcf_generic_walker);
183 static struct tcf_common *tcf_hash_lookup(u32 index, struct tcf_hashinfo *hinfo)
185 struct tcf_common *p = NULL;
186 struct hlist_head *head;
188 spin_lock_bh(&hinfo->lock);
189 head = &hinfo->htab[tcf_hash(index, hinfo->hmask)];
190 hlist_for_each_entry_rcu(p, head, tcfc_head)
191 if (p->tcfc_index == index)
193 spin_unlock_bh(&hinfo->lock);
198 u32 tcf_hash_new_index(struct tc_action_net *tn)
200 struct tcf_hashinfo *hinfo = tn->hinfo;
201 u32 val = hinfo->index;
206 } while (tcf_hash_lookup(val, hinfo));
211 EXPORT_SYMBOL(tcf_hash_new_index);
213 int tcf_hash_search(struct tc_action_net *tn, struct tc_action *a, u32 index)
215 struct tcf_hashinfo *hinfo = tn->hinfo;
216 struct tcf_common *p = tcf_hash_lookup(index, hinfo);
225 EXPORT_SYMBOL(tcf_hash_search);
227 int tcf_hash_check(struct tc_action_net *tn, u32 index, struct tc_action *a,
230 struct tcf_hashinfo *hinfo = tn->hinfo;
231 struct tcf_common *p = NULL;
232 if (index && (p = tcf_hash_lookup(index, hinfo)) != NULL) {
242 EXPORT_SYMBOL(tcf_hash_check);
244 void tcf_hash_cleanup(struct tc_action *a, struct nlattr *est)
246 struct tcf_common *pc = a->priv;
248 gen_kill_estimator(&pc->tcfc_bstats,
250 call_rcu(&pc->tcfc_rcu, free_tcf);
252 EXPORT_SYMBOL(tcf_hash_cleanup);
254 int tcf_hash_create(struct tc_action_net *tn, u32 index, struct nlattr *est,
255 struct tc_action *a, int size, int bind, bool cpustats)
257 struct tcf_common *p = kzalloc(size, GFP_KERNEL);
258 struct tcf_hashinfo *hinfo = tn->hinfo;
268 p->cpu_bstats = netdev_alloc_pcpu_stats(struct gnet_stats_basic_cpu);
269 if (!p->cpu_bstats) {
274 p->cpu_qstats = alloc_percpu(struct gnet_stats_queue);
275 if (!p->cpu_qstats) {
277 free_percpu(p->cpu_bstats);
281 spin_lock_init(&p->tcfc_lock);
282 INIT_HLIST_NODE(&p->tcfc_head);
283 p->tcfc_index = index ? index : tcf_hash_new_index(tn);
284 p->tcfc_tm.install = jiffies;
285 p->tcfc_tm.lastuse = jiffies;
287 err = gen_new_estimator(&p->tcfc_bstats, p->cpu_bstats,
291 free_percpu(p->cpu_qstats);
296 a->priv = (void *) p;
300 EXPORT_SYMBOL(tcf_hash_create);
302 void tcf_hash_insert(struct tc_action_net *tn, struct tc_action *a)
304 struct tcf_common *p = a->priv;
305 struct tcf_hashinfo *hinfo = tn->hinfo;
306 unsigned int h = tcf_hash(p->tcfc_index, hinfo->hmask);
308 spin_lock_bh(&hinfo->lock);
309 hlist_add_head(&p->tcfc_head, &hinfo->htab[h]);
310 spin_unlock_bh(&hinfo->lock);
312 EXPORT_SYMBOL(tcf_hash_insert);
314 void tcf_hashinfo_destroy(const struct tc_action_ops *ops,
315 struct tcf_hashinfo *hinfo)
317 struct tc_action a = {
323 for (i = 0; i < hinfo->hmask + 1; i++) {
324 struct tcf_common *p;
325 struct hlist_node *n;
327 hlist_for_each_entry_safe(p, n, &hinfo->htab[i], tcfc_head) {
331 ret = __tcf_hash_release(&a, false, true);
332 if (ret == ACT_P_DELETED)
333 module_put(ops->owner);
340 EXPORT_SYMBOL(tcf_hashinfo_destroy);
342 static LIST_HEAD(act_base);
343 static DEFINE_RWLOCK(act_mod_lock);
345 int tcf_register_action(struct tc_action_ops *act,
346 struct pernet_operations *ops)
348 struct tc_action_ops *a;
351 if (!act->act || !act->dump || !act->init || !act->walk || !act->lookup)
354 write_lock(&act_mod_lock);
355 list_for_each_entry(a, &act_base, head) {
356 if (act->type == a->type || (strcmp(act->kind, a->kind) == 0)) {
357 write_unlock(&act_mod_lock);
361 list_add_tail(&act->head, &act_base);
362 write_unlock(&act_mod_lock);
364 ret = register_pernet_subsys(ops);
366 tcf_unregister_action(act, ops);
372 EXPORT_SYMBOL(tcf_register_action);
374 int tcf_unregister_action(struct tc_action_ops *act,
375 struct pernet_operations *ops)
377 struct tc_action_ops *a;
380 unregister_pernet_subsys(ops);
382 write_lock(&act_mod_lock);
383 list_for_each_entry(a, &act_base, head) {
385 list_del(&act->head);
390 write_unlock(&act_mod_lock);
393 EXPORT_SYMBOL(tcf_unregister_action);
396 static struct tc_action_ops *tc_lookup_action_n(char *kind)
398 struct tc_action_ops *a, *res = NULL;
401 read_lock(&act_mod_lock);
402 list_for_each_entry(a, &act_base, head) {
403 if (strcmp(kind, a->kind) == 0) {
404 if (try_module_get(a->owner))
409 read_unlock(&act_mod_lock);
414 /* lookup by nlattr */
415 static struct tc_action_ops *tc_lookup_action(struct nlattr *kind)
417 struct tc_action_ops *a, *res = NULL;
420 read_lock(&act_mod_lock);
421 list_for_each_entry(a, &act_base, head) {
422 if (nla_strcmp(kind, a->kind) == 0) {
423 if (try_module_get(a->owner))
428 read_unlock(&act_mod_lock);
433 int tcf_action_exec(struct sk_buff *skb, const struct list_head *actions,
434 struct tcf_result *res)
436 const struct tc_action *a;
439 if (skb->tc_verd & TC_NCLS) {
440 skb->tc_verd = CLR_TC_NCLS(skb->tc_verd);
444 list_for_each_entry(a, actions, list) {
446 ret = a->ops->act(skb, a, res);
447 if (ret == TC_ACT_REPEAT)
448 goto repeat; /* we need a ttl - JHS */
449 if (ret != TC_ACT_PIPE)
455 EXPORT_SYMBOL(tcf_action_exec);
457 int tcf_action_destroy(struct list_head *actions, int bind)
459 struct tc_action *a, *tmp;
462 list_for_each_entry_safe(a, tmp, actions, list) {
463 ret = __tcf_hash_release(a, bind, true);
464 if (ret == ACT_P_DELETED)
465 module_put(a->ops->owner);
475 tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
477 return a->ops->dump(skb, a, bind, ref);
481 tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
484 unsigned char *b = skb_tail_pointer(skb);
487 if (nla_put_string(skb, TCA_KIND, a->ops->kind))
488 goto nla_put_failure;
489 if (tcf_action_copy_stats(skb, a, 0))
490 goto nla_put_failure;
491 nest = nla_nest_start(skb, TCA_OPTIONS);
493 goto nla_put_failure;
494 err = tcf_action_dump_old(skb, a, bind, ref);
496 nla_nest_end(skb, nest);
504 EXPORT_SYMBOL(tcf_action_dump_1);
507 tcf_action_dump(struct sk_buff *skb, struct list_head *actions, int bind, int ref)
513 list_for_each_entry(a, actions, list) {
514 nest = nla_nest_start(skb, a->order);
516 goto nla_put_failure;
517 err = tcf_action_dump_1(skb, a, bind, ref);
520 nla_nest_end(skb, nest);
528 nla_nest_cancel(skb, nest);
532 struct tc_action *tcf_action_init_1(struct net *net, struct nlattr *nla,
533 struct nlattr *est, char *name, int ovr,
537 struct tc_action_ops *a_o;
538 char act_name[IFNAMSIZ];
539 struct nlattr *tb[TCA_ACT_MAX + 1];
544 err = nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL);
548 kind = tb[TCA_ACT_KIND];
551 if (nla_strlcpy(act_name, kind, IFNAMSIZ) >= IFNAMSIZ)
555 if (strlcpy(act_name, name, IFNAMSIZ) >= IFNAMSIZ)
559 a_o = tc_lookup_action_n(act_name);
561 #ifdef CONFIG_MODULES
563 request_module("act_%s", act_name);
566 a_o = tc_lookup_action_n(act_name);
568 /* We dropped the RTNL semaphore in order to
569 * perform the module load. So, even if we
570 * succeeded in loading the module we have to
571 * tell the caller to replay the request. We
572 * indicate this using -EAGAIN.
584 a = kzalloc(sizeof(*a), GFP_KERNEL);
589 INIT_LIST_HEAD(&a->list);
590 /* backward compatibility for policer */
592 err = a_o->init(net, tb[TCA_ACT_OPTIONS], est, a, ovr, bind);
594 err = a_o->init(net, nla, est, a, ovr, bind);
598 /* module count goes up only when brand new policy is created
599 * if it exists and is only bound to in a_o->init() then
600 * ACT_P_CREATED is not returned (a zero is).
602 if (err != ACT_P_CREATED)
603 module_put(a_o->owner);
610 module_put(a_o->owner);
615 int tcf_action_init(struct net *net, struct nlattr *nla,
616 struct nlattr *est, char *name, int ovr,
617 int bind, struct list_head *actions)
619 struct nlattr *tb[TCA_ACT_MAX_PRIO + 1];
620 struct tc_action *act;
624 err = nla_parse_nested(tb, TCA_ACT_MAX_PRIO, nla, NULL);
628 for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) {
629 act = tcf_action_init_1(net, tb[i], est, name, ovr, bind);
635 list_add_tail(&act->list, actions);
640 tcf_action_destroy(actions, bind);
644 int tcf_action_copy_stats(struct sk_buff *skb, struct tc_action *a,
649 struct tcf_common *p = a->priv;
654 /* compat_mode being true specifies a call that is supposed
655 * to add additional backward compatibility statistic TLVs.
658 if (a->type == TCA_OLD_COMPAT)
659 err = gnet_stats_start_copy_compat(skb, 0,
667 err = gnet_stats_start_copy(skb, TCA_ACT_STATS,
668 &p->tcfc_lock, &d, TCA_ACT_PAD);
673 if (gnet_stats_copy_basic(&d, p->cpu_bstats, &p->tcfc_bstats) < 0 ||
674 gnet_stats_copy_rate_est(&d, &p->tcfc_bstats,
675 &p->tcfc_rate_est) < 0 ||
676 gnet_stats_copy_queue(&d, p->cpu_qstats,
678 p->tcfc_qstats.qlen) < 0)
681 if (gnet_stats_finish_copy(&d) < 0)
691 tca_get_fill(struct sk_buff *skb, struct list_head *actions, u32 portid, u32 seq,
692 u16 flags, int event, int bind, int ref)
695 struct nlmsghdr *nlh;
696 unsigned char *b = skb_tail_pointer(skb);
699 nlh = nlmsg_put(skb, portid, seq, event, sizeof(*t), flags);
703 t->tca_family = AF_UNSPEC;
707 nest = nla_nest_start(skb, TCA_ACT_TAB);
711 if (tcf_action_dump(skb, actions, bind, ref) < 0)
714 nla_nest_end(skb, nest);
716 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
725 act_get_notify(struct net *net, u32 portid, struct nlmsghdr *n,
726 struct list_head *actions, int event)
730 skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
733 if (tca_get_fill(skb, actions, portid, n->nlmsg_seq, 0, event, 0, 0) <= 0) {
738 return rtnl_unicast(skb, net, portid);
741 static struct tc_action *create_a(int i)
743 struct tc_action *act;
745 act = kzalloc(sizeof(*act), GFP_KERNEL);
747 pr_debug("create_a: failed to alloc!\n");
751 INIT_LIST_HEAD(&act->list);
755 static struct tc_action *tcf_action_get_1(struct net *net, struct nlattr *nla,
756 struct nlmsghdr *n, u32 portid)
758 struct nlattr *tb[TCA_ACT_MAX + 1];
763 err = nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL);
768 if (tb[TCA_ACT_INDEX] == NULL ||
769 nla_len(tb[TCA_ACT_INDEX]) < sizeof(index))
771 index = nla_get_u32(tb[TCA_ACT_INDEX]);
779 a->ops = tc_lookup_action(tb[TCA_ACT_KIND]);
780 if (a->ops == NULL) /* could happen in batch of actions */
783 if (a->ops->lookup(net, a, index) == 0)
786 module_put(a->ops->owner);
790 module_put(a->ops->owner);
797 static void cleanup_a(struct list_head *actions)
799 struct tc_action *a, *tmp;
801 list_for_each_entry_safe(a, tmp, actions, list) {
807 static int tca_action_flush(struct net *net, struct nlattr *nla,
808 struct nlmsghdr *n, u32 portid)
812 struct nlmsghdr *nlh;
814 struct netlink_callback dcb;
816 struct nlattr *tb[TCA_ACT_MAX + 1];
821 skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
823 pr_debug("tca_action_flush: failed skb alloc\n");
827 b = skb_tail_pointer(skb);
829 err = nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL);
834 kind = tb[TCA_ACT_KIND];
835 memset(&a, 0, sizeof(struct tc_action));
836 INIT_LIST_HEAD(&a.list);
837 a.ops = tc_lookup_action(kind);
838 if (a.ops == NULL) /*some idjot trying to flush unknown action */
841 nlh = nlmsg_put(skb, portid, n->nlmsg_seq, RTM_DELACTION, sizeof(*t), 0);
845 t->tca_family = AF_UNSPEC;
849 nest = nla_nest_start(skb, TCA_ACT_TAB);
853 err = a.ops->walk(net, skb, &dcb, RTM_DELACTION, &a);
859 nla_nest_end(skb, nest);
861 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
862 nlh->nlmsg_flags |= NLM_F_ROOT;
863 module_put(a.ops->owner);
864 err = rtnetlink_send(skb, net, portid, RTNLGRP_TC,
865 n->nlmsg_flags & NLM_F_ECHO);
872 module_put(a.ops->owner);
880 tcf_del_notify(struct net *net, struct nlmsghdr *n, struct list_head *actions,
886 skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
890 if (tca_get_fill(skb, actions, portid, n->nlmsg_seq, 0, RTM_DELACTION,
896 /* now do the delete */
897 ret = tcf_action_destroy(actions, 0);
903 ret = rtnetlink_send(skb, net, portid, RTNLGRP_TC,
904 n->nlmsg_flags & NLM_F_ECHO);
911 tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n,
912 u32 portid, int event)
915 struct nlattr *tb[TCA_ACT_MAX_PRIO + 1];
916 struct tc_action *act;
919 ret = nla_parse_nested(tb, TCA_ACT_MAX_PRIO, nla, NULL);
923 if (event == RTM_DELACTION && n->nlmsg_flags & NLM_F_ROOT) {
925 return tca_action_flush(net, tb[1], n, portid);
930 for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) {
931 act = tcf_action_get_1(net, tb[i], n, portid);
937 list_add_tail(&act->list, &actions);
940 if (event == RTM_GETACTION)
941 ret = act_get_notify(net, portid, n, &actions, event);
943 ret = tcf_del_notify(net, n, &actions, portid);
954 tcf_add_notify(struct net *net, struct nlmsghdr *n, struct list_head *actions,
960 skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
964 if (tca_get_fill(skb, actions, portid, n->nlmsg_seq, n->nlmsg_flags,
965 RTM_NEWACTION, 0, 0) <= 0) {
970 err = rtnetlink_send(skb, net, portid, RTNLGRP_TC,
971 n->nlmsg_flags & NLM_F_ECHO);
978 tcf_action_add(struct net *net, struct nlattr *nla, struct nlmsghdr *n,
984 ret = tcf_action_init(net, nla, NULL, NULL, ovr, 0, &actions);
988 /* dump then free all the actions after update; inserted policy
991 ret = tcf_add_notify(net, n, &actions, portid);
997 static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n)
999 struct net *net = sock_net(skb->sk);
1000 struct nlattr *tca[TCA_ACT_MAX + 1];
1001 u32 portid = skb ? NETLINK_CB(skb).portid : 0;
1002 int ret = 0, ovr = 0;
1004 if ((n->nlmsg_type != RTM_GETACTION) && !netlink_capable(skb, CAP_NET_ADMIN))
1007 ret = nlmsg_parse(n, sizeof(struct tcamsg), tca, TCA_ACT_MAX, NULL);
1011 if (tca[TCA_ACT_TAB] == NULL) {
1012 pr_notice("tc_ctl_action: received NO action attribs\n");
1016 /* n->nlmsg_flags & NLM_F_CREATE */
1017 switch (n->nlmsg_type) {
1019 /* we are going to assume all other flags
1020 * imply create only if it doesn't exist
1021 * Note that CREATE | EXCL implies that
1022 * but since we want avoid ambiguity (eg when flags
1023 * is zero) then just set this
1025 if (n->nlmsg_flags & NLM_F_REPLACE)
1028 ret = tcf_action_add(net, tca[TCA_ACT_TAB], n, portid, ovr);
1033 ret = tca_action_gd(net, tca[TCA_ACT_TAB], n,
1034 portid, RTM_DELACTION);
1037 ret = tca_action_gd(net, tca[TCA_ACT_TAB], n,
1038 portid, RTM_GETACTION);
1047 static struct nlattr *
1048 find_dump_kind(const struct nlmsghdr *n)
1050 struct nlattr *tb1, *tb2[TCA_ACT_MAX + 1];
1051 struct nlattr *tb[TCA_ACT_MAX_PRIO + 1];
1052 struct nlattr *nla[TCAA_MAX + 1];
1053 struct nlattr *kind;
1055 if (nlmsg_parse(n, sizeof(struct tcamsg), nla, TCAA_MAX, NULL) < 0)
1057 tb1 = nla[TCA_ACT_TAB];
1061 if (nla_parse(tb, TCA_ACT_MAX_PRIO, nla_data(tb1),
1062 NLMSG_ALIGN(nla_len(tb1)), NULL) < 0)
1067 if (nla_parse(tb2, TCA_ACT_MAX, nla_data(tb[1]),
1068 nla_len(tb[1]), NULL) < 0)
1070 kind = tb2[TCA_ACT_KIND];
1076 tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
1078 struct net *net = sock_net(skb->sk);
1079 struct nlmsghdr *nlh;
1080 unsigned char *b = skb_tail_pointer(skb);
1081 struct nlattr *nest;
1082 struct tc_action_ops *a_o;
1085 struct tcamsg *t = (struct tcamsg *) nlmsg_data(cb->nlh);
1086 struct nlattr *kind = find_dump_kind(cb->nlh);
1089 pr_info("tc_dump_action: action bad kind\n");
1093 a_o = tc_lookup_action(kind);
1097 memset(&a, 0, sizeof(struct tc_action));
1100 nlh = nlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq,
1101 cb->nlh->nlmsg_type, sizeof(*t), 0);
1103 goto out_module_put;
1104 t = nlmsg_data(nlh);
1105 t->tca_family = AF_UNSPEC;
1109 nest = nla_nest_start(skb, TCA_ACT_TAB);
1111 goto out_module_put;
1113 ret = a_o->walk(net, skb, cb, RTM_GETACTION, &a);
1115 goto out_module_put;
1118 nla_nest_end(skb, nest);
1123 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
1124 if (NETLINK_CB(cb->skb).portid && ret)
1125 nlh->nlmsg_flags |= NLM_F_MULTI;
1126 module_put(a_o->owner);
1130 module_put(a_o->owner);
1135 static int __init tc_action_init(void)
1137 rtnl_register(PF_UNSPEC, RTM_NEWACTION, tc_ctl_action, NULL, NULL);
1138 rtnl_register(PF_UNSPEC, RTM_DELACTION, tc_ctl_action, NULL, NULL);
1139 rtnl_register(PF_UNSPEC, RTM_GETACTION, tc_ctl_action, tc_dump_action,
1145 subsys_initcall(tc_action_init);