Skip to content

Commit 6387aa6

Browse files
committed
netfilter: nftables: add loop check helper function
This patch adds nft_check_loops() to reuse it in the new catch-all element codebase. Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent f8bb788 commit 6387aa6

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8626,26 +8626,38 @@ EXPORT_SYMBOL_GPL(nft_chain_validate_hooks);
86268626
static int nf_tables_check_loops(const struct nft_ctx *ctx,
86278627
const struct nft_chain *chain);
86288628

8629+
static int nft_check_loops(const struct nft_ctx *ctx,
8630+
const struct nft_set_ext *ext)
8631+
{
8632+
const struct nft_data *data;
8633+
int ret;
8634+
8635+
data = nft_set_ext_data(ext);
8636+
switch (data->verdict.code) {
8637+
case NFT_JUMP:
8638+
case NFT_GOTO:
8639+
ret = nf_tables_check_loops(ctx, data->verdict.chain);
8640+
break;
8641+
default:
8642+
ret = 0;
8643+
break;
8644+
}
8645+
8646+
return ret;
8647+
}
8648+
86298649
static int nf_tables_loop_check_setelem(const struct nft_ctx *ctx,
86308650
struct nft_set *set,
86318651
const struct nft_set_iter *iter,
86328652
struct nft_set_elem *elem)
86338653
{
86348654
const struct nft_set_ext *ext = nft_set_elem_ext(set, elem->priv);
8635-
const struct nft_data *data;
86368655

86378656
if (nft_set_ext_exists(ext, NFT_SET_EXT_FLAGS) &&
86388657
*nft_set_ext_flags(ext) & NFT_SET_ELEM_INTERVAL_END)
86398658
return 0;
86408659

8641-
data = nft_set_ext_data(ext);
8642-
switch (data->verdict.code) {
8643-
case NFT_JUMP:
8644-
case NFT_GOTO:
8645-
return nf_tables_check_loops(ctx, data->verdict.chain);
8646-
default:
8647-
return 0;
8648-
}
8660+
return nft_check_loops(ctx, ext);
86498661
}
86508662

86518663
static int nf_tables_check_loops(const struct nft_ctx *ctx,

0 commit comments

Comments
 (0)