~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/bpf/maps.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/bpf/maps.rst (Version linux-6.12-rc7) and /Documentation/bpf/maps.rst (Version linux-5.18.19)


  1                                                     1 
  2 ========                                       !!   2 =========
  3 BPF maps                                       !!   3 eBPF maps
  4 ========                                       << 
  5                                                << 
  6 BPF 'maps' provide generic storage of differen << 
  7 kernel and user space. There are several stora << 
  8 hash, array, bloom filter and radix-tree. Seve << 
  9 support specific BPF helpers that perform acti << 
 10 maps are accessed from BPF programs via BPF he << 
 11 `man-pages`_ for `bpf-helpers(7)`_.            << 
 12                                                << 
 13 BPF maps are accessed from user space via the  << 
 14 commands to create maps, lookup elements, upda << 
 15 More details of the BPF syscall are available  << 
 16 `man-pages`_ for `bpf(2)`_.                    << 
 17                                                << 
 18 Map Types                                      << 
 19 =========                                           4 =========
 20                                                     5 
 21 .. toctree::                                   !!   6 'maps' is a generic storage of different types for sharing data between kernel
 22    :maxdepth: 1                                !!   7 and userspace.
 23    :glob:                                      << 
 24                                                << 
 25    map_*                                       << 
 26                                                << 
 27 Usage Notes                                    << 
 28 ===========                                    << 
 29                                                << 
 30 .. c:function::                                << 
 31    int bpf(int command, union bpf_attr *attr,  << 
 32                                                << 
 33 Use the ``bpf()`` system call to perform the o << 
 34 ``command``. The operation takes parameters pr << 
 35 argument is the size of the ``union bpf_attr`` << 
 36                                                << 
 37 **BPF_MAP_CREATE**                             << 
 38                                                     8 
 39 Create a map with the desired type and attribu !!   9 The maps are accessed from user space via BPF syscall, which has commands:
 40                                                    10 
 41 .. code-block:: c                              !!  11 - create a map with given type and attributes
                                                   >>  12   ``map_fd = bpf(BPF_MAP_CREATE, union bpf_attr *attr, u32 size)``
                                                   >>  13   using attr->map_type, attr->key_size, attr->value_size, attr->max_entries
                                                   >>  14   returns process-local file descriptor or negative error
 42                                                    15 
 43     int fd;                                    !!  16 - lookup key in a given map
 44     union bpf_attr attr = {                    !!  17   ``err = bpf(BPF_MAP_LOOKUP_ELEM, union bpf_attr *attr, u32 size)``
 45             .map_type = BPF_MAP_TYPE_ARRAY;  / !!  18   using attr->map_fd, attr->key, attr->value
 46             .key_size = sizeof(__u32);       / !!  19   returns zero and stores found elem into value or negative error
 47             .value_size = sizeof(__u32);     / << 
 48             .max_entries = 256;              / << 
 49             .map_flags = BPF_F_MMAPABLE;       << 
 50             .map_name = "example_array";       << 
 51     };                                         << 
 52                                                    20 
 53     fd = bpf(BPF_MAP_CREATE, &attr, sizeof(att !!  21 - create or update key/value pair in a given map
                                                   >>  22   ``err = bpf(BPF_MAP_UPDATE_ELEM, union bpf_attr *attr, u32 size)``
                                                   >>  23   using attr->map_fd, attr->key, attr->value
                                                   >>  24   returns zero or negative error
 54                                                    25 
 55 Returns a process-local file descriptor on suc !!  26 - find and delete element by key in a given map
 56 failure. The map can be deleted by calling ``c !!  27   ``err = bpf(BPF_MAP_DELETE_ELEM, union bpf_attr *attr, u32 size)``
 57 file descriptors will be deleted automatically !!  28   using attr->map_fd, attr->key
 58                                                    29 
 59 .. note:: Valid characters for ``map_name`` ar !!  30 - to delete map: close(fd)
 60    ``'_'`` and ``'.'``.                        !!  31   Exiting process will delete maps automatically
 61                                                    32 
 62 **BPF_MAP_LOOKUP_ELEM**                        !!  33 userspace programs use this syscall to create/access maps that eBPF programs
                                                   >>  34 are concurrently updating.
 63                                                    35 
 64 Lookup key in a given map using ``attr->map_fd !!  36 maps can have different types: hash, array, bloom filter, radix-tree, etc.
 65 ``attr->value``. Returns zero and stores found << 
 66 success, or negative error on failure.         << 
 67                                                    37 
 68 **BPF_MAP_UPDATE_ELEM**                        !!  38 The map is defined by:
 69                                                    39 
 70 Create or update key/value pair in a given map !!  40   - type
 71 ``attr->value``. Returns zero on success or ne !!  41   - max number of elements
                                                   >>  42   - key size in bytes
                                                   >>  43   - value size in bytes
 72                                                    44 
 73 **BPF_MAP_DELETE_ELEM**                        !!  45 Map Types
                                                   >>  46 =========
 74                                                    47 
 75 Find and delete element by key in a given map  !!  48 .. toctree::
 76 ``attr->key``. Returns zero on success or nega !!  49    :maxdepth: 1
                                                   >>  50    :glob:
 77                                                    51 
 78 .. Links:                                      !!  52    map_*
 79 .. _man-pages: https://www.kernel.org/doc/man- << 
 80 .. _bpf(2): https://man7.org/linux/man-pages/m << 
 81 .. _bpf-helpers(7): https://man7.org/linux/man << 
 82 .. _ebpf-syscall: https://docs.kernel.org/user << 
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php