Derrik Pates [Tue, 1 Feb 2005 13:28:14 +0000 (13:28 +0000)]
- Sets the 'iptc_fn' global variable to the pointer to the current functions in all major TC_* functions. This is necessary because in certain cases, an error return from a function that doesn't set 'iptc_fn' will conflict with a function-specific error return from one that does, causing TC_STRERROR() to return the wrong error string. This ensures that the right one will be returned.
- Implements a simple reference counter for the netlink socket global variable 'sockfd'; this is necessary for IPTables::IPv4, where multiple tables (filter, nat, mangle, untracked) may be opened at one time. The way libiptc does it in the official version causes previously-opened tables to break such that attempts to commit changes will fail.
- Adds a couple of memset() invocations in TC_COMMIT, based on past analysis with valgrind. It claimed that allocated structure were not being fully initialized, and adding the memset()s corrected this warning.
(Derrik Pates <demon@devrandom.net>)
Rusty Russell [Mon, 3 Jan 2005 03:48:40 +0000 (03:48 +0000)]
Extension revision number support (if kernel supports the getsockopts).
Enhance MARK match with second revision.
Committed in anticipation of the kernel patch being applied.
Rusty Russell [Wed, 22 Dec 2004 00:37:10 +0000 (00:37 +0000)]
Don't need ipt_entry_target()/ip6t_entry_target() now kernel uses static inline instead of extern inline (otherwise it doesn't compile without -O).
Don't re-initialize libiptc/libip6t unless modprobe attempt actually succeeds. This makes nfsim run about 20 times faster, as it doesn't have to explore failures in the first iptc_init().
Rusty Russell [Thu, 16 Dec 2004 14:22:23 +0000 (14:22 +0000)]
Make "is_same" test basics and entries only: targets are generic.
Make target testing aware of different kinds of rules.
Change reverse logic: target_different now target_same.
Set type to MODULE in iptcc_map_target.
Add testcase for this.
Rusty Russell [Thu, 16 Dec 2004 13:21:44 +0000 (13:21 +0000)]
Remove GET_TARGET() define: this was for compiling iptables for debugging (ie. without -O) on old kernels where ipt_get_target() was defined "extern inline". These days it's "static inline", and only developers build without -O anyway.
Fix up DUMP_ENTRIES a little, but remove calls: it only dumps the table as loaded, not the changed (cached) table, which is misleading.
Fix TC_DELETE_ENTRY: we need to use iptcc_map_target() before comparing, otherwise "-j DROP" (as an example) doesn't work.
Martin Josefsson [Thu, 23 Sep 2004 19:25:06 +0000 (19:25 +0000)]
Replace O(n) with O(1) when TC_INSERT_ENTRY() inserts an entry at the end.
Do the same with TC_DELETE_NUM_ENTRY() when deleting the last rule.
My rule management script does both of these things in certain situations.
Created a file with 50.000 rules which my script converted into
iptables-restore format but inserting each rule with an index instead of
appending like the iptables-save output does. That took a while without this
optimization. Same thing when deleting the 45.000 last rules in that chain,
the script outputs deletes by number starting from the bottom.
Inserting or deleting (by number) in the middle of the chain is still O(n)
where n is the rulenumber where the insert/delete is taking place.
Martin Josefsson [Wed, 22 Sep 2004 22:04:07 +0000 (22:04 +0000)]
Make sure to zero all the memory we allocate for the new table.
Makes flushing of chains containing more than a few entries work without
potentially oopsing the kernel.
Martin Josefsson [Wed, 22 Sep 2004 21:04:07 +0000 (21:04 +0000)]
Insertion of rules with -I was broken.
It checked if a rule existed on the position we were inserting to.
Thus inserting into an empty chain didn't work.
And it didn't care about the fact that the first rule in the chain has index 1
the rulenumer we get starts at 0...
Martin Josefsson [Wed, 26 May 2004 21:56:26 +0000 (21:56 +0000)]
With a 64bit kernel only the high 32bits of nfmark was used regardless of
32/64bit userspace. This makes it quite hard to interoperate with 'tc'.
Sync ipv6 versions with ipv4 versions.
Tested on x86 and sparc64 with both 32bit and 64bit userspace.