maps.rst 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. =========
  2. eBPF maps
  3. =========
  4. 'maps' is a generic storage of different types for sharing data between kernel
  5. and userspace.
  6. The maps are accessed from user space via BPF syscall, which has commands:
  7. - create a map with given type and attributes
  8. ``map_fd = bpf(BPF_MAP_CREATE, union bpf_attr *attr, u32 size)``
  9. using attr->map_type, attr->key_size, attr->value_size, attr->max_entries
  10. returns process-local file descriptor or negative error
  11. - lookup key in a given map
  12. ``err = bpf(BPF_MAP_LOOKUP_ELEM, union bpf_attr *attr, u32 size)``
  13. using attr->map_fd, attr->key, attr->value
  14. returns zero and stores found elem into value or negative error
  15. - create or update key/value pair in a given map
  16. ``err = bpf(BPF_MAP_UPDATE_ELEM, union bpf_attr *attr, u32 size)``
  17. using attr->map_fd, attr->key, attr->value
  18. returns zero or negative error
  19. - find and delete element by key in a given map
  20. ``err = bpf(BPF_MAP_DELETE_ELEM, union bpf_attr *attr, u32 size)``
  21. using attr->map_fd, attr->key
  22. - to delete map: close(fd)
  23. Exiting process will delete maps automatically
  24. userspace programs use this syscall to create/access maps that eBPF programs
  25. are concurrently updating.
  26. maps can have different types: hash, array, bloom filter, radix-tree, etc.
  27. The map is defined by:
  28. - type
  29. - max number of elements
  30. - key size in bytes
  31. - value size in bytes
  32. Map Types
  33. =========
  34. .. toctree::
  35. :maxdepth: 1
  36. :glob:
  37. map_*