netfilter: nf_tables: add NFT_CHAIN_POLICY_UNSET and use it
Subsystems (2)
Pablo Neira Ayuso
maintainerPATCH 1/2 netfilter: nf_tables: add NFT_CHAIN_POLICY_UNSET and use it
Default policy is defined as a unsigned 8-bit field, do not use a negative value to leave it unset, use this new NFT_CHAIN_POLICY_UNSET instead.
Signed-off-by Pablo Neira Ayuso <[email protected]>
--- include/net/netfilter/nf_tables.h | 2 ++ net/netfilter/nf_tables_api.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
include/net/netfilter/nf_tables.h +2 -0
@@ -889,6 +889,8 @@ enum nft_chain_flags { NFT_CHAIN_HW_OFFLOAD = 0x2, }; +#define NFT_CHAIN_POLICY_UNSET U8_MAX +/** * struct nft_chain - nf_tables chain *
net/netfilter/nf_tables_api.c +1 -1
@@ -1715,7 +1715,7 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask, goto err2; } -nft_trans_chain_policy (trans) =-1 ; +nft_trans_chain_policy (trans) =NFT_CHAIN_POLICY_UNSET ;if (nft_is_base_chain (chain))nft_trans_chain_policy (trans) = policy;
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH 2/2 netfilter: nf_tables_offload: fix always true policy is unset check
New smatch warnings:net/netfilter/nf_tables_offload.c:316 nft_flow_offload_chain() warn: always true condition '(policy != -1) => (0-255 != (-1))'
Reported-by kbuild test robot <[email protected]>
Fixes c9626a2cbdb2 ("netfilter: nf_tables: add hardware offload support")
Signed-off-by Pablo Neira Ayuso <[email protected]>
--- net/netfilter/nf_tables_offload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_tables_offload.c +1 -1
@@ -313,7 +313,7 @@ static int nft_flow_offload_chain(struct nft_chain *chain, policy = ppolicy ? *ppolicy : basechain->policy;/* Only default policy to accept is supported for now. */ -if (cmd ==FLOW_BLOCK_BIND && policy !=-1 && policy !=NF_ACCEPT ) +if (cmd ==FLOW_BLOCK_BIND && policy ==NF_DROP )return -EOPNOTSUPP ;if (dev->netdev_ops->ndo_setup_tc)
Signature · 1 line
2.11.0