Skip to content

Commit 9621e60

Browse files
borkmannAlexei Starovoitov
authored andcommitted
bpf: Move cgroup iterator helpers to bpf.h
Move them into bpf.h given we also need them in core code. Signed-off-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent fd1c98f commit 9621e60

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

include/linux/bpf-cgroup.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ to_cgroup_bpf_attach_type(enum bpf_attach_type attach_type)
7777
extern struct static_key_false cgroup_bpf_enabled_key[MAX_CGROUP_BPF_ATTACH_TYPE];
7878
#define cgroup_bpf_enabled(atype) static_branch_unlikely(&cgroup_bpf_enabled_key[atype])
7979

80-
#define for_each_cgroup_storage_type(stype) \
81-
for (stype = 0; stype < MAX_BPF_CGROUP_STORAGE_TYPE; stype++)
82-
8380
struct bpf_cgroup_storage_map;
8481

8582
struct bpf_storage_buffer {
@@ -510,8 +507,6 @@ static inline int bpf_percpu_cgroup_storage_update(struct bpf_map *map,
510507
#define BPF_CGROUP_RUN_PROG_SETSOCKOPT(sock, level, optname, optval, optlen, \
511508
kernel_optval) ({ 0; })
512509

513-
#define for_each_cgroup_storage_type(stype) for (; false; )
514-
515510
#endif /* CONFIG_CGROUP_BPF */
516511

517512
#endif /* _BPF_CGROUP_H */

include/linux/bpf.h

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,20 @@ enum btf_field_type {
208208
BPF_RES_SPIN_LOCK = (1 << 12),
209209
};
210210

211+
enum bpf_cgroup_storage_type {
212+
BPF_CGROUP_STORAGE_SHARED,
213+
BPF_CGROUP_STORAGE_PERCPU,
214+
__BPF_CGROUP_STORAGE_MAX
215+
#define MAX_BPF_CGROUP_STORAGE_TYPE __BPF_CGROUP_STORAGE_MAX
216+
};
217+
218+
#ifdef CONFIG_CGROUP_BPF
219+
# define for_each_cgroup_storage_type(stype) \
220+
for (stype = 0; stype < MAX_BPF_CGROUP_STORAGE_TYPE; stype++)
221+
#else
222+
# define for_each_cgroup_storage_type(stype) for (; false; )
223+
#endif /* CONFIG_CGROUP_BPF */
224+
211225
typedef void (*btf_dtor_kfunc_t)(void *);
212226

213227
struct btf_field_kptr {
@@ -1085,14 +1099,6 @@ struct bpf_prog_offload {
10851099
u32 jited_len;
10861100
};
10871101

1088-
enum bpf_cgroup_storage_type {
1089-
BPF_CGROUP_STORAGE_SHARED,
1090-
BPF_CGROUP_STORAGE_PERCPU,
1091-
__BPF_CGROUP_STORAGE_MAX
1092-
};
1093-
1094-
#define MAX_BPF_CGROUP_STORAGE_TYPE __BPF_CGROUP_STORAGE_MAX
1095-
10961102
/* The longest tracepoint has 12 args.
10971103
* See include/trace/bpf_probe.h
10981104
*/

0 commit comments

Comments
 (0)