netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH nf] netfilter: nf_tables: don't fail when updating base chain policy
@ 2019-07-13 21:59 Florian Westphal
  2019-07-16 11:23 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Westphal @ 2019-07-13 21:59 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Florian Westphal

The following nftables test case fails on nf-next:

tests/shell/run-tests.sh tests/shell/testcases/transactions/0011chain_0

The test case contains:
add chain x y { type filter hook input priority 0; }
add chain x y { policy drop; }"

The new test
if (chain->flags ^ flags)
	return -EOPNOTSUPP;

triggers here, because chain->flags has NFT_BASE_CHAIN set, but flags
is 0 because no flag attribute was present in the policy update.

Just fetch the current flag settings of a pre-existing chain in case
userspace did not provide any.

Fixes: c9626a2cbdb20 ("netfilter: nf_tables: add hardware offload support")
Signed-off-by: Florian Westphal <fw@strlen.de>
---
 net/netfilter/nf_tables_api.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index add64bd227a8..5746a7c948fe 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -1914,6 +1914,8 @@ static int nf_tables_newchain(struct net *net, struct sock *nlsk,
 
 	if (nla[NFTA_CHAIN_FLAGS])
 		flags = ntohl(nla_get_be32(nla[NFTA_CHAIN_FLAGS]));
+	else if (chain)
+		flags = chain->flags;
 
 	nft_ctx_init(&ctx, net, skb, nlh, family, table, chain, nla);
 
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH nf] netfilter: nf_tables: don't fail when updating base chain policy
  2019-07-13 21:59 [PATCH nf] netfilter: nf_tables: don't fail when updating base chain policy Florian Westphal
@ 2019-07-16 11:23 ` Pablo Neira Ayuso
  0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2019-07-16 11:23 UTC (permalink / raw)
  To: Florian Westphal; +Cc: netfilter-devel

On Sat, Jul 13, 2019 at 11:59:21PM +0200, Florian Westphal wrote:
> The following nftables test case fails on nf-next:
> 
> tests/shell/run-tests.sh tests/shell/testcases/transactions/0011chain_0
> 
> The test case contains:
> add chain x y { type filter hook input priority 0; }
> add chain x y { policy drop; }"
> 
> The new test
> if (chain->flags ^ flags)
> 	return -EOPNOTSUPP;
> 
> triggers here, because chain->flags has NFT_BASE_CHAIN set, but flags
> is 0 because no flag attribute was present in the policy update.
> 
> Just fetch the current flag settings of a pre-existing chain in case
> userspace did not provide any.

Applied, thanks for fixing up this, this is my fault.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-16 11:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-13 21:59 [PATCH nf] netfilter: nf_tables: don't fail when updating base chain policy Florian Westphal
2019-07-16 11:23 ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).