From: Phil Sutter <phil@nwl.cc>
To: netfilter-devel@vger.kernel.org
Subject: [iptables PATCH 11/13] ebtables: Use struct xt_cmd_parse
Date: Wed, 29 Nov 2023 14:28:25 +0100 [thread overview]
Message-ID: <20231129132827.18166-12-phil@nwl.cc> (raw)
In-Reply-To: <20231129132827.18166-1-phil@nwl.cc>
This is merely to reduce size of the parser merge patch, no functional
change intended.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
iptables/xtables-eb.c | 59 ++++++++++++++++++++++++++-----------------
1 file changed, 36 insertions(+), 23 deletions(-)
diff --git a/iptables/xtables-eb.c b/iptables/xtables-eb.c
index 8ab479237faa8..e03b2b2510eda 100644
--- a/iptables/xtables-eb.c
+++ b/iptables/xtables-eb.c
@@ -767,6 +767,8 @@ int do_commandeb(struct nft_handle *h, int argc, char *argv[], char **table,
.jumpto = "",
.eb.bitmask = EBT_NOPROTO,
};
+ struct xt_cmd_parse p = {
+ };
char command = 'h';
const char *chain = NULL;
const char *policy = NULL;
@@ -1166,56 +1168,67 @@ int do_commandeb(struct nft_handle *h, int argc, char *argv[], char **table,
* The kernel does not have to do this of course */
cs.eb.ethproto = htons(cs.eb.ethproto);
+ p.table = *table;
+ p.chain = chain;
+ p.policy = policy;
+ p.rulenum = rule_nr;
+ p.rulenum_end = rule_nr_end;
+ cs.options = flags;
+
switch (command) {
case 'P':
if (selected_chain >= NF_BR_NUMHOOKS) {
- ret = ebt_cmd_user_chain_policy(h, *table, chain, policy);
+ ret = ebt_cmd_user_chain_policy(h, p.table, p.chain,
+ p.policy);
break;
}
- if (strcmp(policy, "RETURN") == 0) {
+ if (strcmp(p.policy, "RETURN") == 0) {
xtables_error(PARAMETER_PROBLEM,
"Policy RETURN only allowed for user defined chains");
}
- ret = nft_cmd_chain_set(h, *table, chain, policy, NULL);
+ ret = nft_cmd_chain_set(h, p.table, p.chain, p.policy, NULL);
if (ret < 0)
xtables_error(PARAMETER_PROBLEM, "Wrong policy");
break;
case 'L':
- ret = list_rules(h, chain, *table, rule_nr,
- flags & OPT_VERBOSE,
+ ret = list_rules(h, p.chain, p.table, p.rulenum,
+ cs.options & OPT_VERBOSE,
0,
- /*flags&OPT_EXPANDED*/0,
- flags&LIST_N,
- flags&LIST_C);
- if (!(flags & OPT_ZERO))
+ /*cs.options&OPT_EXPANDED*/0,
+ cs.options&LIST_N,
+ cs.options&LIST_C);
+ if (!(cs.options & OPT_ZERO))
break;
case 'Z':
- ret = nft_cmd_chain_zero_counters(h, chain, *table,
- flags & OPT_VERBOSE);
+ ret = nft_cmd_chain_zero_counters(h, p.chain, p.table,
+ cs.options & OPT_VERBOSE);
break;
case 'F':
- ret = nft_cmd_rule_flush(h, chain, *table, flags & OPT_VERBOSE);
+ ret = nft_cmd_rule_flush(h, p.chain, p.table,
+ cs.options & OPT_VERBOSE);
break;
case 'A':
- ret = nft_cmd_rule_append(h, chain, *table, &cs,
- flags & OPT_VERBOSE);
+ ret = nft_cmd_rule_append(h, p.chain, p.table, &cs,
+ cs.options & OPT_VERBOSE);
break;
case 'I':
- ret = nft_cmd_rule_insert(h, chain, *table, &cs,
- rule_nr - 1, flags & OPT_VERBOSE);
+ ret = nft_cmd_rule_insert(h, p.chain, p.table, &cs,
+ p.rulenum - 1,
+ cs.options & OPT_VERBOSE);
break;
case 'D':
- ret = delete_entry(h, chain, *table, &cs, rule_nr - 1,
- rule_nr_end, flags & OPT_VERBOSE);
+ ret = delete_entry(h, p.chain, p.table, &cs, p.rulenum - 1,
+ p.rulenum_end, cs.options & OPT_VERBOSE);
break;
case 14:
- ret = nft_cmd_rule_check(h, chain, *table,
- &cs, flags & OPT_VERBOSE);
+ ret = nft_cmd_rule_check(h, p.chain, p.table,
+ &cs, cs.options & OPT_VERBOSE);
break;
case 'C':
- ret = change_entry_counters(h, chain, *table, &cs,
- rule_nr - 1, rule_nr_end, chcounter,
- flags & OPT_VERBOSE);
+ ret = change_entry_counters(h, p.chain, p.table, &cs,
+ p.rulenum - 1, p.rulenum_end,
+ chcounter,
+ cs.options & OPT_VERBOSE);
break;
}
--
2.41.0
next prev parent reply other threads:[~2023-11-29 13:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-29 13:28 [iptables PATCH 00/13] ebtables: Use the shared commandline parser Phil Sutter
2023-11-29 13:28 ` [iptables PATCH 01/13] xshared: do_parse: Skip option checking for CMD_DELETE_NUM Phil Sutter
2023-11-29 13:28 ` [iptables PATCH 02/13] xshared: Perform protocol value parsing in callback Phil Sutter
2023-11-29 13:28 ` [iptables PATCH 03/13] xshared: Turn command_default() into a callback Phil Sutter
2023-11-29 13:28 ` [iptables PATCH 04/13] xshared: Introduce print_help callback (again) Phil Sutter
2023-11-29 13:28 ` [iptables PATCH 05/13] xshared: Support rule range deletion in do_parse() Phil Sutter
2023-11-29 13:28 ` [iptables PATCH 06/13] xshared: Support for ebtables' --change-counters command Phil Sutter
2023-11-29 13:28 ` [iptables PATCH 07/13] ebtables{,-translate}: Convert if-clause to switch() Phil Sutter
2023-11-29 13:28 ` [iptables PATCH 08/13] ebtables: Change option values to avoid clashes Phil Sutter
2023-11-29 13:28 ` [iptables PATCH 09/13] ebtables: Pass struct iptables_command_state to print_help() Phil Sutter
2023-11-29 13:28 ` [iptables PATCH 10/13] ebtables: Make 'h' case just a call " Phil Sutter
2023-11-29 13:28 ` Phil Sutter [this message]
2023-11-29 13:28 ` [iptables PATCH 12/13] xshared: Introduce option_test_and_reject() Phil Sutter
2023-11-29 13:28 ` [iptables PATCH 13/13] ebtables: Use do_parse() from xshared Phil Sutter
2023-12-05 16:25 ` [iptables PATCH 00/13] ebtables: Use the shared commandline parser 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=20231129132827.18166-12-phil@nwl.cc \
--to=phil@nwl.cc \
--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).