multiple changes/fixes
PATCH 1/1 multiple changes/fixes
Hi,
The attached patch contains the following changes, some of them having been discussed on this mailing-list during the last days. So here it is:
- up tp now iptables-save (with or without -c) used to dump counters for builtin-chains, which was wrong (useless when not called with -c). This is now fixed: counters are dumped _only_ with -c option.
- ip{,6}tables-save (with or without -c) used to dump dummy counters (always [0:0]) for user-chains, which was wrong (never needed, as it makes no sense for user-chains, right?). Fixed as well.
- old iptables-restore -c used to restore old iptables-save dumps (without -c) without any complaints about missing counters (for rules, as counters for builtin-chains were dumped anyway). With this patch, the new iptables-restore -c acts likewise:
it restores iptables-save dumps (without -c) without error, but issues a warning about the lack of the expected counters.
- Note: dump files created by new iptables-save command (without -c) won't be restorable with old iptables-restore -c.
People who really have to use previous iptables-restore versions can use iptables-save -c (new version).
- removed the -t (--test) option from ip{,6}tables-restore, now replaced by -S (--simulate) below.
- added tc_set_nocommit to libip{,6}tc, which enables not to commit ruleset changes to the kernel.
- added -S (--simulate) switch to ip{,6}tables{,-restore}, which replaces old partially undocumented -t (--test) option of ip{,6}tables-restore, and now uses the iptc nocommit facility. That is useful for validating the rule syntax, for example. Added -S to ip{,6}tables{,-restore} help messages and man pages.
- Note: like we said in a thread on netfilter-devel, --simulate is not a pure virtual simulation, as it may have the side effect of loading iptable_* kernel modules and their dependencies, notably ip_conntrack, which can lead to performance issues after the simulation.
In the future, we could remove modules added by the simulation automatically.
- added -t (--table) option to ip{,6}tables-restore, which enables to restore only a specific table of the input file.
When --table is specified, other tables in the input file are not parsed/validated. The file can be validated with --simulate, though.
TODO: enable to specify --table option several times with ip{,6}tables-{save,restore}
- ip{,6}tables-{save,restore} called with wrong options now fails, as it should.
- added -C (--no-comments) option to ip{,6}tables-save: no comment is printed, enabling to compare dumps without pre-processing.
- added help message to ip{,6}tables-save.
- completed ip{,6}tables-{save,restore}.8 with missing (formerly undocumented) options.
- ip{,6}tables-restore.8 contained "None known as of iptables-1.2.1 release". Changed it to iptables-1.2.10, as there was a problem with the order of matches.
- removed --binary option everywhere because it was not documented, not implemented, because there are very few chances it may ever be, and because it will be so easy to add these few lines back if we want to implement it someday.
- changed "magic" initial value of 'line' variable to 0 (instead of -1), as line 0 is a good remarquable value as well, and this avoids to add extra tests to display correct error information in every case with ip{,6}tables{,-restore}.
- added the reason of the failure when ip{,6}tables-restore fails at a particular line.
- fixed wrong call to strerror(), changing it to ip{,6}tc_strerror() on error when creating a chain, in ip{,6}tables.c
- removed all useless exit() calls after exit_error()
- fixed multiple typos, spaces and indentations. Global cleanup of the code.
- even more synchronisation between IPv4 and IPv6 parts.
I tried my best not to forget anything, especially regarding global coherence, synchronisation between IPv4 and IPv6 parts, or between options, help messages and man pages.
Yet, this patch touches quite simple but multiple things, so one never knows... Further reviews/testing welcome!
Herve
Signature · 4 lines
_ (°= Hervé Eychenne //) v_/_ WallFire project: http://www.wallfire.org/
Makefile +1 -1
@@ -26,7 +26,7 @@ # directory for new iptables releases RELEASE_DIR:=/tmp -# Need libc6 for this. FIXME: Should covert to autoconf. +# Need libc6 for this. FIXME: Should convert to autoconf. ifeq ($(shell [ -f /usr/include/netinet/ip6.h ] && echo YES), YES) DO_IPV6:=1 endif
include/libiptc/libip6tc.h +6 -3
@@ -20,15 +20,15 @@/* Transparent handle type. */ typedef struct ip6tc_handle *ip6tc_handle_t ; -/* Does this chain exist? */ -int ip6tc_is_chain (const char *chain,const ip6tc_handle_t handle); -/* Take a snapshot of the rules. Returns NULL on error. */ ip6tc_handle_t ip6tc_init (const char *tablename);/* Cleanup after ip6tc_init(). */ void ip6tc_free (ip6tc_handle_t *h); +/* Enable not to commit anything to the kernel. */ +void ip6tc_set_nocommit (ip6tc_handle_t *h); +/* Iterator functions to run through the chains. Returns NULL at end. */ const char *ip6tc_first_chain (ip6tc_handle_t *handle);const char *ip6tc_next_chain (ip6tc_handle_t *handle);
@@ -45,6 +45,9 @@const char *ip6tc_get_target (const struct ip6t_entry *e,ip6tc_handle_t *handle); +/* Does this chain exist? */ +int ip6tc_is_chain (const char *chain,const ip6tc_handle_t handle); +/* Is this a built-in chain? */ int ip6tc_builtin (const char *chain,const ip6tc_handle_t handle);
include/libiptc/libiptc.h +6 -3
@@ -28,15 +28,15 @@/* Transparent handle type. */ typedef struct iptc_handle *iptc_handle_t ; -/* Does this chain exist? */ -int iptc_is_chain (const char *chain,const iptc_handle_t handle); -/* Take a snapshot of the rules. Returns NULL on error. */ iptc_handle_t iptc_init (const char *tablename);/* Cleanup after iptc_init(). */ void iptc_free (iptc_handle_t *h); +/* Enable not to commit anything to the kernel. */ +void iptc_set_nocommit (iptc_handle_t *h); +/* Iterator functions to run through the chains. Returns NULL at end. */ const char *iptc_first_chain (iptc_handle_t *handle);const char *iptc_next_chain (iptc_handle_t *handle);
@@ -53,6 +53,9 @@const char *iptc_get_target (const struct ipt_entry *e,iptc_handle_t *handle); +/* Does this chain exist? */ +int iptc_is_chain (const char *chain,const iptc_handle_t handle); +/* Is this a built-in chain? */ int iptc_builtin (const char *chain,const iptc_handle_t handle);
ip6tables-restore.8 +29 -7
@@ -21,24 +21,46 @@ .SH NAME ip6tables-restore \- Restore IPv6 Tables .SH SYNOPSIS -.BR "ip6tables-restore " "[-c] [-n]" +.BR "ip6tables-restore " "[-c] [-n] [-t table] [-M cmd] [-v] [-S] [-h]" .br .SH DESCRIPTION .PP .B ip6tables-restore is used to restore IPv6 Tables from data specified on STDIN. Use -I/O redirection provided by your shell to read from a file +I/O redirection provided by your shell to read from a file. .TP \fB\-c\fR, \fB\-\-counters\fR -restore the values of all packet and byte counters -.TP -\fB\-n\fR, \fB\-\-noflush\fR +restore the values of all packet and byte counters. .TP +\fB\-n\fR, \fB\-\-noflush\fR don't flush the previous contents of the table. If not specified, .B ip6tables-restore -flushes (deletes) all previous contents of the respective IPv6 Table. +flush (delete) all previous contents of the respective IPv6 Table. +.TP +\fB\-t\fR, \fB\-\-table\fR \fBtablename\fR +restrict restoration to only one table, even if multiple tables are +present in the input file. When this option is specified, other tables +in the input file are not parsed, thus not validated. +.TP +\fB\-M\fR \fBcommand\fR, \fB\-\-modprobe\fR \fBcommand\fR +if iptables needs to load kernel modules, load them with this command. +.TP +\fB\-v\fR, \fB\-\-verbose\fR +verbose output. +.TP +\fB\-S\fR, \fB\-\-simulate\fR +simulate the restoration, do not commit ruleset changes to the kernel. +Yet, this is not a pure virtual simulation, as it may have the side +effect of loading iptable_* kernel modules and their possible +dependencies. +.\" (add later, as nat table is not implemented yet) @@ +.\" , notably ip_conntrack, which can lead to performance issues +.\" after the simulation. +.TP +\fB\-h\fR, \fB\-\-help\fR +display help message. .SH BUGS -None known as of iptables-1.2.1 release +None known as of iptables-1.2.10 release .SH AUTHORS Harald Welte <[email protected]> .br
ip6tables-restore.c +124 -131
446 lines not on this page · raw message
ip6tables-save.8 +8 -3
@@ -21,7 +21,7 @@ .SH NAME ip6tables-save \- Save IPv6 Tables .SH SYNOPSIS -.BR "ip6tables-save " "[-c] [-t table]" +.BR "ip6tables-save " "[-c] [-t table] [-C] [-h]" .br .SH DESCRIPTION .PP
@@ -30,12 +30,17 @@ to STDOUT. Use I/O-redirection provided by your shell to write to a file. .TP \fB\-c\fR, \fB\-\-counters\fR -include the current values of all packet and byte counters in the output +include the current values of all packet and byte counters in the output. .TP \fB\-t\fR, \fB\-\-table\fR \fBtablename\fR -.TP restrict output to only one table. If not specified, output includes all available tables. +.TP +\fB\-C\fR, \fB\-\-no-comments\fR +do not output any comment. Useful for comparing two dump files. +.TP +\fB\-h\fR, \fB\-\-help\fR +display help message. .SH BUGS None known as of iptables-1.2.1 release .SH AUTHORS
ip6tables-save.c +93 -87
335 lines not on this page · raw message
ip6tables.8.in +14 -5
@@ -145,7 +145,7 @@ versions of this command: the rule can be specified as a number in the chain (starting at 1 for the first rule) or a rule to match. .TP -.B "-I, --insert" +.BR "-I, --insert " "\fIchain\fP [\fIrulenum\fP] \fIrule-specification\fP" Insert one or more rules in the selected chain as the given rule number. So, if the rule number is 1, the rule or rules are inserted at the head of the chain. This is also the default if no rule number
@@ -272,8 +272,8 @@ incremented. .TP .BR "-i, --in-interface " "[!] \fIname\fP" -Name of an interface via which a packet is going to be received (only for -packets entering the +Name of an interface via which a packet was received (only for +packets entering the .BR INPUT , .B FORWARD and
@@ -348,6 +348,15 @@ When adding or inserting rules into a chain, use .B command to load any necessary modules (targets, match extensions, etc). +.TP +.B "-S, --simulate" +simulate the restoration, do not commit ruleset changes to the kernel. +Yet, this is not a pure virtual simulation, as it may have the side +effect of loading iptable_* kernel modules and their possible +dependencies. +.\" (add later, as nat table is not implemented yet) @@ +.\" , notably ip_conntrack, which can lead to performance issues +.\" after the simulation. .SH MATCH EXTENSIONS ip6tables can use extended packet matching modules. These are loaded in two ways: implicitly, when
@@ -389,7 +398,7 @@ This .B ip6tables is very similar to ipchains by Rusty Russell. The main difference is -that the chains +that the chains .B INPUT and .B OUTPUT
@@ -399,7 +408,7 @@ involves both INPUT and OUTPUT chains); previously a forwarded packet would pass through all three. .PP -The other main difference is that +The other main difference is that .B -i refers to the input interface; .B -o
ip6tables.c +55 -45
269 lines not on this page · raw message
iptables-restore.8 +27 -7
@@ -21,24 +21,44 @@ .SH NAME iptables-restore \- Restore IP Tables .SH SYNOPSIS -.BR "iptables-restore " "[-c] [-n]" +.BR "iptables-restore " "[-c] [-n] [-t table] [-M cmd] [-v] [-S] [-h]" .br .SH DESCRIPTION .PP .B iptables-restore is used to restore IP Tables from data specified on STDIN. Use -I/O redirection provided by your shell to read from a file +I/O redirection provided by your shell to read from a file. .TP \fB\-c\fR, \fB\-\-counters\fR -restore the values of all packet and byte counters -.TP -\fB\-n\fR, \fB\-\-noflush\fR +restore the values of all packet and byte counters. .TP +\fB\-n\fR, \fB\-\-noflush\fR don't flush the previous contents of the table. If not specified, .B iptables-restore -flushes (deletes) all previous contents of the respective IP Table. +flush (delete) all previous contents of the respective IP Table. +.TP +\fB\-t\fR, \fB\-\-table\fR \fBtablename\fR +restrict restoration to only one table, even if multiple tables are +present in the input file. When this option is specified, other tables +in the input file are not parsed, thus not validated. +.TP +\fB\-M\fR \fBcommand\fR, \fB\-\-modprobe\fR \fBcommand\fR +if iptables needs to load kernel modules, load them with this command. +.TP +\fB\-v\fR, \fB\-\-verbose\fR +verbose output. +.TP +\fB\-S\fR, \fB\-\-simulate\fR +simulate the restoration, do not commit ruleset changes to the kernel. +Yet, this is not a pure virtual simulation, as it may have the side +effect of loading iptable_* kernel modules and their possible +dependencies, notably ip_conntrack, which can lead to performance +issues after the simulation. +.TP +\fB\-h\fR, \fB\-\-help\fR +display help message. .SH BUGS -None known as of iptables-1.2.1 release +None known as of iptables-1.2.10 release .SH AUTHOR Harald Welte <[email protected]> .SH SEE ALSO
iptables-restore.c +124 -131
439 lines not on this page · raw message
iptables-save.8 +8 -3
@@ -21,7 +21,7 @@ .SH NAME iptables-save \- Save IP Tables .SH SYNOPSIS -.BR "iptables-save " "[-c] [-t table]" +.BR "iptables-save " "[-c] [-t table] [-C] [-h]" .br .SH DESCRIPTION .PP
@@ -30,12 +30,17 @@ to STDOUT. Use I/O-redirection provided by your shell to write to a file. .TP \fB\-c\fR, \fB\-\-counters\fR -include the current values of all packet and byte counters in the output +include the current values of all packet and byte counters in the output. .TP \fB\-t\fR, \fB\-\-table\fR \fBtablename\fR -.TP restrict output to only one table. If not specified, output includes all available tables. +.TP +\fB\-C\fR, \fB\-\-no-comments\fR +do not output any comment. Useful for comparing two dump files. +.TP +\fB\-h\fR, \fB\-\-help\fR +display help message. .SH BUGS None known as of iptables-1.2.1 release .SH AUTHOR
iptables-save.c +96 -89
328 lines not on this page · raw message
iptables.8.in +8 -1
@@ -280,7 +280,7 @@ .TP .BR "-i, --in-interface " "[!] \fIname\fP" Name of an interface via which a packet was received (only for -packets entering the +packets entering the .BR INPUT , .B FORWARD and
@@ -354,6 +354,13 @@ When adding or inserting rules into a chain, use .B command to load any necessary modules (targets, match extensions, etc). +.TP +.B "-S, --simulate" +simulate the restoration, do not commit ruleset changes to the kernel. +Yet, this is not a pure virtual simulation, as it may have the side +effect of loading iptable_* kernel modules and their possible +dependencies, notably ip_conntrack, which can lead to performance +issues after the simulation. .SH MATCH EXTENSIONS iptables can use extended packet matching modules. These are loaded in two ways: implicitly, when
iptables.c +49 -38
246 lines not on this page · raw message
libiptc/libip4tc.c +1 -0
@@ -92,6 +92,7 @@#define TC_GET_RAW_SOCKET iptc_get_raw_socket#define TC_INIT iptc_init#define TC_FREE iptc_free +#define TC_SET_NOCOMMIT iptc_set_nocommit#define TC_COMMIT iptc_commit#define TC_STRERROR iptc_strerror
libiptc/libip6tc.c +1 -0
@@ -87,6 +87,7 @@#define TC_GET_RAW_SOCKET ip6tc_get_raw_socket#define TC_INIT ip6tc_init#define TC_FREE ip6tc_free +#define TC_SET_NOCOMMIT ip6tc_set_nocommit#define TC_COMMIT ip6tc_commit#define TC_STRERROR ip6tc_strerror
libiptc/libiptc.c +15 -5
@@ -78,6 +78,8 @@ STRUCT_TC_HANDLE { +/* Do not commit anything to the kernel if this flag is set. */ +int nocommit;/* Have changes been made? */ int changed;/* Size in here reflects original state. */
@@ -109,6 +111,12 @@ h->changed =1 ; } +void +TC_SET_NOCOMMIT (TC_HANDLE_T *h) +{ + (*h)->nocommit =1 ; +} +#ifdef IPTC_DEBUG static void do_check (TC_HANDLE_T h,unsigned int line);#define CHECK (h) do { if (!getenv("IPTC_NO_CHECK")) do_check((h), __LINE__); } while(0)
@@ -230,6 +238,7 @@ } h->changed =0 ; + h->nocommit =0 ; h->cache_num_chains =0 ; h->cache_chain_heads =NULL ; h->counter_map = (void *)h
@@ -854,6 +863,7 @@if (!newh)return 0 ; newh->info = newinfo; + newh->nocommit = (*handle)->nocommit;/* Copy pre... */ memcpy (newh->entries.entrytable, (*handle)->entries.entrytable,offset);
@@ -1732,17 +1742,17 @@CHECK (*handle); - counterlen =sizeof (STRUCT_COUNTERS_INFO ) - +sizeof (STRUCT_COUNTERS ) * (*handle)->new_number; -#if 0 TC_DUMP_ENTRIES (*handle);#endif -/* Don't commit if nothing changed. */ -if (!(*handle)->changed) +/* Don't commit if nothing changed or if we are is nocommit mode. */ +if (!(*handle)->changed || (*handle)->nocommit) goto finished; + counterlen =sizeof (STRUCT_COUNTERS_INFO ) + +sizeof (STRUCT_COUNTERS ) * (*handle)->new_number; + repl =malloc (sizeof (*repl) + (*handle)->entries.size);if (!repl) { errno =ENOMEM ;
Quoted 6 lines · Herve Eychenne
I tried my best not to forget anything, especially regarding global coherence, synchronisation between IPv4 and IPv6 parts, or between options, help messages and man pages.
Yet, this patch touches quite simple but multiple things, so one never knows... Further reviews/testing welcome!
Would it be possible that you split the patch into logical changes so it's easier to review ?
Regards
Patrick
Quoted 10 lines · Patrick McHardy
Quoted 5 lines · Herve Eychenne
I tried my best not to forget anything, especially regarding global coherence, synchronisation between IPv4 and IPv6 parts, or between options, help messages and man pages.
Yet, this patch touches quite simple but multiple things, so one never knows... Further reviews/testing welcome!Would it be possible that you split the patch into logical changes so it's easier to review ?
I was afraid someone would say that. Does someone know a good tool to split patches? I think of a X11 that would enable to drag and drop diff file portions to several new areas/patches, with an option that would automatically create one containing only whitespace changes.
Otherwise I guess I may not have the courage to do it. :-(
Herve
Signature · 4 lines
_ (°= Hervé Eychenne //) v_/_ WallFire project: http://www.wallfire.org/
Quoted 11 lines · Herve Eychenne
Quoted 3 lines · Patrick McHardy
Would it be possible that you split the patch into logical changes so it's easier to review ?
I was afraid someone would say that. Does someone know a good tool to split patches? I think of a X11 that would enable to drag and drop diff file portions to several new areas/patches, with an option that would automatically create one containing only whitespace changes.
Unfortunately, no. I use bitkeeper, patch and cut-n-paste for that, but that's just my preference.
Quoted 3 lines
Otherwise I guess I may not have the courage to do it. :-(
I hope you're still going to do it. I don't want to throw in a 70k patch which touches stuff all over the place, and it's really hard to judge which change has which purpose with just one big patch that also reindents and reformats stuff. BTW:
-static int print_match(const struct ip6t_entry_match *e,
- const struct ip6t_ip6 *ip)
-{
+static int
+print_match(const struct ip6t_entry_match *e, const struct ip6t_ip6 *ip) {
the opening bracket should be on a seperate line.
Regards
Patrick
On Fri, Aug 27, 2004 at 10:08:54PM +0200, Patrick McHardy wrote:
Disclaimer for overbooked netfilter people: this email is perfecly uninteresting.
Quoted 8 lines
Quoted 6 lines · Herve Eychenne
Quoted 3 lines · Patrick McHardy
Would it be possible that you split the patch into logical changes so it's easier to review ?
Quoted 7 lines
Quoted 4 lines
I was afraid someone would say that. Does someone know a good tool to split patches? I think of a X11 that would enable to drag and drop diff file portions to several new areas/patches, with an option that would automatically create one containing only whitespace changes.
Unfortunately, no. I use bitkeeper, patch and cut-n-paste for that, but that's just my preference.
I certainly wouldn't allow any of my libre work to rely on processes using a "non-libre" application. Question of survival. Anyway, I don't want to create a holy war here, a certain G.W.B. is already doing fine stuff in this area. :-)
BTW, I cannot imagine that an application enabling to wipe spacechanges-only from a patch does not currently exist... Eventually, it could wipe syntaxical changes only (but should be aware of the language structure/grammar), but that's harder, of course. So many things to do, and so little time...
Quoted 3 lines
Quoted 1 line
Otherwise I guess I may not have the courage to do it. :-(
I hope you're still going to do it.
When I think about the time it would take me to do that, compared to the relatively small overhead of having to ignore obvious cosmetic changes during the review, I'm still quite sceptical about it... :-(
Quoted 3 lines
I don't want to throw in a 70k
patch which touches stuff all over the place, and it's really hard to judge which change has which purpose
I don't think it's that hard. But I'm not objective, as I wrote it. :-) The changes are simple, it's just that there are plenty of them. Yet, I can understand your reluctance.
Quoted 1 line
with just one big patch that also reindents and reformats stuff.
I know I'm a bad boy, but if I didn't do these as I was wandering through the code, I would never have done it afterwards, and I still think it was worth cleaning a little bit. Readability is often more important than one thinks.
Quoted 9 lines
BTW:
ip6tables-save.c +2
-3-static int print_match (const struct ip6t_entry_match *e, -const struct ip6t_ip6 *ip) -{ +static int +print_match (const struct ip6t_entry_match *e,const struct ip6t_ip6 *ip) {the opening bracket should be on a seperate line.
For functions only (argh)...
Oh, you're right. The global coding style of the tree is quite different from mine (I particularly hate 8 spaces indentation, but we all know Linus was sent by hell, right? ;-), so I guess I may sometimes have been trapped into unconsciously bringing it closer to mine.
But maybe you'll notice that the (this) coding style is far from having been applied everywhere in the current tree, as multiple people wrote different parts, obviously.
Herve
Signature · 4 lines
_ (°= Hervé Eychenne //) v_/_ WallFire project: http://www.wallfire.org/
Quoted 5 lines · Herve Eychenne
BTW, I cannot imagine that an application enabling to wipe spacechanges-only from a patch does not currently exist... Eventually, it could wipe syntaxical changes only (but should be aware of the language structure/grammar), but that's harder, of course. So many things to do, and so little time...
The problem is most tools including patch & diff is line oriented, not whitespace oriented. It is trivial to weed out changes in indentation or whitespace per line only, but not changes involving reformatting such as moving the curly braket from one line to another etc.
To weed out the simple whitespace changes use "diff -wu"
Another tool which looks promising is xxdiff <url:http://xxdiff.sourceforge.net/>, but I have not been able to try this out yet.
Quoted 1 line
I don't think it's that hard. But I'm not objective, as I wrote it. :-)
I think it is very hard when I do the same thing which happens every now and then when restructuring a large piece of code, but that is me.
Quoted 1 line
The changes are simple, it's just that there are plenty of them.
Which makes the odd change which are different from the rest easy to miss.
Quoted 6 lines
Quoted 1 line
with just one big patch that also reindents and reformats stuff.
I know I'm a bad boy, but if I didn't do these as I was wandering through the code, I would never have done it afterwards, and I still think it was worth cleaning a little bit. Readability is often more important than one thinks.
There is several tools doing a very good job of cleaning up indentation and formatting. My favorite for C code is indent. There is no need of doing this by hand.
On the other hand the same tool can be used to identify the real changes "after the fact" even if the original code was a mess, simply by diffing the modified version with an original version formatted by the same tool.
Regards
Henrik
Quoted 7 lines · Henrik Nordstrom
There is several tools doing a very good job of cleaning up indentation and formatting. My favorite for C code is indent. There is no need of doing this by hand.
On the other hand the same tool can be used to identify the real changes "after the fact" even if the original code was a mess, simply by diffing the modified version with an original version formatted by the same tool.
Yes... run indent on the current tree, run indent on the patched tree, and run diff on the two "indented" trees. But... too late: I took one hour to remove the fluff from my patch (sigh).
I'll post 2 new patches tonight (if my head does not fall heavily on my keyboard til then): one containing the information, the other containing syntaxical or cosmetic changes, and typo fixes.
Herve
Signature · 4 lines
_ (°= Hervé Eychenne //) v_/_ WallFire project: http://www.wallfire.org/
Quoted 3 lines · Herve Eychenne
Yes... run indent on the current tree, run indent on the patched tree, and run diff on the two "indented" trees. But... too late: I took one hour to remove the fluff from my patch (sigh).
Found yet another useful tool for splitting patches with less dependencies: tkdiff
Quoted 3 lines
I'll post 2 new patches tonight (if my head does not fall heavily on my keyboard til then): one containing the information, the other containing syntaxical or cosmetic changes, and typo fixes.
Great!
And thanks for encouraging me to look for tools doing this job easier. Was more things around than I expected to find.
Regards
Henrik
Quoted 8 lines · Henrik Nordstrom
Quoted 3 lines · Herve Eychenne
Yes... run indent on the current tree, run indent on the patched tree, and run diff on the two "indented" trees. But... too late: I took one hour to remove the fluff from my patch (sigh).
Found yet another useful tool for splitting patches with less
dependencies: tkdiff
I use it all the time, but I don't really see how it can help to split patches affecting multiple files efficiently (you're talking about the merge functionnality, aren't you?), as it works with two versions of a file at a time, and not a diff file nor 2 trees...
Quoted 5 lines
Quoted 3 lines
I'll post 2 new patches tonight (if my head does not fall heavily on my keyboard til then): one containing the information, the other containing syntaxical or cosmetic changes, and typo fixes.
Great!
Maybe I've talked a little bit too fast, as the patch modified by hand doesn't apply anymore, and I cannot get it to apply even when playing with rediff and recountdiff (from the patchutils).
Quoted 2 lines
And thanks for encouraging me to look for tools doing this job easier. Was more things around than I expected to find.
You're welcome... ;-)
Herve
Signature · 4 lines
_ (°= Hervé Eychenne //) v_/_ WallFire project: http://www.wallfire.org/
Quoted 10 lines · Patrick McHardy
Quoted 6 lines · Herve Eychenne
I tried my best not to forget anything, especially regarding global coherence, synchronisation between IPv4 and IPv6 parts, or between options, help messages and man pages.
Yet, this patch touches quite simple but multiple things, so one never knows... Further reviews/testing welcome!Would it be possible that you split the patch into logical changes so it's easier to review ?
Yes, it seems like.
After groking the patch file, using not so magic tools (patchutils does not work as well as one hopes it would), patch mangling by hand again, unsure techniques, ..., ... again, without forgetting some
@&#$ of course, and eventually a patch --fuzz=9, I did it (but I swear I will never do that again until descent tools start to appear, doing all the shamanism for me).
So, here is the patch containing the useful information, as well as another patch containing the fluffy things (but you'll see, it's worth applying it anyway, otherwise the shaman will put a spell on you), which applies on top of the first one.
Can I please get some sleep now? ;-)
Herve
Signature · 4 lines
_ (°= Hervé Eychenne //) v_/_ WallFire project: http://www.wallfire.org/
include/libiptc/libip6tc.h +3 -0
@@ -29,6 +29,9 @@/* Cleanup after ip6tc_init(). */ void ip6tc_free (ip6tc_handle_t *h); +/* Enable not to commit anything to the kernel. */ +void ip6tc_set_nocommit (ip6tc_handle_t *h); +/* Iterator functions to run through the chains. Returns NULL at end. */ const char *ip6tc_first_chain (ip6tc_handle_t *handle);const char *ip6tc_next_chain (ip6tc_handle_t *handle);
include/libiptc/libiptc.h +3 -0
@@ -37,6 +37,9 @@/* Cleanup after iptc_init(). */ void iptc_free (iptc_handle_t *h); +/* Enable not to commit anything to the kernel. */ +void iptc_set_nocommit (iptc_handle_t *h); +/* Iterator functions to run through the chains. Returns NULL at end. */ const char *iptc_first_chain (iptc_handle_t *handle);const char *iptc_next_chain (iptc_handle_t *handle);
ip6tables-restore.8 +28 -6
@@ -21,7 +21,7 @@ .SH NAME ip6tables-restore \- Restore IPv6 Tables .SH SYNOPSIS -.BR "ip6tables-restore " "[-c] [-n]" +.BR "ip6tables-restore " "[-c] [-n] [-t table] [-M cmd] [-v] [-S] [-h]" .br .SH DESCRIPTION .PP
@@ -30,15 +30,37 @@ I/O redirection provided by your shell to read from a file .TP \fB\-c\fR, \fB\-\-counters\fR -restore the values of all packet and byte counters -.TP -\fB\-n\fR, \fB\-\-noflush\fR +restore the values of all packet and byte counters. .TP +\fB\-n\fR, \fB\-\-noflush\fR don't flush the previous contents of the table. If not specified, .B ip6tables-restore -flushes (deletes) all previous contents of the respective IPv6 Table. +flush (delete) all previous contents of the respective IPv6 Table. +.TP +\fB\-t\fR, \fB\-\-table\fR \fBtablename\fR +restrict restoration to only one table, even if multiple tables are +present in the input file. When this option is specified, other tables +in the input file are not parsed, thus not validated. +.TP +\fB\-M\fR \fBcommand\fR, \fB\-\-modprobe\fR \fBcommand\fR +if iptables needs to load kernel modules, load them with this command. +.TP +\fB\-v\fR, \fB\-\-verbose\fR +verbose output. +.TP +\fB\-S\fR, \fB\-\-simulate\fR +simulate the restoration, do not commit ruleset changes to the kernel. +Yet, this is not a pure virtual simulation, as it may have the side +effect of loading iptable_* kernel modules and their possible +dependencies. +.\" (add later, as nat table is not implemented yet) @@ +.\" , notably ip_conntrack, which can lead to performance issues +.\" after the simulation. +.TP +\fB\-h\fR, \fB\-\-help\fR +display help message. .SH BUGS -None known as of iptables-1.2.1 release +None known as of iptables-1.2.10 release .SH AUTHORS Harald Welte <[email protected]> .br
ip6tables-restore.c +80 -88
313 lines not on this page · raw message
ip6tables-save.8 +7 -2
@@ -21,7 +21,7 @@ .SH NAME ip6tables-save \- Save IPv6 Tables .SH SYNOPSIS -.BR "ip6tables-save " "[-c] [-t table]" +.BR "ip6tables-save " "[-c] [-t table] [-C] [-h]" .br .SH DESCRIPTION .PP
@@ -33,9 +33,14 @@ include the current values of all packet and byte counters in the output .TP \fB\-t\fR, \fB\-\-table\fR \fBtablename\fR -.TP restrict output to only one table. If not specified, output includes all available tables. +.TP +\fB\-C\fR, \fB\-\-no-comments\fR +do not output any comment. Useful for comparing two dump files. +.TP +\fB\-h\fR, \fB\-\-help\fR +display help message. .SH BUGS None known as of iptables-1.2.1 release .SH AUTHORS
ip6tables-save.c +59 -48
159 lines not on this page · raw message
ip6tables.8.in +12 -3
@@ -145,7 +145,7 @@ versions of this command: the rule can be specified as a number in the chain (starting at 1 for the first rule) or a rule to match. .TP -.B "-I, --insert" +.BR "-I, --insert " "\fIchain\fP [\fIrulenum\fP] \fIrule-specification\fP" Insert one or more rules in the selected chain as the given rule number. So, if the rule number is 1, the rule or rules are inserted at the head of the chain. This is also the default if no rule number
@@ -272,8 +272,8 @@ incremented. .TP .BR "-i, --in-interface " "[!] \fIname\fP" -Name of an interface via which a packet is going to be received (only for -packets entering the +Name of an interface via which a packet was received (only for +packets entering the .BR INPUT , .B FORWARD and
@@ -348,6 +348,15 @@ When adding or inserting rules into a chain, use .B command to load any necessary modules (targets, match extensions, etc). +.TP +.B "-S, --simulate" +simulate the restoration, do not commit ruleset changes to the kernel. +Yet, this is not a pure virtual simulation, as it may have the side +effect of loading iptable_* kernel modules and their possible +dependencies. +.\" (add later, as nat table is not implemented yet) @@ +.\" , notably ip_conntrack, which can lead to performance issues +.\" after the simulation. .SH MATCH EXTENSIONS ip6tables can use extended packet matching modules. These are loaded in two ways: implicitly, when
ip6tables.c +29 -18
110 lines not on this page · raw message
iptables-restore.8 +26 -6
@@ -21,7 +21,7 @@ .SH NAME iptables-restore \- Restore IP Tables .SH SYNOPSIS -.BR "iptables-restore " "[-c] [-n]" +.BR "iptables-restore " "[-c] [-n] [-t table] [-M cmd] [-v] [-S] [-h]" .br .SH DESCRIPTION .PP
@@ -30,15 +30,35 @@ I/O redirection provided by your shell to read from a file .TP \fB\-c\fR, \fB\-\-counters\fR -restore the values of all packet and byte counters -.TP -\fB\-n\fR, \fB\-\-noflush\fR +restore the values of all packet and byte counters. .TP +\fB\-n\fR, \fB\-\-noflush\fR don't flush the previous contents of the table. If not specified, .B iptables-restore -flushes (deletes) all previous contents of the respective IP Table. +flush (delete) all previous contents of the respective IP Table. +.TP +\fB\-t\fR, \fB\-\-table\fR \fBtablename\fR +restrict restoration to only one table, even if multiple tables are +present in the input file. When this option is specified, other tables +in the input file are not parsed, thus not validated. +.TP +\fB\-M\fR \fBcommand\fR, \fB\-\-modprobe\fR \fBcommand\fR +if iptables needs to load kernel modules, load them with this command. +.TP +\fB\-v\fR, \fB\-\-verbose\fR +verbose output. +.TP +\fB\-S\fR, \fB\-\-simulate\fR +simulate the restoration, do not commit ruleset changes to the kernel. +Yet, this is not a pure virtual simulation, as it may have the side +effect of loading iptable_* kernel modules and their possible +dependencies, notably ip_conntrack, which can lead to performance +issues after the simulation. +.TP +\fB\-h\fR, \fB\-\-help\fR +display help message. .SH BUGS -None known as of iptables-1.2.1 release +None known as of iptables-1.2.10 release .SH AUTHOR Harald Welte <[email protected]> .SH SEE ALSO
iptables-restore.c +79 -87
304 lines not on this page · raw message
iptables-save.8 +7 -2
@@ -21,7 +21,7 @@ .SH NAME iptables-save \- Save IP Tables .SH SYNOPSIS -.BR "iptables-save " "[-c] [-t table]" +.BR "iptables-save " "[-c] [-t table] [-C] [-h]" .br .SH DESCRIPTION .PP
@@ -33,9 +33,14 @@ include the current values of all packet and byte counters in the output .TP \fB\-t\fR, \fB\-\-table\fR \fBtablename\fR -.TP restrict output to only one table. If not specified, output includes all available tables. +.TP +\fB\-C\fR, \fB\-\-no-comments\fR +do not output any comment. Useful for comparing two dump files. +.TP +\fB\-h\fR, \fB\-\-help\fR +display help message. .SH BUGS None known as of iptables-1.2.1 release .SH AUTHOR
iptables-save.c +67 -55
173 lines not on this page · raw message
iptables.8.in +7 -0
@@ -354,6 +354,13 @@ When adding or inserting rules into a chain, use .B command to load any necessary modules (targets, match extensions, etc). +.TP +.B "-S, --simulate" +simulate the restoration, do not commit ruleset changes to the kernel. +Yet, this is not a pure virtual simulation, as it may have the side +effect of loading iptable_* kernel modules and their possible +dependencies, notably ip_conntrack, which can lead to performance +issues after the simulation. .SH MATCH EXTENSIONS iptables can use extended packet matching modules. These are loaded in two ways: implicitly, when
iptables.c +26 -15
102 lines not on this page · raw message
libiptc/libip4tc.c +1 -0
@@ -92,6 +92,7 @@#define TC_GET_RAW_SOCKET iptc_get_raw_socket#define TC_INIT iptc_init#define TC_FREE iptc_free +#define TC_SET_NOCOMMIT iptc_set_nocommit#define TC_COMMIT iptc_commit#define TC_STRERROR iptc_strerror
libiptc/libip6tc.c +1 -0
@@ -87,6 +87,7 @@#define TC_GET_RAW_SOCKET ip6tc_get_raw_socket#define TC_INIT ip6tc_init#define TC_FREE ip6tc_free +#define TC_SET_NOCOMMIT ip6tc_set_nocommit#define TC_COMMIT ip6tc_commit#define TC_STRERROR ip6tc_strerror
libiptc/libiptc.c +15 -5
@@ -78,6 +78,8 @@ STRUCT_TC_HANDLE { +/* Do not commit anything to the kernel if this flag is set. */ +int nocommit;/* Have changes been made? */ int changed;/* Size in here reflects original state. */
@@ -109,6 +111,12 @@ h->changed =1 ; } +void +TC_SET_NOCOMMIT (TC_HANDLE_T *h) +{ + (*h)->nocommit =1 ; +} +#ifdef IPTC_DEBUG static void do_check (TC_HANDLE_T h,unsigned int line);#define CHECK (h) do { if (!getenv("IPTC_NO_CHECK")) do_check((h), __LINE__); } while(0)
@@ -230,6 +238,7 @@ } h->changed =0 ; + h->nocommit =0 ; h->cache_num_chains =0 ; h->cache_chain_heads =NULL ; h->counter_map = (void *)h
@@ -854,6 +863,7 @@if (!newh)return 0 ; newh->info = newinfo; + newh->nocommit = (*handle)->nocommit;/* Copy pre... */ memcpy (newh->entries.entrytable, (*handle)->entries.entrytable,offset);
@@ -1732,17 +1742,17 @@CHECK (*handle); - counterlen =sizeof (STRUCT_COUNTERS_INFO ) - +sizeof (STRUCT_COUNTERS ) * (*handle)->new_number; -#if 0 TC_DUMP_ENTRIES (*handle);#endif -/* Don't commit if nothing changed. */ -if (!(*handle)->changed) +/* Don't commit if nothing changed or if we are is nocommit mode. */ +if (!(*handle)->changed || (*handle)->nocommit) goto finished; + counterlen =sizeof (STRUCT_COUNTERS_INFO ) + +sizeof (STRUCT_COUNTERS ) * (*handle)->new_number; + repl =malloc (sizeof (*repl) + (*handle)->entries.size);if (!repl) { errno =ENOMEM ;
Makefile +1 -1
@@ -26,7 +26,7 @@ # directory for new iptables releases RELEASE_DIR:=/tmp -# Need libc6 for this. FIXME: Should covert to autoconf. +# Need libc6 for this. FIXME: Should convert to autoconf. ifeq ($(shell [ -f /usr/include/netinet/ip6.h ] && echo YES), YES) DO_IPV6:=1 endif
include/libiptc/libip6tc.h +3 -3
@@ -20,9 +20,6 @@/* Transparent handle type. */ typedef struct ip6tc_handle *ip6tc_handle_t ; -/* Does this chain exist? */ -int ip6tc_is_chain (const char *chain,const ip6tc_handle_t handle); -/* Take a snapshot of the rules. Returns NULL on error. */ ip6tc_handle_t ip6tc_init (const char *tablename);
@@ -48,6 +45,9 @@const char *ip6tc_get_target (const struct ip6t_entry *e,ip6tc_handle_t *handle); +/* Does this chain exist? */ +int ip6tc_is_chain (const char *chain,const ip6tc_handle_t handle); +/* Is this a built-in chain? */ int ip6tc_builtin (const char *chain,const ip6tc_handle_t handle);
include/libiptc/libiptc.h +3 -3
@@ -28,9 +28,6 @@/* Transparent handle type. */ typedef struct iptc_handle *iptc_handle_t ; -/* Does this chain exist? */ -int iptc_is_chain (const char *chain,const iptc_handle_t handle); -/* Take a snapshot of the rules. Returns NULL on error. */ iptc_handle_t iptc_init (const char *tablename);
@@ -56,6 +53,9 @@const char *iptc_get_target (const struct ipt_entry *e,iptc_handle_t *handle); +/* Does this chain exist? */ +int iptc_is_chain (const char *chain,const iptc_handle_t handle); +/* Is this a built-in chain? */ int iptc_builtin (const char *chain,const iptc_handle_t handle);
ip6tables-restore.8 +1 -1
@@ -27,7 +27,7 @@ .PP .B ip6tables-restore is used to restore IPv6 Tables from data specified on STDIN. Use -I/O redirection provided by your shell to read from a file +I/O redirection provided by your shell to read from a file. .TP \fB\-c\fR, \fB\-\-counters\fR restore the values of all packet and byte counters.
ip6tables-restore.c +57 -50
222 lines not on this page · raw message
ip6tables-save.8 +1 -1
@@ -30,7 +30,7 @@ to STDOUT. Use I/O-redirection provided by your shell to write to a file. .TP \fB\-c\fR, \fB\-\-counters\fR -include the current values of all packet and byte counters in the output +include the current values of all packet and byte counters in the output. .TP \fB\-t\fR, \fB\-\-table\fR \fBtablename\fR restrict output to only one table. If not specified, output includes all
ip6tables-save.c +34 -30
180 lines not on this page · raw message
ip6tables.8.in +2 -2
@@ -398,7 +398,7 @@ This .B ip6tables is very similar to ipchains by Rusty Russell. The main difference is -that the chains +that the chains .B INPUT and .B OUTPUT
@@ -408,7 +408,7 @@ involves both INPUT and OUTPUT chains); previously a forwarded packet would pass through all three. .PP -The other main difference is that +The other main difference is that .B -i refers to the input interface; .B -o
ip6tables.c +26 -27
169 lines not on this page · raw message
iptables-multi.c +3 -1
@@ -7,7 +7,9 @@int iptables_save_main (int argc,char **argv);int iptables_restore_main (int argc,char **argv); -int main (int argc,char **argv) { +int +main (int argc,char **argv) +{char *progname;if (argc ==0 ) {
iptables-restore.8 +1 -1
@@ -27,7 +27,7 @@ .PP .B iptables-restore is used to restore IP Tables from data specified on STDIN. Use -I/O redirection provided by your shell to read from a file +I/O redirection provided by your shell to read from a file. .TP \fB\-c\fR, \fB\-\-counters\fR restore the values of all packet and byte counters.
iptables-restore.c +58 -52
229 lines not on this page · raw message
iptables-save.8 +1 -1
@@ -30,7 +30,7 @@ to STDOUT. Use I/O-redirection provided by your shell to write to a file. .TP \fB\-c\fR, \fB\-\-counters\fR -include the current values of all packet and byte counters in the output +include the current values of all packet and byte counters in the output. .TP \fB\-t\fR, \fB\-\-table\fR \fBtablename\fR restrict output to only one table. If not specified, output includes all
iptables-save.c +29 -25
159 lines not on this page · raw message
iptables.8.in +1 -1
@@ -280,7 +280,7 @@ .TP .BR "-i, --in-interface " "[!] \fIname\fP" Name of an interface via which a packet was received (only for -packets entering the +packets entering the .BR INPUT , .B FORWARD and
iptables.c +23 -23
144 lines not on this page · raw message