aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/act_api.c
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/act_api.c
parentMerge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec-next (diff)
downloadlinux-dev-8953b0770ff4e3038a6d4df3cc021f9bfb47548a.tar.xz
linux-dev-8953b0770ff4e3038a6d4df3cc021f9bfb47548a.zip
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/act_api.c')
-rw-r--r--net/sched/act_api.c24
1 files changed, 8 insertions, 16 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)