iptables: Work around API breakage introduced in iptables 1.4.11
authorStefan Schmidt <stefan@datenfreihafen.org>
Wed, 20 Jul 2011 14:46:06 +0000 (16:46 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 21 Jul 2011 09:34:09 +0000 (11:34 +0200)
The xtables_merge_options() paramter list got extended without version bump.
These clumsy #ifdef's make it possible to work with newer and older iptables
libraries. It got inspired from an iproute2 patch:
https://bugs.gentoo.org/attachment.cgi?id=276401

Once all distributions start to carry 1.4.11 it can be considered to bump the
minimum version for connman and remove these ifdef's.

src/iptables.c
tools/iptables-test.c

index 8f8ab53..e852e01 100644 (file)
@@ -1089,7 +1089,11 @@ static int iptables_command(int argc, char *argv[])
                        if (xt_t->init != NULL)
                                xt_t->init(xt_t->t);
                        iptables_globals.opts =
                        if (xt_t->init != NULL)
                                xt_t->init(xt_t->t);
                        iptables_globals.opts =
-                               xtables_merge_options(iptables_globals.opts,
+                               xtables_merge_options(
+#if XTABLES_VERSION_CODE > 5
+                                                    iptables_globals.orig_opts,
+#endif
+                                                    iptables_globals.opts,
                                                     xt_t->extra_opts,
                                                     &xt_t->option_offset);
                        if (iptables_globals.opts == NULL)
                                                     xt_t->extra_opts,
                                                     &xt_t->option_offset);
                        if (iptables_globals.opts == NULL)
@@ -1113,7 +1117,11 @@ static int iptables_command(int argc, char *argv[])
                                xt_m->init(xt_m->m);
                        if (xt_m != xt_m->next) {
                                iptables_globals.opts =
                                xt_m->init(xt_m->m);
                        if (xt_m != xt_m->next) {
                                iptables_globals.opts =
-                               xtables_merge_options(iptables_globals.opts,
+                               xtables_merge_options(
+#if XTABLES_VERSION_CODE > 5
+                                               iptables_globals.orig_opts,
+#endif
+                                               iptables_globals.opts,
                                                xt_m->extra_opts,
                                                &xt_m->option_offset);
                                if (iptables_globals.opts == NULL)
                                                xt_m->extra_opts,
                                                &xt_m->option_offset);
                                if (iptables_globals.opts == NULL)
index 298f23d..bfe4803 100644 (file)
@@ -1076,7 +1076,11 @@ int main(int argc, char *argv[])
                        if (xt_t->init != NULL)
                                xt_t->init(xt_t->t);
                        connman_iptables_globals.opts =
                        if (xt_t->init != NULL)
                                xt_t->init(xt_t->t);
                        connman_iptables_globals.opts =
-                               xtables_merge_options(connman_iptables_globals.opts,
+                               xtables_merge_options(
+#if XTABLES_VERSION_CODE > 5
+                                                    connman_iptables_globals.orig_opts,
+#endif
+                                                    connman_iptables_globals.opts,
                                                     xt_t->extra_opts,
                                                     &xt_t->option_offset);
                        if (connman_iptables_globals.opts == NULL)
                                                     xt_t->extra_opts,
                                                     &xt_t->option_offset);
                        if (connman_iptables_globals.opts == NULL)
@@ -1102,7 +1106,11 @@ int main(int argc, char *argv[])
                                xt_m->init(xt_m->m);
                        if (xt_m != xt_m->next) {
                                connman_iptables_globals.opts =
                                xt_m->init(xt_m->m);
                        if (xt_m != xt_m->next) {
                                connman_iptables_globals.opts =
-                                       xtables_merge_options(connman_iptables_globals.opts,
+                                       xtables_merge_options(
+#if XTABLES_VERSION_CODE > 5
+                                               connman_iptables_globals.orig_opts,
+#endif
+                                               connman_iptables_globals.opts,
                                                xt_m->extra_opts,
                                                &xt_m->option_offset);
                                if (connman_iptables_globals.opts == NULL)
                                                xt_m->extra_opts,
                                                &xt_m->option_offset);
                                if (connman_iptables_globals.opts == NULL)