Merge branch 'for-3.18/core' of git://git.kernel.dk/linux-block
[firefly-linux-kernel-4.4.55.git] / net / sched / ematch.c
index ad57f4444b9c65cdc7abe6eb588868c4e2b65cd2..6742200b13071b6e63c200767a77a653d2e10c06 100644 (file)
@@ -178,6 +178,7 @@ static int tcf_em_validate(struct tcf_proto *tp,
        struct tcf_ematch_hdr *em_hdr = nla_data(nla);
        int data_len = nla_len(nla) - sizeof(*em_hdr);
        void *data = (void *) em_hdr + sizeof(*em_hdr);
+       struct net *net = dev_net(qdisc_dev(tp->q));
 
        if (!TCF_EM_REL_VALID(em_hdr->flags))
                goto errout;
@@ -240,7 +241,7 @@ static int tcf_em_validate(struct tcf_proto *tp,
                        goto errout;
 
                if (em->ops->change) {
-                       err = em->ops->change(tp, data, data_len, em);
+                       err = em->ops->change(net, data, data_len, em);
                        if (err < 0)
                                goto errout;
                } else if (data_len > 0) {
@@ -271,6 +272,7 @@ static int tcf_em_validate(struct tcf_proto *tp,
        em->matchid = em_hdr->matchid;
        em->flags = em_hdr->flags;
        em->datalen = data_len;
+       em->net = net;
 
        err = 0;
 errout:
@@ -378,7 +380,7 @@ errout:
        return err;
 
 errout_abort:
-       tcf_em_tree_destroy(tp, tree);
+       tcf_em_tree_destroy(tree);
        return err;
 }
 EXPORT_SYMBOL(tcf_em_tree_validate);
@@ -393,7 +395,7 @@ EXPORT_SYMBOL(tcf_em_tree_validate);
  * tcf_em_tree_validate()/tcf_em_tree_change(). You must ensure that
  * the ematch tree is not in use before calling this function.
  */
-void tcf_em_tree_destroy(struct tcf_proto *tp, struct tcf_ematch_tree *tree)
+void tcf_em_tree_destroy(struct tcf_ematch_tree *tree)
 {
        int i;
 
@@ -405,7 +407,7 @@ void tcf_em_tree_destroy(struct tcf_proto *tp, struct tcf_ematch_tree *tree)
 
                if (em->ops) {
                        if (em->ops->destroy)
-                               em->ops->destroy(tp, em);
+                               em->ops->destroy(em);
                        else if (!tcf_em_is_simple(em))
                                kfree((void *) em->data);
                        module_put(em->ops->owner);
@@ -526,9 +528,10 @@ pop_stack:
                match_idx = stack[--stackp];
                cur_match = tcf_em_get_match(tree, match_idx);
 
+               if (tcf_em_is_inverted(cur_match))
+                       res = !res;
+
                if (tcf_em_early_end(cur_match, res)) {
-                       if (tcf_em_is_inverted(cur_match))
-                               res = !res;
                        goto pop_stack;
                } else {
                        match_idx++;