]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bpf: Move cgroup iterator helpers to bpf.h
authorDaniel Borkmann <daniel@iogearbox.net>
Wed, 30 Jul 2025 23:47:32 +0000 (01:47 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 31 Jul 2025 18:30:05 +0000 (11:30 -0700)
Move them into bpf.h given we also need them in core code.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/r/20250730234733.530041-3-daniel@iogearbox.net
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/linux/bpf-cgroup.h
include/linux/bpf.h

index 082ccd8ad96bb76d7cf97f6b63a1b1c1a2ac79f6..aedf573bdb426b1e6b4d293a9f498533ecddb016 100644 (file)
@@ -77,9 +77,6 @@ to_cgroup_bpf_attach_type(enum bpf_attach_type attach_type)
 extern struct static_key_false cgroup_bpf_enabled_key[MAX_CGROUP_BPF_ATTACH_TYPE];
 #define cgroup_bpf_enabled(atype) static_branch_unlikely(&cgroup_bpf_enabled_key[atype])
 
-#define for_each_cgroup_storage_type(stype) \
-       for (stype = 0; stype < MAX_BPF_CGROUP_STORAGE_TYPE; stype++)
-
 struct bpf_cgroup_storage_map;
 
 struct bpf_storage_buffer {
@@ -510,8 +507,6 @@ static inline int bpf_percpu_cgroup_storage_update(struct bpf_map *map,
 #define BPF_CGROUP_RUN_PROG_SETSOCKOPT(sock, level, optname, optval, optlen, \
                                       kernel_optval) ({ 0; })
 
-#define for_each_cgroup_storage_type(stype) for (; false; )
-
 #endif /* CONFIG_CGROUP_BPF */
 
 #endif /* _BPF_CGROUP_H */
index a87646cc539856db4f00ba4a31ee36673d4d32c4..02aa41e301a5b3d4ca2c67a8e0d4d8c52f0c8894 100644 (file)
@@ -208,6 +208,20 @@ enum btf_field_type {
        BPF_RES_SPIN_LOCK = (1 << 12),
 };
 
+enum bpf_cgroup_storage_type {
+       BPF_CGROUP_STORAGE_SHARED,
+       BPF_CGROUP_STORAGE_PERCPU,
+       __BPF_CGROUP_STORAGE_MAX
+#define MAX_BPF_CGROUP_STORAGE_TYPE __BPF_CGROUP_STORAGE_MAX
+};
+
+#ifdef CONFIG_CGROUP_BPF
+# define for_each_cgroup_storage_type(stype) \
+       for (stype = 0; stype < MAX_BPF_CGROUP_STORAGE_TYPE; stype++)
+#else
+# define for_each_cgroup_storage_type(stype) for (; false; )
+#endif /* CONFIG_CGROUP_BPF */
+
 typedef void (*btf_dtor_kfunc_t)(void *);
 
 struct btf_field_kptr {
@@ -1085,14 +1099,6 @@ struct bpf_prog_offload {
        u32                     jited_len;
 };
 
-enum bpf_cgroup_storage_type {
-       BPF_CGROUP_STORAGE_SHARED,
-       BPF_CGROUP_STORAGE_PERCPU,
-       __BPF_CGROUP_STORAGE_MAX
-};
-
-#define MAX_BPF_CGROUP_STORAGE_TYPE __BPF_CGROUP_STORAGE_MAX
-
 /* The longest tracepoint has 12 args.
  * See include/trace/bpf_probe.h
  */