Skip to contentSkip to conversation

src: enable set expiration date for set elements

PATCH Applied nevola 2 participants 2 messages Jun 17, 2019 – Jun 28, 2019 netfilter

v1 of 3 Applied Latest is v3 →

lore
Share & tools
lore

nevola

author
#0 lore raw

PATCH 1/1 src: enable set expiration date for set elements

Currently, the expiration of every element in a set or map is a read-only parameter generated at kernel side.

This change will permit to set a certain expiration date per element that will be required, for example, during stateful replication among several nodes.

This patch will enable the _expires_ input parameter in the parser and propagate NFTNL_SET_ELEM_EXPIRATION in order to send the configured value.

---
 src/netlink.c      | 3 +++
 src/parser_bison.y | 5 +++++
 src/scanner.l      | 1 +
 3 files changed, 9 insertions(+)
src/netlink.c +3 -0
index a6d81b4..40dc41a 100644
@@ -122,6 +122,9 @@ static struct nftnl_set_elem *alloc_nftnl_setelem(const struct expr *set,
 	if (elem->timeout)
 		nftnl_set_elem_set_u64(nlse, NFTNL_SET_ELEM_TIMEOUT,
 				       elem->timeout);
+	if (elem->expiration)
+		nftnl_set_elem_set_u64(nlse, NFTNL_SET_ELEM_EXPIRATION,
+				       elem->expiration);
 	if (elem->comment || expr->elem_flags) {
 		udbuf = nftnl_udata_buf_alloc(NFT_USERDATA_MAXLEN);
 		if (!udbuf)
src/parser_bison.y +5 -0
index 1c0b60c..f732350 100644
@@ -255,6 +255,7 @@ int nft_lex(void *, void *, void *);
 %token TIMEOUT			"timeout"
 %token GC_INTERVAL		"gc-interval"
 %token ELEMENTS			"elements"
+%token EXPIRES			"expires"
 
 %token POLICY			"policy"
 %token MEMORY			"memory"
@@ -3367,6 +3368,10 @@ set_elem_option		:	TIMEOUT			time_spec
 			{
 				$<expr>0->timeout = $2;
 			}
+			|	EXPIRES		time_spec
+			{
+				$<expr>0->expiration = $2;
+			}
 			|	comment_spec
 			{
 				$<expr>0->comment = $1;
src/scanner.l +1 -0
index d1f6e87..b46b25e 100644
@@ -302,6 +302,7 @@ addrstring	({macaddr}|{ip4addr}|{ip6addr})
 "timeout"		{ return TIMEOUT; }
 "gc-interval"		{ return GC_INTERVAL; }
 "elements"		{ return ELEMENTS; }
+"expires"		{ return EXPIRES; }
 
 "policy"		{ return POLICY; }
 "size"			{ return SIZE; }
Signature · 1 line
2.11.0
maintainer Applied
#1 lore raw
Quoted 10 lines · nevola

Currently, the expiration of every element in a set or map is a read-only parameter generated at kernel side.

This change will permit to set a certain expiration date per element that will be required, for example, during stateful replication among several nodes.

This patch will enable the _expires_ input parameter in the parser and propagate NFTNL_SET_ELEM_EXPIRATION in order to send the configured value.

Applied, thanks Laura.