netfilter: nf_tables: revisit chain/object refcounting from elements
Subsystems (2)
Pablo Neira Ayuso
maintainerPATCH 4/4 netfilter: nf_tables: revisit chain/object refcounting from elements
Andreas reports that the following incremental update using our commit protocol doesn't work.
# nft -f incremental-update.nft
delete element ip filter client_to_any { 10.180.86.22 : goto CIn_1 }
delete chain ip filter CIn_1
... Error: Could not process rule: Device or resource busyThe existing code is not well-integrated into the commit phase protocol, since element deletions do not result in refcount decrement from the preparation phase. This results in bogus EBUSY errors like the one above.
Two new functions come with this patch:
* nft_set_elem_activate() function is used from the abort path, to restore the set element refcounting on objects that occurred from the preparation phase.
* nft_set_elem_deactivate() that is called from nft_del_setelem() to decrement set element refcounting on objects from the preparation phase in the commit protocol.
The nft_data_uninit() has been renamed to nft_data_release() since this function does not uninitialize any data store in the data register, instead just releases the references to objects. Moreover, a new function nft_data_hold() has been introduced to be used from nft_set_elem_activate().
--- include/net/netfilter/nf_tables.h | 2 +- net/netfilter/nf_tables_api.c | 76 +++++++++++++++++++++++++++++++++++---- net/netfilter/nft_dynset.c | 2 +- net/netfilter/nft_immediate.c | 5 +-- 4 files changed, 74 insertions(+), 11 deletions(-)
include/net/netfilter/nf_tables.h +1 -1
@@ -176,7 +176,7 @@ struct nft_data_desc {int nft_data_init (const struct nft_ctx *ctx,struct nft_data *data,unsigned int size,struct nft_data_desc *desc,const struct nlattr *nla); -void nft_data_uninit (const struct nft_data *data,enum nft_data_types type); +void nft_data_release (const struct nft_data *data,enum nft_data_types type);int nft_data_dump (struct sk_buff *skb,int attr,const struct nft_data *data,enum nft_data_types type,unsigned int len);
net/netfilter/nf_tables_api.c +69 -7
136 lines not on this page · raw message
net/netfilter/nft_dynset.c +1 -1
@@ -33,7 +33,7 @@ static void nft_dynset_elem_destroy(const struct nft_set *set, void *elem)struct nft_set_ext *ext =nft_set_elem_ext (set, elem);if (nft_set_ext_exists (ext,NFT_SET_EXT_DATA )) -nft_data_uninit (nft_set_ext_data (ext), set->dtype); +nft_data_release (nft_set_ext_data (ext), set->dtype);/* NFT_SET_EXT_EXPR refers to the template, do not release it here. */ kfree (elem); }
net/netfilter/nft_immediate.c +3 -2
@@ -65,7 +65,7 @@ static int nft_immediate_init(const struct nft_ctx *ctx,return 0 ; err1: -nft_data_uninit (&priv->data, desc.type); +nft_data_release (&priv->data, desc.type);return err; }
@@ -73,7 +73,8 @@ static void nft_immediate_destroy(const struct nft_ctx *ctx, const struct nft_expr *expr) {const struct nft_immediate_expr *priv =nft_expr_priv (expr); -return nft_data_uninit (&priv->data,nft_dreg_to_type (priv->dreg)); + +return nft_data_release (&priv->data,nft_dreg_to_type (priv->dreg)); }static int nft_immediate_dump (struct sk_buff *skb,const struct nft_expr *expr)
Signature · 1 line
2.1.4