From: John Lister <john.lister@kickstone.co.uk>
To: netfilter@vger.kernel.org
Subject: Statistic module nth problem
Date: Thu, 26 Feb 2009 20:49:25 +0000 [thread overview]
Message-ID: <49A70055.7090207@kickstone.co.uk> (raw)
In-Reply-To: <49A6F50D.6010405@kickstone.co.uk>
I've played with the nth function of the statistic module and i can't
seem to get it to work, This mirrors a previous post where it matches
each entry once and then doesn't match any more...
looking at the source code makes me surprised it does this unless i've
misunderstood completely...
from /net/netfilter/xt_statistic.c
static bool
statistic_mt(const struct sk_buff *skb, const struct net_device *in,
const struct net_device *out, const struct xt_match *match,
const void *matchinfo, int offset, unsigned int protoff,
bool *hotdrop)
{
struct xt_statistic_info *info = (struct xt_statistic_info *)matchinfo;
bool ret = info->flags & XT_STATISTIC_INVERT;
switch (info->mode) {
case XT_STATISTIC_MODE_RANDOM:
if ((net_random() & 0x7FFFFFFF) < info->u.random.probability)
ret = !ret;
break;
case XT_STATISTIC_MODE_NTH:
info = info->master;
spin_lock_bh(&nth_lock);
if (info->u.nth.count++ == info->u.nth.every) {
info->u.nth.count = 0;
ret = !ret;
}
spin_unlock_bh(&nth_lock);
break;
}
return ret;
}
The second case should look like this - or have i missed something?
case XT_STATISTIC_MODE_NTH:
info = info->master;
spin_lock_bh(&nth_lock);
if (info->u.nth.count == info->u.nth.packet) {
ret=!ret;
}
if (info->u.nth.count++ == info->u.nth.every) {
info->u.nth.count = 0;
}
spin_unlock_bh(&nth_lock);
break;
I'll submit a patch if anyone agrees and i'll also add stuff to handle
multiple counts - why was this removed????
Thanks
prev parent reply other threads:[~2009-02-26 20:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-26 20:01 statistic module John Lister
2009-02-26 20:49 ` John Lister [this message]
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=49A70055.7090207@kickstone.co.uk \
--to=john.lister@kickstone.co.uk \
--cc=netfilter@vger.kernel.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.