netdev.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, kuba@kernel.org
Subject: [PATCH net-next 4/8] netfilter: ipset: Support the -exist flag with the destroy command
Date: Wed,  4 Nov 2020 15:11:45 +0100	[thread overview]
Message-ID: <20201104141149.30082-5-pablo@netfilter.org> (raw)
In-Reply-To: <20201104141149.30082-1-pablo@netfilter.org>

From: Jozsef Kadlecsik <kadlec@netfilter.org>

The -exist flag was supported with the create, add and delete commands.
In order to gracefully handle the destroy command with nonexistent sets,
the -exist flag is added to destroy too.

Signed-off-by: Jozsef Kadlecsik <kadlec@netfilter.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/ipset/ip_set_core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
index 6f35832f0de3..e3c00dacec5c 100644
--- a/net/netfilter/ipset/ip_set_core.c
+++ b/net/netfilter/ipset/ip_set_core.c
@@ -1239,10 +1239,12 @@ static int ip_set_destroy(struct net *net, struct sock *ctnl,
 		/* Modified by ip_set_destroy() only, which is serialized */
 		inst->is_destroyed = false;
 	} else {
+		u32 flags = flag_exist(nlh);
 		s = find_set_and_id(inst, nla_data(attr[IPSET_ATTR_SETNAME]),
 				    &i);
 		if (!s) {
-			ret = -ENOENT;
+			if (!(flags & IPSET_FLAG_EXIST))
+				ret = -ENOENT;
 			goto out;
 		} else if (s->ref || s->ref_netlink) {
 			ret = -IPSET_ERR_BUSY;
-- 
2.20.1


  parent reply	other threads:[~2020-11-04 14:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-04 14:11 [PATCH net-next 0/8] Netfilter updates for net-next Pablo Neira Ayuso
2020-11-04 14:11 ` [PATCH net-next 1/8] netfilter: nf_reject: add reject skbuff creation helpers Pablo Neira Ayuso
2020-11-04 14:11 ` [PATCH net-next 2/8] netfilter: nft_reject: unify reject init and dump into nft_reject Pablo Neira Ayuso
2020-11-04 14:11 ` [PATCH net-next 3/8] netfilter: nft_reject: add reject verdict support for netdev Pablo Neira Ayuso
2020-11-04 14:11 ` Pablo Neira Ayuso [this message]
2020-11-04 14:11 ` [PATCH net-next 5/8] netfilter: ipset: Add bucketsize parameter to all hash types Pablo Neira Ayuso
2020-11-04 14:11 ` [PATCH net-next 6/8] netfilter: ipset: Expose the initval hash parameter to userspace Pablo Neira Ayuso
2020-11-04 14:11 ` [PATCH net-next 7/8] netfilter: nftables: Add __printf() attribute Pablo Neira Ayuso
2020-11-04 14:11 ` [PATCH net-next 8/8] netfilter: nft_reject_inet: allow to use reject from inet ingress Pablo Neira Ayuso
2020-11-05  2:18 ` [PATCH net-next 0/8] Netfilter updates for net-next Jakub Kicinski

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=20201104141149.30082-5-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --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).