Skip to content

Map type BPF_MAP_TYPE_CGRP_STORAGE

v6.2

This is a specialized map, an improved version of BPF_MAP_TYPE_CGROUP_STORAGE. This map type stores data keyed on a cGroup. When a cGroup is deleted, the entry for that cGroup is automatically removed.

Unlike the deprecated BPF_MAP_TYPE_CGROUP_STORAGE, this map type can be used with any program type. BPF programs can use the bpf_cgrp_storage_get and bpf_cgrp_storage_delete helper functions to access any map value as long as they can obtain a pointer to a cGroup.

Userspace can read or update values for any cGroup value, granted they have a file descriptor for that cGroup.

Attributes

The key_size must always be 4 indicating the key is a 32-bit unsigned integer. The value_size of the map may be any size within the limits of the kernel. max_entries must be 0, as the number of entries is determined by the number of cgroups on the system.

This map type also requires the usage of BTF key and value types.

Syscall commands

The following syscall commands work with this map type:

Helper functions

The following helper functions work with this map type:

Flags

The following flags are supported by this map type.

BPF_F_NO_PREALLOC

v4.6

This flag indicates that values for the map are not pre-allocated on creation of the map. This flag is required for the BPF_MAP_TYPE_CGRP_STORAGE map.