Skip to content

netfilter: add hook dump feature

Florian Westphal netfilter-devel 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 0 repliesNew
  2. v14 patches 5 repliesSuperseded

Changes in v2 from the cover letter

Patch 1: init 'ret' to avoid unitialised value
Patch 4:
- include attribute that this is about nf_tables to allow later extension to x_tables if needed for some reason.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4netfilter: nf_tables: allow to dump all registered base hooksinclude/uapi/linux/netfilter/nf_tables.h net/netfilter/nf_queue.c net/netfilter/nf_tables_api.c+219 -20 replies
2/4netfilter: nf_tables: include function and module name in hook dumpsinclude/linux/netfilter.h include/uapi/linux/netfilter/nf_tables.h net/netfilter/core.c +1 more+27 -00 replies
3/4netfilter: annotate nf_tables base hook opsinclude/linux/netfilter.h net/netfilter/nf_tables_api.c+10 -20 replies
4/4netfilter: nf_tables: include table and chain name when dumping hooksinclude/uapi/linux/netfilter/nf_tables.h net/netfilter/nf_tables_api.c+78 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH nf-next v2 0/4] netfilter: add hook dump feature

Changes in v2:
Patch 1: init 'ret' to avoid unitialised value
Patch 4:
- include attribute that this is about nf_tables to allow later extension to x_tables if needed for some reason.

Enable dump of the registered netfilter hooks to userspace. This allows userspace to peek at the active hooks for each family/hook point.

Example:

    $ nft list hook ip type input
    family ip hook input {
            +0000000000 nft_do_chain_inet [nf_tables]       # nft table ip filter chain input
            +0000000010 nft_do_chain_inet [nf_tables]       # nft table ip firewalld chain filter_INPUT
            +0000000100 nf_nat_ipv4_local_in [nf_nat]
            +2147483647 ipv4_confirm [nf_conntrack]
    }

Implementation is done in nf_tables.
Alternative would be to add this as a separate/new nfnetlink family.

Let me know if thats the preferred route and I will respin. I did this in nf_tables because it allows re-use of the existing nft_hook_attributes and it seemed strange to add a new kernel module for this.

Florian Westphal (4):
netfilter: nf_tables: allow to dump all registered base hooks
netfilter: nf_tables: include function and module name in hook dumps
netfilter: annotate nf_tables base hook ops
netfilter: nf_tables: include table and chain name when dumping hooks

 include/linux/netfilter.h                |  12 +-
 include/uapi/linux/netfilter/nf_tables.h |  30 +++
 net/netfilter/core.c                     |   6 +
 net/netfilter/nf_queue.c                 |   4 +-
 net/netfilter/nf_tables_api.c            | 286 ++++++++++++++++++++++-
 5 files changed, 334 insertions(+), 4 deletions(-)
Signature · 1 line
2.26.3