Topics

Simple bpf_map reader prog

Иван Иванов
 

Can you give link or some code to understand, how can i get data from maps in c. I saw example, but as i begginer in such programming, i can understand map_fd, obj...etc.
I create xdp prog, inserted in via ip link set... And can see data with bpftool in hex. How can i simply write a prog to get data from map without writing code to load. I am now at start of the way  )

Yonghong Song
 

This is exactly what `bpftool map` is doing. The source code
https://github.com/torvalds/linux/blob/master/tools/bpf/bpftool/map.c

You can find the map you are interested by iterating all the maps in the system
and then iterating to get all map key/values for that map.

On Mon, Dec 24, 2018 at 9:41 AM Иван Иванов <iwan12iwan12@...> wrote:

Can you give link or some code to understand, how can i get data from maps in c. I saw example, but as i begginer in such programming, i can understand map_fd, obj...etc.
I create xdp prog, inserted in via ip link set... And can see data with bpftool in hex. How can i simply write a prog to get data from map without writing code to load. I am now at start of the way )

Иван Иванов
 

Can not now to compil my prog, to use bpf_get_mad_fd_by_id for just beggining, because dont know enough how to do it. To compile kern prog a lot of examples, but userspace prog can not find... Can you help me with link how to do it? 

P.s. tried to make key size of struct 9 bytes, it does not set to device because of error, about indirect access to mem. I can make only with 4, 8, 12, 16....?