[][src]Attribute Macro redbpf_macros::map

#[map]

Attribute macro that must be used when creating eBPF maps.

The default #[map] places the map into a section of the resulting ELF binary called maps/<item_name>.

If you wish to set the section name manually for BPF programs that require strict naming conventions use #[map(link_section = "foo")] which place the map into a section called foo.

NOTE: The #[map("foo") (which uses link section maps/foo) has been deprecated in favor of #[map] or #[map(link_section = "maps/foo")]

Example

// Will be linked into the ELF in the section 'maps/counts'
#[map]
static mut counts: PerfMap<u64> = PerfMap::with_max_entries(10240);

// Will be linked into the ELF in the section 'dns_queries'
#[map(link_section = "dns_queries")]
static mut queries: PerfMap<Query> = PerfMap::with_max_entries(1024);

struct Query {
// ...
}