ip: fix mc_loop checks for tunnels with multicast outer addresses
[linux-2.6.git] / net / sched / cls_cgroup.c
index 53ada2c..e4877ca 100644 (file)
@@ -24,10 +24,16 @@ struct cgroup_cls_state
        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 *)
-               cgroup_subsys_state(cgrp, net_cls_subsys_id);
+       return container_of(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,
@@ -39,30 +45,24 @@ static struct cgroup_subsys_state *cgrp_create(struct cgroup_subsys *ss,
                return ERR_PTR(-ENOMEM);
 
        if (cgrp->parent)
-               cs->classid = net_cls_state(cgrp->parent)->classid;
+               cs->classid = cgrp_cls_state(cgrp->parent)->classid;
 
        return &cs->css;
 }
 
 static void cgrp_destroy(struct cgroup_subsys *ss, struct cgroup *cgrp)
 {
-       kfree(ss);
+       kfree(cgrp_cls_state(cgrp));
 }
 
 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)
 {
-       if (!cgroup_lock_live_group(cgrp))
-               return -ENODEV;
-
-       net_cls_state(cgrp)->classid = (u32) value;
-
-       cgroup_unlock();
-
+       cgrp_cls_state(cgrp)->classid = (u32) value;
        return 0;
 }
 
@@ -98,8 +98,7 @@ static int cls_cgroup_classify(struct sk_buff *skb, struct tcf_proto *tp,
                               struct tcf_result *res)
 {
        struct cls_cgroup_head *head = tp->root;
-       struct cgroup_cls_state *cs;
-       int ret = 0;
+       u32 classid;
 
        /*
         * Due to the nature of the classifier it is required to ignore all
@@ -115,18 +114,18 @@ static int cls_cgroup_classify(struct sk_buff *skb, struct tcf_proto *tp,
                return -1;
 
        rcu_read_lock();
-       cs = (struct cgroup_cls_state *) task_subsys_state(current,
-                                                          net_cls_subsys_id);
-       if (cs->classid && tcf_em_tree_match(skb, &head->ematches, NULL)) {
-               res->classid = cs->classid;
-               res->class = 0;
-               ret = tcf_exts_exec(skb, &head->exts, res);
-       } else
-               ret = -1;
-
+       classid = task_cls_state(current)->classid;
        rcu_read_unlock();
 
-       return ret;
+       if (!classid)
+               return -1;
+
+       if (!tcf_em_tree_match(skb, &head->ematches, NULL))
+               return -1;
+
+       res->classid = classid;
+       res->class = 0;
+       return tcf_exts_exec(skb, &head->exts, res);
 }
 
 static unsigned long cls_cgroup_get(struct tcf_proto *tp, u32 handle)
@@ -162,6 +161,9 @@ static int cls_cgroup_change(struct tcf_proto *tp, unsigned long base,
        struct tcf_exts e;
        int err;
 
+       if (!tca[TCA_OPTIONS])
+               return -EINVAL;
+
        if (head == NULL) {
                if (!handle)
                        return -EINVAL;
@@ -201,9 +203,7 @@ static int cls_cgroup_change(struct tcf_proto *tp, unsigned long base,
 
 static void cls_cgroup_destroy(struct tcf_proto *tp)
 {
-       struct cls_cgroup_head *head;
-
-       head = (struct cls_cgroup_head *)xchg(&tp->root, NULL);
+       struct cls_cgroup_head *head = tp->root;
 
        if (head) {
                tcf_exts_destroy(tp, &head->exts);