Skip to content

Commit b04945d

Browse files
committed
netfilter: nf_tables: set backend .flush always succeeds
JIRA: https://issues.redhat.com/browse/RHEL-1720 JIRA: https://issues.redhat.com/browse/RHEL-1721 Upstream Status: commit 6509a2e commit 6509a2e Author: Pablo Neira Ayuso <pablo@netfilter.org> Date: Wed Oct 18 22:20:23 2023 +0200 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 <pablo@netfilter.org> Signed-off-by: Florian Westphal <fwestpha@redhat.com>
1 parent 8d1189c commit b04945d

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
@@ -412,7 +412,7 @@ struct nft_set_ops {
412412
void * (*deactivate)(const struct net *net,
413413
const struct nft_set *set,
414414
const struct nft_set_elem *elem);
415-
bool (*flush)(const struct net *net,
415+
void (*flush)(const struct net *net,
416416
const struct nft_set *set,
417417
void *priv);
418418
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
@@ -6809,17 +6809,13 @@ static int nft_setelem_flush(const struct nft_ctx *ctx,
68096809
struct nft_set_elem *elem)
68106810
{
68116811
struct nft_trans *trans;
6812-
int err;
68136812

68146813
trans = nft_trans_alloc_gfp(ctx, NFT_MSG_DELSETELEM,
68156814
sizeof(struct nft_trans_elem), GFP_ATOMIC);
68166815
if (!trans)
68176816
return -ENOMEM;
68186817

6819-
if (!set->ops->flush(ctx->net, set, elem->priv)) {
6820-
err = -ENOENT;
6821-
goto err1;
6822-
}
6818+
set->ops->flush(ctx->net, set, elem->priv);
68236819
set->ndeact++;
68246820

68256821
nft_setelem_data_deactivate(ctx->net, set, elem);
@@ -6828,9 +6824,6 @@ static int nft_setelem_flush(const struct nft_ctx *ctx,
68286824
nft_trans_commit_list_add_tail(ctx->net, trans);
68296825

68306826
return 0;
6831-
err1:
6832-
kfree(trans);
6833-
return err;
68346827
}
68356828

68366829
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
@@ -1811,14 +1811,12 @@ static void *nft_pipapo_deactivate(const struct net *net,
18111811
*
18121812
* Return: true if element was found and deactivated.
18131813
*/
1814-
static bool nft_pipapo_flush(const struct net *net, const struct nft_set *set,
1814+
static void nft_pipapo_flush(const struct net *net, const struct nft_set *set,
18151815
void *elem)
18161816
{
18171817
struct nft_pipapo_elem *e = elem;
18181818

18191819
nft_set_elem_change_active(net, set, &e->ext);
1820-
1821-
return true;
18221820
}
18231821

18241822
/**

net/netfilter/nft_set_rbtree.c

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

533-
static bool nft_rbtree_flush(const struct net *net,
533+
static void nft_rbtree_flush(const struct net *net,
534534
const struct nft_set *set, void *priv)
535535
{
536536
struct nft_rbtree_elem *rbe = priv;
537537

538538
nft_set_elem_change_active(net, set, &rbe->ext);
539-
540-
return true;
541539
}
542540

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

0 commit comments

Comments
 (0)