@@ -5839,10 +5839,10 @@ static int nft_del_setelem(struct nft_ctx *ctx, struct nft_set *set,
5839
5839
return err ;
5840
5840
}
5841
5841
5842
- static int nft_flush_set (const struct nft_ctx * ctx ,
5843
- struct nft_set * set ,
5844
- const struct nft_set_iter * iter ,
5845
- struct nft_set_elem * elem )
5842
+ static int nft_setelem_flush (const struct nft_ctx * ctx ,
5843
+ struct nft_set * set ,
5844
+ const struct nft_set_iter * iter ,
5845
+ struct nft_set_elem * elem )
5846
5846
{
5847
5847
struct nft_trans * trans ;
5848
5848
int err ;
@@ -5869,6 +5869,18 @@ static int nft_flush_set(const struct nft_ctx *ctx,
5869
5869
return err ;
5870
5870
}
5871
5871
5872
+ static int nft_set_flush (struct nft_ctx * ctx , struct nft_set * set , u8 genmask )
5873
+ {
5874
+ struct nft_set_iter iter = {
5875
+ .genmask = genmask ,
5876
+ .fn = nft_setelem_flush ,
5877
+ };
5878
+
5879
+ set -> ops -> walk (ctx , set , & iter );
5880
+
5881
+ return iter .err ;
5882
+ }
5883
+
5872
5884
static int nf_tables_delsetelem (struct sk_buff * skb ,
5873
5885
const struct nfnl_info * info ,
5874
5886
const struct nlattr * const nla [])
@@ -5892,15 +5904,8 @@ static int nf_tables_delsetelem(struct sk_buff *skb,
5892
5904
if (!list_empty (& set -> bindings ) && set -> flags & NFT_SET_CONSTANT )
5893
5905
return - EBUSY ;
5894
5906
5895
- if (nla [NFTA_SET_ELEM_LIST_ELEMENTS ] == NULL ) {
5896
- struct nft_set_iter iter = {
5897
- .genmask = genmask ,
5898
- .fn = nft_flush_set ,
5899
- };
5900
- set -> ops -> walk (& ctx , set , & iter );
5901
-
5902
- return iter .err ;
5903
- }
5907
+ if (!nla [NFTA_SET_ELEM_LIST_ELEMENTS ])
5908
+ return nft_set_flush (& ctx , set , genmask );
5904
5909
5905
5910
nla_for_each_nested (attr , nla [NFTA_SET_ELEM_LIST_ELEMENTS ], rem ) {
5906
5911
err = nft_del_setelem (& ctx , set , attr );
0 commit comments