Skip to contentSkip to conversation

Named sets with timeout

DISCUSSION Matt 4 participants 6 messages Oct 28, 2019 – Oct 30, 2019

lore
Share & tools
lore

Matt

author
#0 lore raw

Dear nft Forum,
I’m a big friend of named sets, specially the timeout function is very great. But one thing is confusing me, assume the following named:

table ip filter_v4 {
set my_drop {
type ipv4_addr
flags timeout
}
...
...
}

Then i add the following sample element to it:
/usr/sbin/nft add set ip filter_v4 my_drop \{type ipv4_addr \; flags
timeout \; elements=\{a.b.c.d timeout 600s \} \;\}

All good so far, a.b.c.d is counting down as expected, begiing with 10min.
But when i wait - say 1 minute and repeat the 'nft add set ... 600s' command from above then the timer remains unchanged (?) It looks as the timer cannot get changed anymore once it has been initialized

Is this behavior by purpose?
And if, am I right to delete the element and re-assign it if I want to get the timer updated?

Many thanks
Matt

#1 lore raw
Quoted 10 lines · Matt

Then i add the following sample element to it:
/usr/sbin/nft add set ip filter_v4 my_drop \{type ipv4_addr \; flags
timeout \; elements=\{a.b.c.d timeout 600s \} \;\}

All good so far, a.b.c.d is counting down as expected, beginning with 10min.
But when I wait - say 1 minute and repeat the 'nft add set ... 600s' command from above then the timer remains unchanged (?) It looks as the timer cannot get changed anymore once it has been initialized.

I think you are right, but see this recent commit (in 0.9.2+):

    24f33c7 2019-06-17 18:15 +0200 LGL
    src: enable set expiration date for set elements

    https://git.netfilter.org/nftables/commit/?id=24f33c7

...which sounds like there is a new (as-yet-undocumented?) keyword for changing (as opposed to initializing) the timeout of a set element.

#2 lore raw
Quoted 15 lines · Trent W. Buck
Quoted 10 lines · Matt

Then i add the following sample element to it:
/usr/sbin/nft add set ip filter_v4 my_drop \{type ipv4_addr \; flags
timeout \; elements=\{a.b.c.d timeout 600s \} \;\}

All good so far, a.b.c.d is counting down as expected, beginning with 10min.
But when I wait - say 1 minute and repeat the 'nft add set ... 600s' command from above then the timer remains unchanged (?) It looks as the timer cannot get changed anymore once it has been initialized.

I think you are right, but see this recent commit (in 0.9.2+):

Quoted 8 lines
    24f33c7 2019-06-17 18:15 +0200 LGL
    src: enable set expiration date for set elements

    https://git.netfilter.org/nftables/commit/?id=24f33c7

...which sounds like there is a new (as-yet-undocumented?) keyword for changing (as opposed to initializing) the timeout of a set element.

It's "update"

I.e. use update instead of add got get timeout to reset.

Needs kernel 5.3 IIRC

Cheers ... Duncan.

#3 lore raw
In reply to Trent W. Buck
Quoted 1 line · Trent W. Buck

[...]

Quoted 11 lines

I think you are right, but see this recent commit (in 0.9.2+):

    24f33c7 2019-06-17 18:15 +0200 LGL
    src: enable set expiration date for set elements

    https://git.netfilter.org/nftables/commit/?id=24f33c7

...which sounds like there is a new (as-yet-undocumented?) keyword for changing (as opposed to initializing) the timeout of a set element.

Hi,

No new or undocumented keyword, it uses the already created syntax to dump expiration values in order to modify it. Please refer to [1] and [2].

As Duncan states, "update" is what you're looking for. Please check the first example of [2].

[1] https://wiki.nftables.org/wiki-nftables/index.php/Element_timeouts
[2] https://wiki.nftables.org/wiki-nftables/index.php/Updating_sets_from_the_packet_path

Cheers.

#4 lore raw
Quoted 9 lines · Laura Garcia
Quoted 4 lines · Trent W. Buck

I think you are right, but see [...]
https://git.netfilter.org/nftables/commit/?id=24f33c7
...which sounds like there is a new (as-yet-undocumented?) keyword for changing (as opposed to initializing) the timeout of a set element.

No new or undocumented keyword, [...]
"update" is what you're looking for. [....]
[2] https://wiki.nftables.org/wiki-nftables/index.php/Updating_sets_from_the_packet_path

Thanks!

I apologize for my wrong & misleading answer. :-{

#5 lore raw
Quoted 9 lines · Trent W. Buck
Quoted 6 lines · Laura Garcia
Quoted 4 lines · Trent W. Buck

I think you are right, but see [...]
https://git.netfilter.org/nftables/commit/?id=24f33c7
...which sounds like there is a new (as-yet-undocumented?) keyword for changing (as opposed to initializing) the timeout of a set element.

Quoted 8 lines
Quoted 3 lines

No new or undocumented keyword, [...]
"update" is what you're looking for. [....]
[2] https://wiki.nftables.org/wiki-nftables/index.php/Updating_sets_from_the_packet_path

Thanks!

I apologize for my wrong & misleading answer. :-{

No problem :)