netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Pirko <jpirko@redhat.com>
To: Patrick McHardy <kaber@trash.net>
Cc: netdev@vger.kernel.org, netfilter-devel@vger.kernel.org,
	netfilter@vger.kernel.org, davem@davemloft.net,
	Krzysztof Oledzki <ole@ans.pl>
Subject: Re: [net-next-2.6 PATCH] netfilter: ctnetlink: compute message size properly
Date: Wed, 31 Mar 2010 20:21:17 +0200	[thread overview]
Message-ID: <20100331182116.GB2822@psychotron.redhat.com> (raw)
In-Reply-To: <4BB38A8A.9050501@trash.net>

Wed, Mar 31, 2010 at 07:46:50PM CEST, kaber@trash.net wrote:
>Jiri Pirko wrote:
>> Message size should be dependent on net->ct.sysctl_acct, not on
>> CONFIG_NF_CT_ACCT definition.
>
>Krzysztof actually wanted to get rid of the config option entirely
>some time ago, but at that time there were some (now solved) problems
>that prevented his. I've CCed him, hoping that this will finally
>get completed :)
>
>> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
>> 
>> diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
>> index 569410a..2b0cfa4 100644
>> --- a/net/netfilter/nf_conntrack_netlink.c
>> +++ b/net/netfilter/nf_conntrack_netlink.c
>> @@ -426,6 +426,19 @@ ctnetlink_proto_size(const struct nf_conn *ct)
>>  }
>>  
>>  static inline size_t
>> +ctnetlink_counters_size(const struct nf_conn *ct)
>> +{
>> +	struct net *net = nf_ct_net(ct);
>> +
>> +	if (!net->ct.sysctl_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 */
>> +	       ;
>
>This is also not fully correct since the sysctl only affects newly
>created conntracks, existing ones still have counters that are dumped.
>I'd suggest to simple check whether the conntrack has an accounting
>extension.

Okay, I see your point. How about this:

Subject: [net-next-2.6 PATCH] netfilter: ctnetlink: compute message size properly V2

Message size should be dependent on net->ct.sysctl_acct, not on
CONFIG_NF_CT_ACCT definition.

Signed-off-by: Jiri Pirko <jpirko@redhat.com>

diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 569410a..44487d8 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -426,6 +426,17 @@ ctnetlink_proto_size(const struct nf_conn *ct)
 }
 
 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
 ctnetlink_nlmsg_size(const struct nf_conn *ct)
 {
 	return NLMSG_ALIGN(sizeof(struct nfgenmsg))
@@ -435,11 +446,7 @@ ctnetlink_nlmsg_size(const struct nf_conn *ct)
 	       + 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_STATUS */
-#ifdef CONFIG_NF_CT_ACCT
-	       + 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
+	       + ctnetlink_counters_size(ct)
 	       + nla_total_size(sizeof(u_int32_t)) /* CTA_TIMEOUT */
 	       + nla_total_size(0) /* CTA_PROTOINFO */
 	       + nla_total_size(0) /* CTA_HELP */

  reply	other threads:[~2010-03-31 18:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-31 15:11 [net-next-2.6 PATCH] netfilter: ctnetlink: compute message size properly Jiri Pirko
2010-03-31 17:46 ` Patrick McHardy
2010-03-31 18:21   ` Jiri Pirko [this message]
2010-03-31 18:35     ` Eric Dumazet
2010-04-01 10:40       ` Patrick McHardy
2010-04-01 10:43         ` Jiri Pirko
2010-04-01 10:50           ` Patrick McHardy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100331182116.GB2822@psychotron.redhat.com \
    --to=jpirko@redhat.com \
    --cc=davem@davemloft.net \
    --cc=kaber@trash.net \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=netfilter@vger.kernel.org \
    --cc=ole@ans.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).