Detecting modification of a bpf map from userspace

Pablo Alvarez

Dear devs,

Is there a way to poll() or select() or otherwise not-busy-wait on a bpf map in userspace? I would like to react quickly to new data coming into the map from my bpf program withoug consuming too many resources.

I ran an experiment using the map fd and poll(), and found that the revents field always returned with POLLIN set, whether there was new data in the map or not. This makes a certain sense, since one never calls read() on the map to clear the field, but is not particularly useful.

The question applies both to
- a tc cls map added with "tc filter add dev eth0 egress bpf da obj clsact_get_packet.o sec getpacket"
- a map accessed from a bpf program inserted into a TCP socket (with load_bpf_file() and setsockopt(sockfd, SOL_SOCKET, SO_ATTACH_BPF, prog_fd,       sizeof(prog_fd[0])).

If not, is there another way to get a bpf program to signal up to userspace that something has happened?


Pablo Alvarez

Join to automatically receive all group messages.