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