netfilter: nf_tables: add support to destroy operation
Subsystems (2)
PATCH v3 1/1 netfilter: nf_tables: add support to destroy operation
Introduce NFT_MSG_DESTROY* message type. The destroy operation performs a delete operation but ignoring the ENOENT errors.
---
v1: initial patch
v2: fix bug on rule destroy without handle
v3: adjust some lines length
--- include/uapi/linux/netfilter/nf_tables.h | 14 +++++ net/netfilter/nf_tables_api.c | 73 ++++++++++++++++++++++++ 2 files changed, 87 insertions(+)
include/uapi/linux/netfilter/nf_tables.h +14 -0
@@ -97,6 +97,13 @@ enum nft_verdicts {* @NFT_MSG_NEWFLOWTABLE: add new flow table (enum nft_flowtable_attributes) * @NFT_MSG_GETFLOWTABLE: get flow table (enum nft_flowtable_attributes) * @NFT_MSG_DELFLOWTABLE: delete flow table (enum nft_flowtable_attributes) +* @NFT_MSG_DESTROYTABLE: destroy a table (enum nft_table_attributes) +* @NFT_MSG_DESTROYCHAIN: destroy a chain (enum nft_chain_attributes) +* @NFT_MSG_DESTROYRULE: destroy a rule (enum nft_rule_attributes) +* @NFT_MSG_DESTROYSET: destroy a set (enum nft_set_attributes) +* @NFT_MSG_DESTROYSETELEM: destroy a set element (enum nft_set_elem_attributes) +* @NFT_MSG_DESTROYOBJ: destroy a stateful object (enum nft_object_attributes) +* @NFT_MSG_DESTROYFLOWTABLE: destroy flow table (enum nft_flowtable_attributes) */ enum nf_tables_msg_types {NFT_MSG_NEWTABLE ,
@@ -124,6 +131,13 @@ enum nf_tables_msg_types {NFT_MSG_NEWFLOWTABLE ,NFT_MSG_GETFLOWTABLE ,NFT_MSG_DELFLOWTABLE , +NFT_MSG_DESTROYTABLE , +NFT_MSG_DESTROYCHAIN , +NFT_MSG_DESTROYRULE , +NFT_MSG_DESTROYSET , +NFT_MSG_DESTROYSETELEM , +NFT_MSG_DESTROYOBJ , +NFT_MSG_DESTROYFLOWTABLE , NFT_MSG_MAX, };
net/netfilter/nf_tables_api.c +73 -0
163 lines not on this page · raw message
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerQuoted 2 lines · Fernando Fernandez Mancera
Introduce NFT_MSG_DESTROY* message type. The destroy operation performs a delete operation but ignoring the ENOENT errors.
A made a few comestic updates, then I realize we also need to handle this from the command and abort paths. We also might need to update the _notify() functions to report the destroy events to userspace (that is still missing in the patch that I'm attaching).
I think this is almost there but it needs a bit more work.
Note, this patch applies on top of latests Phil's update on nf-next.
From 3d4cd6ec426909cae841da5e97d5a2c8253ce840 Mon Sep 17 00:00:00 2001
From: Fernando Fernandez Mancera <[email protected]>
Date: Sat, 29 Oct 2022 10:59:40 +0200
Subject: [PATCH] netfilter: nf_tables: add support to destroy operation
Introduce NFT_MSG_DESTROY* message type. The destroy operation performs a delete operation but ignoring the ENOENT errors.
This is useful for the transaction semantics, where failing to delete an object which does not exist results in aborting the transaction.
This new command allows the transaction to proceed in case the object does not exist.
--- include/uapi/linux/netfilter/nf_tables.h | 14 ++++ net/netfilter/nf_tables_api.c | 95 ++++++++++++++++++++++++ 2 files changed, 109 insertions(+)
include/uapi/linux/netfilter/nf_tables.h +14 -0
@@ -98,6 +98,13 @@ enum nft_verdicts {* @NFT_MSG_GETFLOWTABLE: get flow table (enum nft_flowtable_attributes) * @NFT_MSG_DELFLOWTABLE: delete flow table (enum nft_flowtable_attributes) * @NFT_MSG_GETRULE_RESET: get rules and reset stateful expressions (enum nft_obj_attributes) +* @NFT_MSG_DESTROYTABLE: destroy a table (enum nft_table_attributes) +* @NFT_MSG_DESTROYCHAIN: destroy a chain (enum nft_chain_attributes) +* @NFT_MSG_DESTROYRULE: destroy a rule (enum nft_rule_attributes) +* @NFT_MSG_DESTROYSET: destroy a set (enum nft_set_attributes) +* @NFT_MSG_DESTROYSETELEM: destroy a set element (enum nft_set_elem_attributes) +* @NFT_MSG_DESTROYOBJ: destroy a stateful object (enum nft_object_attributes) +* @NFT_MSG_DESTROYFLOWTABLE: destroy flow table (enum nft_flowtable_attributes) */ enum nf_tables_msg_types {NFT_MSG_NEWTABLE ,
@@ -126,6 +133,13 @@ enum nf_tables_msg_types {NFT_MSG_GETFLOWTABLE ,NFT_MSG_DELFLOWTABLE ,NFT_MSG_GETRULE_RESET , +NFT_MSG_DESTROYTABLE , +NFT_MSG_DESTROYCHAIN , +NFT_MSG_DESTROYRULE , +NFT_MSG_DESTROYSET , +NFT_MSG_DESTROYSETELEM , +NFT_MSG_DESTROYOBJ , +NFT_MSG_DESTROYFLOWTABLE , NFT_MSG_MAX, };
net/netfilter/nf_tables_api.c +95 -0
301 lines not on this page · raw message
Signature · 1 line
2.30.2
Quoted 4 lines · Pablo Neira Ayuso
Quoted 2 lines · Fernando Fernandez Mancera
Introduce NFT_MSG_DESTROY* message type. The destroy operation performs a delete operation but ignoring the ENOENT errors.
Quoted 8 lines
A made a few comestic updates, then I realize we also need to handle this from the command and abort paths. We also might need to update the
_notify()functions to report the destroy events to userspace (that is still missing in the patch that I'm attaching).I think this is almost there but it needs a bit more work.
Note, this patch applies on top of latests Phil's update on nf-next.
Thanks Pablo, let me handle the _notify() functions and will send a new version of the patch.
Thanks,
Fernando.