libnl: nla_put_be64(): align on a 64-bit area
nla_data() is now aligned on a 64-bit area. A temporary version (nla_put_be64_32bit()) is added for nla_put_net64(). This function is removed in the next patch. Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
e7479122be
commit
b46f6ded90
@@ -245,8 +245,10 @@ dump_counters(struct sk_buff *skb, struct nf_conn_acct *acct,
|
||||
if (!nest_count)
|
||||
goto nla_put_failure;
|
||||
|
||||
if (nla_put_be64(skb, CTA_COUNTERS_PACKETS, cpu_to_be64(pkts)) ||
|
||||
nla_put_be64(skb, CTA_COUNTERS_BYTES, cpu_to_be64(bytes)))
|
||||
if (nla_put_be64(skb, CTA_COUNTERS_PACKETS, cpu_to_be64(pkts),
|
||||
CTA_COUNTERS_PAD) ||
|
||||
nla_put_be64(skb, CTA_COUNTERS_BYTES, cpu_to_be64(bytes),
|
||||
CTA_COUNTERS_PAD))
|
||||
goto nla_put_failure;
|
||||
|
||||
nla_nest_end(skb, nest_count);
|
||||
@@ -287,9 +289,11 @@ ctnetlink_dump_timestamp(struct sk_buff *skb, const struct nf_conn *ct)
|
||||
if (!nest_count)
|
||||
goto nla_put_failure;
|
||||
|
||||
if (nla_put_be64(skb, CTA_TIMESTAMP_START, cpu_to_be64(tstamp->start)) ||
|
||||
if (nla_put_be64(skb, CTA_TIMESTAMP_START, cpu_to_be64(tstamp->start),
|
||||
CTA_TIMESTAMP_PAD) ||
|
||||
(tstamp->stop != 0 && nla_put_be64(skb, CTA_TIMESTAMP_STOP,
|
||||
cpu_to_be64(tstamp->stop))))
|
||||
cpu_to_be64(tstamp->stop),
|
||||
CTA_TIMESTAMP_PAD)))
|
||||
goto nla_put_failure;
|
||||
nla_nest_end(skb, nest_count);
|
||||
|
||||
@@ -562,8 +566,8 @@ ctnetlink_acct_size(const struct nf_conn *ct)
|
||||
if (!nf_ct_ext_exist(ct, NF_CT_EXT_ACCT))
|
||||
return 0;
|
||||
return 2 * nla_total_size(0) /* CTA_COUNTERS_ORIG|REPL */
|
||||
+ 2 * nla_total_size(sizeof(uint64_t)) /* CTA_COUNTERS_PACKETS */
|
||||
+ 2 * nla_total_size(sizeof(uint64_t)) /* CTA_COUNTERS_BYTES */
|
||||
+ 2 * nla_total_size_64bit(sizeof(uint64_t)) /* CTA_COUNTERS_PACKETS */
|
||||
+ 2 * nla_total_size_64bit(sizeof(uint64_t)) /* CTA_COUNTERS_BYTES */
|
||||
;
|
||||
}
|
||||
|
||||
@@ -590,7 +594,7 @@ ctnetlink_timestamp_size(const struct nf_conn *ct)
|
||||
#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
|
||||
if (!nf_ct_ext_exist(ct, NF_CT_EXT_TSTAMP))
|
||||
return 0;
|
||||
return nla_total_size(0) + 2 * nla_total_size(sizeof(uint64_t));
|
||||
return nla_total_size(0) + 2 * nla_total_size_64bit(sizeof(uint64_t));
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
@@ -645,7 +645,8 @@ static int dccp_to_nlattr(struct sk_buff *skb, struct nlattr *nla,
|
||||
nla_put_u8(skb, CTA_PROTOINFO_DCCP_ROLE,
|
||||
ct->proto.dccp.role[IP_CT_DIR_ORIGINAL]) ||
|
||||
nla_put_be64(skb, CTA_PROTOINFO_DCCP_HANDSHAKE_SEQ,
|
||||
cpu_to_be64(ct->proto.dccp.handshake_seq)))
|
||||
cpu_to_be64(ct->proto.dccp.handshake_seq),
|
||||
CTA_PROTOINFO_DCCP_PAD))
|
||||
goto nla_put_failure;
|
||||
nla_nest_end(skb, nest_parms);
|
||||
spin_unlock_bh(&ct->lock);
|
||||
@@ -660,6 +661,7 @@ static const struct nla_policy dccp_nla_policy[CTA_PROTOINFO_DCCP_MAX + 1] = {
|
||||
[CTA_PROTOINFO_DCCP_STATE] = { .type = NLA_U8 },
|
||||
[CTA_PROTOINFO_DCCP_ROLE] = { .type = NLA_U8 },
|
||||
[CTA_PROTOINFO_DCCP_HANDSHAKE_SEQ] = { .type = NLA_U64 },
|
||||
[CTA_PROTOINFO_DCCP_PAD] = { .type = NLA_UNSPEC },
|
||||
};
|
||||
|
||||
static int nlattr_to_dccp(struct nlattr *cda[], struct nf_conn *ct)
|
||||
|
||||
@@ -944,8 +944,10 @@ static int nft_dump_stats(struct sk_buff *skb, struct nft_stats __percpu *stats)
|
||||
if (nest == NULL)
|
||||
goto nla_put_failure;
|
||||
|
||||
if (nla_put_be64(skb, NFTA_COUNTER_PACKETS, cpu_to_be64(total.pkts)) ||
|
||||
nla_put_be64(skb, NFTA_COUNTER_BYTES, cpu_to_be64(total.bytes)))
|
||||
if (nla_put_be64(skb, NFTA_COUNTER_PACKETS, cpu_to_be64(total.pkts),
|
||||
NFTA_COUNTER_PAD) ||
|
||||
nla_put_be64(skb, NFTA_COUNTER_BYTES, cpu_to_be64(total.bytes),
|
||||
NFTA_COUNTER_PAD))
|
||||
goto nla_put_failure;
|
||||
|
||||
nla_nest_end(skb, nest);
|
||||
@@ -975,7 +977,8 @@ static int nf_tables_fill_chain_info(struct sk_buff *skb, struct net *net,
|
||||
|
||||
if (nla_put_string(skb, NFTA_CHAIN_TABLE, table->name))
|
||||
goto nla_put_failure;
|
||||
if (nla_put_be64(skb, NFTA_CHAIN_HANDLE, cpu_to_be64(chain->handle)))
|
||||
if (nla_put_be64(skb, NFTA_CHAIN_HANDLE, cpu_to_be64(chain->handle),
|
||||
NFTA_CHAIN_PAD))
|
||||
goto nla_put_failure;
|
||||
if (nla_put_string(skb, NFTA_CHAIN_NAME, chain->name))
|
||||
goto nla_put_failure;
|
||||
@@ -1803,13 +1806,15 @@ static int nf_tables_fill_rule_info(struct sk_buff *skb, struct net *net,
|
||||
goto nla_put_failure;
|
||||
if (nla_put_string(skb, NFTA_RULE_CHAIN, chain->name))
|
||||
goto nla_put_failure;
|
||||
if (nla_put_be64(skb, NFTA_RULE_HANDLE, cpu_to_be64(rule->handle)))
|
||||
if (nla_put_be64(skb, NFTA_RULE_HANDLE, cpu_to_be64(rule->handle),
|
||||
NFTA_RULE_PAD))
|
||||
goto nla_put_failure;
|
||||
|
||||
if ((event != NFT_MSG_DELRULE) && (rule->list.prev != &chain->rules)) {
|
||||
prule = list_entry(rule->list.prev, struct nft_rule, list);
|
||||
if (nla_put_be64(skb, NFTA_RULE_POSITION,
|
||||
cpu_to_be64(prule->handle)))
|
||||
cpu_to_be64(prule->handle),
|
||||
NFTA_RULE_PAD))
|
||||
goto nla_put_failure;
|
||||
}
|
||||
|
||||
@@ -2473,7 +2478,8 @@ static int nf_tables_fill_set(struct sk_buff *skb, const struct nft_ctx *ctx,
|
||||
}
|
||||
|
||||
if (set->timeout &&
|
||||
nla_put_be64(skb, NFTA_SET_TIMEOUT, cpu_to_be64(set->timeout)))
|
||||
nla_put_be64(skb, NFTA_SET_TIMEOUT, cpu_to_be64(set->timeout),
|
||||
NFTA_SET_PAD))
|
||||
goto nla_put_failure;
|
||||
if (set->gc_int &&
|
||||
nla_put_be32(skb, NFTA_SET_GC_INTERVAL, htonl(set->gc_int)))
|
||||
@@ -3076,7 +3082,8 @@ static int nf_tables_fill_setelem(struct sk_buff *skb,
|
||||
|
||||
if (nft_set_ext_exists(ext, NFT_SET_EXT_TIMEOUT) &&
|
||||
nla_put_be64(skb, NFTA_SET_ELEM_TIMEOUT,
|
||||
cpu_to_be64(*nft_set_ext_timeout(ext))))
|
||||
cpu_to_be64(*nft_set_ext_timeout(ext)),
|
||||
NFTA_SET_ELEM_PAD))
|
||||
goto nla_put_failure;
|
||||
|
||||
if (nft_set_ext_exists(ext, NFT_SET_EXT_EXPIRATION)) {
|
||||
@@ -3089,7 +3096,8 @@ static int nf_tables_fill_setelem(struct sk_buff *skb,
|
||||
expires = 0;
|
||||
|
||||
if (nla_put_be64(skb, NFTA_SET_ELEM_EXPIRATION,
|
||||
cpu_to_be64(jiffies_to_msecs(expires))))
|
||||
cpu_to_be64(jiffies_to_msecs(expires)),
|
||||
NFTA_SET_ELEM_PAD))
|
||||
goto nla_put_failure;
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +156,8 @@ static int nf_trace_fill_rule_info(struct sk_buff *nlskb,
|
||||
return 0;
|
||||
|
||||
return nla_put_be64(nlskb, NFTA_TRACE_RULE_HANDLE,
|
||||
cpu_to_be64(info->rule->handle));
|
||||
cpu_to_be64(info->rule->handle),
|
||||
NFTA_TRACE_PAD);
|
||||
}
|
||||
|
||||
void nft_trace_notify(struct nft_traceinfo *info)
|
||||
@@ -174,7 +175,7 @@ void nft_trace_notify(struct nft_traceinfo *info)
|
||||
size = nlmsg_total_size(sizeof(struct nfgenmsg)) +
|
||||
nla_total_size(NFT_TABLE_MAXNAMELEN) +
|
||||
nla_total_size(NFT_CHAIN_MAXNAMELEN) +
|
||||
nla_total_size(sizeof(__be64)) + /* rule handle */
|
||||
nla_total_size_64bit(sizeof(__be64)) + /* rule handle */
|
||||
nla_total_size(sizeof(__be32)) + /* trace type */
|
||||
nla_total_size(0) + /* VERDICT, nested */
|
||||
nla_total_size(sizeof(u32)) + /* verdict code */
|
||||
|
||||
@@ -160,15 +160,18 @@ nfnl_acct_fill_info(struct sk_buff *skb, u32 portid, u32 seq, u32 type,
|
||||
pkts = atomic64_read(&acct->pkts);
|
||||
bytes = atomic64_read(&acct->bytes);
|
||||
}
|
||||
if (nla_put_be64(skb, NFACCT_PKTS, cpu_to_be64(pkts)) ||
|
||||
nla_put_be64(skb, NFACCT_BYTES, cpu_to_be64(bytes)) ||
|
||||
if (nla_put_be64(skb, NFACCT_PKTS, cpu_to_be64(pkts),
|
||||
NFACCT_PAD) ||
|
||||
nla_put_be64(skb, NFACCT_BYTES, cpu_to_be64(bytes),
|
||||
NFACCT_PAD) ||
|
||||
nla_put_be32(skb, NFACCT_USE, htonl(atomic_read(&acct->refcnt))))
|
||||
goto nla_put_failure;
|
||||
if (acct->flags & NFACCT_F_QUOTA) {
|
||||
u64 *quota = (u64 *)acct->data;
|
||||
|
||||
if (nla_put_be32(skb, NFACCT_FLAGS, htonl(old_flags)) ||
|
||||
nla_put_be64(skb, NFACCT_QUOTA, cpu_to_be64(*quota)))
|
||||
nla_put_be64(skb, NFACCT_QUOTA, cpu_to_be64(*quota),
|
||||
NFACCT_PAD))
|
||||
goto nla_put_failure;
|
||||
}
|
||||
nlmsg_end(skb, nlh);
|
||||
|
||||
@@ -76,8 +76,10 @@ static int nft_counter_dump(struct sk_buff *skb, const struct nft_expr *expr)
|
||||
|
||||
nft_counter_fetch(priv->counter, &total);
|
||||
|
||||
if (nla_put_be64(skb, NFTA_COUNTER_BYTES, cpu_to_be64(total.bytes)) ||
|
||||
nla_put_be64(skb, NFTA_COUNTER_PACKETS, cpu_to_be64(total.packets)))
|
||||
if (nla_put_be64(skb, NFTA_COUNTER_BYTES, cpu_to_be64(total.bytes),
|
||||
NFTA_COUNTER_PAD) ||
|
||||
nla_put_be64(skb, NFTA_COUNTER_PACKETS, cpu_to_be64(total.packets),
|
||||
NFTA_COUNTER_PAD))
|
||||
goto nla_put_failure;
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -227,7 +227,8 @@ static int nft_dynset_dump(struct sk_buff *skb, const struct nft_expr *expr)
|
||||
goto nla_put_failure;
|
||||
if (nla_put_string(skb, NFTA_DYNSET_SET_NAME, priv->set->name))
|
||||
goto nla_put_failure;
|
||||
if (nla_put_be64(skb, NFTA_DYNSET_TIMEOUT, cpu_to_be64(priv->timeout)))
|
||||
if (nla_put_be64(skb, NFTA_DYNSET_TIMEOUT, cpu_to_be64(priv->timeout),
|
||||
NFTA_DYNSET_PAD))
|
||||
goto nla_put_failure;
|
||||
if (priv->expr && nft_expr_dump(skb, NFTA_DYNSET_EXPR, priv->expr))
|
||||
goto nla_put_failure;
|
||||
|
||||
@@ -97,8 +97,10 @@ static int nft_limit_dump(struct sk_buff *skb, const struct nft_limit *limit,
|
||||
u64 secs = div_u64(limit->nsecs, NSEC_PER_SEC);
|
||||
u64 rate = limit->rate - limit->burst;
|
||||
|
||||
if (nla_put_be64(skb, NFTA_LIMIT_RATE, cpu_to_be64(rate)) ||
|
||||
nla_put_be64(skb, NFTA_LIMIT_UNIT, cpu_to_be64(secs)) ||
|
||||
if (nla_put_be64(skb, NFTA_LIMIT_RATE, cpu_to_be64(rate),
|
||||
NFTA_LIMIT_PAD) ||
|
||||
nla_put_be64(skb, NFTA_LIMIT_UNIT, cpu_to_be64(secs),
|
||||
NFTA_LIMIT_PAD) ||
|
||||
nla_put_be32(skb, NFTA_LIMIT_BURST, htonl(limit->burst)) ||
|
||||
nla_put_be32(skb, NFTA_LIMIT_TYPE, htonl(type)) ||
|
||||
nla_put_be32(skb, NFTA_LIMIT_FLAGS, htonl(flags)))
|
||||
|
||||
Reference in New Issue
Block a user