Skip to content

Commit 6509a2e

Browse files
committed
netfilter: nf_tables: set backend .flush always succeeds
.flush is always successful since this results from iterating over the set elements to toggle mark the element as inactive in the next generation. Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 26cec9d commit 6509a2e

File tree

6 files changed

+7
-23
lines changed

6 files changed

+7
-23
lines changed

include/net/netfilter/nf_tables.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ struct nft_set_ops {
449449
void * (*deactivate)(const struct net *net,
450450
const struct nft_set *set,
451451
const struct nft_set_elem *elem);
452-
bool (*flush)(const struct net *net,
452+
void (*flush)(const struct net *net,
453453
const struct nft_set *set,
454454
void *priv);
455455
void (*remove)(const struct net *net,

net/netfilter/nf_tables_api.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7146,17 +7146,13 @@ static int nft_setelem_flush(const struct nft_ctx *ctx,
71467146
struct nft_set_elem *elem)
71477147
{
71487148
struct nft_trans *trans;
7149-
int err;
71507149

71517150
trans = nft_trans_alloc_gfp(ctx, NFT_MSG_DELSETELEM,
71527151
sizeof(struct nft_trans_elem), GFP_ATOMIC);
71537152
if (!trans)
71547153
return -ENOMEM;
71557154

7156-
if (!set->ops->flush(ctx->net, set, elem->priv)) {
7157-
err = -ENOENT;
7158-
goto err1;
7159-
}
7155+
set->ops->flush(ctx->net, set, elem->priv);
71607156
set->ndeact++;
71617157

71627158
nft_setelem_data_deactivate(ctx->net, set, elem);
@@ -7165,9 +7161,6 @@ static int nft_setelem_flush(const struct nft_ctx *ctx,
71657161
nft_trans_commit_list_add_tail(ctx->net, trans);
71667162

71677163
return 0;
7168-
err1:
7169-
kfree(trans);
7170-
return err;
71717164
}
71727165

71737166
static int __nft_set_catchall_flush(const struct nft_ctx *ctx,

net/netfilter/nft_set_bitmap.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static void nft_bitmap_activate(const struct net *net,
174174
nft_set_elem_change_active(net, set, &be->ext);
175175
}
176176

177-
static bool nft_bitmap_flush(const struct net *net,
177+
static void nft_bitmap_flush(const struct net *net,
178178
const struct nft_set *set, void *_be)
179179
{
180180
struct nft_bitmap *priv = nft_set_priv(set);
@@ -186,8 +186,6 @@ static bool nft_bitmap_flush(const struct net *net,
186186
/* Enter 10 state, similar to deactivation. */
187187
priv->bitmap[idx] &= ~(genmask << off);
188188
nft_set_elem_change_active(net, set, &be->ext);
189-
190-
return true;
191189
}
192190

193191
static void *nft_bitmap_deactivate(const struct net *net,

net/netfilter/nft_set_hash.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,12 @@ static void nft_rhash_activate(const struct net *net, const struct nft_set *set,
192192
nft_set_elem_change_active(net, set, &he->ext);
193193
}
194194

195-
static bool nft_rhash_flush(const struct net *net,
195+
static void nft_rhash_flush(const struct net *net,
196196
const struct nft_set *set, void *priv)
197197
{
198198
struct nft_rhash_elem *he = priv;
199199

200200
nft_set_elem_change_active(net, set, &he->ext);
201-
202-
return true;
203201
}
204202

205203
static void *nft_rhash_deactivate(const struct net *net,
@@ -590,13 +588,12 @@ static void nft_hash_activate(const struct net *net, const struct nft_set *set,
590588
nft_set_elem_change_active(net, set, &he->ext);
591589
}
592590

593-
static bool nft_hash_flush(const struct net *net,
591+
static void nft_hash_flush(const struct net *net,
594592
const struct nft_set *set, void *priv)
595593
{
596594
struct nft_hash_elem *he = priv;
597595

598596
nft_set_elem_change_active(net, set, &he->ext);
599-
return true;
600597
}
601598

602599
static void *nft_hash_deactivate(const struct net *net,

net/netfilter/nft_set_pipapo.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,14 +1809,12 @@ static void *nft_pipapo_deactivate(const struct net *net,
18091809
*
18101810
* Return: true if element was found and deactivated.
18111811
*/
1812-
static bool nft_pipapo_flush(const struct net *net, const struct nft_set *set,
1812+
static void nft_pipapo_flush(const struct net *net, const struct nft_set *set,
18131813
void *elem)
18141814
{
18151815
struct nft_pipapo_elem *e = elem;
18161816

18171817
nft_set_elem_change_active(net, set, &e->ext);
1818-
1819-
return true;
18201818
}
18211819

18221820
/**

net/netfilter/nft_set_rbtree.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,14 +535,12 @@ static void nft_rbtree_activate(const struct net *net,
535535
nft_set_elem_change_active(net, set, &rbe->ext);
536536
}
537537

538-
static bool nft_rbtree_flush(const struct net *net,
538+
static void nft_rbtree_flush(const struct net *net,
539539
const struct nft_set *set, void *priv)
540540
{
541541
struct nft_rbtree_elem *rbe = priv;
542542

543543
nft_set_elem_change_active(net, set, &rbe->ext);
544-
545-
return true;
546544
}
547545

548546
static void *nft_rbtree_deactivate(const struct net *net,

0 commit comments

Comments
 (0)