OSDN Git Service

netfilter: nf_tables: revisit chain/object refcounting from elements
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 15 May 2017 10:17:34 +0000 (11:17 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 15 May 2017 10:51:41 +0000 (12:51 +0200)
commit591054469b3eef34bc097c30fae8ededddf8d796
tree6dfcdd522ab793a3accec95ccda1bd57d5354639
parent71df14b0ce094be46d105b5a3ededd83b8e779a0
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 busy

The 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().

Reported-by: Andreas Schultz <aschultz@tpip.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/net/netfilter/nf_tables.h
net/netfilter/nf_tables_api.c
net/netfilter/nft_bitwise.c
net/netfilter/nft_cmp.c
net/netfilter/nft_immediate.c
net/netfilter/nft_range.c