hrtimer: convert net::sched_cbq to the new hrtimer apis
[safe/jmp/linux-2.6] / net / sched / act_api.c
index 3602260..9974b3f 100644 (file)
@@ -41,7 +41,7 @@ void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo)
                        return;
                }
        }
-       BUG_TRAP(0);
+       WARN_ON(1);
 }
 EXPORT_SYMBOL(tcf_hash_destroy);
 
@@ -121,7 +121,7 @@ static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a,
        nest = nla_nest_start(skb, a->order);
        if (nest == NULL)
                goto nla_put_failure;
-       NLA_PUT(skb, TCA_KIND, IFNAMSIZ, a->ops->kind);
+       NLA_PUT_STRING(skb, TCA_KIND, a->ops->kind);
        for (i = 0; i < (hinfo->hmask + 1); i++) {
                p = hinfo->htab[tcf_hash(i, hinfo->hmask)];
 
@@ -133,7 +133,7 @@ static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a,
                        p = s_p;
                }
        }
-       NLA_PUT(skb, TCA_FCNT, 4, &n_i);
+       NLA_PUT_U32(skb, TCA_FCNT, n_i);
        nla_nest_end(skb, nest);
 
        return n_i;
@@ -205,10 +205,9 @@ struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a, int bind,
 {
        struct tcf_common *p = NULL;
        if (index && (p = tcf_hash_lookup(index, hinfo)) != NULL) {
-               if (bind) {
+               if (bind)
                        p->tcfc_bindcnt++;
-                       p->tcfc_refcnt++;
-               }
+               p->tcfc_refcnt++;
                a->priv = p;
        }
        return p;
@@ -423,7 +422,7 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
        if (a->ops == NULL || a->ops->dump == NULL)
                return err;
 
-       NLA_PUT(skb, TCA_KIND, IFNAMSIZ, a->ops->kind);
+       NLA_PUT_STRING(skb, TCA_KIND, a->ops->kind);
        if (tcf_action_copy_stats(skb, a, 0))
                goto nla_put_failure;
        nest = nla_nest_start(skb, TCA_OPTIONS);
@@ -690,7 +689,7 @@ tcf_action_get_1(struct nlattr *nla, struct nlmsghdr *n, u32 pid)
        if (tb[TCA_ACT_INDEX] == NULL ||
            nla_len(tb[TCA_ACT_INDEX]) < sizeof(index))
                goto err_out;
-       index = *(int *)nla_data(tb[TCA_ACT_INDEX]);
+       index = nla_get_u32(tb[TCA_ACT_INDEX]);
 
        err = -ENOMEM;
        a = kzalloc(sizeof(struct tc_action), GFP_KERNEL);
@@ -752,7 +751,7 @@ static int tca_action_flush(struct nlattr *nla, struct nlmsghdr *n, u32 pid)
        struct nlattr *tb[TCA_ACT_MAX+1];
        struct nlattr *kind;
        struct tc_action *a = create_a(0);
-       int err = -EINVAL;
+       int err = -ENOMEM;
 
        if (a == NULL) {
                printk("tca_action_flush: couldnt create tc_action\n");
@@ -763,7 +762,7 @@ static int tca_action_flush(struct nlattr *nla, struct nlmsghdr *n, u32 pid)
        if (!skb) {
                printk("tca_action_flush: failed skb alloc\n");
                kfree(a);
-               return -ENOBUFS;
+               return err;
        }
 
        b = skb_tail_pointer(skb);
@@ -791,6 +790,8 @@ static int tca_action_flush(struct nlattr *nla, struct nlmsghdr *n, u32 pid)
        err = a->ops->walk(skb, &dcb, RTM_DELACTION, a);
        if (err < 0)
                goto nla_put_failure;
+       if (err == 0)
+               goto noflush_out;
 
        nla_nest_end(skb, nest);
 
@@ -808,6 +809,7 @@ nla_put_failure:
 nlmsg_failure:
        module_put(a->ops->owner);
 err_out:
+noflush_out:
        kfree_skb(skb);
        kfree(a);
        return err;
@@ -825,8 +827,10 @@ tca_action_gd(struct nlattr *nla, struct nlmsghdr *n, u32 pid, int event)
                return ret;
 
        if (event == RTM_DELACTION && n->nlmsg_flags&NLM_F_ROOT) {
-               if (tb[0] != NULL && tb[1] == NULL)
-                       return tca_action_flush(tb[0], n, pid);
+               if (tb[1] != NULL)
+                       return tca_action_flush(tb[1], n, pid);
+               else
+                       return -EINVAL;
        }
 
        for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) {
@@ -951,7 +955,7 @@ done:
 
 static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
 {
-       struct net *net = skb->sk->sk_net;
+       struct net *net = sock_net(skb->sk);
        struct nlattr *tca[TCA_ACT_MAX + 1];
        u32 pid = skb ? NETLINK_CB(skb).pid : 0;
        int ret = 0, ovr = 0;
@@ -1029,7 +1033,7 @@ find_dump_kind(struct nlmsghdr *n)
 static int
 tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
 {
-       struct net *net = skb->sk->sk_net;
+       struct net *net = sock_net(skb->sk);
        struct nlmsghdr *nlh;
        unsigned char *b = skb_tail_pointer(skb);
        struct nlattr *nest;