Cannot delete hashlimit match entries
As noted by a bugzilla reporter,
iptables -A foo -m hashlimit --hashlimit 5/s --hashlimit-mode srcip --hashlimit-name foo iptables -D foo -m hashlimit --hashlimit 5/s --hashlimit-mode srcip --hashlimit-name foo
iptables: Bad rule (does a matching rule exist in that chain?)
In reviewing this, I think the fact that *hinfo is initialized by the kernel will make this a tough problem to fix. The unitialized match is:
(gdb) inspect *(struct ipt_hashlimit_info *)((struct ipt_entry_match)*a->elems)->data $42 = {name = "foo\000\000\000\000\000\000\000\000\000", cfg = {mode = 6, avg = 2000, burst = 5,
size = 0, max = 0, gc_interval = 1000, expire = 10000}, hinfo = 0x0, u = {ptr = 0x0,
master = 0x0}}while once initialized:
(gdb) inspect *(struct ipt_hashlimit_info *)((struct ipt_entry_match)*b->elems)->data $43 = {name = "foo\000\000\000\000\000\000\000\000\000", cfg = {mode = 6, avg = 2000, burst = 5,
size = 0, max = 0, gc_interval = 1000, expire = 10000}, hinfo = 0xd4875000, u = {
ptr = 0xd48733d0, master = 0xd48733d0}}So...unless I'm missing something, they really don't match.
Ideas?
Phil
Quoted 9 lines · Phil Oester
As noted by a bugzilla reporter,
iptables -A foo -m hashlimit --hashlimit 5/s --hashlimit-mode srcip --hashlimit-name foo iptables -D foo -m hashlimit --hashlimit 5/s --hashlimit-mode srcip --hashlimit-name foo
iptables: Bad rule (does a matching rule exist in that chain?)In reviewing this, I think the fact that *hinfo is initialized by the kernel will make this a tough problem to fix. The unitialized match is:
Yes. The only way am aware of to fix it is sizing the matching part with offsetof(). Fortunately, in this case, all modified member are at end so we can use this hack without breaking any compatibility.
Quoted 1 line
Ideas?
libipt_hashlimit.c (working copy) renamed from libipt_hashlimit.c (revision 3525) +1 -2
@@ -351,8 +351,7 @@ .name = "hashlimit", .version = IPTABLES_VERSION, .size = IPT_ALIGN(sizeof(struct ipt_hashlimit_info)), - .userspacesize = IPT_ALIGN(sizeof(struct ipt_hashlimit_info)), - //offsetof(struct ipt_hashlimit_info, prev), + .userspacesize = offsetof(struct ipt_hashlimit_info, hinfo), .help = &help, .init = &init, .parse = &parse,
By now, SVN is crush. 8( I can't tell wheter this patch applies or not. but at least, you got the idea.
Quoted 3 lines
Phil
Cheers,
Samuel
Quoted 5 lines · Samuel Jean
Yes. The only way am aware of to fix it is sizing the matching part with
offsetof().
Fortunately, in this case, all modified member are at end so we can use this hack without
breaking any compatibility.
Thanks!
Sending extensions/libipt_hashlimit.c
Transmitting file data .
Committed revision 3654.
Signature · 5 lines
- Harald Welte <[email protected]> http://www.netfilter.org/ ============================================================================ "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie