diff options
author | Phil Sutter <phil@nwl.cc> | 2024-07-31 23:07:48 +0200 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2024-08-14 09:50:31 +0200 |
commit | 5bef3c1293092e4849a5d06032b3fa3ec10aba99 (patch) | |
tree | e1c8138659f3f0ac6fb318eb891e657fd2c33745 | |
parent | 7b7c0936303abd0a7b26c8bc1382136265815677 (diff) |
ebtables: Introduce nft_bridge_init_cs()
The custom init done by nft_rule_to_ebtables_command_state() (which is
also the reason for its existence in the first place) should better go
into an ebtables-specific init_cs callback. Properly calling it from
do_commandeb() then removes the need for that custom rule_to_cs
callback.
Signed-off-by: Phil Sutter <phil@nwl.cc>
-rw-r--r-- | iptables/nft-bridge.c | 11 | ||||
-rw-r--r-- | iptables/xtables-eb.c | 4 |
2 files changed, 8 insertions, 7 deletions
diff --git a/iptables/nft-bridge.c b/iptables/nft-bridge.c index f75a13fb..1623acba 100644 --- a/iptables/nft-bridge.c +++ b/iptables/nft-bridge.c @@ -203,12 +203,9 @@ static int nft_bridge_add(struct nft_handle *h, struct nft_rule_ctx *ctx, return _add_action(r, cs); } -static bool nft_rule_to_ebtables_command_state(struct nft_handle *h, - const struct nftnl_rule *r, - struct iptables_command_state *cs) +static void nft_bridge_init_cs(struct iptables_command_state *cs) { cs->eb.bitmask = EBT_NOPROTO; - return nft_rule_to_iptables_command_state(h, r, cs); } static void print_iface(const char *option, const char *name, bool invert) @@ -353,7 +350,8 @@ static void nft_bridge_print_rule(struct nft_handle *h, struct nftnl_rule *r, if (format & FMT_LINENUMBERS) printf("%d. ", num); - nft_rule_to_ebtables_command_state(h, r, &cs); + nft_bridge_init_cs(&cs); + nft_rule_to_iptables_command_state(h, r, &cs); __nft_bridge_save_rule(&cs, format); ebt_cs_clean(&cs); } @@ -699,7 +697,8 @@ struct nft_family_ops nft_family_ops_bridge = { .print_rule = nft_bridge_print_rule, .save_rule = nft_bridge_save_rule, .save_chain = nft_bridge_save_chain, - .rule_to_cs = nft_rule_to_ebtables_command_state, + .rule_to_cs = nft_rule_to_iptables_command_state, + .init_cs = nft_bridge_init_cs, .clear_cs = ebt_cs_clean, .xlate = nft_bridge_xlate, }; diff --git a/iptables/xtables-eb.c b/iptables/xtables-eb.c index 51c699de..45663a3a 100644 --- a/iptables/xtables-eb.c +++ b/iptables/xtables-eb.c @@ -557,7 +557,6 @@ int do_commandeb(struct nft_handle *h, int argc, char *argv[], char **table, .argc = argc, .argv = argv, .jumpto = "", - .eb.bitmask = EBT_NOPROTO, }; const struct builtin_table *t; struct xtables_args args = { @@ -572,6 +571,9 @@ int do_commandeb(struct nft_handle *h, int argc, char *argv[], char **table, }; int ret = 0; + if (h->ops->init_cs) + h->ops->init_cs(&cs); + do_parse(argc, argv, &p, &cs, &args); h->verbose = p.verbose; |