All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: Krzysztof Oledzki <ole@ans.pl>
Cc: netfilter-devel@lists.netfilter.org,
	Krzysztof Oledzki <olenf@ans.pl>,
	Pablo Neira Ayuso <pablo@netfilter.org>
Subject: Re: connbytes & 64bit counters
Date: Thu, 23 Nov 2006 15:05:59 +0100	[thread overview]
Message-ID: <4565AAC7.8050702@trash.net> (raw)
In-Reply-To: <Pine.LNX.4.64.0610302055060.3941@bizon.gios.gov.pl>

Krzysztof Oledzki wrote:
> 
> 
> On Mon, 30 Oct 2006, Patrick McHardy wrote:
> 
>> Krzysztof Oledzki wrote:
>>
>>> [NETFILTER] Reimplementation of 64bit counters for bytes/packets
>>> accounting
>>>
>>> Initially netfilter has had 64bit counters for conntrack-based
>>> accounting, but
>>> it was changed in 2.6.14 to save memory. Unfortunately in-kernel 64bit
>>> counters are
>>> still required, for example for "connbytes" extension. Add possibility
>>> to choose
>>> between 32 and 64bits but keep default 32bit counters.
>>>
>>> Signed-off-by: Krzysztof Piotr Oledzki <ole@ans.pl>
>>>
>>> +++ linux-2.6.19-rc3/net/netfilter/nf_conntrack_netlink.c    2006-10-28
>>> 18:24:12.000000000 +0200
>>> @@ -194,13 +194,23 @@
>>>  {
>>>      enum ctattr_type type = dir ? CTA_COUNTERS_REPLY:
>>> CTA_COUNTERS_ORIG;
>>>      struct nfattr *nest_count = NFA_NEST(skb, type);
>>> -    u_int32_t tmp;
>>> +#ifdef CONFIG_NF_CT_ACCT_64BIT_COUNTERS
>>> +    __be64 tmp;
>>> +
>>> +    tmp = cpu_to_be64(ct->counters[dir].packets);
>>> +    NFA_PUT(skb, CTA_COUNTERS_PACKETS, sizeof(__be64), &tmp);
>>> +
>>> +    tmp = cpu_to_be64(ct->counters[dir].bytes);
>>> +    NFA_PUT(skb, CTA_COUNTERS_BYTES, sizeof(__be64), &tmp);
>>> +#else
>>
>>
>> We can't make the API depend on config options
> 
> But this does not change the API imho, and this situation is perfectly
> handled by libnetfilter_conntrack:


It does change the API since we currently use u32. But you're
right that it shouldn't break anything (even if something
besides libnetfilter_conntrack uses the raw attributes) since
we use big endian.

>> (and I don't like all those ifdefs).
> 
> Why?

Because they make the code ugly and unreadable.

>> For now I would suggest to keep the ctnetlink interface as it is and
>> use 64 bit counters either unconditionally or only when the connbytes
>> match is enabled.
> 
> 
> What is wrong in sending 64 bit counters to userspace if we already have
> 64 bit counters in kernel?

Nothing - but changing the API based on config options is bad design.
I am fine with sending 64 bit unconditionally. But you need to make
sure you don't send (32 bit) overflow events to userspace anymore.

Mhh .. this hole thing is a mess:

enum ctattr_counters {
        CTA_COUNTERS_UNSPEC,
        CTA_COUNTERS_PACKETS,           /* old 64bit counters */
        CTA_COUNTERS_BYTES,             /* old 64bit counters */
        CTA_COUNTERS32_PACKETS,
        CTA_COUNTERS32_BYTES,

        __CTA_COUNTERS_MAX
};

So apparently we already broke compatibility. My prefered solution would
be to get rid of this mess and return to 64 bit counters unconditionally
and everywhere.

  reply	other threads:[~2006-11-23 14:05 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-24 22:53 connbytes & 64bit counters Krzysztof Oledzki
2006-10-25 22:20 ` Patrick McHardy
2006-10-28 16:48   ` Krzysztof Oledzki
2006-10-30 12:01     ` Amin Azez
2006-10-30 15:54     ` Patrick McHardy
2006-10-30 20:01       ` Krzysztof Oledzki
2006-11-23 14:05         ` Patrick McHardy [this message]
2006-11-23 21:04           ` Pablo Neira Ayuso
2006-11-24  9:09             ` Patrick McHardy
2006-12-25  1:59               ` Krzysztof Oledzki
2007-01-10 13:36                 ` Patrick McHardy
2007-01-15 10:45                   ` Krzysztof Oledzki
2007-01-15 14:37                     ` Patrick McHardy
2007-07-20 22:13                       ` Krzysztof Oledzki
2007-07-20 22:42                         ` Krzysztof Oledzki
2007-07-21  4:18                           ` Patrick McHardy
2007-07-21 16:38                             ` Jan Engelhardt
2007-07-23  2:27                             ` Yasuyuki KOZAKAI
     [not found]                             ` <200707230227.l6N2R1hs010163@toshiba.co.jp>
2007-08-06 11:30                               ` Krzysztof Oledzki
2007-08-29 11:31                                 ` Krzysztof Oledzki
2006-11-01 15:08       ` Amin Azez

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=4565AAC7.8050702@trash.net \
    --to=kaber@trash.net \
    --cc=netfilter-devel@lists.netfilter.org \
    --cc=ole@ans.pl \
    --cc=olenf@ans.pl \
    --cc=pablo@netfilter.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.