Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 232910 - Iptables and kernel 2.6.25 incompatible with -m recent module (--hitcount)
Summary: Iptables and kernel 2.6.25 incompatible with -m recent module (--hitcount)
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High major (vote)
Assignee: Gentoo Kernel Bug Wranglers and Kernel Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-25 10:44 UTC by Mike Baikov
Modified: 2008-11-20 15:18 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
config of kernel (config,24.89 KB, text/plain)
2008-07-25 10:45 UTC, Mike Baikov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Baikov 2008-07-25 10:44:26 UTC
$IPTABLES -N ok_tcp
$IPTABLES -A ok_tcp -p TCP -m state --state NEW -m recent --name ftcp --set
$IPTABLES -A ok_tcp -p TCP -m state --state NEW -m recent --name ftcp --update --seconds 30 --hitcount 300 -j DROP
$IPTABLES -A ok_tcp -j ACCEPT

Reproducible: Always




iptables 1.4.0-r1, kernel 2.6.25-r7
Comment 1 Mike Baikov 2008-07-25 10:45:58 UTC
Created attachment 161342 [details]
config of kernel
Comment 2 SpanKY gentoo-dev 2008-08-17 14:18:27 UTC
have you tried iptables-1.4.1.1 ?
Comment 3 Mike Baikov 2008-09-11 13:17:27 UTC
No. 

echo "    - Creating a allowed TCP chain"
$IPTABLES -N ok_tcp
$IPTABLES -A ok_tcp -p TCP -m state --state NEW -m recent --name ftcp --set
$IPTABLES -A ok_tcp -p TCP -m state --state NEW -m recent --name ftcp --update --seconds 5 --hitcount 20 -j REJECT --reject-with tcp-reset
$IPTABLES -A ok_tcp -p TCP --syn -j ACCEPT
$IPTABLES -A ok_tcp -p TCP -m state --state ESTABLISHED,RELATED -j ACCEPT

No more than 20 :(



- Creating a allowed UDP chain
iptables: Invalid argument

mike ~ # iptables -V
iptables v1.4.1.1
Comment 4 Mike Baikov 2008-09-11 13:28:55 UTC
from net/ipv4/netfilter/ipt_recent.c:

static unsigned int ip_list_tot = 100;
static unsigned int ip_pkt_list_tot = 20;
MODULE_PARM_DESC(ip_list_tot, "number of IPs to remember per list");
MODULE_PARM_DESC(ip_pkt_list_tot, "number of packets per IP to remember (max. 255)");

Maybe this wrong?
Comment 5 Mike Baikov 2008-09-11 15:06:22 UTC
Compile kernel with IPTABLES modules <M> (old status is <*>)
Re-emerge iptables 1.4.1.1
Reboot

Now is working fine. No more than 255 hitcount. :-)

Thanks.
Comment 6 Mike Baikov 2008-09-11 15:08:37 UTC
Oops, sorry

I'm change kernel tree for it:

static unsigned int ip_list_tot = 500;
static unsigned int ip_pkt_list_tot = 255;

Sorry. I don't know, what is :(
Comment 7 SpanKY gentoo-dev 2008-10-26 05:06:14 UTC
sounds like a kernel issue and not anything userspace then ... thanks for the research into the source
Comment 8 Mike Pagano gentoo-dev 2008-10-28 00:15:39 UTC
Can you test with gentoo-sources-2.6.27-rX
Comment 9 Mike Pagano gentoo-dev 2008-10-28 00:16:35 UTC
whoops - taking back
Comment 10 Daniel Drake (RETIRED) gentoo-dev 2008-10-28 22:46:55 UTC
Did this work on pre-2.6.25 kernels? If so, which ones did you test?
Comment 11 Daniel Drake (RETIRED) gentoo-dev 2008-10-31 11:56:00 UTC
Also, it would be useful if you ran the iptables commands one by one so that we know exactly which one is failing. Right now it could be any one of the five, and we can only place guesses which one is actually producing the error.
Comment 12 Mike Baikov 2008-11-01 15:23:31 UTC
This command is failing:

iptables -A ok_tcp -p TCP -m state --state NEW -m recent --name ftcp --update
--seconds 30 --hitcount 300 -j DROP

Try it.

No, i can't test in pre- kernels and .27 kernels. Sorry.
Comment 13 Eray Aslan gentoo-dev 2008-11-19 15:01:40 UTC
(In reply to comment #4)
> from net/ipv4/netfilter/ipt_recent.c:
> static unsigned int ip_list_tot = 100;
> static unsigned int ip_pkt_list_tot = 20;
> MODULE_PARM_DESC(ip_list_tot, "number of IPs to remember per list");
> MODULE_PARM_DESC(ip_pkt_list_tot, "number of packets per IP to remember (max.
> 255)");
> Maybe this wrong?

Am I missing something here?  The above are the defaults.  If you want to keep track of more than 20 packets per IP (up to 255) load the module with the correct parameter.  For example,

# modprobe ipt_recent ip_pkt_list_tot=200
Comment 14 Mike Baikov 2008-11-20 12:00:37 UTC
This default behaviour have changed after 2.6.24????  :-/

Thanks for help! :-)
Comment 15 Daniel Drake (RETIRED) gentoo-dev 2008-11-20 15:18:06 UTC
I checked 2.6.24 and it has the same defaults.

I then found this commit, which has come since 2.6.24:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=d0ebf133590abdc035af6e19a6568667af0ab3b0

So, your iptables rule wasn't working on 2.6.24, but there was no failure message. Since then, netfilter has been fixed not to silently accept the unmatchable rule, hence you seeing the error message from iptables.

The fix is to set the right value in the module parameter. Eray, thanks a lot for looking into this!