Commit 532aec7e authored by Florian Westphal's avatar Florian Westphal Committed by Pablo Neira Ayuso

netfilter: nft_set_pipapo: remove dirty flag

After previous change:
 ->clone exists: ->dirty is always true
 ->clone == NULL ->dirty is always false

So remove this flag.
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Reviewed-by: default avatarStefano Brivio <sbrivio@redhat.com>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 3f1d886c
...@@ -1299,7 +1299,6 @@ static int nft_pipapo_insert(const struct net *net, const struct nft_set *set, ...@@ -1299,7 +1299,6 @@ static int nft_pipapo_insert(const struct net *net, const struct nft_set *set,
union nft_pipapo_map_bucket rulemap[NFT_PIPAPO_MAX_FIELDS]; union nft_pipapo_map_bucket rulemap[NFT_PIPAPO_MAX_FIELDS];
const u8 *start = (const u8 *)elem->key.val.data, *end; const u8 *start = (const u8 *)elem->key.val.data, *end;
struct nft_pipapo_match *m = pipapo_maybe_clone(set); struct nft_pipapo_match *m = pipapo_maybe_clone(set);
struct nft_pipapo *priv = nft_set_priv(set);
u8 genmask = nft_genmask_next(net); u8 genmask = nft_genmask_next(net);
struct nft_pipapo_elem *e, *dup; struct nft_pipapo_elem *e, *dup;
u64 tstamp = nft_net_tstamp(net); u64 tstamp = nft_net_tstamp(net);
...@@ -1370,8 +1369,6 @@ static int nft_pipapo_insert(const struct net *net, const struct nft_set *set, ...@@ -1370,8 +1369,6 @@ static int nft_pipapo_insert(const struct net *net, const struct nft_set *set,
} }
/* Insert */ /* Insert */
priv->dirty = true;
bsize_max = m->bsize_max; bsize_max = m->bsize_max;
nft_pipapo_for_each_field(f, i, m) { nft_pipapo_for_each_field(f, i, m) {
...@@ -1736,8 +1733,6 @@ static void pipapo_gc(struct nft_set *set, struct nft_pipapo_match *m) ...@@ -1736,8 +1733,6 @@ static void pipapo_gc(struct nft_set *set, struct nft_pipapo_match *m)
* NFT_SET_ELEM_DEAD_BIT. * NFT_SET_ELEM_DEAD_BIT.
*/ */
if (__nft_set_elem_expired(&e->ext, tstamp)) { if (__nft_set_elem_expired(&e->ext, tstamp)) {
priv->dirty = true;
gc = nft_trans_gc_queue_sync(gc, GFP_KERNEL); gc = nft_trans_gc_queue_sync(gc, GFP_KERNEL);
if (!gc) if (!gc)
return; return;
...@@ -1823,13 +1818,9 @@ static void nft_pipapo_commit(struct nft_set *set) ...@@ -1823,13 +1818,9 @@ static void nft_pipapo_commit(struct nft_set *set)
if (time_after_eq(jiffies, priv->last_gc + nft_set_gc_interval(set))) if (time_after_eq(jiffies, priv->last_gc + nft_set_gc_interval(set)))
pipapo_gc(set, priv->clone); pipapo_gc(set, priv->clone);
if (!priv->dirty)
return;
old = rcu_replace_pointer(priv->match, priv->clone, old = rcu_replace_pointer(priv->match, priv->clone,
nft_pipapo_transaction_mutex_held(set)); nft_pipapo_transaction_mutex_held(set));
priv->clone = NULL; priv->clone = NULL;
priv->dirty = false;
if (old) if (old)
call_rcu(&old->rcu, pipapo_reclaim_match); call_rcu(&old->rcu, pipapo_reclaim_match);
...@@ -1839,12 +1830,8 @@ static void nft_pipapo_abort(const struct nft_set *set) ...@@ -1839,12 +1830,8 @@ static void nft_pipapo_abort(const struct nft_set *set)
{ {
struct nft_pipapo *priv = nft_set_priv(set); struct nft_pipapo *priv = nft_set_priv(set);
if (!priv->dirty)
return;
if (!priv->clone) if (!priv->clone)
return; return;
priv->dirty = false;
pipapo_free_match(priv->clone); pipapo_free_match(priv->clone);
priv->clone = NULL; priv->clone = NULL;
} }
...@@ -2098,7 +2085,6 @@ static void nft_pipapo_remove(const struct net *net, const struct nft_set *set, ...@@ -2098,7 +2085,6 @@ static void nft_pipapo_remove(const struct net *net, const struct nft_set *set,
match_end += NFT_PIPAPO_GROUPS_PADDED_SIZE(f); match_end += NFT_PIPAPO_GROUPS_PADDED_SIZE(f);
if (last && f->mt[rulemap[i].to].e == e) { if (last && f->mt[rulemap[i].to].e == e) {
priv->dirty = true;
pipapo_drop(m, rulemap); pipapo_drop(m, rulemap);
return; return;
} }
...@@ -2295,21 +2281,10 @@ static int nft_pipapo_init(const struct nft_set *set, ...@@ -2295,21 +2281,10 @@ static int nft_pipapo_init(const struct nft_set *set,
f->mt = NULL; f->mt = NULL;
} }
/* Create an initial clone of matching data for next insertion */
priv->clone = pipapo_clone(m);
if (!priv->clone) {
err = -ENOMEM;
goto out_free;
}
priv->dirty = false;
rcu_assign_pointer(priv->match, m); rcu_assign_pointer(priv->match, m);
return 0; return 0;
out_free:
free_percpu(m->scratch);
out_scratch: out_scratch:
kfree(m); kfree(m);
......
...@@ -155,14 +155,12 @@ struct nft_pipapo_match { ...@@ -155,14 +155,12 @@ struct nft_pipapo_match {
* @match: Currently in-use matching data * @match: Currently in-use matching data
* @clone: Copy where pending insertions and deletions are kept * @clone: Copy where pending insertions and deletions are kept
* @width: Total bytes to be matched for one packet, including padding * @width: Total bytes to be matched for one packet, including padding
* @dirty: Working copy has pending insertions or deletions
* @last_gc: Timestamp of last garbage collection run, jiffies * @last_gc: Timestamp of last garbage collection run, jiffies
*/ */
struct nft_pipapo { struct nft_pipapo {
struct nft_pipapo_match __rcu *match; struct nft_pipapo_match __rcu *match;
struct nft_pipapo_match *clone; struct nft_pipapo_match *clone;
int width; int width;
bool dirty;
unsigned long last_gc; unsigned long last_gc;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment