diff options
Diffstat (limited to 'include/net/cls_cgroup.h')
-rw-r--r-- | include/net/cls_cgroup.h | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/include/net/cls_cgroup.h b/include/net/cls_cgroup.h index a4dc5b027bd9..b6a6eeb3905f 100644 --- a/include/net/cls_cgroup.h +++ b/include/net/cls_cgroup.h | |||
@@ -17,14 +17,16 @@ | |||
17 | #include <linux/hardirq.h> | 17 | #include <linux/hardirq.h> |
18 | #include <linux/rcupdate.h> | 18 | #include <linux/rcupdate.h> |
19 | 19 | ||
20 | #ifdef CONFIG_CGROUPS | 20 | #if IS_ENABLED(CONFIG_NET_CLS_CGROUP) |
21 | struct cgroup_cls_state | 21 | struct cgroup_cls_state |
22 | { | 22 | { |
23 | struct cgroup_subsys_state css; | 23 | struct cgroup_subsys_state css; |
24 | u32 classid; | 24 | u32 classid; |
25 | }; | 25 | }; |
26 | 26 | ||
27 | #ifdef CONFIG_NET_CLS_CGROUP | 27 | extern void sock_update_classid(struct sock *sk); |
28 | |||
29 | #if IS_BUILTIN(CONFIG_NET_CLS_CGROUP) | ||
28 | static inline u32 task_cls_classid(struct task_struct *p) | 30 | static inline u32 task_cls_classid(struct task_struct *p) |
29 | { | 31 | { |
30 | int classid; | 32 | int classid; |
@@ -39,32 +41,33 @@ static inline u32 task_cls_classid(struct task_struct *p) | |||
39 | 41 | ||
40 | return classid; | 42 | return classid; |
41 | } | 43 | } |
42 | #else | 44 | #elif IS_MODULE(CONFIG_NET_CLS_CGROUP) |
43 | extern int net_cls_subsys_id; | ||
44 | |||
45 | static inline u32 task_cls_classid(struct task_struct *p) | 45 | static inline u32 task_cls_classid(struct task_struct *p) |
46 | { | 46 | { |
47 | int id; | 47 | struct cgroup_subsys_state *css; |
48 | u32 classid = 0; | 48 | u32 classid = 0; |
49 | 49 | ||
50 | if (in_interrupt()) | 50 | if (in_interrupt()) |
51 | return 0; | 51 | return 0; |
52 | 52 | ||
53 | rcu_read_lock(); | 53 | rcu_read_lock(); |
54 | id = rcu_dereference_index_check(net_cls_subsys_id, | 54 | css = task_subsys_state(p, net_cls_subsys_id); |
55 | rcu_read_lock_held()); | 55 | if (css) |
56 | if (id >= 0) | 56 | classid = container_of(css, |
57 | classid = container_of(task_subsys_state(p, id), | ||
58 | struct cgroup_cls_state, css)->classid; | 57 | struct cgroup_cls_state, css)->classid; |
59 | rcu_read_unlock(); | 58 | rcu_read_unlock(); |
60 | 59 | ||
61 | return classid; | 60 | return classid; |
62 | } | 61 | } |
63 | #endif | 62 | #endif |
64 | #else | 63 | #else /* !CGROUP_NET_CLS_CGROUP */ |
64 | static inline void sock_update_classid(struct sock *sk) | ||
65 | { | ||
66 | } | ||
67 | |||
65 | static inline u32 task_cls_classid(struct task_struct *p) | 68 | static inline u32 task_cls_classid(struct task_struct *p) |
66 | { | 69 | { |
67 | return 0; | 70 | return 0; |
68 | } | 71 | } |
69 | #endif | 72 | #endif /* CGROUP_NET_CLS_CGROUP */ |
70 | #endif /* _NET_CLS_CGROUP_H */ | 73 | #endif /* _NET_CLS_CGROUP_H */ |