[NET_SCHED]: Use nla_nest_start/nla_nest_end
[linux-2.6.git] / net / sched / ematch.c
index 72d9b27..daa9c4e 100644 (file)
@@ -301,7 +301,7 @@ errout:
 int tcf_em_tree_validate(struct tcf_proto *tp, struct nlattr *nla,
                         struct tcf_ematch_tree *tree)
 {
-       int idx, list_len, matches_len, err = -EINVAL;
+       int idx, list_len, matches_len, err;
        struct nlattr *tb[TCA_EMATCH_TREE_MAX + 1];
        struct nlattr *rt_match, *rt_hdr, *rt_list;
        struct tcf_ematch_tree_hdr *tree_hdr;
@@ -312,9 +312,11 @@ int tcf_em_tree_validate(struct tcf_proto *tp, struct nlattr *nla,
                return 0;
        }
 
-       if (nla_parse_nested(tb, TCA_EMATCH_TREE_MAX, nla, NULL) < 0)
+       err = nla_parse_nested(tb, TCA_EMATCH_TREE_MAX, nla, NULL);
+       if (err < 0)
                goto errout;
 
+       err = -EINVAL;
        rt_hdr = tb[TCA_EMATCH_TREE_HDR];
        rt_list = tb[TCA_EMATCH_TREE_LIST];
 
@@ -434,14 +436,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++) {
@@ -468,8 +474,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;