mirror of
https://github.com/adulau/aha.git
synced 2024-12-29 12:16:20 +00:00
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>
This commit is contained in:
parent
2f068bf871
commit
8e8ba85417
1 changed files with 14 additions and 9 deletions
|
@ -24,10 +24,16 @@ struct cgroup_cls_state
|
||||||
u32 classid;
|
u32 classid;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline struct cgroup_cls_state *net_cls_state(struct cgroup *cgrp)
|
static inline struct cgroup_cls_state *cgrp_cls_state(struct cgroup *cgrp)
|
||||||
{
|
{
|
||||||
return (struct cgroup_cls_state *)
|
return container_of(cgroup_subsys_state(cgrp, net_cls_subsys_id),
|
||||||
cgroup_subsys_state(cgrp, net_cls_subsys_id);
|
struct cgroup_cls_state, css);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline struct cgroup_cls_state *task_cls_state(struct task_struct *p)
|
||||||
|
{
|
||||||
|
return container_of(task_subsys_state(p, net_cls_subsys_id),
|
||||||
|
struct cgroup_cls_state, css);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cgroup_subsys_state *cgrp_create(struct cgroup_subsys *ss,
|
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,
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
if (cgrp->parent)
|
if (cgrp->parent)
|
||||||
cs->classid = net_cls_state(cgrp->parent)->classid;
|
cs->classid = cgrp_cls_state(cgrp->parent)->classid;
|
||||||
|
|
||||||
return &cs->css;
|
return &cs->css;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cgrp_destroy(struct cgroup_subsys *ss, struct cgroup *cgrp)
|
static void cgrp_destroy(struct cgroup_subsys *ss, struct cgroup *cgrp)
|
||||||
{
|
{
|
||||||
kfree(net_cls_state(cgrp));
|
kfree(cgrp_cls_state(cgrp));
|
||||||
}
|
}
|
||||||
|
|
||||||
static u64 read_classid(struct cgroup *cgrp, struct cftype *cft)
|
static u64 read_classid(struct cgroup *cgrp, struct cftype *cft)
|
||||||
{
|
{
|
||||||
return net_cls_state(cgrp)->classid;
|
return cgrp_cls_state(cgrp)->classid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int write_classid(struct cgroup *cgrp, struct cftype *cft, u64 value)
|
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)
|
||||||
if (!cgroup_lock_live_group(cgrp))
|
if (!cgroup_lock_live_group(cgrp))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
net_cls_state(cgrp)->classid = (u32) value;
|
cgrp_cls_state(cgrp)->classid = (u32) value;
|
||||||
|
|
||||||
cgroup_unlock();
|
cgroup_unlock();
|
||||||
|
|
||||||
|
@ -115,8 +121,7 @@ static int cls_cgroup_classify(struct sk_buff *skb, struct tcf_proto *tp,
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
cs = (struct cgroup_cls_state *) task_subsys_state(current,
|
cs = task_cls_state(current);
|
||||||
net_cls_subsys_id);
|
|
||||||
if (cs->classid && tcf_em_tree_match(skb, &head->ematches, NULL)) {
|
if (cs->classid && tcf_em_tree_match(skb, &head->ematches, NULL)) {
|
||||||
res->classid = cs->classid;
|
res->classid = cs->classid;
|
||||||
res->class = 0;
|
res->class = 0;
|
||||||
|
|
Loading…
Reference in a new issue