and changed files
[powerpc.git] / net / sched / act_api.c
index a2587b5..711dd26 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
 #include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/socket.h>
 #include <linux/interrupt.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
-#include <linux/rtnetlink.h>
 #include <linux/init.h>
 #include <linux/kmod.h>
 #include <net/sock.h>
 #include <net/sch_generic.h>
 #include <net/act_api.h>
+#include <net/netlink.h>
 
-#if 0 /* control */
-#define DPRINTK(format, args...) printk(KERN_DEBUG format, ##args)
-#else
-#define DPRINTK(format, args...)
+void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo)
+{
+       unsigned int h = tcf_hash(p->tcfc_index, hinfo->hmask);
+       struct tcf_common **p1p;
+
+       for (p1p = &hinfo->htab[h]; *p1p; p1p = &(*p1p)->tcfc_next) {
+               if (*p1p == p) {
+                       write_lock_bh(hinfo->lock);
+                       *p1p = p->tcfc_next;
+                       write_unlock_bh(hinfo->lock);
+#ifdef CONFIG_NET_ESTIMATOR
+                       gen_kill_estimator(&p->tcfc_bstats,
+                                          &p->tcfc_rate_est);
 #endif
-#if 0 /* data */
-#define D2PRINTK(format, args...) printk(KERN_DEBUG format, ##args)
-#else
-#define D2PRINTK(format, args...)
+                       kfree(p);
+                       return;
+               }
+       }
+       BUG_TRAP(0);
+}
+EXPORT_SYMBOL(tcf_hash_destroy);
+
+int tcf_hash_release(struct tcf_common *p, int bind,
+                    struct tcf_hashinfo *hinfo)
+{
+       int ret = 0;
+
+       if (p) {
+               if (bind)
+                       p->tcfc_bindcnt--;
+
+               p->tcfc_refcnt--;
+               if (p->tcfc_bindcnt <= 0 && p->tcfc_refcnt <= 0) {
+                       tcf_hash_destroy(p, hinfo);
+                       ret = 1;
+               }
+       }
+       return ret;
+}
+EXPORT_SYMBOL(tcf_hash_release);
+
+static int tcf_dump_walker(struct sk_buff *skb, struct netlink_callback *cb,
+                          struct tc_action *a, struct tcf_hashinfo *hinfo)
+{
+       struct tcf_common *p;
+       int err = 0, index = -1,i = 0, s_i = 0, n_i = 0;
+       struct rtattr *r ;
+
+       read_lock(hinfo->lock);
+
+       s_i = cb->args[0];
+
+       for (i = 0; i < (hinfo->hmask + 1); i++) {
+               p = hinfo->htab[tcf_hash(i, hinfo->hmask)];
+
+               for (; p; p = p->tcfc_next) {
+                       index++;
+                       if (index < s_i)
+                               continue;
+                       a->priv = p;
+                       a->order = n_i;
+                       r = (struct rtattr *)skb_tail_pointer(skb);
+                       RTA_PUT(skb, a->order, 0, NULL);
+                       err = tcf_action_dump_1(skb, a, 0, 0);
+                       if (err < 0) {
+                               index--;
+                               nlmsg_trim(skb, r);
+                               goto done;
+                       }
+                       r->rta_len = skb_tail_pointer(skb) - (u8 *)r;
+                       n_i++;
+                       if (n_i >= TCA_ACT_MAX_PRIO)
+                               goto done;
+               }
+       }
+done:
+       read_unlock(hinfo->lock);
+       if (n_i)
+               cb->args[0] += n_i;
+       return n_i;
+
+rtattr_failure:
+       nlmsg_trim(skb, r);
+       goto done;
+}
+
+static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a,
+                         struct tcf_hashinfo *hinfo)
+{
+       struct tcf_common *p, *s_p;
+       struct rtattr *r ;
+       int i= 0, n_i = 0;
+
+       r = (struct rtattr *)skb_tail_pointer(skb);
+       RTA_PUT(skb, a->order, 0, NULL);
+       RTA_PUT(skb, TCA_KIND, IFNAMSIZ, a->ops->kind);
+       for (i = 0; i < (hinfo->hmask + 1); i++) {
+               p = hinfo->htab[tcf_hash(i, hinfo->hmask)];
+
+               while (p != NULL) {
+                       s_p = p->tcfc_next;
+                       if (ACT_P_DELETED == tcf_hash_release(p, 0, hinfo))
+                                module_put(a->ops->owner);
+                       n_i++;
+                       p = s_p;
+               }
+       }
+       RTA_PUT(skb, TCA_FCNT, 4, &n_i);
+       r->rta_len = skb_tail_pointer(skb) - (u8 *)r;
+
+       return n_i;
+rtattr_failure:
+       nlmsg_trim(skb, r);
+       return -EINVAL;
+}
+
+int tcf_generic_walker(struct sk_buff *skb, struct netlink_callback *cb,
+                      int type, struct tc_action *a)
+{
+       struct tcf_hashinfo *hinfo = a->ops->hinfo;
+
+       if (type == RTM_DELACTION) {
+               return tcf_del_walker(skb, a, hinfo);
+       } else if (type == RTM_GETACTION) {
+               return tcf_dump_walker(skb, cb, a, hinfo);
+       } else {
+               printk("tcf_generic_walker: unknown action %d\n", type);
+               return -EINVAL;
+       }
+}
+EXPORT_SYMBOL(tcf_generic_walker);
+
+struct tcf_common *tcf_hash_lookup(u32 index, struct tcf_hashinfo *hinfo)
+{
+       struct tcf_common *p;
+
+       read_lock(hinfo->lock);
+       for (p = hinfo->htab[tcf_hash(index, hinfo->hmask)]; p;
+            p = p->tcfc_next) {
+               if (p->tcfc_index == index)
+                       break;
+       }
+       read_unlock(hinfo->lock);
+
+       return p;
+}
+EXPORT_SYMBOL(tcf_hash_lookup);
+
+u32 tcf_hash_new_index(u32 *idx_gen, struct tcf_hashinfo *hinfo)
+{
+       u32 val = *idx_gen;
+
+       do {
+               if (++val == 0)
+                       val = 1;
+       } while (tcf_hash_lookup(val, hinfo));
+
+       return (*idx_gen = val);
+}
+EXPORT_SYMBOL(tcf_hash_new_index);
+
+int tcf_hash_search(struct tc_action *a, u32 index)
+{
+       struct tcf_hashinfo *hinfo = a->ops->hinfo;
+       struct tcf_common *p = tcf_hash_lookup(index, hinfo);
+
+       if (p) {
+               a->priv = p;
+               return 1;
+       }
+       return 0;
+}
+EXPORT_SYMBOL(tcf_hash_search);
+
+struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a, int bind,
+                                 struct tcf_hashinfo *hinfo)
+{
+       struct tcf_common *p = NULL;
+       if (index && (p = tcf_hash_lookup(index, hinfo)) != NULL) {
+               if (bind) {
+                       p->tcfc_bindcnt++;
+                       p->tcfc_refcnt++;
+               }
+               a->priv = p;
+       }
+       return p;
+}
+EXPORT_SYMBOL(tcf_hash_check);
+
+struct tcf_common *tcf_hash_create(u32 index, struct rtattr *est, struct tc_action *a, int size, int bind, u32 *idx_gen, struct tcf_hashinfo *hinfo)
+{
+       struct tcf_common *p = kzalloc(size, GFP_KERNEL);
+
+       if (unlikely(!p))
+               return p;
+       p->tcfc_refcnt = 1;
+       if (bind)
+               p->tcfc_bindcnt = 1;
+
+       spin_lock_init(&p->tcfc_lock);
+       p->tcfc_stats_lock = &p->tcfc_lock;
+       p->tcfc_index = index ? index : tcf_hash_new_index(idx_gen, hinfo);
+       p->tcfc_tm.install = jiffies;
+       p->tcfc_tm.lastuse = jiffies;
+#ifdef CONFIG_NET_ESTIMATOR
+       if (est)
+               gen_new_estimator(&p->tcfc_bstats, &p->tcfc_rate_est,
+                                 p->tcfc_stats_lock, est);
 #endif
+       a->priv = (void *) p;
+       return p;
+}
+EXPORT_SYMBOL(tcf_hash_create);
+
+void tcf_hash_insert(struct tcf_common *p, struct tcf_hashinfo *hinfo)
+{
+       unsigned int h = tcf_hash(p->tcfc_index, hinfo->hmask);
+
+       write_lock_bh(hinfo->lock);
+       p->tcfc_next = hinfo->htab[h];
+       hinfo->htab[h] = p;
+       write_unlock_bh(hinfo->lock);
+}
+EXPORT_SYMBOL(tcf_hash_insert);
 
 static struct tc_action_ops *act_base = NULL;
 static DEFINE_RWLOCK(act_mod_lock);
@@ -148,16 +361,13 @@ static struct tc_action_ops *tc_lookup_action_id(u32 type)
 #endif
 
 int tcf_action_exec(struct sk_buff *skb, struct tc_action *act,
-                    struct tcf_result *res)
+                   struct tcf_result *res)
 {
        struct tc_action *a;
        int ret = -1;
 
        if (skb->tc_verd & TC_NCLS) {
                skb->tc_verd = CLR_TC_NCLS(skb->tc_verd);
-               D2PRINTK("(%p)tcf_action_exec: cleared TC_NCLS in %s out %s\n",
-                        skb, skb->input_dev ? skb->input_dev->name : "xxx",
-                        skb->dev->name);
                ret = TC_ACT_OK;
                goto exec_done;
        }
@@ -187,8 +397,6 @@ void tcf_action_destroy(struct tc_action *act, int bind)
 
        for (a = act; a; a = act) {
                if (a->ops && a->ops->cleanup) {
-                       DPRINTK("tcf_action_destroy destroying %p next %p\n",
-                               a, a->next);
                        if (a->ops->cleanup(a, bind) == ACT_P_DELETED)
                                module_put(a->ops->owner);
                        act = act->next;
@@ -215,7 +423,7 @@ int
 tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
 {
        int err = -EINVAL;
-       unsigned char *b = skb->tail;
+       unsigned char *b = skb_tail_pointer(skb);
        struct rtattr *r;
 
        if (a->ops == NULL || a->ops->dump == NULL)
@@ -224,15 +432,15 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
        RTA_PUT(skb, TCA_KIND, IFNAMSIZ, a->ops->kind);
        if (tcf_action_copy_stats(skb, a, 0))
                goto rtattr_failure;
-       r = (struct rtattr*) skb->tail;
+       r = (struct rtattr *)skb_tail_pointer(skb);
        RTA_PUT(skb, TCA_OPTIONS, 0, NULL);
        if ((err = tcf_action_dump_old(skb, a, bind, ref)) > 0) {
-               r->rta_len = skb->tail - (u8*)r;
+               r->rta_len = skb_tail_pointer(skb) - (u8 *)r;
                return err;
        }
 
 rtattr_failure:
-       skb_trim(skb, b - skb->data);
+       nlmsg_trim(skb, b);
        return -1;
 }
 
@@ -241,17 +449,17 @@ tcf_action_dump(struct sk_buff *skb, struct tc_action *act, int bind, int ref)
 {
        struct tc_action *a;
        int err = -EINVAL;
-       unsigned char *b = skb->tail;
+       unsigned char *b = skb_tail_pointer(skb);
        struct rtattr *r ;
 
        while ((a = act) != NULL) {
-               r = (struct rtattr*) skb->tail;
+               r = (struct rtattr *)skb_tail_pointer(skb);
                act = a->next;
                RTA_PUT(skb, a->order, 0, NULL);
                err = tcf_action_dump_1(skb, a, bind, ref);
                if (err < 0)
                        goto errout;
-               r->rta_len = skb->tail - (u8*)r;
+               r->rta_len = skb_tail_pointer(skb) - (u8 *)r;
        }
 
        return 0;
@@ -259,12 +467,12 @@ tcf_action_dump(struct sk_buff *skb, struct tc_action *act, int bind, int ref)
 rtattr_failure:
        err = -EINVAL;
 errout:
-       skb_trim(skb, b - skb->data);
+       nlmsg_trim(skb, b);
        return err;
 }
 
 struct tc_action *tcf_action_init_1(struct rtattr *rta, struct rtattr *est,
-                                    char *name, int ovr, int bind, int *err)
+                                   char *name, int ovr, int bind, int *err)
 {
        struct tc_action *a;
        struct tc_action_ops *a_o;
@@ -331,7 +539,6 @@ struct tc_action *tcf_action_init_1(struct rtattr *rta, struct rtattr *est,
        if (*err != ACT_P_CREATED)
                module_put(a_o->owner);
        a->ops = a_o;
-       DPRINTK("tcf_action_init_1: successfull %s\n", act_name);
 
        *err = 0;
        return a;
@@ -345,7 +552,7 @@ err_out:
 }
 
 struct tc_action *tcf_action_init(struct rtattr *rta, struct rtattr *est,
-                                  char *name, int ovr, int bind, int *err)
+                                 char *name, int ovr, int bind, int *err)
 {
        struct rtattr *tb[TCA_ACT_MAX_PRIO+1];
        struct tc_action *head = NULL, *act, *act_prev = NULL;
@@ -382,7 +589,7 @@ int tcf_action_copy_stats(struct sk_buff *skb, struct tc_action *a,
        int err = 0;
        struct gnet_dump d;
        struct tcf_act_hdr *h = a->priv;
-       
+
        if (h == NULL)
                goto errout;
 
@@ -392,12 +599,12 @@ int tcf_action_copy_stats(struct sk_buff *skb, struct tc_action *a,
        if (compat_mode) {
                if (a->type == TCA_OLD_COMPAT)
                        err = gnet_stats_start_copy_compat(skb, 0,
-                               TCA_STATS, TCA_XSTATS, h->stats_lock, &d);
+                               TCA_STATS, TCA_XSTATS, h->tcf_stats_lock, &d);
                else
                        return 0;
        } else
                err = gnet_stats_start_copy(skb, TCA_ACT_STATS,
-                       h->stats_lock, &d);
+                       h->tcf_stats_lock, &d);
 
        if (err < 0)
                goto errout;
@@ -406,11 +613,11 @@ int tcf_action_copy_stats(struct sk_buff *skb, struct tc_action *a,
                if (a->ops->get_stats(skb, a) < 0)
                        goto errout;
 
-       if (gnet_stats_copy_basic(&d, &h->bstats) < 0 ||
+       if (gnet_stats_copy_basic(&d, &h->tcf_bstats) < 0 ||
 #ifdef CONFIG_NET_ESTIMATOR
-           gnet_stats_copy_rate_est(&d, &h->rate_est) < 0 ||
+           gnet_stats_copy_rate_est(&d, &h->tcf_rate_est) < 0 ||
 #endif
-           gnet_stats_copy_queue(&d, &h->qstats) < 0)
+           gnet_stats_copy_queue(&d, &h->tcf_qstats) < 0)
                goto errout;
 
        if (gnet_stats_finish_copy(&d) < 0)
@@ -424,11 +631,11 @@ errout:
 
 static int
 tca_get_fill(struct sk_buff *skb, struct tc_action *a, u32 pid, u32 seq,
-             u16 flags, int event, int bind, int ref)
+            u16 flags, int event, int bind, int ref)
 {
        struct tcamsg *t;
        struct nlmsghdr *nlh;
-       unsigned char *b = skb->tail;
+       unsigned char *b = skb_tail_pointer(skb);
        struct rtattr *x;
 
        nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*t), flags);
@@ -437,21 +644,21 @@ tca_get_fill(struct sk_buff *skb, struct tc_action *a, u32 pid, u32 seq,
        t->tca_family = AF_UNSPEC;
        t->tca__pad1 = 0;
        t->tca__pad2 = 0;
-       
-       x = (struct rtattr*) skb->tail;
+
+       x = (struct rtattr *)skb_tail_pointer(skb);
        RTA_PUT(skb, TCA_ACT_TAB, 0, NULL);
 
        if (tcf_action_dump(skb, a, bind, ref) < 0)
                goto rtattr_failure;
 
-       x->rta_len = skb->tail - (u8*)x;
-       
-       nlh->nlmsg_len = skb->tail - b;
+       x->rta_len = skb_tail_pointer(skb) - (u8 *)x;
+
+       nlh->nlmsg_len = skb_tail_pointer(skb) - b;
        return skb->len;
 
 rtattr_failure:
 nlmsg_failure:
-       skb_trim(skb, b - skb->data);
+       nlmsg_trim(skb, b);
        return -1;
 }
 
@@ -459,7 +666,6 @@ static int
 act_get_notify(u32 pid, struct nlmsghdr *n, struct tc_action *a, int event)
 {
        struct sk_buff *skb;
-       int err = 0;
 
        skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
        if (!skb)
@@ -468,10 +674,8 @@ act_get_notify(u32 pid, struct nlmsghdr *n, struct tc_action *a, int event)
                kfree_skb(skb);
                return -EINVAL;
        }
-       err = netlink_unicast(rtnl, skb, pid, MSG_DONTWAIT);
-       if (err > 0)
-               err = 0;
-       return err;
+
+       return rtnl_unicast(skb, pid);
 }
 
 static struct tc_action *
@@ -563,7 +767,7 @@ static int tca_action_flush(struct rtattr *rta, struct nlmsghdr *n, u32 pid)
                return -ENOBUFS;
        }
 
-       b = (unsigned char *)skb->tail;
+       b = skb_tail_pointer(skb);
 
        if (rtattr_parse_nested(tb, TCA_ACT_MAX, rta) < 0)
                goto err_out;
@@ -579,16 +783,16 @@ static int tca_action_flush(struct rtattr *rta, struct nlmsghdr *n, u32 pid)
        t->tca__pad1 = 0;
        t->tca__pad2 = 0;
 
-       x = (struct rtattr *) skb->tail;
+       x = (struct rtattr *)skb_tail_pointer(skb);
        RTA_PUT(skb, TCA_ACT_TAB, 0, NULL);
 
        err = a->ops->walk(skb, &dcb, RTM_DELACTION, a);
        if (err < 0)
                goto rtattr_failure;
 
-       x->rta_len = skb->tail - (u8 *) x;
+       x->rta_len = skb_tail_pointer(skb) - (u8 *)x;
 
-       nlh->nlmsg_len = skb->tail - b;
+       nlh->nlmsg_len = skb_tail_pointer(skb) - b;
        nlh->nlmsg_flags |= NLM_F_ROOT;
        module_put(a->ops->owner);
        kfree(a);
@@ -647,7 +851,7 @@ tca_action_gd(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int event)
                }
 
                if (tca_get_fill(skb, head, pid, n->nlmsg_seq, 0, event,
-                                0, 1) <= 0) {
+                                0, 1) <= 0) {
                        kfree_skb(skb);
                        ret = -EINVAL;
                        goto err;
@@ -656,7 +860,7 @@ tca_action_gd(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int event)
                /* now do the delete */
                tcf_action_destroy(head, 0);
                ret = rtnetlink_send(skb, pid, RTNLGRP_TC,
-                                    n->nlmsg_flags&NLM_F_ECHO);
+                                    n->nlmsg_flags&NLM_F_ECHO);
                if (ret > 0)
                        return 0;
                return ret;
@@ -667,7 +871,7 @@ err:
 }
 
 static int tcf_add_notify(struct tc_action *a, u32 pid, u32 seq, int event,
-                          u16 flags)
+                         u16 flags)
 {
        struct tcamsg *t;
        struct nlmsghdr *nlh;
@@ -680,7 +884,7 @@ static int tcf_add_notify(struct tc_action *a, u32 pid, u32 seq, int event,
        if (!skb)
                return -ENOBUFS;
 
-       b = (unsigned char *)skb->tail;
+       b = skb_tail_pointer(skb);
 
        nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*t), flags);
        t = NLMSG_DATA(nlh);
@@ -688,17 +892,17 @@ static int tcf_add_notify(struct tc_action *a, u32 pid, u32 seq, int event,
        t->tca__pad1 = 0;
        t->tca__pad2 = 0;
 
-       x = (struct rtattr*) skb->tail;
+       x = (struct rtattr *)skb_tail_pointer(skb);
        RTA_PUT(skb, TCA_ACT_TAB, 0, NULL);
 
        if (tcf_action_dump(skb, a, 0, 0) < 0)
                goto rtattr_failure;
 
-       x->rta_len = skb->tail - (u8*)x;
-       
-       nlh->nlmsg_len = skb->tail - b;
+       x->rta_len = skb_tail_pointer(skb) - (u8 *)x;
+
+       nlh->nlmsg_len = skb_tail_pointer(skb) - b;
        NETLINK_CB(skb).dst_group = RTNLGRP_TC;
-       
+
        err = rtnetlink_send(skb, pid, RTNLGRP_TC, flags&NLM_F_ECHO);
        if (err > 0)
                err = 0;
@@ -710,7 +914,7 @@ nlmsg_failure:
        return -1;
 }
 
-       
+
 static int
 tcf_action_add(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int ovr)
 {
@@ -794,13 +998,13 @@ find_dump_kind(struct nlmsghdr *n)
                return NULL;
 
        if (rtattr_parse(tb, TCA_ACT_MAX_PRIO, RTA_DATA(tb1),
-                        NLMSG_ALIGN(RTA_PAYLOAD(tb1))) < 0)
+                        NLMSG_ALIGN(RTA_PAYLOAD(tb1))) < 0)
                return NULL;
        if (tb[0] == NULL)
                return NULL;
 
        if (rtattr_parse(tb2, TCA_ACT_MAX, RTA_DATA(tb[0]),
-                        RTA_PAYLOAD(tb[0])) < 0)
+                        RTA_PAYLOAD(tb[0])) < 0)
                return NULL;
        kind = tb2[TCA_ACT_KIND-1];
 
@@ -811,7 +1015,7 @@ static int
 tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
 {
        struct nlmsghdr *nlh;
-       unsigned char *b = skb->tail;
+       unsigned char *b = skb_tail_pointer(skb);
        struct rtattr *x;
        struct tc_action_ops *a_o;
        struct tc_action a;
@@ -838,13 +1042,13 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
        }
 
        nlh = NLMSG_PUT(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq,
-                       cb->nlh->nlmsg_type, sizeof(*t));
+                       cb->nlh->nlmsg_type, sizeof(*t));
        t = NLMSG_DATA(nlh);
        t->tca_family = AF_UNSPEC;
        t->tca__pad1 = 0;
        t->tca__pad2 = 0;
 
-       x = (struct rtattr *) skb->tail;
+       x = (struct rtattr *)skb_tail_pointer(skb);
        RTA_PUT(skb, TCA_ACT_TAB, 0, NULL);
 
        ret = a_o->walk(skb, cb, RTM_GETACTION, &a);
@@ -852,12 +1056,12 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
                goto rtattr_failure;
 
        if (ret > 0) {
-               x->rta_len = skb->tail - (u8 *) x;
+               x->rta_len = skb_tail_pointer(skb) - (u8 *)x;
                ret = skb->len;
        } else
-               skb_trim(skb, (u8*)x - skb->data);
+               nlmsg_trim(skb, x);
 
-       nlh->nlmsg_len = skb->tail - b;
+       nlh->nlmsg_len = skb_tail_pointer(skb) - b;
        if (NETLINK_CB(cb->skb).pid && ret)
                nlh->nlmsg_flags |= NLM_F_MULTI;
        module_put(a_o->owner);
@@ -866,20 +1070,15 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
 rtattr_failure:
 nlmsg_failure:
        module_put(a_o->owner);
-       skb_trim(skb, b - skb->data);
+       nlmsg_trim(skb, b);
        return skb->len;
 }
 
 static int __init tc_action_init(void)
 {
-       struct rtnetlink_link *link_p = rtnetlink_links[PF_UNSPEC];
-
-       if (link_p) {
-               link_p[RTM_NEWACTION-RTM_BASE].doit = tc_ctl_action;
-               link_p[RTM_DELACTION-RTM_BASE].doit = tc_ctl_action;
-               link_p[RTM_GETACTION-RTM_BASE].doit = tc_ctl_action;
-               link_p[RTM_GETACTION-RTM_BASE].dumpit = tc_dump_action;
-       }
+       rtnl_register(PF_UNSPEC, RTM_NEWACTION, tc_ctl_action, NULL);
+       rtnl_register(PF_UNSPEC, RTM_DELACTION, tc_ctl_action, NULL);
+       rtnl_register(PF_UNSPEC, RTM_GETACTION, tc_ctl_action, tc_dump_action);
 
        return 0;
 }