Skip to content

Latest commit

 

History

History
81 lines (48 loc) · 3.49 KB

BPF_MAP_TYPE_STACK.md

File metadata and controls

81 lines (48 loc) · 3.49 KB
title description
Map Type 'BPF_MAP_TYPE_STACK'
This page documents the 'BPF_MAP_TYPE_STACK' eBPF map type, including its defintion, usage, program types that can use it, and examples.

Map type BPF_MAP_TYPE_STACK

:octicons-tag-24: v4.20

The stack map type is a generic map type, resembling a stack data structure.

Usage

This map type has no keys, only values. The size and type of the values can be specified by the user to fit a large variety of use cases. The typical use-case for this map type is for brace matching ({,}) when parsing JSON for example.

As apposed to most map types, this map type uses a custom set of helpers to pop, peek and push elements, noted in the helper functions section below.

Attributes

While the value_size is essentially unrestricted, the key_size must always be 0 since this map type has no keys.

Syscall commands

The following syscall commands work with this map type:

!!! note The BPF_MAP_LOOKUP_ELEM syscall command acts as peek, BPF_MAP_LOOKUP_AND_DELETE_ELEM as pop, and BPF_MAP_UPDATE_ELEM as push.

Helper functions

Flags

BPF_F_NUMA_NODE

:octicons-tag-24: v4.14

When set, the numa_node attribute is respected during map creation.

BPF_F_RDONLY

:octicons-tag-24: v4.15

Setting this flag will make it so the map can only be read via the syscall interface, but not written to.

For details please check the generic description.

BPF_F_WRONLY

:octicons-tag-24: v4.15

Setting this flag will make it so the map can only be written to via the syscall interface, but not read from.

BPF_F_RDONLY_PROG

:octicons-tag-24: v5.2

Setting this flag will make it so the map can only be read via helper functions, but not written to.

For details please check the generic description.

BPF_F_WRONLY_PROG

:octicons-tag-24: v5.2

Setting this flag will make it so the map can only be written to via helper functions, but not read from.

For details please check the generic description.