From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: [iptables PATCH v3 1/7] xtables-restore: Integrate restore callbacks into struct nft_xt_restore_parse
Date: Thu, 24 Oct 2019 18:37:06 +0200 [thread overview]
Message-ID: <20191024163712.22405-2-phil@nwl.cc> (raw)
In-Reply-To: <20191024163712.22405-1-phil@nwl.cc>
There's really no point in passing those as separate parameter. While
being at it, make them static const everywhere.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
iptables/nft-shared.h | 18 +++++++++---------
iptables/xtables-restore.c | 13 ++++++++-----
iptables/xtables-translate.c | 6 ++++--
3 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/iptables/nft-shared.h b/iptables/nft-shared.h
index 8b073b18fb0d9..3ff7251f9f7ec 100644
--- a/iptables/nft-shared.h
+++ b/iptables/nft-shared.h
@@ -232,13 +232,6 @@ void do_parse(struct nft_handle *h, int argc, char *argv[],
struct nft_xt_cmd_parse *p, struct iptables_command_state *cs,
struct xtables_args *args);
-struct nft_xt_restore_parse {
- FILE *in;
- int testing;
- const char *tablename;
- bool commit;
-};
-
struct nftnl_chain_list;
struct nft_xt_restore_cb {
@@ -258,9 +251,16 @@ struct nft_xt_restore_cb {
int (*abort)(struct nft_handle *h);
};
+struct nft_xt_restore_parse {
+ FILE *in;
+ int testing;
+ const char *tablename;
+ bool commit;
+ const struct nft_xt_restore_cb *cb;
+};
+
void xtables_restore_parse(struct nft_handle *h,
- const struct nft_xt_restore_parse *p,
- const struct nft_xt_restore_cb *cb);
+ const struct nft_xt_restore_parse *p);
void nft_check_xt_legacy(int family, bool is_ipt_save);
#endif
diff --git a/iptables/xtables-restore.c b/iptables/xtables-restore.c
index 8d6cb7a97ea37..341579bd8d1c3 100644
--- a/iptables/xtables-restore.c
+++ b/iptables/xtables-restore.c
@@ -69,10 +69,10 @@ static const struct nft_xt_restore_cb restore_cb = {
};
void xtables_restore_parse(struct nft_handle *h,
- const struct nft_xt_restore_parse *p,
- const struct nft_xt_restore_cb *cb)
+ const struct nft_xt_restore_parse *p)
{
const struct builtin_table *curtable = NULL;
+ const struct nft_xt_restore_cb *cb = p->cb;
struct argv_store av_store = {};
char buffer[10240];
int in_table = 0;
@@ -279,6 +279,7 @@ xtables_restore_main(int family, const char *progname, int argc, char *argv[])
int c;
struct nft_xt_restore_parse p = {
.commit = true,
+ .cb = &restore_cb,
};
line = 0;
@@ -383,7 +384,7 @@ xtables_restore_main(int family, const char *progname, int argc, char *argv[])
exit(EXIT_FAILURE);
}
- xtables_restore_parse(&h, &p, &restore_cb);
+ xtables_restore_parse(&h, &p);
nft_fini(&h);
fclose(p.in);
@@ -427,6 +428,7 @@ int xtables_eb_restore_main(int argc, char *argv[])
{
struct nft_xt_restore_parse p = {
.in = stdin,
+ .cb = &ebt_restore_cb,
};
bool noflush = false;
struct nft_handle h;
@@ -448,7 +450,7 @@ int xtables_eb_restore_main(int argc, char *argv[])
nft_init_eb(&h, "ebtables-restore");
h.noflush = noflush;
- xtables_restore_parse(&h, &p, &ebt_restore_cb);
+ xtables_restore_parse(&h, &p);
nft_fini(&h);
return 0;
@@ -467,11 +469,12 @@ int xtables_arp_restore_main(int argc, char *argv[])
{
struct nft_xt_restore_parse p = {
.in = stdin,
+ .cb = &arp_restore_cb,
};
struct nft_handle h;
nft_init_arp(&h, "arptables-restore");
- xtables_restore_parse(&h, &p, &arp_restore_cb);
+ xtables_restore_parse(&h, &p);
nft_fini(&h);
return 0;
diff --git a/iptables/xtables-translate.c b/iptables/xtables-translate.c
index 43607901fc62b..a42c60a3b64c6 100644
--- a/iptables/xtables-translate.c
+++ b/iptables/xtables-translate.c
@@ -498,7 +498,9 @@ static int xtables_restore_xlate_main(int family, const char *progname,
.family = family,
};
const char *file = NULL;
- struct nft_xt_restore_parse p = {};
+ struct nft_xt_restore_parse p = {
+ .cb = &cb_xlate,
+ };
time_t now = time(NULL);
int c;
@@ -535,7 +537,7 @@ static int xtables_restore_xlate_main(int family, const char *progname,
printf("# Translated by %s v%s on %s",
argv[0], PACKAGE_VERSION, ctime(&now));
- xtables_restore_parse(&h, &p, &cb_xlate);
+ xtables_restore_parse(&h, &p);
printf("# Completed on %s", ctime(&now));
nft_fini(&h);
--
2.23.0
next prev parent reply other threads:[~2019-10-24 16:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-24 16:37 [iptables PATCH v3 0/7] Improve xtables-restore performance Phil Sutter
2019-10-24 16:37 ` Phil Sutter [this message]
2019-10-24 16:37 ` [iptables PATCH v3 2/7] xtables-restore: Introduce struct nft_xt_restore_state Phil Sutter
2019-10-24 16:37 ` [iptables PATCH v3 3/7] xtables-restore: Introduce line parsing function Phil Sutter
2019-10-24 16:37 ` [iptables PATCH v3 4/7] xtables-restore: Remove some pointless linebreaks Phil Sutter
2019-10-24 16:37 ` [iptables PATCH v3 5/7] xtables-restore: Allow lines without trailing newline character Phil Sutter
2019-10-24 16:37 ` [iptables PATCH v3 6/7] xtables-restore: Improve performance of --noflush operation Phil Sutter
2019-10-24 16:37 ` [iptables PATCH v3 7/7] tests: shell: Add ipt-restore/0007-flush-noflush_0 Phil Sutter
2019-10-31 15:02 ` [iptables PATCH v3 0/7] Improve xtables-restore performance Pablo Neira Ayuso
2019-10-31 17:19 ` Phil Sutter
2019-11-06 9:24 ` Pablo Neira Ayuso
2019-11-06 12:31 ` Phil Sutter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191024163712.22405-2-phil@nwl.cc \
--to=phil@nwl.cc \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).