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 tc_action *a)
41 struct tcf_common *p = a->priv;
42 struct tcf_hashinfo *hinfo = a->ops->hinfo;
44 spin_lock_bh(&hinfo->lock);
45 hlist_del(&p->tcfc_head);
46 spin_unlock_bh(&hinfo->lock);
47 gen_kill_estimator(&p->tcfc_bstats,
50 * gen_estimator est_timer() might access p->tcfc_lock
51 * or bstats, wait a RCU grace period before freeing p
53 call_rcu(&p->tcfc_rcu, free_tcf);
56 int __tcf_hash_release(struct tc_action *a, bool bind, bool strict)
58 struct tcf_common *p = a->priv;
64 else if (strict && p->tcfc_bindcnt > 0)
68 if (p->tcfc_bindcnt <= 0 && p->tcfc_refcnt <= 0) {
70 a->ops->cleanup(a, bind);
78 EXPORT_SYMBOL(__tcf_hash_release);
80 static int tcf_dump_walker(struct sk_buff *skb, struct netlink_callback *cb,
83 struct tcf_hashinfo *hinfo = a->ops->hinfo;
84 struct hlist_head *head;
86 int err = 0, index = -1, i = 0, s_i = 0, n_i = 0;
89 spin_lock_bh(&hinfo->lock);
93 for (i = 0; i < (hinfo->hmask + 1); i++) {
94 head = &hinfo->htab[tcf_hash(i, hinfo->hmask)];
96 hlist_for_each_entry_rcu(p, head, tcfc_head) {
103 nest = nla_nest_start(skb, a->order);
105 goto nla_put_failure;
106 err = tcf_action_dump_1(skb, a, 0, 0);
109 nlmsg_trim(skb, nest);
112 nla_nest_end(skb, nest);
114 if (n_i >= TCA_ACT_MAX_PRIO)
119 spin_unlock_bh(&hinfo->lock);
125 nla_nest_cancel(skb, nest);
129 static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a)
131 struct tcf_hashinfo *hinfo = a->ops->hinfo;
132 struct hlist_head *head;
133 struct hlist_node *n;
134 struct tcf_common *p;
139 nest = nla_nest_start(skb, a->order);
141 goto nla_put_failure;
142 if (nla_put_string(skb, TCA_KIND, a->ops->kind))
143 goto nla_put_failure;
144 for (i = 0; i < (hinfo->hmask + 1); i++) {
145 head = &hinfo->htab[tcf_hash(i, hinfo->hmask)];
146 hlist_for_each_entry_safe(p, n, head, tcfc_head) {
148 ret = __tcf_hash_release(a, false, true);
149 if (ret == ACT_P_DELETED) {
150 module_put(a->ops->owner);
153 goto nla_put_failure;
156 if (nla_put_u32(skb, TCA_FCNT, n_i))
157 goto nla_put_failure;
158 nla_nest_end(skb, nest);
162 nla_nest_cancel(skb, nest);
166 static int tcf_generic_walker(struct sk_buff *skb, struct netlink_callback *cb,
167 int type, struct tc_action *a)
169 if (type == RTM_DELACTION) {
170 return tcf_del_walker(skb, a);
171 } else if (type == RTM_GETACTION) {
172 return tcf_dump_walker(skb, cb, a);
174 WARN(1, "tcf_generic_walker: unknown action %d\n", type);
179 static struct tcf_common *tcf_hash_lookup(u32 index, struct tcf_hashinfo *hinfo)
181 struct tcf_common *p = NULL;
182 struct hlist_head *head;
184 spin_lock_bh(&hinfo->lock);
185 head = &hinfo->htab[tcf_hash(index, hinfo->hmask)];
186 hlist_for_each_entry_rcu(p, head, tcfc_head)
187 if (p->tcfc_index == index)
189 spin_unlock_bh(&hinfo->lock);
194 u32 tcf_hash_new_index(struct tcf_hashinfo *hinfo)
196 u32 val = hinfo->index;
201 } while (tcf_hash_lookup(val, hinfo));
206 EXPORT_SYMBOL(tcf_hash_new_index);
208 int tcf_hash_search(struct tc_action *a, u32 index)
210 struct tcf_hashinfo *hinfo = a->ops->hinfo;
211 struct tcf_common *p = tcf_hash_lookup(index, hinfo);
219 EXPORT_SYMBOL(tcf_hash_search);
221 int tcf_hash_check(u32 index, struct tc_action *a, int bind)
223 struct tcf_hashinfo *hinfo = a->ops->hinfo;
224 struct tcf_common *p = NULL;
225 if (index && (p = tcf_hash_lookup(index, hinfo)) != NULL) {
234 EXPORT_SYMBOL(tcf_hash_check);
236 void tcf_hash_cleanup(struct tc_action *a, struct nlattr *est)
238 struct tcf_common *pc = a->priv;
240 gen_kill_estimator(&pc->tcfc_bstats,
242 call_rcu(&pc->tcfc_rcu, free_tcf);
244 EXPORT_SYMBOL(tcf_hash_cleanup);
246 int tcf_hash_create(u32 index, struct nlattr *est, struct tc_action *a,
247 int size, int bind, bool cpustats)
249 struct tcf_hashinfo *hinfo = a->ops->hinfo;
250 struct tcf_common *p = kzalloc(size, GFP_KERNEL);
260 p->cpu_bstats = netdev_alloc_pcpu_stats(struct gnet_stats_basic_cpu);
261 if (!p->cpu_bstats) {
266 p->cpu_qstats = alloc_percpu(struct gnet_stats_queue);
267 if (!p->cpu_qstats) {
269 free_percpu(p->cpu_bstats);
273 spin_lock_init(&p->tcfc_lock);
274 INIT_HLIST_NODE(&p->tcfc_head);
275 p->tcfc_index = index ? index : tcf_hash_new_index(hinfo);
276 p->tcfc_tm.install = jiffies;
277 p->tcfc_tm.lastuse = jiffies;
279 err = gen_new_estimator(&p->tcfc_bstats, p->cpu_bstats,
283 free_percpu(p->cpu_qstats);
288 a->priv = (void *) p;
291 EXPORT_SYMBOL(tcf_hash_create);
293 void tcf_hash_insert(struct tc_action *a)
295 struct tcf_common *p = a->priv;
296 struct tcf_hashinfo *hinfo = a->ops->hinfo;
297 unsigned int h = tcf_hash(p->tcfc_index, hinfo->hmask);
299 spin_lock_bh(&hinfo->lock);
300 hlist_add_head(&p->tcfc_head, &hinfo->htab[h]);
301 spin_unlock_bh(&hinfo->lock);
303 EXPORT_SYMBOL(tcf_hash_insert);
305 static void tcf_hashinfo_destroy(const struct tc_action_ops *ops)
307 struct tcf_hashinfo *hinfo = ops->hinfo;
308 struct tc_action a = {
313 for (i = 0; i < hinfo->hmask + 1; i++) {
314 struct tcf_common *p;
315 struct hlist_node *n;
317 hlist_for_each_entry_safe(p, n, &hinfo->htab[i], tcfc_head) {
321 ret = __tcf_hash_release(&a, false, true);
322 if (ret == ACT_P_DELETED)
323 module_put(ops->owner);
331 static LIST_HEAD(act_base);
332 static DEFINE_RWLOCK(act_mod_lock);
334 int tcf_register_action(struct tc_action_ops *act, unsigned int mask)
336 struct tc_action_ops *a;
339 /* Must supply act, dump and init */
340 if (!act->act || !act->dump || !act->init)
343 /* Supply defaults */
345 act->lookup = tcf_hash_search;
347 act->walk = tcf_generic_walker;
349 act->hinfo = kmalloc(sizeof(struct tcf_hashinfo), GFP_KERNEL);
352 err = tcf_hashinfo_init(act->hinfo, mask);
358 write_lock(&act_mod_lock);
359 list_for_each_entry(a, &act_base, head) {
360 if (act->type == a->type || (strcmp(act->kind, a->kind) == 0)) {
361 write_unlock(&act_mod_lock);
362 tcf_hashinfo_destroy(act);
367 list_add_tail(&act->head, &act_base);
368 write_unlock(&act_mod_lock);
371 EXPORT_SYMBOL(tcf_register_action);
373 int tcf_unregister_action(struct tc_action_ops *act)
375 struct tc_action_ops *a;
378 write_lock(&act_mod_lock);
379 list_for_each_entry(a, &act_base, head) {
381 list_del(&act->head);
382 tcf_hashinfo_destroy(act);
388 write_unlock(&act_mod_lock);
391 EXPORT_SYMBOL(tcf_unregister_action);
394 static struct tc_action_ops *tc_lookup_action_n(char *kind)
396 struct tc_action_ops *a, *res = NULL;
399 read_lock(&act_mod_lock);
400 list_for_each_entry(a, &act_base, head) {
401 if (strcmp(kind, a->kind) == 0) {
402 if (try_module_get(a->owner))
407 read_unlock(&act_mod_lock);
412 /* lookup by nlattr */
413 static struct tc_action_ops *tc_lookup_action(struct nlattr *kind)
415 struct tc_action_ops *a, *res = NULL;
418 read_lock(&act_mod_lock);
419 list_for_each_entry(a, &act_base, head) {
420 if (nla_strcmp(kind, a->kind) == 0) {
421 if (try_module_get(a->owner))
426 read_unlock(&act_mod_lock);
431 int tcf_action_exec(struct sk_buff *skb, const struct list_head *actions,
432 struct tcf_result *res)
434 const struct tc_action *a;
437 if (skb->tc_verd & TC_NCLS) {
438 skb->tc_verd = CLR_TC_NCLS(skb->tc_verd);
442 list_for_each_entry(a, actions, list) {
444 ret = a->ops->act(skb, a, res);
445 if (ret == TC_ACT_REPEAT)
446 goto repeat; /* we need a ttl - JHS */
447 if (ret != TC_ACT_PIPE)
453 EXPORT_SYMBOL(tcf_action_exec);
455 int tcf_action_destroy(struct list_head *actions, int bind)
457 struct tc_action *a, *tmp;
460 list_for_each_entry_safe(a, tmp, actions, list) {
461 ret = __tcf_hash_release(a, bind, true);
462 if (ret == ACT_P_DELETED)
463 module_put(a->ops->owner);
473 tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
475 return a->ops->dump(skb, a, bind, ref);
479 tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
482 unsigned char *b = skb_tail_pointer(skb);
485 if (nla_put_string(skb, TCA_KIND, a->ops->kind))
486 goto nla_put_failure;
487 if (tcf_action_copy_stats(skb, a, 0))
488 goto nla_put_failure;
489 nest = nla_nest_start(skb, TCA_OPTIONS);
491 goto nla_put_failure;
492 err = tcf_action_dump_old(skb, a, bind, ref);
494 nla_nest_end(skb, nest);
502 EXPORT_SYMBOL(tcf_action_dump_1);
505 tcf_action_dump(struct sk_buff *skb, struct list_head *actions, int bind, int ref)
511 list_for_each_entry(a, actions, list) {
512 nest = nla_nest_start(skb, a->order);
514 goto nla_put_failure;
515 err = tcf_action_dump_1(skb, a, bind, ref);
518 nla_nest_end(skb, nest);
526 nla_nest_cancel(skb, nest);
530 struct tc_action *tcf_action_init_1(struct net *net, struct nlattr *nla,
531 struct nlattr *est, char *name, int ovr,
535 struct tc_action_ops *a_o;
536 char act_name[IFNAMSIZ];
537 struct nlattr *tb[TCA_ACT_MAX + 1];
542 err = nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL);
546 kind = tb[TCA_ACT_KIND];
549 if (nla_strlcpy(act_name, kind, IFNAMSIZ) >= IFNAMSIZ)
553 if (strlcpy(act_name, name, IFNAMSIZ) >= IFNAMSIZ)
557 a_o = tc_lookup_action_n(act_name);
559 #ifdef CONFIG_MODULES
561 request_module("act_%s", act_name);
564 a_o = tc_lookup_action_n(act_name);
566 /* We dropped the RTNL semaphore in order to
567 * perform the module load. So, even if we
568 * succeeded in loading the module we have to
569 * tell the caller to replay the request. We
570 * indicate this using -EAGAIN.
582 a = kzalloc(sizeof(*a), GFP_KERNEL);
587 INIT_LIST_HEAD(&a->list);
588 /* backward compatibility for policer */
590 err = a_o->init(net, tb[TCA_ACT_OPTIONS], est, a, ovr, bind);
592 err = a_o->init(net, nla, est, a, ovr, bind);
596 /* module count goes up only when brand new policy is created
597 * if it exists and is only bound to in a_o->init() then
598 * ACT_P_CREATED is not returned (a zero is).
600 if (err != ACT_P_CREATED)
601 module_put(a_o->owner);
608 module_put(a_o->owner);
613 int tcf_action_init(struct net *net, struct nlattr *nla,
614 struct nlattr *est, char *name, int ovr,
615 int bind, struct list_head *actions)
617 struct nlattr *tb[TCA_ACT_MAX_PRIO + 1];
618 struct tc_action *act;
622 err = nla_parse_nested(tb, TCA_ACT_MAX_PRIO, nla, NULL);
626 for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) {
627 act = tcf_action_init_1(net, tb[i], est, name, ovr, bind);
633 list_add_tail(&act->list, actions);
638 tcf_action_destroy(actions, bind);
642 int tcf_action_copy_stats(struct sk_buff *skb, struct tc_action *a,
647 struct tcf_common *p = a->priv;
652 /* compat_mode being true specifies a call that is supposed
653 * to add additional backward compatibility statistic TLVs.
656 if (a->type == TCA_OLD_COMPAT)
657 err = gnet_stats_start_copy_compat(skb, 0,
658 TCA_STATS, TCA_XSTATS, &p->tcfc_lock, &d);
662 err = gnet_stats_start_copy(skb, TCA_ACT_STATS,
668 if (gnet_stats_copy_basic(&d, p->cpu_bstats, &p->tcfc_bstats) < 0 ||
669 gnet_stats_copy_rate_est(&d, &p->tcfc_bstats,
670 &p->tcfc_rate_est) < 0 ||
671 gnet_stats_copy_queue(&d, p->cpu_qstats,
673 p->tcfc_qstats.qlen) < 0)
676 if (gnet_stats_finish_copy(&d) < 0)
686 tca_get_fill(struct sk_buff *skb, struct list_head *actions, u32 portid, u32 seq,
687 u16 flags, int event, int bind, int ref)
690 struct nlmsghdr *nlh;
691 unsigned char *b = skb_tail_pointer(skb);
694 nlh = nlmsg_put(skb, portid, seq, event, sizeof(*t), flags);
698 t->tca_family = AF_UNSPEC;
702 nest = nla_nest_start(skb, TCA_ACT_TAB);
706 if (tcf_action_dump(skb, actions, bind, ref) < 0)
709 nla_nest_end(skb, nest);
711 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
720 act_get_notify(struct net *net, u32 portid, struct nlmsghdr *n,
721 struct list_head *actions, int event)
725 skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
728 if (tca_get_fill(skb, actions, portid, n->nlmsg_seq, 0, event, 0, 0) <= 0) {
733 return rtnl_unicast(skb, net, portid);
736 static struct tc_action *create_a(int i)
738 struct tc_action *act;
740 act = kzalloc(sizeof(*act), GFP_KERNEL);
742 pr_debug("create_a: failed to alloc!\n");
746 INIT_LIST_HEAD(&act->list);
750 static struct tc_action *
751 tcf_action_get_1(struct nlattr *nla, struct nlmsghdr *n, u32 portid)
753 struct nlattr *tb[TCA_ACT_MAX + 1];
758 err = nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL);
763 if (tb[TCA_ACT_INDEX] == NULL ||
764 nla_len(tb[TCA_ACT_INDEX]) < sizeof(index))
766 index = nla_get_u32(tb[TCA_ACT_INDEX]);
774 a->ops = tc_lookup_action(tb[TCA_ACT_KIND]);
775 if (a->ops == NULL) /* could happen in batch of actions */
778 if (a->ops->lookup(a, index) == 0)
781 module_put(a->ops->owner);
785 module_put(a->ops->owner);
792 static void cleanup_a(struct list_head *actions)
794 struct tc_action *a, *tmp;
796 list_for_each_entry_safe(a, tmp, actions, list) {
802 static int tca_action_flush(struct net *net, struct nlattr *nla,
803 struct nlmsghdr *n, u32 portid)
807 struct nlmsghdr *nlh;
809 struct netlink_callback dcb;
811 struct nlattr *tb[TCA_ACT_MAX + 1];
816 skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
818 pr_debug("tca_action_flush: failed skb alloc\n");
822 b = skb_tail_pointer(skb);
824 err = nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL);
829 kind = tb[TCA_ACT_KIND];
830 memset(&a, 0, sizeof(struct tc_action));
831 INIT_LIST_HEAD(&a.list);
832 a.ops = tc_lookup_action(kind);
833 if (a.ops == NULL) /*some idjot trying to flush unknown action */
836 nlh = nlmsg_put(skb, portid, n->nlmsg_seq, RTM_DELACTION, sizeof(*t), 0);
840 t->tca_family = AF_UNSPEC;
844 nest = nla_nest_start(skb, TCA_ACT_TAB);
848 err = a.ops->walk(skb, &dcb, RTM_DELACTION, &a);
854 nla_nest_end(skb, nest);
856 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
857 nlh->nlmsg_flags |= NLM_F_ROOT;
858 module_put(a.ops->owner);
859 err = rtnetlink_send(skb, net, portid, RTNLGRP_TC,
860 n->nlmsg_flags & NLM_F_ECHO);
867 module_put(a.ops->owner);
875 tcf_del_notify(struct net *net, struct nlmsghdr *n, struct list_head *actions,
881 skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
885 if (tca_get_fill(skb, actions, portid, n->nlmsg_seq, 0, RTM_DELACTION,
891 /* now do the delete */
892 ret = tcf_action_destroy(actions, 0);
898 ret = rtnetlink_send(skb, net, portid, RTNLGRP_TC,
899 n->nlmsg_flags & NLM_F_ECHO);
906 tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n,
907 u32 portid, int event)
910 struct nlattr *tb[TCA_ACT_MAX_PRIO + 1];
911 struct tc_action *act;
914 ret = nla_parse_nested(tb, TCA_ACT_MAX_PRIO, nla, NULL);
918 if (event == RTM_DELACTION && n->nlmsg_flags & NLM_F_ROOT) {
920 return tca_action_flush(net, tb[1], n, portid);
925 for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) {
926 act = tcf_action_get_1(tb[i], n, portid);
932 list_add_tail(&act->list, &actions);
935 if (event == RTM_GETACTION)
936 ret = act_get_notify(net, portid, n, &actions, event);
938 ret = tcf_del_notify(net, n, &actions, portid);
949 tcf_add_notify(struct net *net, struct nlmsghdr *n, struct list_head *actions,
955 skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
959 if (tca_get_fill(skb, actions, portid, n->nlmsg_seq, n->nlmsg_flags,
960 RTM_NEWACTION, 0, 0) <= 0) {
965 err = rtnetlink_send(skb, net, portid, RTNLGRP_TC,
966 n->nlmsg_flags & NLM_F_ECHO);
973 tcf_action_add(struct net *net, struct nlattr *nla, struct nlmsghdr *n,
979 ret = tcf_action_init(net, nla, NULL, NULL, ovr, 0, &actions);
983 /* dump then free all the actions after update; inserted policy
986 ret = tcf_add_notify(net, n, &actions, portid);
992 static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n)
994 struct net *net = sock_net(skb->sk);
995 struct nlattr *tca[TCA_ACT_MAX + 1];
996 u32 portid = skb ? NETLINK_CB(skb).portid : 0;
997 int ret = 0, ovr = 0;
999 if ((n->nlmsg_type != RTM_GETACTION) && !netlink_capable(skb, CAP_NET_ADMIN))
1002 ret = nlmsg_parse(n, sizeof(struct tcamsg), tca, TCA_ACT_MAX, NULL);
1006 if (tca[TCA_ACT_TAB] == NULL) {
1007 pr_notice("tc_ctl_action: received NO action attribs\n");
1011 /* n->nlmsg_flags & NLM_F_CREATE */
1012 switch (n->nlmsg_type) {
1014 /* we are going to assume all other flags
1015 * imply create only if it doesn't exist
1016 * Note that CREATE | EXCL implies that
1017 * but since we want avoid ambiguity (eg when flags
1018 * is zero) then just set this
1020 if (n->nlmsg_flags & NLM_F_REPLACE)
1023 ret = tcf_action_add(net, tca[TCA_ACT_TAB], n, portid, ovr);
1028 ret = tca_action_gd(net, tca[TCA_ACT_TAB], n,
1029 portid, RTM_DELACTION);
1032 ret = tca_action_gd(net, tca[TCA_ACT_TAB], n,
1033 portid, RTM_GETACTION);
1042 static struct nlattr *
1043 find_dump_kind(const struct nlmsghdr *n)
1045 struct nlattr *tb1, *tb2[TCA_ACT_MAX + 1];
1046 struct nlattr *tb[TCA_ACT_MAX_PRIO + 1];
1047 struct nlattr *nla[TCAA_MAX + 1];
1048 struct nlattr *kind;
1050 if (nlmsg_parse(n, sizeof(struct tcamsg), nla, TCAA_MAX, NULL) < 0)
1052 tb1 = nla[TCA_ACT_TAB];
1056 if (nla_parse(tb, TCA_ACT_MAX_PRIO, nla_data(tb1),
1057 NLMSG_ALIGN(nla_len(tb1)), NULL) < 0)
1062 if (nla_parse(tb2, TCA_ACT_MAX, nla_data(tb[1]),
1063 nla_len(tb[1]), NULL) < 0)
1065 kind = tb2[TCA_ACT_KIND];
1071 tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
1073 struct nlmsghdr *nlh;
1074 unsigned char *b = skb_tail_pointer(skb);
1075 struct nlattr *nest;
1076 struct tc_action_ops *a_o;
1079 struct tcamsg *t = (struct tcamsg *) nlmsg_data(cb->nlh);
1080 struct nlattr *kind = find_dump_kind(cb->nlh);
1083 pr_info("tc_dump_action: action bad kind\n");
1087 a_o = tc_lookup_action(kind);
1091 memset(&a, 0, sizeof(struct tc_action));
1094 nlh = nlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq,
1095 cb->nlh->nlmsg_type, sizeof(*t), 0);
1097 goto out_module_put;
1098 t = nlmsg_data(nlh);
1099 t->tca_family = AF_UNSPEC;
1103 nest = nla_nest_start(skb, TCA_ACT_TAB);
1105 goto out_module_put;
1107 ret = a_o->walk(skb, cb, RTM_GETACTION, &a);
1109 goto out_module_put;
1112 nla_nest_end(skb, nest);
1115 nla_nest_cancel(skb, nest);
1117 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
1118 if (NETLINK_CB(cb->skb).portid && ret)
1119 nlh->nlmsg_flags |= NLM_F_MULTI;
1120 module_put(a_o->owner);
1124 module_put(a_o->owner);
1129 static int __init tc_action_init(void)
1131 rtnl_register(PF_UNSPEC, RTM_NEWACTION, tc_ctl_action, NULL, NULL);
1132 rtnl_register(PF_UNSPEC, RTM_DELACTION, tc_ctl_action, NULL, NULL);
1133 rtnl_register(PF_UNSPEC, RTM_GETACTION, tc_ctl_action, tc_dump_action,
1139 subsys_initcall(tc_action_init);