aboutsummaryrefslogtreecommitdiffstats
path: root/net/netfilter
diff options
context:
space:
mode:
authorNicolas Dichtel <nicolas.dichtel@6wind.com>2016-04-22 11:31:18 -0400
committerDavid S. Miller <davem@davemloft.net>2016-04-23 20:13:24 -0400
commitb46f6ded906ef0be52a4881ba50a084aeca64d7e (patch)
treeb17273779de462616ce20c370da5c7659f0cb975 /net/netfilter
parente7479122befd7026cf0fb3b3740f17ebd9c64d35 (diff)
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>
Diffstat (limited to 'net/netfilter')
-rw-r--r--net/netfilter/nf_conntrack_netlink.c18
-rw-r--r--net/netfilter/nf_conntrack_proto_dccp.c4
-rw-r--r--net/netfilter/nf_tables_api.c24
-rw-r--r--net/netfilter/nf_tables_trace.c5
-rw-r--r--net/netfilter/nfnetlink_acct.c9
-rw-r--r--net/netfilter/nft_counter.c6
-rw-r--r--net/netfilter/nft_dynset.c3
-rw-r--r--net/netfilter/nft_limit.c6
8 files changed, 49 insertions, 26 deletions
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 355e8552fd5b..3362d65f3285 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -245,8 +245,10 @@ dump_counters(struct sk_buff *skb, struct nf_conn_acct *acct,
245 if (!nest_count) 245 if (!nest_count)
246 goto nla_put_failure; 246 goto nla_put_failure;
247 247
248 if (nla_put_be64(skb, CTA_COUNTERS_PACKETS, cpu_to_be64(pkts)) || 248 if (nla_put_be64(skb, CTA_COUNTERS_PACKETS, cpu_to_be64(pkts),
249 nla_put_be64(skb, CTA_COUNTERS_BYTES, cpu_to_be64(bytes))) 249 CTA_COUNTERS_PAD) ||
250 nla_put_be64(skb, CTA_COUNTERS_BYTES, cpu_to_be64(bytes),
251 CTA_COUNTERS_PAD))
250 goto nla_put_failure; 252 goto nla_put_failure;
251 253
252 nla_nest_end(skb, nest_count); 254 nla_nest_end(skb, nest_count);
@@ -287,9 +289,11 @@ ctnetlink_dump_timestamp(struct sk_buff *skb, const struct nf_conn *ct)
287 if (!nest_count) 289 if (!nest_count)
288 goto nla_put_failure; 290 goto nla_put_failure;
289 291
290 if (nla_put_be64(skb, CTA_TIMESTAMP_START, cpu_to_be64(tstamp->start)) || 292 if (nla_put_be64(skb, CTA_TIMESTAMP_START, cpu_to_be64(tstamp->start),
293 CTA_TIMESTAMP_PAD) ||
291 (tstamp->stop != 0 && nla_put_be64(skb, CTA_TIMESTAMP_STOP, 294 (tstamp->stop != 0 && nla_put_be64(skb, CTA_TIMESTAMP_STOP,
292 cpu_to_be64(tstamp->stop)))) 295 cpu_to_be64(tstamp->stop),
296 CTA_TIMESTAMP_PAD)))
293 goto nla_put_failure; 297 goto nla_put_failure;
294 nla_nest_end(skb, nest_count); 298 nla_nest_end(skb, nest_count);
295 299
@@ -562,8 +566,8 @@ ctnetlink_acct_size(const struct nf_conn *ct)
562 if (!nf_ct_ext_exist(ct, NF_CT_EXT_ACCT)) 566 if (!nf_ct_ext_exist(ct, NF_CT_EXT_ACCT))
563 return 0; 567 return 0;
564 return 2 * nla_total_size(0) /* CTA_COUNTERS_ORIG|REPL */ 568 return 2 * nla_total_size(0) /* CTA_COUNTERS_ORIG|REPL */
565 + 2 * nla_total_size(sizeof(uint64_t)) /* CTA_COUNTERS_PACKETS */ 569 + 2 * nla_total_size_64bit(sizeof(uint64_t)) /* CTA_COUNTERS_PACKETS */
566 + 2 * nla_total_size(sizeof(uint64_t)) /* CTA_COUNTERS_BYTES */ 570 + 2 * nla_total_size_64bit(sizeof(uint64_t)) /* CTA_COUNTERS_BYTES */
567 ; 571 ;
568} 572}
569 573
@@ -590,7 +594,7 @@ ctnetlink_timestamp_size(const struct nf_conn *ct)
590#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP 594#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
591 if (!nf_ct_ext_exist(ct, NF_CT_EXT_TSTAMP)) 595 if (!nf_ct_ext_exist(ct, NF_CT_EXT_TSTAMP))
592 return 0; 596 return 0;
593 return nla_total_size(0) + 2 * nla_total_size(sizeof(uint64_t)); 597 return nla_total_size(0) + 2 * nla_total_size_64bit(sizeof(uint64_t));
594#else 598#else
595 return 0; 599 return 0;
596#endif 600#endif
diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
index fce1b1cca32d..399a38fd685a 100644
--- a/net/netfilter/nf_conntrack_proto_dccp.c
+++ b/net/netfilter/nf_conntrack_proto_dccp.c
@@ -645,7 +645,8 @@ static int dccp_to_nlattr(struct sk_buff *skb, struct nlattr *nla,
645 nla_put_u8(skb, CTA_PROTOINFO_DCCP_ROLE, 645 nla_put_u8(skb, CTA_PROTOINFO_DCCP_ROLE,
646 ct->proto.dccp.role[IP_CT_DIR_ORIGINAL]) || 646 ct->proto.dccp.role[IP_CT_DIR_ORIGINAL]) ||
647 nla_put_be64(skb, CTA_PROTOINFO_DCCP_HANDSHAKE_SEQ, 647 nla_put_be64(skb, CTA_PROTOINFO_DCCP_HANDSHAKE_SEQ,
648 cpu_to_be64(ct->proto.dccp.handshake_seq))) 648 cpu_to_be64(ct->proto.dccp.handshake_seq),
649 CTA_PROTOINFO_DCCP_PAD))
649 goto nla_put_failure; 650 goto nla_put_failure;
650 nla_nest_end(skb, nest_parms); 651 nla_nest_end(skb, nest_parms);
651 spin_unlock_bh(&ct->lock); 652 spin_unlock_bh(&ct->lock);
@@ -660,6 +661,7 @@ static const struct nla_policy dccp_nla_policy[CTA_PROTOINFO_DCCP_MAX + 1] = {
660 [CTA_PROTOINFO_DCCP_STATE] = { .type = NLA_U8 }, 661 [CTA_PROTOINFO_DCCP_STATE] = { .type = NLA_U8 },
661 [CTA_PROTOINFO_DCCP_ROLE] = { .type = NLA_U8 }, 662 [CTA_PROTOINFO_DCCP_ROLE] = { .type = NLA_U8 },
662 [CTA_PROTOINFO_DCCP_HANDSHAKE_SEQ] = { .type = NLA_U64 }, 663 [CTA_PROTOINFO_DCCP_HANDSHAKE_SEQ] = { .type = NLA_U64 },
664 [CTA_PROTOINFO_DCCP_PAD] = { .type = NLA_UNSPEC },
663}; 665};
664 666
665static int nlattr_to_dccp(struct nlattr *cda[], struct nf_conn *ct) 667static int nlattr_to_dccp(struct nlattr *cda[], struct nf_conn *ct)
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 2011977cd79d..7a85a9dd37ad 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -944,8 +944,10 @@ static int nft_dump_stats(struct sk_buff *skb, struct nft_stats __percpu *stats)
944 if (nest == NULL) 944 if (nest == NULL)
945 goto nla_put_failure; 945 goto nla_put_failure;
946 946
947 if (nla_put_be64(skb, NFTA_COUNTER_PACKETS, cpu_to_be64(total.pkts)) || 947 if (nla_put_be64(skb, NFTA_COUNTER_PACKETS, cpu_to_be64(total.pkts),
948 nla_put_be64(skb, NFTA_COUNTER_BYTES, cpu_to_be64(total.bytes))) 948 NFTA_COUNTER_PAD) ||
949 nla_put_be64(skb, NFTA_COUNTER_BYTES, cpu_to_be64(total.bytes),
950 NFTA_COUNTER_PAD))
949 goto nla_put_failure; 951 goto nla_put_failure;
950 952
951 nla_nest_end(skb, nest); 953 nla_nest_end(skb, nest);
@@ -975,7 +977,8 @@ static int nf_tables_fill_chain_info(struct sk_buff *skb, struct net *net,
975 977
976 if (nla_put_string(skb, NFTA_CHAIN_TABLE, table->name)) 978 if (nla_put_string(skb, NFTA_CHAIN_TABLE, table->name))
977 goto nla_put_failure; 979 goto nla_put_failure;
978 if (nla_put_be64(skb, NFTA_CHAIN_HANDLE, cpu_to_be64(chain->handle))) 980 if (nla_put_be64(skb, NFTA_CHAIN_HANDLE, cpu_to_be64(chain->handle),
981 NFTA_CHAIN_PAD))
979 goto nla_put_failure; 982 goto nla_put_failure;
980 if (nla_put_string(skb, NFTA_CHAIN_NAME, chain->name)) 983 if (nla_put_string(skb, NFTA_CHAIN_NAME, chain->name))
981 goto nla_put_failure; 984 goto nla_put_failure;
@@ -1803,13 +1806,15 @@ static int nf_tables_fill_rule_info(struct sk_buff *skb, struct net *net,
1803 goto nla_put_failure; 1806 goto nla_put_failure;
1804 if (nla_put_string(skb, NFTA_RULE_CHAIN, chain->name)) 1807 if (nla_put_string(skb, NFTA_RULE_CHAIN, chain->name))
1805 goto nla_put_failure; 1808 goto nla_put_failure;
1806 if (nla_put_be64(skb, NFTA_RULE_HANDLE, cpu_to_be64(rule->handle))) 1809 if (nla_put_be64(skb, NFTA_RULE_HANDLE, cpu_to_be64(rule->handle),
1810 NFTA_RULE_PAD))
1807 goto nla_put_failure; 1811 goto nla_put_failure;
1808 1812
1809 if ((event != NFT_MSG_DELRULE) && (rule->list.prev != &chain->rules)) { 1813 if ((event != NFT_MSG_DELRULE) && (rule->list.prev != &chain->rules)) {
1810 prule = list_entry(rule->list.prev, struct nft_rule, list); 1814 prule = list_entry(rule->list.prev, struct nft_rule, list);
1811 if (nla_put_be64(skb, NFTA_RULE_POSITION, 1815 if (nla_put_be64(skb, NFTA_RULE_POSITION,
1812 cpu_to_be64(prule->handle))) 1816 cpu_to_be64(prule->handle),
1817 NFTA_RULE_PAD))
1813 goto nla_put_failure; 1818 goto nla_put_failure;
1814 } 1819 }
1815 1820
@@ -2473,7 +2478,8 @@ static int nf_tables_fill_set(struct sk_buff *skb, const struct nft_ctx *ctx,
2473 } 2478 }
2474 2479
2475 if (set->timeout && 2480 if (set->timeout &&
2476 nla_put_be64(skb, NFTA_SET_TIMEOUT, cpu_to_be64(set->timeout))) 2481 nla_put_be64(skb, NFTA_SET_TIMEOUT, cpu_to_be64(set->timeout),
2482 NFTA_SET_PAD))
2477 goto nla_put_failure; 2483 goto nla_put_failure;
2478 if (set->gc_int && 2484 if (set->gc_int &&
2479 nla_put_be32(skb, NFTA_SET_GC_INTERVAL, htonl(set->gc_int))) 2485 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,
3076 3082
3077 if (nft_set_ext_exists(ext, NFT_SET_EXT_TIMEOUT) && 3083 if (nft_set_ext_exists(ext, NFT_SET_EXT_TIMEOUT) &&
3078 nla_put_be64(skb, NFTA_SET_ELEM_TIMEOUT, 3084 nla_put_be64(skb, NFTA_SET_ELEM_TIMEOUT,
3079 cpu_to_be64(*nft_set_ext_timeout(ext)))) 3085 cpu_to_be64(*nft_set_ext_timeout(ext)),
3086 NFTA_SET_ELEM_PAD))
3080 goto nla_put_failure; 3087 goto nla_put_failure;
3081 3088
3082 if (nft_set_ext_exists(ext, NFT_SET_EXT_EXPIRATION)) { 3089 if (nft_set_ext_exists(ext, NFT_SET_EXT_EXPIRATION)) {
@@ -3089,7 +3096,8 @@ static int nf_tables_fill_setelem(struct sk_buff *skb,
3089 expires = 0; 3096 expires = 0;
3090 3097
3091 if (nla_put_be64(skb, NFTA_SET_ELEM_EXPIRATION, 3098 if (nla_put_be64(skb, NFTA_SET_ELEM_EXPIRATION,
3092 cpu_to_be64(jiffies_to_msecs(expires)))) 3099 cpu_to_be64(jiffies_to_msecs(expires)),
3100 NFTA_SET_ELEM_PAD))
3093 goto nla_put_failure; 3101 goto nla_put_failure;
3094 } 3102 }
3095 3103
diff --git a/net/netfilter/nf_tables_trace.c b/net/netfilter/nf_tables_trace.c
index e9e959f65d91..39eb1cc62e91 100644
--- a/net/netfilter/nf_tables_trace.c
+++ b/net/netfilter/nf_tables_trace.c
@@ -156,7 +156,8 @@ static int nf_trace_fill_rule_info(struct sk_buff *nlskb,
156 return 0; 156 return 0;
157 157
158 return nla_put_be64(nlskb, NFTA_TRACE_RULE_HANDLE, 158 return nla_put_be64(nlskb, NFTA_TRACE_RULE_HANDLE,
159 cpu_to_be64(info->rule->handle)); 159 cpu_to_be64(info->rule->handle),
160 NFTA_TRACE_PAD);
160} 161}
161 162
162void nft_trace_notify(struct nft_traceinfo *info) 163void nft_trace_notify(struct nft_traceinfo *info)
@@ -174,7 +175,7 @@ void nft_trace_notify(struct nft_traceinfo *info)
174 size = nlmsg_total_size(sizeof(struct nfgenmsg)) + 175 size = nlmsg_total_size(sizeof(struct nfgenmsg)) +
175 nla_total_size(NFT_TABLE_MAXNAMELEN) + 176 nla_total_size(NFT_TABLE_MAXNAMELEN) +
176 nla_total_size(NFT_CHAIN_MAXNAMELEN) + 177 nla_total_size(NFT_CHAIN_MAXNAMELEN) +
177 nla_total_size(sizeof(__be64)) + /* rule handle */ 178 nla_total_size_64bit(sizeof(__be64)) + /* rule handle */
178 nla_total_size(sizeof(__be32)) + /* trace type */ 179 nla_total_size(sizeof(__be32)) + /* trace type */
179 nla_total_size(0) + /* VERDICT, nested */ 180 nla_total_size(0) + /* VERDICT, nested */
180 nla_total_size(sizeof(u32)) + /* verdict code */ 181 nla_total_size(sizeof(u32)) + /* verdict code */
diff --git a/net/netfilter/nfnetlink_acct.c b/net/netfilter/nfnetlink_acct.c
index 4c2b4c0c4d5f..d016066a25e3 100644
--- a/net/netfilter/nfnetlink_acct.c
+++ b/net/netfilter/nfnetlink_acct.c
@@ -160,15 +160,18 @@ nfnl_acct_fill_info(struct sk_buff *skb, u32 portid, u32 seq, u32 type,
160 pkts = atomic64_read(&acct->pkts); 160 pkts = atomic64_read(&acct->pkts);
161 bytes = atomic64_read(&acct->bytes); 161 bytes = atomic64_read(&acct->bytes);
162 } 162 }
163 if (nla_put_be64(skb, NFACCT_PKTS, cpu_to_be64(pkts)) || 163 if (nla_put_be64(skb, NFACCT_PKTS, cpu_to_be64(pkts),
164 nla_put_be64(skb, NFACCT_BYTES, cpu_to_be64(bytes)) || 164 NFACCT_PAD) ||
165 nla_put_be64(skb, NFACCT_BYTES, cpu_to_be64(bytes),
166 NFACCT_PAD) ||
165 nla_put_be32(skb, NFACCT_USE, htonl(atomic_read(&acct->refcnt)))) 167 nla_put_be32(skb, NFACCT_USE, htonl(atomic_read(&acct->refcnt))))
166 goto nla_put_failure; 168 goto nla_put_failure;
167 if (acct->flags & NFACCT_F_QUOTA) { 169 if (acct->flags & NFACCT_F_QUOTA) {
168 u64 *quota = (u64 *)acct->data; 170 u64 *quota = (u64 *)acct->data;
169 171
170 if (nla_put_be32(skb, NFACCT_FLAGS, htonl(old_flags)) || 172 if (nla_put_be32(skb, NFACCT_FLAGS, htonl(old_flags)) ||
171 nla_put_be64(skb, NFACCT_QUOTA, cpu_to_be64(*quota))) 173 nla_put_be64(skb, NFACCT_QUOTA, cpu_to_be64(*quota),
174 NFACCT_PAD))
172 goto nla_put_failure; 175 goto nla_put_failure;
173 } 176 }
174 nlmsg_end(skb, nlh); 177 nlmsg_end(skb, nlh);
diff --git a/net/netfilter/nft_counter.c b/net/netfilter/nft_counter.c
index c9743f78f219..77db8358ab14 100644
--- a/net/netfilter/nft_counter.c
+++ b/net/netfilter/nft_counter.c
@@ -76,8 +76,10 @@ static int nft_counter_dump(struct sk_buff *skb, const struct nft_expr *expr)
76 76
77 nft_counter_fetch(priv->counter, &total); 77 nft_counter_fetch(priv->counter, &total);
78 78
79 if (nla_put_be64(skb, NFTA_COUNTER_BYTES, cpu_to_be64(total.bytes)) || 79 if (nla_put_be64(skb, NFTA_COUNTER_BYTES, cpu_to_be64(total.bytes),
80 nla_put_be64(skb, NFTA_COUNTER_PACKETS, cpu_to_be64(total.packets))) 80 NFTA_COUNTER_PAD) ||
81 nla_put_be64(skb, NFTA_COUNTER_PACKETS, cpu_to_be64(total.packets),
82 NFTA_COUNTER_PAD))
81 goto nla_put_failure; 83 goto nla_put_failure;
82 return 0; 84 return 0;
83 85
diff --git a/net/netfilter/nft_dynset.c b/net/netfilter/nft_dynset.c
index 9dec3bd1b63c..78d4914fb39c 100644
--- a/net/netfilter/nft_dynset.c
+++ b/net/netfilter/nft_dynset.c
@@ -227,7 +227,8 @@ static int nft_dynset_dump(struct sk_buff *skb, const struct nft_expr *expr)
227 goto nla_put_failure; 227 goto nla_put_failure;
228 if (nla_put_string(skb, NFTA_DYNSET_SET_NAME, priv->set->name)) 228 if (nla_put_string(skb, NFTA_DYNSET_SET_NAME, priv->set->name))
229 goto nla_put_failure; 229 goto nla_put_failure;
230 if (nla_put_be64(skb, NFTA_DYNSET_TIMEOUT, cpu_to_be64(priv->timeout))) 230 if (nla_put_be64(skb, NFTA_DYNSET_TIMEOUT, cpu_to_be64(priv->timeout),
231 NFTA_DYNSET_PAD))
231 goto nla_put_failure; 232 goto nla_put_failure;
232 if (priv->expr && nft_expr_dump(skb, NFTA_DYNSET_EXPR, priv->expr)) 233 if (priv->expr && nft_expr_dump(skb, NFTA_DYNSET_EXPR, priv->expr))
233 goto nla_put_failure; 234 goto nla_put_failure;
diff --git a/net/netfilter/nft_limit.c b/net/netfilter/nft_limit.c
index 99d18578afc6..070b98938e02 100644
--- a/net/netfilter/nft_limit.c
+++ b/net/netfilter/nft_limit.c
@@ -97,8 +97,10 @@ static int nft_limit_dump(struct sk_buff *skb, const struct nft_limit *limit,
97 u64 secs = div_u64(limit->nsecs, NSEC_PER_SEC); 97 u64 secs = div_u64(limit->nsecs, NSEC_PER_SEC);
98 u64 rate = limit->rate - limit->burst; 98 u64 rate = limit->rate - limit->burst;
99 99
100 if (nla_put_be64(skb, NFTA_LIMIT_RATE, cpu_to_be64(rate)) || 100 if (nla_put_be64(skb, NFTA_LIMIT_RATE, cpu_to_be64(rate),
101 nla_put_be64(skb, NFTA_LIMIT_UNIT, cpu_to_be64(secs)) || 101 NFTA_LIMIT_PAD) ||
102 nla_put_be64(skb, NFTA_LIMIT_UNIT, cpu_to_be64(secs),
103 NFTA_LIMIT_PAD) ||
102 nla_put_be32(skb, NFTA_LIMIT_BURST, htonl(limit->burst)) || 104 nla_put_be32(skb, NFTA_LIMIT_BURST, htonl(limit->burst)) ||
103 nla_put_be32(skb, NFTA_LIMIT_TYPE, htonl(type)) || 105 nla_put_be32(skb, NFTA_LIMIT_TYPE, htonl(type)) ||
104 nla_put_be32(skb, NFTA_LIMIT_FLAGS, htonl(flags))) 106 nla_put_be32(skb, NFTA_LIMIT_FLAGS, htonl(flags)))