summaryrefslogtreecommitdiffstats
path: root/net/sched
diff options
context:
space:
mode:
authorJiri Pirko <jiri@mellanox.com>2020-03-28 16:37:42 +0100
committerDavid S. Miller <davem@davemloft.net>2020-03-30 11:06:49 -0700
commit8953b0770ff4e3038a6d4df3cc021f9bfb47548a (patch)
tree3a99e78f5accc546792f7b5e89637eb94bd26c1a /net/sched
parentacc086bfb957542be49a8165eb794bc74f6cb51b (diff)
downloadlinux-8953b0770ff4e3038a6d4df3cc021f9bfb47548a.tar.bz2
net: introduce nla_put_bitfield32() helper and use it
Introduce a helper to pass value and selector to. The helper packs them into struct and puts them into netlink message. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched')
-rw-r--r--net/sched/act_api.c24
-rw-r--r--net/sched/sch_red.c7
2 files changed, 10 insertions, 21 deletions
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 861a831b0ef7..33cc77e6e56c 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -789,23 +789,15 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
}
rcu_read_unlock();
- if (a->hw_stats != TCA_ACT_HW_STATS_ANY) {
- struct nla_bitfield32 hw_stats = {
- a->hw_stats,
- TCA_ACT_HW_STATS_ANY,
- };
-
- if (nla_put(skb, TCA_ACT_HW_STATS, sizeof(hw_stats), &hw_stats))
- goto nla_put_failure;
- }
-
- if (a->tcfa_flags) {
- struct nla_bitfield32 flags = { a->tcfa_flags,
- a->tcfa_flags, };
+ if (a->hw_stats != TCA_ACT_HW_STATS_ANY &&
+ nla_put_bitfield32(skb, TCA_ACT_HW_STATS,
+ a->hw_stats, TCA_ACT_HW_STATS_ANY))
+ goto nla_put_failure;
- if (nla_put(skb, TCA_ACT_FLAGS, sizeof(flags), &flags))
- goto nla_put_failure;
- }
+ if (a->tcfa_flags &&
+ nla_put_bitfield32(skb, TCA_ACT_FLAGS,
+ a->tcfa_flags, a->tcfa_flags))
+ goto nla_put_failure;
nest = nla_nest_start_noflag(skb, TCA_OPTIONS);
if (nest == NULL)
diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c
index 3ef0a4f7399b..c7de47c942e3 100644
--- a/net/sched/sch_red.c
+++ b/net/sched/sch_red.c
@@ -349,10 +349,6 @@ static int red_dump_offload_stats(struct Qdisc *sch)
static int red_dump(struct Qdisc *sch, struct sk_buff *skb)
{
struct red_sched_data *q = qdisc_priv(sch);
- struct nla_bitfield32 flags_bf = {
- .selector = red_supported_flags,
- .value = q->flags,
- };
struct nlattr *opts = NULL;
struct tc_red_qopt opt = {
.limit = q->limit,
@@ -375,7 +371,8 @@ static int red_dump(struct Qdisc *sch, struct sk_buff *skb)
goto nla_put_failure;
if (nla_put(skb, TCA_RED_PARMS, sizeof(opt), &opt) ||
nla_put_u32(skb, TCA_RED_MAX_P, q->parms.max_P) ||
- nla_put(skb, TCA_RED_FLAGS, sizeof(flags_bf), &flags_bf))
+ nla_put_bitfield32(skb, TCA_RED_FLAGS,
+ q->flags, red_supported_flags))
goto nla_put_failure;
return nla_nest_end(skb, opts);