Commit 24beeab5 authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

[NET_SCHED]: Use typeful attribute construction helpers

Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 57e1c487
...@@ -133,7 +133,7 @@ static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a, ...@@ -133,7 +133,7 @@ static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a,
p = s_p; p = s_p;
} }
} }
NLA_PUT(skb, TCA_FCNT, 4, &n_i); NLA_PUT_U32(skb, TCA_FCNT, n_i);
nla_nest_end(skb, nest); nla_nest_end(skb, nest);
return n_i; return n_i;
......
...@@ -254,8 +254,8 @@ static int tcf_ipt_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ...@@ -254,8 +254,8 @@ static int tcf_ipt_dump(struct sk_buff *skb, struct tc_action *a, int bind, int
strcpy(t->u.user.name, ipt->tcfi_t->u.kernel.target->name); strcpy(t->u.user.name, ipt->tcfi_t->u.kernel.target->name);
NLA_PUT(skb, TCA_IPT_TARG, ipt->tcfi_t->u.user.target_size, t); NLA_PUT(skb, TCA_IPT_TARG, ipt->tcfi_t->u.user.target_size, t);
NLA_PUT(skb, TCA_IPT_INDEX, 4, &ipt->tcf_index); NLA_PUT_U32(skb, TCA_IPT_INDEX, ipt->tcf_index);
NLA_PUT(skb, TCA_IPT_HOOK, 4, &ipt->tcfi_hook); NLA_PUT_U32(skb, TCA_IPT_HOOK, ipt->tcfi_hook);
NLA_PUT(skb, TCA_IPT_CNT, sizeof(struct tc_cnt), &c); NLA_PUT(skb, TCA_IPT_CNT, sizeof(struct tc_cnt), &c);
NLA_PUT_STRING(skb, TCA_IPT_TABLE, ipt->tcfi_tname); NLA_PUT_STRING(skb, TCA_IPT_TABLE, ipt->tcfi_tname);
tm.install = jiffies_to_clock_t(jiffies - ipt->tcf_tm.install); tm.install = jiffies_to_clock_t(jiffies - ipt->tcf_tm.install);
......
...@@ -339,10 +339,9 @@ tcf_act_police_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ref) ...@@ -339,10 +339,9 @@ tcf_act_police_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
memset(&opt.peakrate, 0, sizeof(opt.peakrate)); memset(&opt.peakrate, 0, sizeof(opt.peakrate));
NLA_PUT(skb, TCA_POLICE_TBF, sizeof(opt), &opt); NLA_PUT(skb, TCA_POLICE_TBF, sizeof(opt), &opt);
if (police->tcfp_result) if (police->tcfp_result)
NLA_PUT(skb, TCA_POLICE_RESULT, sizeof(int), NLA_PUT_U32(skb, TCA_POLICE_RESULT, police->tcfp_result);
&police->tcfp_result);
if (police->tcfp_ewma_rate) if (police->tcfp_ewma_rate)
NLA_PUT(skb, TCA_POLICE_AVRATE, 4, &police->tcfp_ewma_rate); NLA_PUT_U32(skb, TCA_POLICE_AVRATE, police->tcfp_ewma_rate);
return skb->len; return skb->len;
nla_put_failure: nla_put_failure:
......
...@@ -258,7 +258,7 @@ static int basic_dump(struct tcf_proto *tp, unsigned long fh, ...@@ -258,7 +258,7 @@ static int basic_dump(struct tcf_proto *tp, unsigned long fh,
goto nla_put_failure; goto nla_put_failure;
if (f->res.classid) if (f->res.classid)
NLA_PUT(skb, TCA_BASIC_CLASSID, sizeof(u32), &f->res.classid); NLA_PUT_U32(skb, TCA_BASIC_CLASSID, f->res.classid);
if (tcf_exts_dump(skb, &f->exts, &basic_ext_map) < 0 || if (tcf_exts_dump(skb, &f->exts, &basic_ext_map) < 0 ||
tcf_em_tree_dump(skb, &f->ematches, TCA_BASIC_EMATCHES) < 0) tcf_em_tree_dump(skb, &f->ematches, TCA_BASIC_EMATCHES) < 0)
......
...@@ -349,13 +349,13 @@ static int fw_dump(struct tcf_proto *tp, unsigned long fh, ...@@ -349,13 +349,13 @@ static int fw_dump(struct tcf_proto *tp, unsigned long fh,
goto nla_put_failure; goto nla_put_failure;
if (f->res.classid) if (f->res.classid)
NLA_PUT(skb, TCA_FW_CLASSID, 4, &f->res.classid); NLA_PUT_U32(skb, TCA_FW_CLASSID, f->res.classid);
#ifdef CONFIG_NET_CLS_IND #ifdef CONFIG_NET_CLS_IND
if (strlen(f->indev)) if (strlen(f->indev))
NLA_PUT_STRING(skb, TCA_FW_INDEV, f->indev); NLA_PUT_STRING(skb, TCA_FW_INDEV, f->indev);
#endif /* CONFIG_NET_CLS_IND */ #endif /* CONFIG_NET_CLS_IND */
if (head->mask != 0xFFFFFFFF) if (head->mask != 0xFFFFFFFF)
NLA_PUT(skb, TCA_FW_MASK, 4, &head->mask); NLA_PUT_U32(skb, TCA_FW_MASK, head->mask);
if (tcf_exts_dump(skb, &f->exts, &fw_ext_map) < 0) if (tcf_exts_dump(skb, &f->exts, &fw_ext_map) < 0)
goto nla_put_failure; goto nla_put_failure;
......
...@@ -565,17 +565,17 @@ static int route4_dump(struct tcf_proto *tp, unsigned long fh, ...@@ -565,17 +565,17 @@ static int route4_dump(struct tcf_proto *tp, unsigned long fh,
if (!(f->handle&0x8000)) { if (!(f->handle&0x8000)) {
id = f->id&0xFF; id = f->id&0xFF;
NLA_PUT(skb, TCA_ROUTE4_TO, sizeof(id), &id); NLA_PUT_U32(skb, TCA_ROUTE4_TO, id);
} }
if (f->handle&0x80000000) { if (f->handle&0x80000000) {
if ((f->handle>>16) != 0xFFFF) if ((f->handle>>16) != 0xFFFF)
NLA_PUT(skb, TCA_ROUTE4_IIF, sizeof(f->iif), &f->iif); NLA_PUT_U32(skb, TCA_ROUTE4_IIF, f->iif);
} else { } else {
id = f->id>>16; id = f->id>>16;
NLA_PUT(skb, TCA_ROUTE4_FROM, sizeof(id), &id); NLA_PUT_U32(skb, TCA_ROUTE4_FROM, id);
} }
if (f->res.classid) if (f->res.classid)
NLA_PUT(skb, TCA_ROUTE4_CLASSID, 4, &f->res.classid); NLA_PUT_U32(skb, TCA_ROUTE4_CLASSID, f->res.classid);
if (tcf_exts_dump(skb, &f->exts, &route_ext_map) < 0) if (tcf_exts_dump(skb, &f->exts, &route_ext_map) < 0)
goto nla_put_failure; goto nla_put_failure;
......
...@@ -617,7 +617,7 @@ static int rsvp_dump(struct tcf_proto *tp, unsigned long fh, ...@@ -617,7 +617,7 @@ static int rsvp_dump(struct tcf_proto *tp, unsigned long fh,
pinfo.pad = 0; pinfo.pad = 0;
NLA_PUT(skb, TCA_RSVP_PINFO, sizeof(pinfo), &pinfo); NLA_PUT(skb, TCA_RSVP_PINFO, sizeof(pinfo), &pinfo);
if (f->res.classid) if (f->res.classid)
NLA_PUT(skb, TCA_RSVP_CLASSID, 4, &f->res.classid); NLA_PUT_U32(skb, TCA_RSVP_CLASSID, f->res.classid);
if (((f->handle>>8)&0xFF) != 16) if (((f->handle>>8)&0xFF) != 16)
NLA_PUT(skb, TCA_RSVP_SRC, sizeof(f->src), f->src); NLA_PUT(skb, TCA_RSVP_SRC, sizeof(f->src), f->src);
......
...@@ -449,11 +449,10 @@ static int tcindex_dump(struct tcf_proto *tp, unsigned long fh, ...@@ -449,11 +449,10 @@ static int tcindex_dump(struct tcf_proto *tp, unsigned long fh,
if (!fh) { if (!fh) {
t->tcm_handle = ~0; /* whatever ... */ t->tcm_handle = ~0; /* whatever ... */
NLA_PUT(skb, TCA_TCINDEX_HASH, sizeof(p->hash), &p->hash); NLA_PUT_U32(skb, TCA_TCINDEX_HASH, p->hash);
NLA_PUT(skb, TCA_TCINDEX_MASK, sizeof(p->mask), &p->mask); NLA_PUT_U16(skb, TCA_TCINDEX_MASK, p->mask);
NLA_PUT(skb, TCA_TCINDEX_SHIFT, sizeof(p->shift), &p->shift); NLA_PUT_U32(skb, TCA_TCINDEX_SHIFT, p->shift);
NLA_PUT(skb, TCA_TCINDEX_FALL_THROUGH, sizeof(p->fall_through), NLA_PUT_U32(skb, TCA_TCINDEX_FALL_THROUGH, p->fall_through);
&p->fall_through);
nla_nest_end(skb, nest); nla_nest_end(skb, nest);
} else { } else {
if (p->perfect) { if (p->perfect) {
...@@ -473,7 +472,7 @@ static int tcindex_dump(struct tcf_proto *tp, unsigned long fh, ...@@ -473,7 +472,7 @@ static int tcindex_dump(struct tcf_proto *tp, unsigned long fh,
} }
pr_debug("handle = %d\n", t->tcm_handle); pr_debug("handle = %d\n", t->tcm_handle);
if (r->res.class) if (r->res.class)
NLA_PUT(skb, TCA_TCINDEX_CLASSID, 4, &r->res.classid); NLA_PUT_U32(skb, TCA_TCINDEX_CLASSID, r->res.classid);
if (tcf_exts_dump(skb, &r->exts, &tcindex_ext_map) < 0) if (tcf_exts_dump(skb, &r->exts, &tcindex_ext_map) < 0)
goto nla_put_failure; goto nla_put_failure;
......
...@@ -708,19 +708,19 @@ static int u32_dump(struct tcf_proto *tp, unsigned long fh, ...@@ -708,19 +708,19 @@ static int u32_dump(struct tcf_proto *tp, unsigned long fh,
if (TC_U32_KEY(n->handle) == 0) { if (TC_U32_KEY(n->handle) == 0) {
struct tc_u_hnode *ht = (struct tc_u_hnode*)fh; struct tc_u_hnode *ht = (struct tc_u_hnode*)fh;
u32 divisor = ht->divisor+1; u32 divisor = ht->divisor+1;
NLA_PUT(skb, TCA_U32_DIVISOR, 4, &divisor); NLA_PUT_U32(skb, TCA_U32_DIVISOR, divisor);
} else { } else {
NLA_PUT(skb, TCA_U32_SEL, NLA_PUT(skb, TCA_U32_SEL,
sizeof(n->sel) + n->sel.nkeys*sizeof(struct tc_u32_key), sizeof(n->sel) + n->sel.nkeys*sizeof(struct tc_u32_key),
&n->sel); &n->sel);
if (n->ht_up) { if (n->ht_up) {
u32 htid = n->handle & 0xFFFFF000; u32 htid = n->handle & 0xFFFFF000;
NLA_PUT(skb, TCA_U32_HASH, 4, &htid); NLA_PUT_U32(skb, TCA_U32_HASH, htid);
} }
if (n->res.classid) if (n->res.classid)
NLA_PUT(skb, TCA_U32_CLASSID, 4, &n->res.classid); NLA_PUT_U32(skb, TCA_U32_CLASSID, n->res.classid);
if (n->ht_down) if (n->ht_down)
NLA_PUT(skb, TCA_U32_LINK, 4, &n->ht_down->handle); NLA_PUT_U32(skb, TCA_U32_LINK, n->ht_down->handle);
#ifdef CONFIG_CLS_U32_MARK #ifdef CONFIG_CLS_U32_MARK
if (n->mark.val || n->mark.mask) if (n->mark.val || n->mark.mask)
......
...@@ -623,8 +623,7 @@ static int meta_int_dump(struct sk_buff *skb, struct meta_value *v, int tlv) ...@@ -623,8 +623,7 @@ static int meta_int_dump(struct sk_buff *skb, struct meta_value *v, int tlv)
if (v->len == sizeof(unsigned long)) if (v->len == sizeof(unsigned long))
NLA_PUT(skb, tlv, sizeof(unsigned long), &v->val); NLA_PUT(skb, tlv, sizeof(unsigned long), &v->val);
else if (v->len == sizeof(u32)) { else if (v->len == sizeof(u32)) {
u32 d = v->val; NLA_PUT_U32(skb, tlv, v->val);
NLA_PUT(skb, tlv, sizeof(d), &d);
} }
return 0; return 0;
......
...@@ -629,14 +629,12 @@ static int atm_tc_dump_class(struct Qdisc *sch, unsigned long cl, ...@@ -629,14 +629,12 @@ static int atm_tc_dump_class(struct Qdisc *sch, unsigned long cl,
pvc.sap_addr.vci = flow->vcc->vci; pvc.sap_addr.vci = flow->vcc->vci;
NLA_PUT(skb, TCA_ATM_ADDR, sizeof(pvc), &pvc); NLA_PUT(skb, TCA_ATM_ADDR, sizeof(pvc), &pvc);
state = ATM_VF2VS(flow->vcc->flags); state = ATM_VF2VS(flow->vcc->flags);
NLA_PUT(skb, TCA_ATM_STATE, sizeof(state), &state); NLA_PUT_U32(skb, TCA_ATM_STATE, state);
} }
if (flow->excess) if (flow->excess)
NLA_PUT(skb, TCA_ATM_EXCESS, sizeof(u32), &flow->classid); NLA_PUT_U32(skb, TCA_ATM_EXCESS, flow->classid);
else { else {
static u32 zero; NLA_PUT_U32(skb, TCA_ATM_EXCESS, 0);
NLA_PUT(skb, TCA_ATM_EXCESS, sizeof(zero), &zero);
} }
nla_nest_end(skb, nest); nla_nest_end(skb, nest);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment