On 5/28/20 4:25 AM, Jesper Dangaard Brouer wrote:
> That said, you should use the new SEC(".maps") definitions, but you
> need to use some tricks to avoid a BTF-ID getting generated.  Let me
> help you with something that should work:
> 
> /* DEVMAP values */
> struct devmap_val {
>       __u32 ifindex;   /* device index */
> };
> 
> struct {
>       __uint(type, BPF_MAP_TYPE_DEVMAP);
>       __uint(key_size, sizeof(u32));
>       __uint(value_size, sizeof(struct devmap_val));
>       __uint(max_entries, 4);
> } dm_ports SEC(".maps");
> 
> Notice by setting key_size and value_size, instead of the "__type",
> then a BTF-ID will be generated for this map.
> Normally with proper BTF it should look like:
> 
> struct {
>       __uint(type, BPF_MAP_TYPE_DEVMAP);
>       __type(key, u32);
>       __type(value, struct devmap_val);
>       __uint(max_entries, 4);
> } dm_ports_with_BTF SEC(".maps");
> 
> 

Thanks for the tip.

Reply via email to