Thread (18 messages) 18 messages, 5 authors, 2020-05-28

Re: [PATCH v2 bpf-next 5/5] selftest: Add tests for XDP programs in devmap entries

From: David Ahern <hidden>
Date: 2020-05-28 22:56:27

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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help