Home > Blockchain >  Clean up a map in XDP program
Clean up a map in XDP program

Time:08-05

I would like to clean up data in the map (bloomfilter in my case) every X seconds but I couldn't find any function which would allow me to do so: looks like there are only pop_elem functions kernel/bpf/helpers.c. What could be the workaround for this problem? Like reload the eBPF program (don't know if it is expensive performance-wise) or somehow clean up the shared memory.

CodePudding user response:

Deleting from bloom filters is currently not supported, here is the original commit which says:

Deleting an element in the bloom filter map is not supported

The only way to reset a bloom filter map is to replace it with a new map. The commit also states:

The bloom filter map may be used as an inner map.

So I suggest using a map-in-map array/hash map and replacing the inner map once in a while, and adding back the desired entries.You can create the new map while the old one is still being used and swap out once you are ready. Performance depends on the amount of entries to add to the new map.

  • Related