Commit d26e6a02 authored by Jiri Pirko's avatar Jiri Pirko Committed by Patrick McHardy

netfilter: ctnetlink: compute message size properly

Message size should be dependent on the presence of an accounting
extension, not on CONFIG_NF_CT_ACCT definition.
Signed-off-by: default avatarJiri Pirko <jpirko@redhat.com>
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
parent b4467288
...@@ -425,6 +425,17 @@ ctnetlink_proto_size(const struct nf_conn *ct) ...@@ -425,6 +425,17 @@ ctnetlink_proto_size(const struct nf_conn *ct)
return len; return len;
} }
static inline size_t
ctnetlink_counters_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 */
;
}
static inline size_t static inline size_t
ctnetlink_nlmsg_size(const struct nf_conn *ct) ctnetlink_nlmsg_size(const struct nf_conn *ct)
{ {
...@@ -435,11 +446,7 @@ ctnetlink_nlmsg_size(const struct nf_conn *ct) ...@@ -435,11 +446,7 @@ ctnetlink_nlmsg_size(const struct nf_conn *ct)
+ 3 * nla_total_size(sizeof(u_int8_t)) /* CTA_PROTO_NUM */ + 3 * nla_total_size(sizeof(u_int8_t)) /* CTA_PROTO_NUM */
+ nla_total_size(sizeof(u_int32_t)) /* CTA_ID */ + nla_total_size(sizeof(u_int32_t)) /* CTA_ID */
+ nla_total_size(sizeof(u_int32_t)) /* CTA_STATUS */ + nla_total_size(sizeof(u_int32_t)) /* CTA_STATUS */
#ifdef CONFIG_NF_CT_ACCT + ctnetlink_counters_size(ct)
+ 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 */
#endif
+ nla_total_size(sizeof(u_int32_t)) /* CTA_TIMEOUT */ + nla_total_size(sizeof(u_int32_t)) /* CTA_TIMEOUT */
+ nla_total_size(0) /* CTA_PROTOINFO */ + nla_total_size(0) /* CTA_PROTOINFO */
+ nla_total_size(0) /* CTA_HELP */ + nla_total_size(0) /* CTA_HELP */
......
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