Skip to contentSkip to conversation

expr: add last match time support

PATCH New Pablo Neira Ayuso 1 participant 2 messages Jun 10, 2021 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/2 expr: add last match time support

This new expression displays when last matching has happened.

---
Already applied, I accidentally pushed it out, just for the record.

 include/libnftnl/expr.h |   4 ++
 src/Makefile.am         |   1 +
 src/expr/last.c         | 118 ++++++++++++++++++++++++++++++++++++++++
 src/expr_ops.c          |   2 +
 4 files changed, 125 insertions(+)
 create mode 100644 src/expr/last.c
include/libnftnl/expr.h +4 -0
index 4e6059a609df..9b90e3ea3569 100644
@@ -311,6 +311,10 @@ enum {
 	NFTNL_EXPR_SYNPROXY_FLAGS,
 };
 
+enum {
+	NFTNL_EXPR_LAST_MSECS = NFTNL_EXPR_BASE,
+};
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif
src/Makefile.am +1 -0
index 90b1967420b1..c3b0ab974bd2 100644
@@ -34,6 +34,7 @@ libnftnl_la_SOURCES = utils.c		\
 		      expr/flow_offload.c \
 		      expr/fib.c	\
 		      expr/fwd.c	\
+		      expr/last.c	\
 		      expr/limit.c	\
 		      expr/log.c	\
 		      expr/lookup.c	\
src/expr/last.c new file +118 -0

118 lines not on this page · raw message

src/expr_ops.c +2 -0
index 3538dd60a6b7..7248e4f98b0a 100644
@@ -14,6 +14,7 @@ extern struct expr_ops expr_ops_dup;
 extern struct expr_ops expr_ops_exthdr;
 extern struct expr_ops expr_ops_fwd;
 extern struct expr_ops expr_ops_immediate;
+extern struct expr_ops expr_ops_last;
 extern struct expr_ops expr_ops_limit;
 extern struct expr_ops expr_ops_log;
 extern struct expr_ops expr_ops_lookup;
@@ -57,6 +58,7 @@ static struct expr_ops *expr_ops[] = {
 	&expr_ops_exthdr,
 	&expr_ops_fwd,
 	&expr_ops_immediate,
+	&expr_ops_last,
 	&expr_ops_limit,
 	&expr_ops_log,
 	&expr_ops_lookup,
Signature · 1 line
2.30.2
author maintainer
#1 lore raw

PATCH 2/2 expr: missing netlink attribute in last expression

NFTA_LAST_SET is missing, add it.

Fixes ed7c442c2d04 ("expr: add last match time support")

---
Already applied, I accidentally pushed it out, just for the record.

 include/linux/netfilter/nf_tables.h | 2 ++
 1 file changed, 2 insertions(+)
include/linux/netfilter/nf_tables.h +2 -0
index 5beb5a807687..e94d1fa554cb 100644
@@ -1198,10 +1198,12 @@ enum nft_counter_attributes {
 /**
  * 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
Signature · 1 line
2.30.2