netfilter: nf_tables: add last expression
Subsystems (2)
Pablo Neira Ayuso
maintainerPATCH v5 1/1 netfilter: nf_tables: add last expression
Add a new optional expression that tells you when last matching on a given rule / set element element has happened.
Signed-off-by Pablo Neira Ayuso <[email protected]>
---
v5: mitigate jiffies wraparound by clearing up last update from netlink
dump path.
include/net/netfilter/nf_tables_core.h | 1 + include/uapi/linux/netfilter/nf_tables.h | 15 ++++ net/netfilter/Makefile | 2 +- net/netfilter/nf_tables_core.c | 1 + net/netfilter/nft_last.c | 87 ++++++++++++++++++++++++ 5 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 net/netfilter/nft_last.c
include/net/netfilter/nf_tables_core.h +1 -0
@@ -16,6 +16,7 @@ extern struct nft_expr_type nft_range_type;extern struct nft_expr_type nft_meta_type;extern struct nft_expr_type nft_rt_type;extern struct nft_expr_type nft_exthdr_type; +extern struct nft_expr_type nft_last_type;#ifdef CONFIG_NETWORK_SECMARK extern struct nft_object_type nft_secmark_obj_type;
include/uapi/linux/netfilter/nf_tables.h +15 -0
@@ -1195,6 +1195,21 @@ enum nft_counter_attributes { };#define NFTA_COUNTER_MAX (__NFTA_COUNTER_MAX - 1) +/** +* enum nft_last_attributes - nf_tables last expression netlink attributes +* +* @NFTA_LAST_SET: last update has been set, zero means never updated (NLA_U32) +* @NFTA_LAST_MSECS: milliseconds since last update (NLA_U64) +*/ +enum nft_last_attributes { +NFTA_LAST_UNSPEC , +NFTA_LAST_SET , +NFTA_LAST_MSECS , +NFTA_LAST_PAD , + __NFTA_LAST_MAX +}; +#define NFTA_LAST_MAX (__NFTA_LAST_MAX - 1) +/** * enum nft_log_attributes - nf_tables log expression netlink attributes *
net/netfilter/Makefile +1 -1
@@ -74,7 +74,7 @@ obj-$(CONFIG_NF_DUP_NETDEV) += nf_dup_netdev.o nf_tables-objs := nf_tables_core.o nf_tables_api.o nft_chain_filter.o \ nf_tables_trace.o nft_immediate.o nft_cmp.o nft_range.o \ nft_bitwise.o nft_byteorder.o nft_payload.o nft_lookup.o \ - nft_dynset.o nft_meta.o nft_rt.o nft_exthdr.o \ + nft_dynset.o nft_meta.o nft_rt.o nft_exthdr.o nft_last.o \ nft_chain_route.o nf_tables_offload.o \ nft_set_hash.o nft_set_bitmap.o nft_set_rbtree.o \ nft_set_pipapo.o
net/netfilter/nf_tables_core.c +1 -0
@@ -268,6 +268,7 @@ static struct nft_expr_type *nft_basic_types[] = { &nft_meta_type, &nft_rt_type, &nft_exthdr_type, + &nft_last_type, }; static struct nft_object_type *nft_basic_objects[] = {
net/netfilter/nft_last.c new file +87 -0
87 lines not on this page · raw message
Signature · 1 line
2.30.2