]> err.no Git - linux-2.6/blobdiff - net/sched/ematch.c
net: use software GSO for SG+CSUM capable netdevices
[linux-2.6] / net / sched / ematch.c
index daa9c4e7e81da2f5fc78446dfbabd438ff617dc9..5e6f82e0e6f3ca7c092e3a1628d69b416604d0f5 100644 (file)
@@ -282,6 +282,11 @@ errout:
        return err;
 }
 
+static const struct nla_policy em_policy[TCA_EMATCH_TREE_MAX + 1] = {
+       [TCA_EMATCH_TREE_HDR]   = { .len = sizeof(struct tcf_ematch_tree_hdr) },
+       [TCA_EMATCH_TREE_LIST]  = { .type = NLA_NESTED },
+};
+
 /**
  * tcf_em_tree_validate - validate ematch config TLV and build ematch tree
  *
@@ -307,12 +312,11 @@ int tcf_em_tree_validate(struct tcf_proto *tp, struct nlattr *nla,
        struct tcf_ematch_tree_hdr *tree_hdr;
        struct tcf_ematch *em;
 
-       if (!nla) {
-               memset(tree, 0, sizeof(*tree));
+       memset(tree, 0, sizeof(*tree));
+       if (!nla)
                return 0;
-       }
 
-       err = nla_parse_nested(tb, TCA_EMATCH_TREE_MAX, nla, NULL);
+       err = nla_parse_nested(tb, TCA_EMATCH_TREE_MAX, nla, em_policy);
        if (err < 0)
                goto errout;
 
@@ -323,10 +327,6 @@ int tcf_em_tree_validate(struct tcf_proto *tp, struct nlattr *nla,
        if (rt_hdr == NULL || rt_list == NULL)
                goto errout;
 
-       if (nla_len(rt_hdr) < sizeof(*tree_hdr) ||
-           nla_len(rt_list) < sizeof(*rt_match))
-               goto errout;
-
        tree_hdr = nla_data(rt_hdr);
        memcpy(&tree->hdr, tree_hdr, sizeof(*tree_hdr));
 
@@ -409,7 +409,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);
-                       else if (!tcf_em_is_simple(em) && em->data)
+                       else if (!tcf_em_is_simple(em))
                                kfree((void *) em->data);
                        module_put(em->ops->owner);
                }
@@ -417,6 +417,7 @@ void tcf_em_tree_destroy(struct tcf_proto *tp, struct tcf_ematch_tree *tree)
 
        tree->hdr.nmatches = 0;
        kfree(tree->matches);
+       tree->matches = NULL;
 }
 EXPORT_SYMBOL(tcf_em_tree_destroy);