All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH nft 5/5] parser_bison: allow delete command with map via handle
Date: Sun, 15 Jun 2025 12:00:19 +0200	[thread overview]
Message-ID: <20250615100019.2988872-6-pablo@netfilter.org> (raw)
In-Reply-To: <20250615100019.2988872-1-pablo@netfilter.org>

For consistency with sets, allow delete via handle for maps too.

This fix requires the handle hashtable lookup infrastructure.

Fixes: f4a34d25f6d5 ("src: list set handle and delete set via set handle")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 src/parser_bison.y                                            | 2 +-
 tests/shell/testcases/cache/0008_delete_by_handle_0           | 4 ++++
 tests/shell/testcases/cache/0009_delete_by_handle_incorrect_0 | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/parser_bison.y b/src/parser_bison.y
index 87b34293d22c..9278b67a2931 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -1450,7 +1450,7 @@ delete_cmd		:	TABLE		table_or_id_spec
 			{
 				$$ = cmd_alloc(CMD_DELETE, CMD_OBJ_SET, &$2, &@$, NULL);
 			}
-			|	MAP		set_spec
+			|	MAP		set_or_id_spec
 			{
 				$$ = cmd_alloc(CMD_DELETE, CMD_OBJ_SET, &$2, &@$, NULL);
 			}
diff --git a/tests/shell/testcases/cache/0008_delete_by_handle_0 b/tests/shell/testcases/cache/0008_delete_by_handle_0
index 0db4c693f6d4..9eb75e6ce374 100755
--- a/tests/shell/testcases/cache/0008_delete_by_handle_0
+++ b/tests/shell/testcases/cache/0008_delete_by_handle_0
@@ -16,6 +16,10 @@ $NFT add set t s { type ipv4_addr\; }
 HANDLE=`$NFT -a list ruleset | grep "set.*handle" | cut -d' ' -f6`
 $NFT delete set t handle $HANDLE
 
+$NFT add map t m { type ipv4_addr : ipv4_addr\; }
+HANDLE=`$NFT -a list ruleset | grep "map.*handle" | cut -d' ' -f6`
+$NFT delete map t handle $HANDLE
+
 $NFT add flowtable t f { hook ingress priority 0\; devices = { lo } \; }
 HANDLE=`$NFT -a list ruleset | grep "flowtable.*handle" | cut -d' ' -f6`
 $NFT delete flowtable t handle $HANDLE
diff --git a/tests/shell/testcases/cache/0009_delete_by_handle_incorrect_0 b/tests/shell/testcases/cache/0009_delete_by_handle_incorrect_0
index f0bb02a636ee..dd390e73c8e8 100755
--- a/tests/shell/testcases/cache/0009_delete_by_handle_incorrect_0
+++ b/tests/shell/testcases/cache/0009_delete_by_handle_incorrect_0
@@ -3,6 +3,7 @@
 $NFT delete table handle 4000 && exit 1
 $NFT delete chain t handle 4000 && exit 1
 $NFT delete set t handle 4000 && exit 1
+$NFT delete map t handle 4000 && exit 1
 $NFT delete flowtable t handle 4000 && exit 1
 $NFT delete counter t handle 4000 && exit 1
 exit 0
-- 
2.30.2


  parent reply	other threads:[~2025-06-15 10:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-15 10:00 [PATCH nft 0/5] assorted updates and fixes Pablo Neira Ayuso
2025-06-15 10:00 ` [PATCH nft 1/5] rule: skip fuzzy lookup if object name is not available Pablo Neira Ayuso
2025-06-15 10:00 ` [PATCH nft 2/5] cache: assert name is non-nul when looking up Pablo Neira Ayuso
2025-06-15 10:00 ` [PATCH nft 3/5] cache: pass name to cache_add() Pablo Neira Ayuso
2025-06-15 10:00 ` [PATCH nft 4/5] parser_bison: only reset by name is supported by now Pablo Neira Ayuso
2025-06-15 10:00 ` Pablo Neira Ayuso [this message]
2025-06-23 17:08 ` [PATCH nft 0/5] assorted updates and fixes Pablo Neira Ayuso

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=20250615100019.2988872-6-pablo@netfilter.org \
    --to=pablo@netfilter.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.