netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: [iptables PATCH 2/8] xtables-restore: Use xt_params->program_name
Date: Fri, 18 Oct 2019 00:48:30 +0200	[thread overview]
Message-ID: <20191017224836.8261-3-phil@nwl.cc> (raw)
In-Reply-To: <20191017224836.8261-1-phil@nwl.cc>

Instead of setting newargv[0] to argv[0]'s value, just use whatever
xt_params->program_name contains. The latter is arbitrarily defined, but
may still be more correct than real argv[0] which may simply be for
instance xtables-nft-multi. Either way, there is no practical
significance since newargv[0] is used exclusively in debug output.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 iptables/nft-shared.h        |  3 +--
 iptables/xtables-restore.c   | 11 +++++------
 iptables/xtables-translate.c |  2 +-
 3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/iptables/nft-shared.h b/iptables/nft-shared.h
index a330aceb9785c..5c6641505f3db 100644
--- a/iptables/nft-shared.h
+++ b/iptables/nft-shared.h
@@ -262,8 +262,7 @@ struct nft_xt_restore_cb {
 
 void xtables_restore_parse(struct nft_handle *h,
 			   const struct nft_xt_restore_parse *p,
-			   struct nft_xt_restore_cb *cb,
-			   int argc, char *argv[]);
+			   struct nft_xt_restore_cb *cb);
 
 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 cb03104e91a7b..24bfce516d34c 100644
--- a/iptables/xtables-restore.c
+++ b/iptables/xtables-restore.c
@@ -87,8 +87,7 @@ static const struct xtc_ops xtc_ops = {
 
 void xtables_restore_parse(struct nft_handle *h,
 			   const struct nft_xt_restore_parse *p,
-			   struct nft_xt_restore_cb *cb,
-			   int argc, char *argv[])
+			   struct nft_xt_restore_cb *cb)
 {
 	const struct builtin_table *curtable = NULL;
 	char buffer[10240];
@@ -264,7 +263,7 @@ void xtables_restore_parse(struct nft_handle *h,
 				parsestart = buffer;
 			}
 
-			add_argv(argv[0], 0);
+			add_argv(xt_params->program_name, 0);
 			add_argv("-t", 0);
 			add_argv(curtable->name, 0);
 
@@ -434,7 +433,7 @@ xtables_restore_main(int family, const char *progname, int argc, char *argv[])
 		exit(EXIT_FAILURE);
 	}
 
-	xtables_restore_parse(&h, &p, &restore_cb, argc, argv);
+	xtables_restore_parse(&h, &p, &restore_cb);
 
 	nft_fini(&h);
 	fclose(p.in);
@@ -500,7 +499,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, argc, argv);
+	xtables_restore_parse(&h, &p, &ebt_restore_cb);
 	nft_fini(&h);
 
 	return 0;
@@ -524,7 +523,7 @@ int xtables_arp_restore_main(int argc, char *argv[])
 	struct nft_handle h;
 
 	nft_init_arp(&h, "arptables-restore");
-	xtables_restore_parse(&h, &p, &arp_restore_cb, argc, argv);
+	xtables_restore_parse(&h, &p, &arp_restore_cb);
 	nft_fini(&h);
 
 	return 0;
diff --git a/iptables/xtables-translate.c b/iptables/xtables-translate.c
index 4ae9ff57c0eb3..64e7667a253e7 100644
--- a/iptables/xtables-translate.c
+++ b/iptables/xtables-translate.c
@@ -535,7 +535,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, argc, argv);
+	xtables_restore_parse(&h, &p, &cb_xlate);
 	printf("# Completed on %s", ctime(&now));
 
 	nft_fini(&h);
-- 
2.23.0


  parent reply	other threads:[~2019-10-17 22:48 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-17 22:48 [iptables PATCH 0/8] A bit of *tables-restore review fallout Phil Sutter
2019-10-17 22:48 ` [iptables PATCH 1/8] xtables-restore: Treat struct nft_xt_restore_parse as const Phil Sutter
2019-10-18  8:09   ` Pablo Neira Ayuso
2019-10-17 22:48 ` Phil Sutter [this message]
2019-10-18  8:09   ` [iptables PATCH 2/8] xtables-restore: Use xt_params->program_name Pablo Neira Ayuso
2019-10-17 22:48 ` [iptables PATCH 3/8] xtables-restore: Introduce rule counter tokenizer function Phil Sutter
2019-10-18  8:11   ` Pablo Neira Ayuso
2019-10-18  9:50     ` Phil Sutter
2019-10-18 10:03       ` Pablo Neira Ayuso
2019-10-17 22:48 ` [iptables PATCH 4/8] xtables-restore: Constify struct nft_xt_restore_cb Phil Sutter
2019-10-18  8:11   ` Pablo Neira Ayuso
2019-10-17 22:48 ` [iptables PATCH 5/8] iptables-restore: Constify struct iptables_restore_cb Phil Sutter
2019-10-18  8:12   ` Pablo Neira Ayuso
2019-10-17 22:48 ` [iptables PATCH 6/8] xtables-restore: Drop pointless newargc reset Phil Sutter
2019-10-18  8:30   ` Pablo Neira Ayuso
2019-10-18  9:54     ` Phil Sutter
2019-10-17 22:48 ` [iptables PATCH 7/8] xtables-restore: Drop local xtc_ops instance Phil Sutter
2019-10-18  8:31   ` Pablo Neira Ayuso
2019-10-17 22:48 ` [iptables PATCH 8/8] xtables-restore: Drop chain_list callback Phil Sutter
2019-10-18  8:32   ` Pablo Neira Ayuso

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=20191017224836.8261-3-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).