From: Nuutti Kotivuori <naked@iki.fi>
To: Harald Welte <laforge@netfilter.org>
Cc: netfilter-devel@lists.netfilter.org
Subject: Re: [PATCH] Very first try: ipt_connrate patch.
Date: Thu, 19 Feb 2004 21:05:25 +0200 [thread overview]
Message-ID: <87znbe7uve.fsf@iki.fi> (raw)
In-Reply-To: <20040219182818.GF4797@sunbeam.de.gnumonks.org> (Harald Welte's message of "Thu, 19 Feb 2004 19:28:18 +0100")
Harald Welte wrote:
> On Mon, Feb 16, 2004 at 04:22:11AM +0200, Nuutti Kotivuori wrote:
>> This is intentional. 'prev' is used to store a jiffies value, as by
>> the comment - which is an unsigned long on all platforms I
>> believe. 'avgrate' is again something calculated internally in the
>> algorithm, and it should be 32 bits to keep the assumptions I make
>> valid.
>
> the issue is sparc64, which has 32bit userspace and 64bit
> kernelspace. So libipt_XX.c will be compiled with a 32bit unsigned
> long, and the kernel with a 64bit unsigned long :(
Ah, right! There's a mixup between two things here.
First of all, you are correct, struct ipt_connrate_info is at fault:
,----
| struct ipt_connrate_info
| {
| /* Per connection transfer rate, in bytes per second. If
| 'from' is smaller or equal to 'to', rate is matched to be
| inside the inclusive range [from,to], otherwise rate is
| matched to be outside the inclusive range [to,from]. */
| unsigned long from, to;
| };
`----
And that was just a mistake from my side - I will change them to be
u_int32_t. The value they compare against is already u_int32_t.
But, the other structure, namely ip_conntrack_rate:
,----
| struct ip_conntrack_rate {
| /* jiffies of previous received packet */
| unsigned long prev;
| /* average rate of tokens per jiffy */
| u_int32_t avgrate;
| };
`----
This is a part of the ip_conntrack struct. This structure seems to be
inside #ifdef __KERNEL__ to begin with, and there are no need for
userspace software to access it. So I believe it is fine.
But if it would be needed from userspace, what is the correct datatype
that will hold a kernel jiffies value both inside the kernel and in
userspace?
Thanks,
-- Naked
next prev parent reply other threads:[~2004-02-19 19:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-08 19:56 [PATCH] Very first try: ipt_connrate patch Nuutti Kotivuori
2004-02-14 20:14 ` Harald Welte
2004-02-16 2:22 ` Nuutti Kotivuori
2004-02-19 18:28 ` Harald Welte
2004-02-19 19:05 ` Nuutti Kotivuori [this message]
2004-02-16 11:18 ` Patrick McHardy
2004-02-16 12:34 ` Nuutti Kotivuori
2004-02-16 13:07 ` Patrick McHardy
2004-02-16 16:19 ` Nuutti Kotivuori
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=87znbe7uve.fsf@iki.fi \
--to=naked@iki.fi \
--cc=laforge@netfilter.org \
--cc=netfilter-devel@lists.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.