I would like to know if there is a syscall which can be used through libbpf to lookup a map and also update the contents of the map. My use case is to lookup and update an map type of BPF_MAP_TYPE_ARRAY by holding a bpf spin lock.
I thought of changing my map type to BPF_MAP_TYPE_HASH and use the BPF_MAP_LOOKUP_AND_DELETE_ELEM. But in my use case, I don't have to delete the map element but to update the map to an initial value.
No, there is no such thing as BPF_MAP_LOOKUP_AND_UPDATE_ELEM
in bpf(2) today. You can see the list of bpf(2) commands at https://elixir.bootlin.com/linux/v6.9.1/source/include/uapi/linux/bpf.h#L922.