netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net-next-2.6 PATCH] netfilter: ctnetlink: compute message size properly
@ 2010-03-31 15:11 Jiri Pirko
  2010-03-31 17:46 ` Patrick McHardy
  0 siblings, 1 reply; 7+ messages in thread
From: Jiri Pirko @ 2010-03-31 15:11 UTC (permalink / raw)
  To: netdev; +Cc: netfilter-devel, kaber, netfilter, davem

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..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 */
+	       ;
+}
+
+static inline size_t
 ctnetlink_nlmsg_size(const struct nf_conn *ct)
 {
 	return NLMSG_ALIGN(sizeof(struct nfgenmsg))
@@ -435,11 +448,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 */


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [net-next-2.6 PATCH] netfilter: ctnetlink: compute message size properly
  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
  0 siblings, 1 reply; 7+ messages in thread
From: Patrick McHardy @ 2010-03-31 17:46 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: netdev, netfilter-devel, netfilter, davem, Krzysztof Oledzki

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [net-next-2.6 PATCH] netfilter: ctnetlink: compute message size properly
  2010-03-31 17:46 ` Patrick McHardy
@ 2010-03-31 18:21   ` Jiri Pirko
  2010-03-31 18:35     ` Eric Dumazet
  0 siblings, 1 reply; 7+ messages in thread
From: Jiri Pirko @ 2010-03-31 18:21 UTC (permalink / raw)
  To: Patrick McHardy
  Cc: netdev, netfilter-devel, netfilter, davem, Krzysztof Oledzki

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 */

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [net-next-2.6 PATCH] netfilter: ctnetlink: compute message size properly
  2010-03-31 18:21   ` Jiri Pirko
@ 2010-03-31 18:35     ` Eric Dumazet
  2010-04-01 10:40       ` Patrick McHardy
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Dumazet @ 2010-03-31 18:35 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: Patrick McHardy, netdev, netfilter-devel, netfilter, davem,
	Krzysztof Oledzki

Le mercredi 31 mars 2010 à 20:21 +0200, Jiri Pirko a écrit :
> 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.
> 

Then Changelog is not updated with the actual test :)

> 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 */
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [net-next-2.6 PATCH] netfilter: ctnetlink: compute message size properly
  2010-03-31 18:35     ` Eric Dumazet
@ 2010-04-01 10:40       ` Patrick McHardy
  2010-04-01 10:43         ` Jiri Pirko
  0 siblings, 1 reply; 7+ messages in thread
From: Patrick McHardy @ 2010-04-01 10:40 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Jiri Pirko, netdev, netfilter-devel, netfilter, davem,
	Krzysztof Oledzki

Eric Dumazet wrote:
> Le mercredi 31 mars 2010 à 20:21 +0200, Jiri Pirko a écrit :
>> 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.
>>
> 
> Then Changelog is not updated with the actual test :)

I've fixed up the changelog and applied the patch, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [net-next-2.6 PATCH] netfilter: ctnetlink: compute message size properly
  2010-04-01 10:40       ` Patrick McHardy
@ 2010-04-01 10:43         ` Jiri Pirko
  2010-04-01 10:50           ` Patrick McHardy
  0 siblings, 1 reply; 7+ messages in thread
From: Jiri Pirko @ 2010-04-01 10:43 UTC (permalink / raw)
  To: Patrick McHardy
  Cc: Eric Dumazet, netdev, netfilter-devel, netfilter, davem,
	Krzysztof Oledzki

Thu, Apr 01, 2010 at 12:40:23PM CEST, kaber@trash.net wrote:
>Eric Dumazet wrote:
>> Le mercredi 31 mars 2010 à 20:21 +0200, Jiri Pirko a écrit :
>>> 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.
>>>
>> 
>> Then Changelog is not updated with the actual test :)
>
>I've fixed up the changelog and applied the patch, thanks.

Cand I ask on which tree?

thanks

Jirka

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [net-next-2.6 PATCH] netfilter: ctnetlink: compute message size properly
  2010-04-01 10:43         ` Jiri Pirko
@ 2010-04-01 10:50           ` Patrick McHardy
  0 siblings, 0 replies; 7+ messages in thread
From: Patrick McHardy @ 2010-04-01 10:50 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: Eric Dumazet, netdev, netfilter-devel, netfilter, davem,
	Krzysztof Oledzki

Jiri Pirko wrote:
> Thu, Apr 01, 2010 at 12:40:23PM CEST, kaber@trash.net wrote:
>> Eric Dumazet wrote:
>>> Le mercredi 31 mars 2010 à 20:21 +0200, Jiri Pirko a écrit :
>>>> 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.
>>>>
>>> Then Changelog is not updated with the actual test :)
>> I've fixed up the changelog and applied the patch, thanks.
> 
> Cand I ask on which tree?

Since this doesn't confirm to Dave's definition of crucial fixes,
I've applied it to nf-next-2.6.git :)

git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-next-2.6.git
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-04-01 16:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).