]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/sched/ematch.c
svc: Add a generic transport svc_create_xprt function
[linux-2.6-omap-h63xx.git] / net / sched / ematch.c
index d2b480f01a40608856b5f6168502ff36c7a75e31..74ff918455a2acc2885f5fce5e9da30db3d527fa 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
  *
@@ -312,7 +317,7 @@ int tcf_em_tree_validate(struct tcf_proto *tp, struct nlattr *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 +328,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));
 
@@ -436,14 +437,18 @@ int tcf_em_tree_dump(struct sk_buff *skb, struct tcf_ematch_tree *tree, int tlv)
 {
        int i;
        u8 *tail;
-       struct nlattr *top_start = (struct nlattr *)skb_tail_pointer(skb);
+       struct nlattr *top_start;
        struct nlattr *list_start;
 
-       NLA_PUT(skb, tlv, 0, NULL);
+       top_start = nla_nest_start(skb, tlv);
+       if (top_start == NULL)
+               goto nla_put_failure;
+
        NLA_PUT(skb, TCA_EMATCH_TREE_HDR, sizeof(tree->hdr), &tree->hdr);
 
-       list_start = (struct nlattr *)skb_tail_pointer(skb);
-       NLA_PUT(skb, TCA_EMATCH_TREE_LIST, 0, NULL);
+       list_start = nla_nest_start(skb, TCA_EMATCH_TREE_LIST);
+       if (list_start == NULL)
+               goto nla_put_failure;
 
        tail = skb_tail_pointer(skb);
        for (i = 0; i < tree->hdr.nmatches; i++) {
@@ -470,8 +475,8 @@ int tcf_em_tree_dump(struct sk_buff *skb, struct tcf_ematch_tree *tree, int tlv)
                match_start->nla_len = tail - (u8 *)match_start;
        }
 
-       list_start->nla_len = tail - (u8 *)list_start;
-       top_start->nla_len = tail - (u8 *)top_start;
+       nla_nest_end(skb, list_start);
+       nla_nest_end(skb, top_start);
 
        return 0;