bpftool-cgroup.rst 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. ================
  2. bpftool-cgroup
  3. ================
  4. -------------------------------------------------------------------------------
  5. tool for inspection and simple manipulation of eBPF progs
  6. -------------------------------------------------------------------------------
  7. :Manual section: 8
  8. SYNOPSIS
  9. ========
  10. **bpftool** [*OPTIONS*] **cgroup** *COMMAND*
  11. *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-f** | **--bpffs** } }
  12. *COMMANDS* :=
  13. { **show** | **list** | **attach** | **detach** | **help** }
  14. MAP COMMANDS
  15. =============
  16. | **bpftool** **cgroup { show | list }** *CGROUP*
  17. | **bpftool** **cgroup attach** *CGROUP* *ATTACH_TYPE* *PROG* [*ATTACH_FLAGS*]
  18. | **bpftool** **cgroup detach** *CGROUP* *ATTACH_TYPE* *PROG*
  19. | **bpftool** **cgroup help**
  20. |
  21. | *PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* }
  22. | *ATTACH_TYPE* := { **ingress** | **egress** | **sock_create** | **sock_ops** | **device** |
  23. | **bind4** | **bind6** | **post_bind4** | **post_bind6** | **connect4** | **connect6** |
  24. | **sendmsg4** | **sendmsg6** }
  25. | *ATTACH_FLAGS* := { **multi** | **override** }
  26. DESCRIPTION
  27. ===========
  28. **bpftool cgroup { show | list }** *CGROUP*
  29. List all programs attached to the cgroup *CGROUP*.
  30. Output will start with program ID followed by attach type,
  31. attach flags and program name.
  32. **bpftool cgroup attach** *CGROUP* *ATTACH_TYPE* *PROG* [*ATTACH_FLAGS*]
  33. Attach program *PROG* to the cgroup *CGROUP* with attach type
  34. *ATTACH_TYPE* and optional *ATTACH_FLAGS*.
  35. *ATTACH_FLAGS* can be one of: **override** if a sub-cgroup installs
  36. some bpf program, the program in this cgroup yields to sub-cgroup
  37. program; **multi** if a sub-cgroup installs some bpf program,
  38. that cgroup program gets run in addition to the program in this
  39. cgroup.
  40. Only one program is allowed to be attached to a cgroup with
  41. no attach flags or the **override** flag. Attaching another
  42. program will release old program and attach the new one.
  43. Multiple programs are allowed to be attached to a cgroup with
  44. **multi**. They are executed in FIFO order (those that were
  45. attached first, run first).
  46. Non-default *ATTACH_FLAGS* are supported by kernel version 4.14
  47. and later.
  48. *ATTACH_TYPE* can be on of:
  49. **ingress** ingress path of the inet socket (since 4.10);
  50. **egress** egress path of the inet socket (since 4.10);
  51. **sock_create** opening of an inet socket (since 4.10);
  52. **sock_ops** various socket operations (since 4.12);
  53. **device** device access (since 4.15);
  54. **bind4** call to bind(2) for an inet4 socket (since 4.17);
  55. **bind6** call to bind(2) for an inet6 socket (since 4.17);
  56. **post_bind4** return from bind(2) for an inet4 socket (since 4.17);
  57. **post_bind6** return from bind(2) for an inet6 socket (since 4.17);
  58. **connect4** call to connect(2) for an inet4 socket (since 4.17);
  59. **connect6** call to connect(2) for an inet6 socket (since 4.17);
  60. **sendmsg4** call to sendto(2), sendmsg(2), sendmmsg(2) for an
  61. unconnected udp4 socket (since 4.18);
  62. **sendmsg6** call to sendto(2), sendmsg(2), sendmmsg(2) for an
  63. unconnected udp6 socket (since 4.18).
  64. **bpftool cgroup detach** *CGROUP* *ATTACH_TYPE* *PROG*
  65. Detach *PROG* from the cgroup *CGROUP* and attach type
  66. *ATTACH_TYPE*.
  67. **bpftool prog help**
  68. Print short help message.
  69. OPTIONS
  70. =======
  71. -h, --help
  72. Print short generic help message (similar to **bpftool help**).
  73. -v, --version
  74. Print version number (similar to **bpftool version**).
  75. -j, --json
  76. Generate JSON output. For commands that cannot produce JSON, this
  77. option has no effect.
  78. -p, --pretty
  79. Generate human-readable JSON output. Implies **-j**.
  80. -f, --bpffs
  81. Show file names of pinned programs.
  82. EXAMPLES
  83. ========
  84. |
  85. | **# mount -t bpf none /sys/fs/bpf/**
  86. | **# mkdir /sys/fs/cgroup/test.slice**
  87. | **# bpftool prog load ./device_cgroup.o /sys/fs/bpf/prog**
  88. | **# bpftool cgroup attach /sys/fs/cgroup/test.slice/ device id 1 allow_multi**
  89. **# bpftool cgroup list /sys/fs/cgroup/test.slice/**
  90. ::
  91. ID AttachType AttachFlags Name
  92. 1 device allow_multi bpf_prog1
  93. |
  94. | **# bpftool cgroup detach /sys/fs/cgroup/test.slice/ device id 1**
  95. | **# bpftool cgroup list /sys/fs/cgroup/test.slice/**
  96. ::
  97. ID AttachType AttachFlags Name
  98. SEE ALSO
  99. ========
  100. **bpftool**\ (8), **bpftool-prog**\ (8), **bpftool-map**\ (8)