Skip to content

Map type BPF_MAP_TYPE_SK_STORAGE

v5.2

This map type stores data keyed on a socket. The user can only create, update or delete entries for existing sockets. When a socket is deleted, the entry for that socket is automatically removed.

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

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 sockets 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_SK_STORAGE map.

BPF_F_CLONE

v5.4

This flag specifically applies to BPF_MAP_TYPE_SK_STORAGE maps. Sockets can be cloned. Setting this flag on the socket storage allows it to be cloned along with the socket itself when this happens. By default the storage is not cloned and the socket storage on the cloned socket will stay empty.