netfilter: nf_tables: add NFT_CHAIN_BINDING
Subsystems (2)
Pablo Neira Ayuso
maintainerPATCH v2 6/6 netfilter: nf_tables: add NFT_CHAIN_BINDING
This new chain flag specifies that:
* the kernel dynamically allocates the chain name, if no chain name is specified.
* If the immediate expression that refers to this chain is removed, then this bound chain (and its content) is destroyed.
Signed-off-by Pablo Neira Ayuso <[email protected]>
---
v2: fix NFTA_CHAIN_FLAGS netlink dumping.
include/net/netfilter/nf_tables.h | 13 +++- include/uapi/linux/netfilter/nf_tables.h | 1 + net/netfilter/nf_tables_api.c | 78 ++++++++++++++++++++---- net/netfilter/nft_immediate.c | 51 ++++++++++++++++ 4 files changed, 130 insertions(+), 13 deletions(-)
include/net/netfilter/nf_tables.h +12 -1
@@ -899,6 +899,8 @@ static inline struct nft_userdata *nft_userdata(const struct nft_rule *rule)return (void *)&rule->data[rule->dlen]; } +void nf_tables_rule_destroy (const struct nft_ctx *ctx,struct nft_rule *rule); +static inline void nft_set_elem_update_expr (const struct nft_set_ext *ext,struct nft_regs *regs,const struct nft_pktinfo *pkt)
@@ -944,7 +946,8 @@ struct nft_chain {struct nft_table *table;u64 handle;u32 use; - u8 flags:6, + u8 flags:5, + bound:1, genmask:2;char *name;
@@ -989,6 +992,14 @@ int nft_chain_validate_dependency(const struct nft_chain *chain,int nft_chain_validate_hooks (const struct nft_chain *chain,unsigned int hook_flags); +static inline bool nft_chain_is_bound (struct nft_chain *chain) +{ +return (chain->flags &NFT_CHAIN_BINDING ) && chain->bound; +} + +void nft_chain_del (struct nft_chain *chain); +void nf_tables_chain_destroy (struct nft_ctx *ctx); +struct nft_stats {u64 bytes;u64 pkts;
include/uapi/linux/netfilter/nf_tables.h +1 -0
@@ -187,6 +187,7 @@ enum nft_table_attributes {enum nft_chain_flags {NFT_CHAIN_BASE = (1 <<0 ),NFT_CHAIN_HW_OFFLOAD = (1 <<1 ), +NFT_CHAIN_BINDING = (1 <<2 ), };/**
net/netfilter/nf_tables_api.c +66 -12
168 lines not on this page · raw message
net/netfilter/nft_immediate.c +51 -0
69 lines not on this page · raw message
Signature · 1 line
2.20.1