]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 9 Sep 2025 16:54:11 +0000 (18:54 +0200)
[ Upstream commit 9621e60f59eae87eb9ffe88d90f24f391a1ef0f0 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/bpf-cgroup.h
include/linux/bpf.h

index 57e9e109257e5db61c4d83ab37199097010354e9..429c766310c073515f60d5d21658554dc4ea13d8 100644 (file)
@@ -72,9 +72,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 {
@@ -506,8 +503,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 2aaa1ed7383034769ed6ceb9a69fc034947b2487..9fac355afde7ab44850560059f3fb9093599d267 100644 (file)
@@ -181,6 +181,20 @@ enum bpf_kptr_type {
        BPF_KPTR_REF,
 };
 
+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 */
+
 struct bpf_map_value_off_desc {
        u32 offset;
        enum bpf_kptr_type type;
@@ -794,14 +808,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
  */