ALSA: sound/usb: add preliminary support for UAC2 interrupts
[safe/jmp/linux-2.6] / net / sched / act_gact.c
index 85de7ef..e7f796a 100644 (file)
  *
  */
 
-#include <asm/uaccess.h>
-#include <asm/system.h>
-#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/sockios.h>
-#include <linux/in.h>
 #include <linux/errno.h>
-#include <linux/interrupt.h>
-#include <linux/netdevice.h>
 #include <linux/skbuff.h>
 #include <linux/rtnetlink.h>
 #include <linux/module.h>
 #include <linux/init.h>
-#include <linux/proc_fs.h>
-#include <net/sock.h>
+#include <net/netlink.h>
 #include <net/pkt_sched.h>
 #include <linux/tc_act/tc_gact.h>
 #include <net/tc_act/tc_gact.h>
@@ -64,28 +53,34 @@ typedef int (*g_rand)(struct tcf_gact *gact);
 static g_rand gact_rand[MAX_RAND]= { NULL, gact_net_rand, gact_determ };
 #endif /* CONFIG_GACT_PROB */
 
-static int tcf_gact_init(struct rtattr *rta, struct rtattr *est,
-                         struct tc_action *a, int ovr, int bind)
+static const struct nla_policy gact_policy[TCA_GACT_MAX + 1] = {
+       [TCA_GACT_PARMS]        = { .len = sizeof(struct tc_gact) },
+       [TCA_GACT_PROB]         = { .len = sizeof(struct tc_gact_p) },
+};
+
+static int tcf_gact_init(struct nlattr *nla, struct nlattr *est,
+                        struct tc_action *a, int ovr, int bind)
 {
-       struct rtattr *tb[TCA_GACT_MAX];
+       struct nlattr *tb[TCA_GACT_MAX + 1];
        struct tc_gact *parm;
        struct tcf_gact *gact;
        struct tcf_common *pc;
        int ret = 0;
+       int err;
 
-       if (rta == NULL || rtattr_parse_nested(tb, TCA_GACT_MAX, rta) < 0)
+       if (nla == NULL)
                return -EINVAL;
 
-       if (tb[TCA_GACT_PARMS - 1] == NULL ||
-           RTA_PAYLOAD(tb[TCA_GACT_PARMS - 1]) < sizeof(*parm))
+       err = nla_parse_nested(tb, TCA_GACT_MAX, nla, gact_policy);
+       if (err < 0)
+               return err;
+
+       if (tb[TCA_GACT_PARMS] == NULL)
                return -EINVAL;
-       parm = RTA_DATA(tb[TCA_GACT_PARMS - 1]);
+       parm = nla_data(tb[TCA_GACT_PARMS]);
 
-       if (tb[TCA_GACT_PROB-1] != NULL)
-#ifdef CONFIG_GACT_PROB
-               if (RTA_PAYLOAD(tb[TCA_GACT_PROB-1]) < sizeof(struct tc_gact_p))
-                       return -EINVAL;
-#else
+#ifndef CONFIG_GACT_PROB
+       if (tb[TCA_GACT_PROB] != NULL)
                return -EOPNOTSUPP;
 #endif
 
@@ -93,8 +88,8 @@ static int tcf_gact_init(struct rtattr *rta, struct rtattr *est,
        if (!pc) {
                pc = tcf_hash_create(parm->index, est, a, sizeof(*gact),
                                     bind, &gact_idx_gen, &gact_hash_info);
-               if (unlikely(!pc))
-                       return -ENOMEM;
+               if (IS_ERR(pc))
+                   return PTR_ERR(pc);
                ret = ACT_P_CREATED;
        } else {
                if (!ovr) {
@@ -108,8 +103,8 @@ static int tcf_gact_init(struct rtattr *rta, struct rtattr *est,
        spin_lock_bh(&gact->tcf_lock);
        gact->tcf_action = parm->action;
 #ifdef CONFIG_GACT_PROB
-       if (tb[TCA_GACT_PROB-1] != NULL) {
-               struct tc_gact_p *p_parm = RTA_DATA(tb[TCA_GACT_PROB-1]);
+       if (tb[TCA_GACT_PROB] != NULL) {
+               struct tc_gact_p *p_parm = nla_data(tb[TCA_GACT_PROB]);
                gact->tcfg_paction = p_parm->paction;
                gact->tcfg_pval    = p_parm->pval;
                gact->tcfg_ptype   = p_parm->ptype;
@@ -144,7 +139,7 @@ static int tcf_gact(struct sk_buff *skb, struct tc_action *a, struct tcf_result
 #else
        action = gact->tcf_action;
 #endif
-       gact->tcf_bstats.bytes += skb->len;
+       gact->tcf_bstats.bytes += qdisc_pkt_len(skb);
        gact->tcf_bstats.packets++;
        if (action == TC_ACT_SHOT)
                gact->tcf_qstats.drops++;
@@ -156,7 +151,7 @@ static int tcf_gact(struct sk_buff *skb, struct tc_action *a, struct tcf_result
 
 static int tcf_gact_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
 {
-       unsigned char *b = skb->tail;
+       unsigned char *b = skb_tail_pointer(skb);
        struct tc_gact opt;
        struct tcf_gact *gact = a->priv;
        struct tcf_t t;
@@ -165,24 +160,24 @@ static int tcf_gact_dump(struct sk_buff *skb, struct tc_action *a, int bind, int
        opt.refcnt = gact->tcf_refcnt - ref;
        opt.bindcnt = gact->tcf_bindcnt - bind;
        opt.action = gact->tcf_action;
-       RTA_PUT(skb, TCA_GACT_PARMS, sizeof(opt), &opt);
+       NLA_PUT(skb, TCA_GACT_PARMS, sizeof(opt), &opt);
 #ifdef CONFIG_GACT_PROB
        if (gact->tcfg_ptype) {
                struct tc_gact_p p_opt;
                p_opt.paction = gact->tcfg_paction;
                p_opt.pval = gact->tcfg_pval;
                p_opt.ptype = gact->tcfg_ptype;
-               RTA_PUT(skb, TCA_GACT_PROB, sizeof(p_opt), &p_opt);
+               NLA_PUT(skb, TCA_GACT_PROB, sizeof(p_opt), &p_opt);
        }
 #endif
        t.install = jiffies_to_clock_t(jiffies - gact->tcf_tm.install);
        t.lastuse = jiffies_to_clock_t(jiffies - gact->tcf_tm.lastuse);
        t.expires = jiffies_to_clock_t(gact->tcf_tm.expires);
-       RTA_PUT(skb, TCA_GACT_TM, sizeof(t), &t);
+       NLA_PUT(skb, TCA_GACT_TM, sizeof(t), &t);
        return skb->len;
 
-rtattr_failure:
-       skb_trim(skb, b - skb->data);
+nla_put_failure:
+       nlmsg_trim(skb, b);
        return -1;
 }