Merge tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso...
[firefly-linux-kernel-4.4.55.git] / net / sched / cls_tcindex.c
index b86535a401695259ab9a765573180c33eb72fe00..eed8404443d8f0145942c3e459b79934ada9c48d 100644 (file)
@@ -24,9 +24,6 @@
 #define DEFAULT_HASH_SIZE      64      /* optimized for diffserv */
 
 
-#define        PRIV(tp)        ((struct tcindex_data *) (tp)->root)
-
-
 struct tcindex_filter_result {
        struct tcf_exts         exts;
        struct tcf_result       res;
@@ -50,11 +47,6 @@ struct tcindex_data {
        int fall_through;       /* 0: only classify if explicit match */
 };
 
-static const struct tcf_ext_map tcindex_ext_map = {
-       .police = TCA_TCINDEX_POLICE,
-       .action = TCA_TCINDEX_ACT
-};
-
 static inline int
 tcindex_filter_is_set(struct tcindex_filter_result *r)
 {
@@ -82,7 +74,7 @@ tcindex_lookup(struct tcindex_data *p, u16 key)
 static int tcindex_classify(struct sk_buff *skb, const struct tcf_proto *tp,
                            struct tcf_result *res)
 {
-       struct tcindex_data *p = PRIV(tp);
+       struct tcindex_data *p = tp->root;
        struct tcindex_filter_result *f;
        int key = (skb->tc_index & p->mask) >> p->shift;
 
@@ -107,7 +99,7 @@ static int tcindex_classify(struct sk_buff *skb, const struct tcf_proto *tp,
 
 static unsigned long tcindex_get(struct tcf_proto *tp, u32 handle)
 {
-       struct tcindex_data *p = PRIV(tp);
+       struct tcindex_data *p = tp->root;
        struct tcindex_filter_result *r;
 
        pr_debug("tcindex_get(tp %p,handle 0x%08x)\n", tp, handle);
@@ -145,7 +137,7 @@ static int tcindex_init(struct tcf_proto *tp)
 static int
 __tcindex_delete(struct tcf_proto *tp, unsigned long arg, int lock)
 {
-       struct tcindex_data *p = PRIV(tp);
+       struct tcindex_data *p = tp->root;
        struct tcindex_filter_result *r = (struct tcindex_filter_result *) arg;
        struct tcindex_filter *f = NULL;
 
@@ -209,17 +201,21 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
        struct tcindex_filter *f = NULL; /* make gcc behave */
        struct tcf_exts e;
 
-       err = tcf_exts_validate(net, tp, tb, est, &e, &tcindex_ext_map);
+       tcf_exts_init(&e, TCA_TCINDEX_ACT, TCA_TCINDEX_POLICE);
+       err = tcf_exts_validate(net, tp, tb, est, &e);
        if (err < 0)
                return err;
 
        memcpy(&cp, p, sizeof(cp));
        memset(&new_filter_result, 0, sizeof(new_filter_result));
+       tcf_exts_init(&new_filter_result.exts, TCA_TCINDEX_ACT, TCA_TCINDEX_POLICE);
 
        if (old_r)
                memcpy(&cr, r, sizeof(cr));
-       else
+       else {
                memset(&cr, 0, sizeof(cr));
+               tcf_exts_init(&cr.exts, TCA_TCINDEX_ACT, TCA_TCINDEX_POLICE);
+       }
 
        if (tb[TCA_TCINDEX_HASH])
                cp.hash = nla_get_u32(tb[TCA_TCINDEX_HASH]);
@@ -339,7 +335,7 @@ tcindex_change(struct net *net, struct sk_buff *in_skb,
 {
        struct nlattr *opt = tca[TCA_OPTIONS];
        struct nlattr *tb[TCA_TCINDEX_MAX + 1];
-       struct tcindex_data *p = PRIV(tp);
+       struct tcindex_data *p = tp->root;
        struct tcindex_filter_result *r = (struct tcindex_filter_result *) *arg;
        int err;
 
@@ -361,7 +357,7 @@ tcindex_change(struct net *net, struct sk_buff *in_skb,
 
 static void tcindex_walk(struct tcf_proto *tp, struct tcf_walker *walker)
 {
-       struct tcindex_data *p = PRIV(tp);
+       struct tcindex_data *p = tp->root;
        struct tcindex_filter *f, *next;
        int i;
 
@@ -408,7 +404,7 @@ static int tcindex_destroy_element(struct tcf_proto *tp,
 
 static void tcindex_destroy(struct tcf_proto *tp)
 {
-       struct tcindex_data *p = PRIV(tp);
+       struct tcindex_data *p = tp->root;
        struct tcf_walker walker;
 
        pr_debug("tcindex_destroy(tp %p),p %p\n", tp, p);
@@ -423,10 +419,10 @@ static void tcindex_destroy(struct tcf_proto *tp)
 }
 
 
-static int tcindex_dump(struct tcf_proto *tp, unsigned long fh,
+static int tcindex_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,
     struct sk_buff *skb, struct tcmsg *t)
 {
-       struct tcindex_data *p = PRIV(tp);
+       struct tcindex_data *p = tp->root;
        struct tcindex_filter_result *r = (struct tcindex_filter_result *) fh;
        unsigned char *b = skb_tail_pointer(skb);
        struct nlattr *nest;
@@ -468,11 +464,11 @@ static int tcindex_dump(struct tcf_proto *tp, unsigned long fh,
                    nla_put_u32(skb, TCA_TCINDEX_CLASSID, r->res.classid))
                        goto nla_put_failure;
 
-               if (tcf_exts_dump(skb, &r->exts, &tcindex_ext_map) < 0)
+               if (tcf_exts_dump(skb, &r->exts) < 0)
                        goto nla_put_failure;
                nla_nest_end(skb, nest);
 
-               if (tcf_exts_dump_stats(skb, &r->exts, &tcindex_ext_map) < 0)
+               if (tcf_exts_dump_stats(skb, &r->exts) < 0)
                        goto nla_put_failure;
        }