Skip to content

Commit 6a82dc5

Browse files
4astSomasundaram Krishnasamy
authored andcommitted
libbpf: sync bpf.h
tools/include/uapi/linux/bpf.h got out of sync with actual kernel header. Update it. Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: Daniel Borkmann <[email protected]> Signed-off-by: David S. Miller <[email protected]> (cherry picked from commit defd9c4) Orabug: 31667601 Signed-off-by: Alan Maguire <[email protected]> Reviewed-by: Mark Haywood <[email protected]> Conflicts: tools/include/uapi/linux/bpf.h contextual differences plus KABI wrapping needed for anonymous struct used for queries Signed-off-by: Somasundaram Krishnasamy <[email protected]>
1 parent 53b25cd commit 6a82dc5

File tree

1 file changed

+56
-3
lines changed
  • tools/include/uapi/linux

1 file changed

+56
-3
lines changed

tools/include/uapi/linux/bpf.h

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ enum bpf_cmd {
9393
BPF_PROG_GET_FD_BY_ID,
9494
BPF_MAP_GET_FD_BY_ID,
9595
BPF_OBJ_GET_INFO_BY_FD,
96+
BPF_PROG_QUERY,
9697
};
9798

9899
enum bpf_map_type {
@@ -144,11 +145,47 @@ enum bpf_attach_type {
144145

145146
#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
146147

147-
/* If BPF_F_ALLOW_OVERRIDE flag is used in BPF_PROG_ATTACH command
148-
* to the given target_fd cgroup the descendent cgroup will be able to
149-
* override effective bpf program that was inherited from this cgroup
148+
/* cgroup-bpf attach flags used in BPF_PROG_ATTACH command
149+
*
150+
* NONE(default): No further bpf programs allowed in the subtree.
151+
*
152+
* BPF_F_ALLOW_OVERRIDE: If a sub-cgroup installs some bpf program,
153+
* the program in this cgroup yields to sub-cgroup program.
154+
*
155+
* BPF_F_ALLOW_MULTI: If a sub-cgroup installs some bpf program,
156+
* that cgroup program gets run in addition to the program in this cgroup.
157+
*
158+
* Only one program is allowed to be attached to a cgroup with
159+
* NONE or BPF_F_ALLOW_OVERRIDE flag.
160+
* Attaching another program on top of NONE or BPF_F_ALLOW_OVERRIDE will
161+
* release old program and attach the new one. Attach flags has to match.
162+
*
163+
* Multiple programs are allowed to be attached to a cgroup with
164+
* BPF_F_ALLOW_MULTI flag. They are executed in FIFO order
165+
* (those that were attached first, run first)
166+
* The programs of sub-cgroup are executed first, then programs of
167+
* this cgroup and then programs of parent cgroup.
168+
* When children program makes decision (like picking TCP CA or sock bind)
169+
* parent program has a chance to override it.
170+
*
171+
* A cgroup with MULTI or OVERRIDE flag allows any attach flags in sub-cgroups.
172+
* A cgroup with NONE doesn't allow any programs in sub-cgroups.
173+
* Ex1:
174+
* cgrp1 (MULTI progs A, B) ->
175+
* cgrp2 (OVERRIDE prog C) ->
176+
* cgrp3 (MULTI prog D) ->
177+
* cgrp4 (OVERRIDE prog E) ->
178+
* cgrp5 (NONE prog F)
179+
* the event in cgrp5 triggers execution of F,D,A,B in that order.
180+
* if prog F is detached, the execution is E,D,A,B
181+
* if prog F and D are detached, the execution is E,A,B
182+
* if prog F, E and D are detached, the execution is C,A,B
183+
*
184+
* All eligible programs are executed regardless of return code from
185+
* earlier programs.
150186
*/
151187
#define BPF_F_ALLOW_OVERRIDE (1U << 0)
188+
#define BPF_F_ALLOW_MULTI (1U << 1)
152189

153190
/* If BPF_F_STRICT_ALIGNMENT is used in BPF_PROG_LOAD command, the
154191
* verifier will perform strict alignment checking as if the kernel
@@ -176,6 +213,11 @@ enum bpf_attach_type {
176213
/* Specify numa node during map creation */
177214
#define BPF_F_NUMA_NODE (1U << 2)
178215

216+
/* flags for BPF_PROG_QUERY */
217+
#define BPF_F_QUERY_EFFECTIVE (1U << 0)
218+
219+
#define BPF_OBJ_NAME_LEN 16U
220+
179221
union bpf_attr {
180222
struct { /* anonymous struct used by BPF_MAP_CREATE command */
181223
__u32 map_type; /* one of enum bpf_map_type */
@@ -253,6 +295,17 @@ union bpf_attr {
253295
__u32 info_len;
254296
__aligned_u64 info;
255297
} info;
298+
299+
#ifndef __GENKSYMS__
300+
struct { /* anonymous struct used by BPF_PROG_QUERY command */
301+
__u32 target_fd; /* container object to query */
302+
__u32 attach_type;
303+
__u32 query_flags;
304+
__u32 attach_flags;
305+
__aligned_u64 prog_ids;
306+
__u32 prog_cnt;
307+
} query;
308+
#endif
256309
} __attribute__((aligned(8)));
257310

258311
/* BPF helper function descriptions:

0 commit comments

Comments
 (0)