On Thu, Jan 28, 2021 at 6:54 PM Alexei Starovoitov <alexei.starovoitov@xxxxxxxxx> wrote: > > I meant it would look like: > > noinline per_elem_callback(map, key, value, ...) > { > if (value->foo > ...) > bpf_delete_map_elem(map, key); > } > > noinline timer_callback(timer, ctx) > { > map = ctx->map; > bpf_for_each_map_elem(map, per_elem_callback, ...); > } > > int main_bpf_prog(skb) > { > bpf_timer_setup(my_timer, timer_callback, ...); > bpf_mod_timer(my_timer, HZ); > } > > The bpf_for_each_map_elem() work is already in progress. Expect patches to hit > mailing list soon. We don't want a per-element timer, we want a per-map timer but that requires a way to iterate the whole map. If you or other can provide bpf_for_each_map_elem(), we can certainly build our timeout map on top of it. > If you can work on patches for bpf_timer_*() it would be awesome. Yeah, I will work on this, not only for timeout map, but also possibly for the ebpf qdisc I plan to add soon. Thanks.