* [PATCH] libxtables: Make ip6tables, iptables and iptables-xml use xtables_globals
@ 2009-02-10 3:32 jamal
2009-02-11 12:04 ` Patrick McHardy
2009-02-11 15:22 ` Jan Engelhardt
0 siblings, 2 replies; 5+ messages in thread
From: jamal @ 2009-02-10 3:32 UTC (permalink / raw)
To: Patrick McHardy; +Cc: Jan Engelhardt, Pablo Neira Ayuso, netfilter-devel
[-- Attachment #1: Type: text/plain, Size: 69 bytes --]
Next step is to get rid of exit_error from xtables.c
cheers,
jamal
[-- Attachment #2: iptv2-3 --]
[-- Type: text/plain, Size: 3614 bytes --]
commit 1ffb5ab094585266e072a6b3e4950b50fbf4b9b4
Author: Jamal Hadi Salim <hadi@cyberus.ca>
Date: Mon Feb 9 22:12:05 2009 -0500
convert ip6tables, iptables and iptables-xml to use
xtables_globals/xtables_set_params()
Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>
diff --git a/Makefile.am b/Makefile.am
index 0ffb978..96de1b2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -21,6 +21,7 @@ iptables_SOURCES = iptables-standalone.c iptables.c
iptables_LDFLAGS = -rdynamic
iptables_LDADD = -ldl -lm libiptc/libiptc.a extensions/libext4.a libxtables.la
+iptables_xml_LDADD = -ldl libxtables.la
iptables_multi_SOURCES = iptables-multi.c iptables-save.c \
iptables-restore.c iptables-xml.c \
iptables-standalone.c iptables.c
diff --git a/ip6tables.c b/ip6tables.c
index 233974f..7561353 100644
--- a/ip6tables.c
+++ b/ip6tables.c
@@ -145,6 +145,13 @@ int line = -1;
static struct option *opts = original_opts;
static unsigned int global_option_offset = 0;
+struct xtables_globals ip6tables_globals = {
+ .option_offset = 0,
+ .program_version = IPTABLES_VERSION,
+ .program_name = "ip6tables",
+ .opts = original_opts,
+ .exit_error = exit_error,
+};
/* Table of legal combinations of commands and options. If any of the
* given commands make an option legal, that option is legal (applies to
@@ -1371,6 +1378,7 @@ int do_command6(int argc, char *argv[], char **table, struct ip6tc_handle **hand
demand-load a protocol. */
opterr = 0;
+ xtables_set_params(&ip6tables_globals);
while ((c = getopt_long(argc, argv,
"-A:D:R:I:L::S::M:F::Z::N:X::E:P:Vh::o:p:s:d:j:i:bvnt:m:xc:g:",
opts, NULL)) != -1) {
diff --git a/iptables-xml.c b/iptables-xml.c
index 307845c..329c598 100644
--- a/iptables-xml.c
+++ b/iptables-xml.c
@@ -17,6 +17,7 @@
#include "iptables.h"
#include "libiptc/libiptc.h"
#include "iptables-multi.h"
+#include <xtables.h>
#ifdef DEBUG
#define DEBUGP(x, args...) fprintf(stderr, x, ## args)
@@ -629,6 +630,12 @@ do_rule(char *pcnt, char *bcnt, int argc, char *argv[], int argvattr[])
do_rule_part(NULL, NULL, 1, argc, argv, argvattr);
}
+struct xtables_globals iptables_xml_globals = {
+ .option_offset = 0,
+ .program_version = IPTABLES_VERSION,
+ .program_name = "iptables-xml",
+ .exit_error = exit_error,
+};
#ifdef IPTABLES_MULTI
int
@@ -646,6 +653,7 @@ main(int argc, char *argv[])
program_version = IPTABLES_VERSION;
line = 0;
+ xtables_set_params(&iptables_xml_globals);
while ((c = getopt_long(argc, argv, "cvh", options, NULL)) != -1) {
switch (c) {
case 'c':
diff --git a/iptables.c b/iptables.c
index f1a5d33..e8bed87 100644
--- a/iptables.c
+++ b/iptables.c
@@ -145,6 +145,14 @@ int line = -1;
static struct option *opts = original_opts;
static unsigned int global_option_offset = 0;
+struct xtables_globals iptables_globals = {
+ .option_offset = 0,
+ .program_version = IPTABLES_VERSION,
+ .program_name = "iptables",
+ .opts = original_opts,
+ .exit_error = exit_error,
+};
+
/* Table of legal combinations of commands and options. If any of the
* given commands make an option legal, that option is legal (applies to
* CMD_LIST and CMD_ZERO only).
@@ -1393,6 +1401,7 @@ int do_command(int argc, char *argv[], char **table, struct iptc_handle **handle
demand-load a protocol. */
opterr = 0;
+ xtables_set_params(&iptables_globals);
while ((c = getopt_long(argc, argv,
"-A:D:R:I:L::S::M:F::Z::N:X::E:P:Vh::o:p:s:d:j:i:fbvnt:m:xc:g:",
opts, NULL)) != -1) {
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] libxtables: Make ip6tables, iptables and iptables-xml use xtables_globals
2009-02-10 3:32 [PATCH] libxtables: Make ip6tables, iptables and iptables-xml use xtables_globals jamal
@ 2009-02-11 12:04 ` Patrick McHardy
2009-02-11 15:22 ` Jan Engelhardt
1 sibling, 0 replies; 5+ messages in thread
From: Patrick McHardy @ 2009-02-11 12:04 UTC (permalink / raw)
To: hadi; +Cc: Jan Engelhardt, Pablo Neira Ayuso, netfilter-devel
jamal wrote:
> Next step is to get rid of exit_error from xtables.c
Applied, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] libxtables: Make ip6tables, iptables and iptables-xml use xtables_globals
2009-02-10 3:32 [PATCH] libxtables: Make ip6tables, iptables and iptables-xml use xtables_globals jamal
2009-02-11 12:04 ` Patrick McHardy
@ 2009-02-11 15:22 ` Jan Engelhardt
2009-02-11 17:18 ` jamal
1 sibling, 1 reply; 5+ messages in thread
From: Jan Engelhardt @ 2009-02-11 15:22 UTC (permalink / raw)
To: jamal; +Cc: Patrick McHardy, Pablo Neira Ayuso, netfilter-devel
On Tuesday 2009-02-10 04:32, jamal wrote:
>+++ b/Makefile.am
>@@ -21,6 +21,7 @@ iptables_SOURCES = iptables-standalone.c iptables.c
> iptables_LDFLAGS = -rdynamic
> iptables_LDADD = -ldl -lm libiptc/libiptc.a extensions/libext4.a libxtables.la
>
>+iptables_xml_LDADD = -ldl libxtables.la
> iptables_multi_SOURCES = iptables-multi.c iptables-save.c \
> iptables-restore.c iptables-xml.c \
> iptables-standalone.c iptables.c
-ldl does not belong to iptables_xml, this must be added
to libxtables_la_LIBADD instead (see 5c3e076 in my tree)
>+struct xtables_globals ip6tables_globals = {
>+ .option_offset = 0,
>+ .program_version = IPTABLES_VERSION,
>+ .program_name = "ip6tables",
>+ .opts = original_opts,
>+ .exit_error = exit_error,
>+};
>
> /* Table of legal combinations of commands and options. If any of the
> * given commands make an option legal, that option is legal (applies to
>@@ -1371,6 +1378,7 @@ int do_command6(int argc, char *argv[], char **table, struct ip6tc_handle **hand
> demand-load a protocol. */
> opterr = 0;
>
>+ xtables_set_params(&ip6tables_globals);
This looks like it would print "ip6tables" even when you
run ip6tables-restore, which is not what is wanted.
That said, libxtables does not even make use of _globals->program_name,
so I am terribly confused.
>+struct xtables_globals iptables_xml_globals = {
>+ .option_offset = 0,
>+ .program_version = IPTABLES_VERSION,
>+ .program_name = "iptables-xml",
>+ .exit_error = exit_error,
>+};
>
> #ifdef IPTABLES_MULTI
> int
>@@ -646,6 +653,7 @@ main(int argc, char *argv[])
> program_version = IPTABLES_VERSION;
> line = 0;
>
>+ xtables_set_params(&iptables_xml_globals);
> while ((c = getopt_long(argc, argv, "cvh", options, NULL)) != -1) {
> switch (c) {
> case 'c':
>diff --git a/iptables.c b/iptables.c
>index f1a5d33..e8bed87 100644
>--- a/iptables.c
>+++ b/iptables.c
>@@ -145,6 +145,14 @@ int line = -1;
> static struct option *opts = original_opts;
> static unsigned int global_option_offset = 0;
>
>+struct xtables_globals iptables_globals = {
>+ .option_offset = 0,
>+ .program_version = IPTABLES_VERSION,
>+ .program_name = "iptables",
>+ .opts = original_opts,
>+ .exit_error = exit_error,
>+};
>+
> /* Table of legal combinations of commands and options. If any of the
> * given commands make an option legal, that option is legal (applies to
> * CMD_LIST and CMD_ZERO only).
>@@ -1393,6 +1401,7 @@ int do_command(int argc, char *argv[], char **table, struct iptc_handle **handle
> demand-load a protocol. */
> opterr = 0;
>
>+ xtables_set_params(&iptables_globals);
> while ((c = getopt_long(argc, argv,
> "-A:D:R:I:L::S::M:F::Z::N:X::E:P:Vh::o:p:s:d:j:i:fbvnt:m:xc:g:",
> opts, NULL)) != -1) {
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] libxtables: Make ip6tables, iptables and iptables-xml use xtables_globals
2009-02-11 15:22 ` Jan Engelhardt
@ 2009-02-11 17:18 ` jamal
2009-02-11 17:30 ` Jan Engelhardt
0 siblings, 1 reply; 5+ messages in thread
From: jamal @ 2009-02-11 17:18 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: Patrick McHardy, Pablo Neira Ayuso, netfilter-devel
On Wed, 2009-02-11 at 16:22 +0100, Jan Engelhardt wrote:
> On Tuesday 2009-02-10 04:32, jamal wrote:
> -ldl does not belong to iptables_xml, this must be added
> to libxtables_la_LIBADD instead (see 5c3e076 in my tree)
>
Ok. Shall i send an addendum patch?
>
> This looks like it would print "ip6tables" even when you
> run ip6tables-restore, which is not what is wanted.
Good catch. I have actually fixed it in the patch i promised
on xtables_init_all() - it was easier to spot there. I will send
that patch later when i finish responding.
> That said, libxtables does not even make use of _globals->program_name,
> so I am terribly confused.
I was planning to send one huge patch which gets rid of program_name,
program_version and xtables_program_name at the end.
cheers,
jamal
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] libxtables: Make ip6tables, iptables and iptables-xml use xtables_globals
2009-02-11 17:18 ` jamal
@ 2009-02-11 17:30 ` Jan Engelhardt
0 siblings, 0 replies; 5+ messages in thread
From: Jan Engelhardt @ 2009-02-11 17:30 UTC (permalink / raw)
To: jamal; +Cc: Patrick McHardy, Pablo Neira Ayuso, netfilter-devel
On Wednesday 2009-02-11 18:18, jamal wrote:
>On Wed, 2009-02-11 at 16:22 +0100, Jan Engelhardt wrote:
>> On Tuesday 2009-02-10 04:32, jamal wrote:
>
>> -ldl does not belong to iptables_xml, this must be added
>> to libxtables_la_LIBADD instead (see 5c3e076 in my tree)
>>
>
>Ok. Shall i send an addendum patch?
Since this patch, too, has already been applied, I took care of it.
>> That said, libxtables does not even make use of _globals->program_name,
>> so I am terribly confused.
>
>I was planning to send one huge patch which gets rid of program_name,
>program_version and xtables_program_name at the end.
Just don't make it too huge :)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-02-11 17:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-10 3:32 [PATCH] libxtables: Make ip6tables, iptables and iptables-xml use xtables_globals jamal
2009-02-11 12:04 ` Patrick McHardy
2009-02-11 15:22 ` Jan Engelhardt
2009-02-11 17:18 ` jamal
2009-02-11 17:30 ` Jan Engelhardt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).