netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: [PATCH 08/14] netfilter: nf_tables: don't fail when updating base chain policy
Date: Fri, 19 Jul 2019 18:45:11 +0200	[thread overview]
Message-ID: <20190719164517.29496-9-pablo@netfilter.org> (raw)
In-Reply-To: <20190719164517.29496-1-pablo@netfilter.org>

From: Florian Westphal <fw@strlen.de>

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>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 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 ed17a7c29b86..014e06b0b5cf 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -1900,6 +1900,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.11.0



  parent reply	other threads:[~2019-07-19 16:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-19 16:45 [PATCH 00/14] Netfilter fixes for net Pablo Neira Ayuso
2019-07-19 16:45 ` [PATCH 01/14] netfilter: nfnetlink: avoid deadlock due to synchronous request_module Pablo Neira Ayuso
2019-07-19 16:45 ` [PATCH 02/14] netfilter: Fix rpfilter dropping vrf packets by mistake Pablo Neira Ayuso
2019-07-19 16:45 ` [PATCH 03/14] netfilter: nf_conntrack_sip: fix expectation clash Pablo Neira Ayuso
2019-07-19 16:45 ` [PATCH 04/14] netfilter: Update obsolete comments referring to ip_conntrack Pablo Neira Ayuso
2019-07-19 16:45 ` [PATCH 05/14] netfilter: nf_tables: fix module autoload for redir Pablo Neira Ayuso
2019-07-19 16:45 ` [PATCH 06/14] netfilter: synproxy: fix erroneous tcp mss option Pablo Neira Ayuso
2019-07-19 16:45 ` [PATCH 07/14] netfilter: conntrack: always store window size un-scaled Pablo Neira Ayuso
2019-07-19 16:45 ` Pablo Neira Ayuso [this message]
2019-07-19 16:45 ` [PATCH 09/14] netfilter: nft_hash: fix symhash with modulus one Pablo Neira Ayuso
2019-07-20  4:25 ` [PATCH 00/14] Netfilter fixes for net David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190719164517.29496-9-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).