All of lore.kernel.org
 help / color / mirror / Atom feed
* Sets update
@ 2024-07-21  7:44 Slavko
  2024-07-21  9:58 ` Kerin Millar
  0 siblings, 1 reply; 18+ messages in thread
From: Slavko @ 2024-07-21  7:44 UTC (permalink / raw)
  To: netfilter ML

Hi all,

i recently start to port my ipsets to nftables set. I was using these
ipsets (beside other) in manner, where they was some timeout set
and its content was regulary updated (from various sources, online
and local). If some IP(v6) was removed, i didn't bother to remove it
from ipset, as it was removed by timeout...

Now i fight with the same approach in nftables sets (kernel 5.15, nft
1.0.8). I learned, that to update element's timeout i need to remove
element and then (re)add it again. As here is not simple way to do
it from shell (simple shell command) i play with python script, which
consumes IP list on input and produces appropriate nft commands,
eg.:

   fetch someiplist | myscript.py | nft -f -

Now i am not sure, how to produce that output. Have i do it per IP?
Eg.:

    add element ... {IP1}
    delete element ... {IP1}
    add element ... {IP1 ...}
    add element ... {IP2}
    delete element ... {IP2}
    add element ... {IP2 ...}
    etc

Or have i produce output for all IPs at once? Eg:

    add element ... {IP1, IP2, ...}
    delete element ... {IP1, IP2, ...}
    add element ... {IP1 ..., IP2 ..., ...}

Please, is here technical difference or something other to consider?
The IP lists ranges from some hundreds to some thounsand of IPs,
thus nothing really big, but not small.

Another question/problem is, that this approach (delete/add) does't
preserve counters. Please, how to preserve counters? Is only way
to fetch and parse counters before i delete element and then add
them into final add? IMO, this isn't very memory friendly (in script...).

While these counters are not crucial for me, i use them in some
ipsets for statistics, eg. i fill items from various sources into one
ipset and group/count them by comment then. In ipset it is really
simple task for awk and it was working even on small OpenWrt
devices. But nftables sets doesn't produce as straighforward output.
Please, how i can/have to parse element' counters? I am even not
sure, if i will able to parse it by python (but i didn't try it yet), is here
some tool for that?

regards

-- 
Slavko
https://www.slavino.sk/

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2024-07-23 12:19 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-21  7:44 Sets update Slavko
2024-07-21  9:58 ` Kerin Millar
2024-07-21 10:04   ` Kerin Millar
2024-07-21 11:23   ` Slavko
2024-07-21 12:29     ` Kerin Millar
2024-07-21 14:38       ` Slavko
2024-07-21 15:46         ` Kerin Millar
2024-07-23  7:24       ` Slavko
2024-07-23  7:37         ` Slavko
2024-07-23  9:39         ` Pablo Neira Ayuso
2024-07-23 10:23           ` Slavko
2024-07-23 11:32           ` Kerin Millar
2024-07-23 12:19             ` Pablo Neira Ayuso
2024-07-21 16:09   ` Eric
2024-07-21 16:46     ` Kerin Millar
2024-07-21 17:58   ` Slavko
2024-07-22 20:36   ` Pablo Neira Ayuso
2024-07-23  7:26     ` Slavko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.