Linux Netfilter discussions
 help / color / mirror / Atom feed
* Is there an efficient way to delete multiple elements from a set?
@ 2024-01-31  8:14 Anton
  2024-01-31  8:21 ` Reindl Harald
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Anton @ 2024-01-31  8:14 UTC (permalink / raw)
  To: netfilter

Hello, I've been experimenting with nftables sets for the purpose of
geoip blocking. Let's say I'd like to add ip blocks for multiple
countries to a blacklist or to a whitelist. Perhaps the most efficient
way to do that would be by combining all required ip blocks in one set
(for each family). However since country ip blocks are a moving
target, I would need to regularly refresh parts of that set. My idea
was to delete all ip addresses corresponding to an ip block from the
set and then add the updated ip block. The problem is, this is very
slow. While adding an ip block takes (in my VM) 0.09s, deleting all
ip's from that same block takes 14.5s.

This is how I'm doing the deletion and the time measurement:
printf '%s\n' "delete element inet test testset { $(cat test.set) };"
| /usr/bin/time -f %es nft -f -

(the test.set file stores a comma-separated list of subnets)

Is there a more efficient way to do this? I could of course flush the
set and rebuild it every time I need to update some part of it, but I
thought I'd ask before deciding to implement that.

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

end of thread, other threads:[~2024-02-02  0:37 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-31  8:14 Is there an efficient way to delete multiple elements from a set? Anton
2024-01-31  8:21 ` Reindl Harald
2024-01-31  8:27   ` Anton
2024-01-31 12:20 ` Kerin Millar
2024-01-31 22:13   ` Anton
2024-01-31 22:39     ` Kerin Millar
2024-01-31 23:11       ` Anton
2024-02-01  9:41 ` Pablo Neira Ayuso
2024-02-01  9:42   ` Pablo Neira Ayuso
2024-02-01 10:24     ` Jozsef Kadlecsik
2024-02-01 12:20   ` Kerin Millar
2024-02-02  0:36     ` Anton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox