]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
nft: family_ops: Pass nft_handle to 'rule_find' callback
authorPhil Sutter <phil@nwl.cc>
Tue, 20 Aug 2019 16:20:53 +0000 (18:20 +0200)
committerPhil Sutter <phil@nwl.cc>
Mon, 25 Nov 2019 22:30:52 +0000 (23:30 +0100)
In order to prepare for rules containing set references, nft handle has
to be passed to nft_rule_to_iptables_command_state() in order to let it
access the set in cache.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
iptables/nft-arp.c
iptables/nft-bridge.c
iptables/nft-shared.c
iptables/nft-shared.h
iptables/nft.c

index de7743392afa1c675e42993b85e73b03a930f423..5ad7556c637b83286cfd70afe7a0a362a4ebcbe5 100644 (file)
@@ -632,7 +632,7 @@ static bool nft_arp_is_same(const void *data_a,
                                  (unsigned char *)b->arp.outiface_mask);
 }
 
-static bool nft_arp_rule_find(struct nft_family_ops *ops, struct nftnl_rule *r,
+static bool nft_arp_rule_find(struct nft_handle *h, struct nftnl_rule *r,
                              void *data)
 {
        const struct iptables_command_state *cs = data;
@@ -653,7 +653,7 @@ static bool nft_arp_rule_find(struct nft_family_ops *ops, struct nftnl_rule *r,
 
        ret = true;
 out:
-       ops->clear_cs(&this);
+       h->ops->clear_cs(&this);
        return ret;
 }
 
index 0fc21b3a3c0d6b5304a1aa5b07fae0100fdacd56..73bca2f38101e8c2eefd3ec884f994349e09a6c6 100644 (file)
@@ -537,7 +537,7 @@ static bool nft_bridge_is_same(const void *data_a, const void *data_b)
        return strcmp(a->in, b->in) == 0 && strcmp(a->out, b->out) == 0;
 }
 
-static bool nft_bridge_rule_find(struct nft_family_ops *ops, struct nftnl_rule *r,
+static bool nft_bridge_rule_find(struct nft_handle *h, struct nftnl_rule *r,
                                 void *data)
 {
        struct iptables_command_state *cs = data;
@@ -568,7 +568,7 @@ static bool nft_bridge_rule_find(struct nft_family_ops *ops, struct nftnl_rule *
 
        ret = true;
 out:
-       ops->clear_cs(&this);
+       h->ops->clear_cs(&this);
        return ret;
 }
 
index 6fd8ade5a1e5995b950c08f325ffb2a1f0048dbc..b6d85f1af1da9665d4b7f59b67f2c934a18042fc 100644 (file)
@@ -982,8 +982,7 @@ void nft_ipv46_parse_target(struct xtables_target *t, void *data)
        cs->target = t;
 }
 
-bool nft_ipv46_rule_find(struct nft_family_ops *ops,
-                        struct nftnl_rule *r, void *data)
+bool nft_ipv46_rule_find(struct nft_handle *h, struct nftnl_rule *r, void *data)
 {
        struct iptables_command_state *cs = data, this = {};
        bool ret = false;
@@ -994,7 +993,7 @@ bool nft_ipv46_rule_find(struct nft_family_ops *ops,
 #ifdef DEBUG_DEL
        nft_rule_print_save(r, NFT_RULE_APPEND, 0);
 #endif
-       if (!ops->is_same(cs, &this))
+       if (!h->ops->is_same(cs, &this))
                goto out;
 
        if (!compare_matches(cs->matches, this.matches)) {
@@ -1014,7 +1013,7 @@ bool nft_ipv46_rule_find(struct nft_family_ops *ops,
 
        ret = true;
 out:
-       ops->clear_cs(&this);
+       h->ops->clear_cs(&this);
        return ret;
 }
 
index 1cb2ea70a409f5665f0c069cbed38b7a41dc2cf5..8c64d6e795ccd3ecf9cbd1b95783f497810d8f28 100644 (file)
@@ -104,7 +104,7 @@ struct nft_family_ops {
        void (*rule_to_cs)(const struct nftnl_rule *r,
                           struct iptables_command_state *cs);
        void (*clear_cs)(struct iptables_command_state *cs);
-       bool (*rule_find)(struct nft_family_ops *ops, struct nftnl_rule *r,
+       bool (*rule_find)(struct nft_handle *h, struct nftnl_rule *r,
                          void *data);
        int (*xlate)(const void *data, struct xt_xlate *xl);
 };
@@ -165,7 +165,7 @@ void save_matches_and_target(const struct iptables_command_state *cs,
 struct nft_family_ops *nft_family_ops_lookup(int family);
 
 void nft_ipv46_parse_target(struct xtables_target *t, void *data);
-bool nft_ipv46_rule_find(struct nft_family_ops *ops, struct nftnl_rule *r,
+bool nft_ipv46_rule_find(struct nft_handle *h, struct nftnl_rule *r,
                         void *data);
 
 bool compare_matches(struct xtables_rule_match *mt1, struct xtables_rule_match *mt2);
index e31f28347cbad9606c2dbe653ecc16e23dcb76fd..387aada9f86db932126a292085540de126a6b749 100644 (file)
@@ -1907,7 +1907,7 @@ nft_rule_find(struct nft_handle *h, struct nftnl_chain *c, void *data, int rulen
 
        r = nftnl_rule_iter_next(iter);
        while (r != NULL) {
-               found = h->ops->rule_find(h->ops, r, data);
+               found = h->ops->rule_find(h, r, data);
                if (found)
                        break;
                r = nftnl_rule_iter_next(iter);