PCI: Add vendor ID for the PCI SIG
[sfrench/cifs-2.6.git] / include / linux / bpf-cgroup-defs.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _BPF_CGROUP_DEFS_H
3 #define _BPF_CGROUP_DEFS_H
4
5 #ifdef CONFIG_CGROUP_BPF
6
7 #include <linux/list.h>
8 #include <linux/percpu-refcount.h>
9 #include <linux/workqueue.h>
10
11 struct bpf_prog_array;
12
13 enum cgroup_bpf_attach_type {
14         CGROUP_BPF_ATTACH_TYPE_INVALID = -1,
15         CGROUP_INET_INGRESS = 0,
16         CGROUP_INET_EGRESS,
17         CGROUP_INET_SOCK_CREATE,
18         CGROUP_SOCK_OPS,
19         CGROUP_DEVICE,
20         CGROUP_INET4_BIND,
21         CGROUP_INET6_BIND,
22         CGROUP_INET4_CONNECT,
23         CGROUP_INET6_CONNECT,
24         CGROUP_INET4_POST_BIND,
25         CGROUP_INET6_POST_BIND,
26         CGROUP_UDP4_SENDMSG,
27         CGROUP_UDP6_SENDMSG,
28         CGROUP_SYSCTL,
29         CGROUP_UDP4_RECVMSG,
30         CGROUP_UDP6_RECVMSG,
31         CGROUP_GETSOCKOPT,
32         CGROUP_SETSOCKOPT,
33         CGROUP_INET4_GETPEERNAME,
34         CGROUP_INET6_GETPEERNAME,
35         CGROUP_INET4_GETSOCKNAME,
36         CGROUP_INET6_GETSOCKNAME,
37         CGROUP_INET_SOCK_RELEASE,
38         MAX_CGROUP_BPF_ATTACH_TYPE
39 };
40
41 struct cgroup_bpf {
42         /* array of effective progs in this cgroup */
43         struct bpf_prog_array __rcu *effective[MAX_CGROUP_BPF_ATTACH_TYPE];
44
45         /* attached progs to this cgroup and attach flags
46          * when flags == 0 or BPF_F_ALLOW_OVERRIDE the progs list will
47          * have either zero or one element
48          * when BPF_F_ALLOW_MULTI the list can have up to BPF_CGROUP_MAX_PROGS
49          */
50         struct list_head progs[MAX_CGROUP_BPF_ATTACH_TYPE];
51         u32 flags[MAX_CGROUP_BPF_ATTACH_TYPE];
52
53         /* list of cgroup shared storages */
54         struct list_head storages;
55
56         /* temp storage for effective prog array used by prog_attach/detach */
57         struct bpf_prog_array *inactive;
58
59         /* reference counter used to detach bpf programs after cgroup removal */
60         struct percpu_ref refcnt;
61
62         /* cgroup_bpf is released using a work queue */
63         struct work_struct release_work;
64 };
65
66 #else /* CONFIG_CGROUP_BPF */
67 struct cgroup_bpf {};
68 #endif /* CONFIG_CGROUP_BPF */
69
70 #endif