From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: Florian Westphal <fw@strlen.de>
Subject: [PATCH nft 3/6] main: add -O help to dump list of supported optimzation flags
Date: Thu, 27 May 2021 17:43:20 +0200 [thread overview]
Message-ID: <20210527154323.4003-4-fw@strlen.de> (raw)
In-Reply-To: <20210527154323.4003-1-fw@strlen.de>
Print list of supported options.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
src/main.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/src/main.c b/src/main.c
index 6e14a7f26b0f..cf00f27f06de 100644
--- a/src/main.c
+++ b/src/main.c
@@ -86,6 +86,7 @@ enum opt_vals {
enum optimization_feature {
OPTIMIZE_UNDEFINED,
+ OPTIMIZE_HELP,
OPTIMIZE_REMOVE_DEPENDENCIES,
};
@@ -315,11 +316,18 @@ static const struct {
static const struct {
const char *name;
+ const char *help;
enum optimization_feature level;
enum nft_optimization_flags flag;
} optimization_param[] = {
+ {
+ .name = "help",
+ .help = "",
+ .level = OPTIMIZE_HELP,
+ },
{
.name = "remove-dependencies",
+ .help = "ruleset listing with redundant expressions removed",
.level = OPTIMIZE_REMOVE_DEPENDENCIES,
.flag = NFT_OPTIMIZATION_F_REMOVE_DEPS,
},
@@ -372,6 +380,7 @@ static bool nft_options_check(int argc, char * const argv[])
static void optimize_settings_set_custom(struct nft_ctx *ctx, char *options)
{
+ unsigned int default_flags = ctx->optimization_flags;
unsigned int i;
char *end;
@@ -401,7 +410,21 @@ static void optimize_settings_set_custom(struct nft_ctx *ctx, char *options)
switch (level) {
case OPTIMIZE_UNDEFINED:
fprintf(stderr, "invalid optimization option `%s'\n", options);
+ fprintf(stderr, "Try \"-O help\" for list of options.\n");
exit(EXIT_FAILURE);
+ case OPTIMIZE_HELP:
+ for (i = 0; i < array_size(optimization_param); i++) {
+ if (level == optimization_param[i].level)
+ continue;
+
+ flag = optimization_param[i].flag;
+ printf("%s: %s (default %s)\n",
+ optimization_param[i].name, optimization_param[i].help,
+ default_flags & flag ? "on" : "off");
+ }
+
+ printf("\nPrepend \"no-\" to disable options that are enabled by default.\n");
+ exit(EXIT_SUCCESS);
case OPTIMIZE_REMOVE_DEPENDENCIES:
break;
}
--
2.26.3
next prev parent reply other threads:[~2021-05-27 15:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-27 15:43 [PATCH nft 0/6] nftables: add --optimize support Florian Westphal
2021-05-27 15:43 ` [PATCH nft 1/6] src: add proto ctx options Florian Westphal
2021-05-27 15:43 ` [PATCH nft 2/6] src: allow to turn off dependency removal Florian Westphal
2021-05-27 15:43 ` Florian Westphal [this message]
2021-05-27 15:43 ` [PATCH nft 4/6] evaluate: optionally kill anon sets with one element Florian Westphal
2021-05-27 15:43 ` [PATCH nft 5/6] tests: add test case for -O no-remove-dependencies Florian Westphal
2021-05-27 15:43 ` [PATCH nft 6/6] tests: add test case for removal of anon sets with only a single element Florian Westphal
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=20210527154323.4003-4-fw@strlen.de \
--to=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.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).