Skip to content

Commit d271e8b

Browse files
vaesookaber
authored andcommitted
ctnetlink: compute generic part of event more acurately
On a box with most of the optional Netfilter switches turned off some of the NLAs are never send, e. g. secmark, mark or the conntrack byte/packet counters. As a worst case scenario this may possibly still lead to ctnetlink skbs being reallocated in netlink_trim() later, loosing all the nice effects from the previous patches. I try to solve that (at least partly) by correctly #ifdef'ing the NLAs in the computation. Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org> Signed-off-by: Patrick McHardy <kaber@trash.net>
1 parent a400c30 commit d271e8b

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎net/netfilter/nf_conntrack_netlink.c‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,19 +441,28 @@ ctnetlink_alloc_skb(const struct nf_conntrack_tuple *tuple, gfp_t gfp)
441441
+ 3 * NLA_TYPE_SIZE(u_int8_t) /* CTA_PROTO_NUM */
442442
+ NLA_TYPE_SIZE(u_int32_t) /* CTA_ID */
443443
+ NLA_TYPE_SIZE(u_int32_t) /* CTA_STATUS */
444+
#ifdef CONFIG_NF_CT_ACCT
444445
+ 2 * nla_total_size(0) /* CTA_COUNTERS_ORIG|REPL */
445446
+ 2 * NLA_TYPE_SIZE(uint64_t) /* CTA_COUNTERS_PACKETS */
446447
+ 2 * NLA_TYPE_SIZE(uint64_t) /* CTA_COUNTERS_BYTES */
448+
#endif
447449
+ NLA_TYPE_SIZE(u_int32_t) /* CTA_TIMEOUT */
448450
+ nla_total_size(0) /* CTA_PROTOINFO */
449451
+ nla_total_size(0) /* CTA_HELP */
450452
+ nla_total_size(NF_CT_HELPER_NAME_LEN) /* CTA_HELP_NAME */
453+
#ifdef CONFIG_NF_CONNTRACK_SECMARK
451454
+ NLA_TYPE_SIZE(u_int32_t) /* CTA_SECMARK */
455+
#endif
456+
#ifdef CONFIG_NF_NAT_NEEDED
452457
+ 2 * nla_total_size(0) /* CTA_NAT_SEQ_ADJ_ORIG|REPL */
453458
+ 2 * NLA_TYPE_SIZE(u_int32_t) /* CTA_NAT_SEQ_CORRECTION_POS */
454459
+ 2 * NLA_TYPE_SIZE(u_int32_t) /* CTA_NAT_SEQ_CORRECTION_BEFORE */
455460
+ 2 * NLA_TYPE_SIZE(u_int32_t) /* CTA_NAT_SEQ_CORRECTION_AFTER */
456-
+ NLA_TYPE_SIZE(u_int32_t); /* CTA_MARK */
461+
#endif
462+
#ifdef CONFIG_NF_CONNTRACK_MARK
463+
+ NLA_TYPE_SIZE(u_int32_t) /* CTA_MARK */
464+
#endif
465+
;
457466

458467
#undef NLA_TYPE_SIZE
459468

0 commit comments

Comments
 (0)