]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
ebtables: Introduce nft_bridge_init_cs()
authorPhil Sutter <phil@nwl.cc>
Wed, 31 Jul 2024 21:07:48 +0000 (23:07 +0200)
committerPhil Sutter <phil@nwl.cc>
Wed, 14 Aug 2024 07:50:31 +0000 (09:50 +0200)
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>
iptables/nft-bridge.c
iptables/xtables-eb.c

index f75a13fbf1120d63f39081484a663e8be9e8d355..1623acbac0ba62926b1a03fed890fe8aa8fe3b1c 100644 (file)
@@ -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,
 };
index 51c699defb047614ce8b0cd23d6d866b6bc1e3ba..45663a3ad0ee0bd3fe1d12a88eb6a4951a51b63b 100644 (file)
@@ -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;