From: Laszlo Valko <valko@linux.karinthy.hu>
To: Chris Wilson <chris@netservers.co.uk>
Cc: netfilter-devel@lists.netfilter.org
Subject: Re: [PATCH] New match module: byte rate match
Date: Tue, 21 Jan 2003 16:51:52 +0100 [thread overview]
Message-ID: <20030121165152.A24205@linux.karinthy.hu> (raw)
In-Reply-To: <Pine.LNX.4.44.0301161438250.2232-100000@localhost>; from chris@netservers.co.uk on Mon, Jan 20, 2003 at 03:58:19PM +0000
On Mon, Jan 20, 2003 at 03:58:19PM +0000, Chris Wilson wrote:
> Hi all,
>
> NetServers.co.uk would like to submit a new module for your perusal and
> hopefully for inclusion in Netfilter. It's based on ipt_limit, but matches
> the number of bytes per second instead of the number of packets. This
> means that it can be used for basic quality-of-service implementation,
> thus:
Hi Chris!
Please consider fixing this structure:
struct ipt_bytelimit_info {
/* Public parameters, supplied from user space */
u_int32_t rate; /* Number of bytes credited per second */
u_int32_t credit_cap; /* Maximum credit which may accumulate */
/* Used internally by the kernel */
u_int32_t jiffy_rate; /* Number of bytes credited per jiffy */
unsigned long prev; /* Time of last match, in jiffies */
u_int32_t credit; /* Current balance */
};
Using unsigned long in there will make your code inoperable on 64bit
platforms with 32bit userspace. Please change it to something similar
to this one:
struct ipt_bytelimit_info {
/* Public parameters, supplied from user space */
u_int32_t rate; /* Number of bytes credited per second */
u_int32_t credit_cap; /* Maximum credit which may accumulate */
/* Used internally by the kernel */
u_int32_t jiffy_rate; /* Number of bytes credited per jiffy */
u_int32_t credit; /* Current balance */
union {
unsigned long prev; /* Time of last match, in jiffies */
u_int8_t padding[8]; /* Cover prev always */
} u;
};
Moving credit field upwards one slot will make the structure more
compact on 64bit platforms (24 bytes instead of 28).
You might as well eliminate unsigned long totally, but I'm not sure
whether it's easy considering that jiffies is unsigned long.
Also this is incorrect as r->credit is not of type int,
DEBUGP("ipt_bytelimit: accepted %d bytes, "
"remaining credit %d\n", packet_size, r->credit);
so you should use the appropriate format specifier (%lu for unsigned long).
I know ipt_limit (that your module is based on) is broken as well,
but it's not easy to fix it without breaking compatibility. On the other
hand, we should not replicating a broken interface...
Laszlo
next prev parent reply other threads:[~2003-01-21 15:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-20 15:58 [PATCH] New match module: byte rate match Chris Wilson
2003-01-21 10:38 ` Nigel Kukard
2003-01-21 15:51 ` Laszlo Valko [this message]
2003-01-21 17:12 ` Chris Wilson
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=20030121165152.A24205@linux.karinthy.hu \
--to=valko@linux.karinthy.hu \
--cc=chris@netservers.co.uk \
--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.