diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2008-12-29 22:39:03 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-12-29 22:40:45 -0500 |
commit | 8e8ba85417366afd2361e315c6ba5949d3eff56f (patch) | |
tree | f093eb8aedd4ca4a888ae9f867cb1b1277a12073 | |
parent | 2f068bf8711c35b98bf9a0172555b8390a762fc0 (diff) |
cls_cgroup: clean up for cgroup part
- It's better to use container_of() instead of casting cgroup_subsys_state *
to cgroup_cls_state *.
- Add helper function task_cls_state().
- Rename net_cls_state() to cgrp_cls_state().
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/sched/cls_cgroup.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/net/sched/cls_cgroup.c b/net/sched/cls_cgroup.c index 31d95b1946c6..91a3db4a76f8 100644 --- a/net/sched/cls_cgroup.c +++ b/net/sched/cls_cgroup.c | |||
@@ -24,10 +24,16 @@ struct cgroup_cls_state | |||
24 | u32 classid; | 24 | u32 classid; |
25 | }; | 25 | }; |
26 | 26 | ||
27 | static inline struct cgroup_cls_state *net_cls_state(struct cgroup *cgrp) | 27 | static inline struct cgroup_cls_state *cgrp_cls_state(struct cgroup *cgrp) |
28 | { | 28 | { |
29 | return (struct cgroup_cls_state *) | 29 | return container_of(cgroup_subsys_state(cgrp, net_cls_subsys_id), |
30 | cgroup_subsys_state(cgrp, net_cls_subsys_id); | 30 | struct cgroup_cls_state, css); |
31 | } | ||
32 | |||
33 | static inline struct cgroup_cls_state *task_cls_state(struct task_struct *p) | ||
34 | { | ||
35 | return container_of(task_subsys_state(p, net_cls_subsys_id), | ||
36 | struct cgroup_cls_state, css); | ||
31 | } | 37 | } |
32 | 38 | ||
33 | static struct cgroup_subsys_state *cgrp_create(struct cgroup_subsys *ss, | 39 | static struct cgroup_subsys_state *cgrp_create(struct cgroup_subsys *ss, |
@@ -39,19 +45,19 @@ static struct cgroup_subsys_state *cgrp_create(struct cgroup_subsys *ss, | |||
39 | return ERR_PTR(-ENOMEM); | 45 | return ERR_PTR(-ENOMEM); |
40 | 46 | ||
41 | if (cgrp->parent) | 47 | if (cgrp->parent) |
42 | cs->classid = net_cls_state(cgrp->parent)->classid; | 48 | cs->classid = cgrp_cls_state(cgrp->parent)->classid; |
43 | 49 | ||
44 | return &cs->css; | 50 | return &cs->css; |
45 | } | 51 | } |
46 | 52 | ||
47 | static void cgrp_destroy(struct cgroup_subsys *ss, struct cgroup *cgrp) | 53 | static void cgrp_destroy(struct cgroup_subsys *ss, struct cgroup *cgrp) |
48 | { | 54 | { |
49 | kfree(net_cls_state(cgrp)); | 55 | kfree(cgrp_cls_state(cgrp)); |
50 | } | 56 | } |
51 | 57 | ||
52 | static u64 read_classid(struct cgroup *cgrp, struct cftype *cft) | 58 | static u64 read_classid(struct cgroup *cgrp, struct cftype *cft) |
53 | { | 59 | { |
54 | return net_cls_state(cgrp)->classid; | 60 | return cgrp_cls_state(cgrp)->classid; |
55 | } | 61 | } |
56 | 62 | ||
57 | static int write_classid(struct cgroup *cgrp, struct cftype *cft, u64 value) | 63 | static int write_classid(struct cgroup *cgrp, struct cftype *cft, u64 value) |
@@ -59,7 +65,7 @@ static int write_classid(struct cgroup *cgrp, struct cftype *cft, u64 value) | |||
59 | if (!cgroup_lock_live_group(cgrp)) | 65 | if (!cgroup_lock_live_group(cgrp)) |
60 | return -ENODEV; | 66 | return -ENODEV; |
61 | 67 | ||
62 | net_cls_state(cgrp)->classid = (u32) value; | 68 | cgrp_cls_state(cgrp)->classid = (u32) value; |
63 | 69 | ||
64 | cgroup_unlock(); | 70 | cgroup_unlock(); |
65 | 71 | ||
@@ -115,8 +121,7 @@ static int cls_cgroup_classify(struct sk_buff *skb, struct tcf_proto *tp, | |||
115 | return -1; | 121 | return -1; |
116 | 122 | ||
117 | rcu_read_lock(); | 123 | rcu_read_lock(); |
118 | cs = (struct cgroup_cls_state *) task_subsys_state(current, | 124 | cs = task_cls_state(current); |
119 | net_cls_subsys_id); | ||
120 | if (cs->classid && tcf_em_tree_match(skb, &head->ematches, NULL)) { | 125 | if (cs->classid && tcf_em_tree_match(skb, &head->ematches, NULL)) { |
121 | res->classid = cs->classid; | 126 | res->classid = cs->classid; |
122 | res->class = 0; | 127 | res->class = 0; |