[PATCH] iptables-save.c fix for problem saving MIRROR target
Harald Welte
laforge@gnumonks.org
Tue, 16 Oct 2001 11:41:08 +0200
--HlL+5n6rz5pIUxbD
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi!
There was indeed a problem in the iptables-save core with regard to the
MIRROR target, or to be more precise: with regard to all targets which
don't provide a save function.
attached patch fixes the problem. Also fixed in netfilter/iptables CVS
now.
--
Live long and prosper
- Harald Welte / laforge@gnumonks.org http://www.gnumonks.org
============================================================================
GCS/E/IT d- s-: a-- C+++ UL++++$ P+++ L++++$ E--- W- N++ o? K- w--- O- M-
V-- PS+ PE-- Y+ PGP++ t++ 5-- !X !R tv-- b+++ DI? !D G+ e* h+ r% y+(*)
--HlL+5n6rz5pIUxbD
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="iptables-save.notarget.patch"
Index: iptables-save.c
===================================================================
RCS file: /data/cvs/netfilter/userspace/iptables-save.c,v
retrieving revision 1.19
diff -u -r1.19 iptables-save.c
--- iptables-save.c 6 Aug 2001 18:50:22 -0000 1.19
+++ iptables-save.c 16 Oct 2001 09:35:50 -0000
@@ -192,14 +192,22 @@
struct iptables_target *target
= find_target(t->u.user.name, TRY_LOAD);
- if (target)
+ if (!target) {
+ fprintf(stderr, "Can't find library for target `%s'\n",
+ t->u.user.name);
+ exit(1);
+ }
+
+ if (target->save)
target->save(&e->ip, t);
else {
- /* If some bits are non-zero, it implies we *need*
- to understand it */
- if (t->u.target_size) {
- fprintf(stderr,
- "Can't find library for target `%s'\n",
+ /* If the target size is greater than ipt_entry_target
+ * there is something to be saved, we just don't know
+ * how to print it */
+ if (t->u.target_size !=
+ sizeof(struct ipt_entry_target)) {
+ fprintf(stderr, "Target `%s' is missing "
+ "save function\n",
t->u.user.name);
exit(1);
}
--HlL+5n6rz5pIUxbD--