12 #include <linux/module.h>
13 #include <linux/slab.h>
14 #include <linux/types.h>
15 #include <linux/string.h>
16 #include <linux/errno.h>
25 static inline struct cgroup_cls_state *cgrp_cls_state(
struct cgroup *cgrp)
27 return container_of(cgroup_subsys_state(cgrp, net_cls_subsys_id),
28 struct cgroup_cls_state, css);
31 static inline struct cgroup_cls_state *task_cls_state(
struct task_struct *
p)
33 return container_of(task_subsys_state(p, net_cls_subsys_id),
34 struct cgroup_cls_state, css);
37 static struct cgroup_subsys_state *cgrp_create(
struct cgroup *cgrp)
39 struct cgroup_cls_state *
cs;
46 cs->classid = cgrp_cls_state(cgrp->parent)->classid;
51 static void cgrp_destroy(
struct cgroup *cgrp)
53 kfree(cgrp_cls_state(cgrp));
56 static u64 read_classid(
struct cgroup *cgrp,
struct cftype *cft)
58 return cgrp_cls_state(cgrp)->classid;
61 static int write_classid(
struct cgroup *cgrp,
struct cftype *cft,
u64 value)
63 cgrp_cls_state(cgrp)->classid = (
u32) value;
67 static struct cftype ss_files[] = {
70 .read_u64 = read_classid,
71 .write_u64 = write_classid,
78 .create = cgrp_create,
79 .destroy = cgrp_destroy,
80 .subsys_id = net_cls_subsys_id,
81 .base_cftypes = ss_files,
91 .broken_hierarchy =
true,
107 classid = task_cls_state(
current)->classid;
124 classid = skb->
sk->sk_classid;
135 return tcf_exts_exec(skb, &head->
exts, res);
143 static void cls_cgroup_put(
struct tcf_proto *tp,
unsigned long f)
147 static int cls_cgroup_init(
struct tcf_proto *tp)
161 static int cls_cgroup_change(
struct sk_buff *in_skb,
162 struct tcf_proto *tp,
unsigned long base,
190 if (handle != head->
handle)
212 static void cls_cgroup_destroy(
struct tcf_proto *tp)
223 static int cls_cgroup_delete(
struct tcf_proto *tp,
unsigned long arg)
235 if (arg->
fn(tp, (
unsigned long) head, arg) < 0) {
243 static int cls_cgroup_dump(
struct tcf_proto *tp,
unsigned long fh,
247 unsigned char *
b = skb_tail_pointer(skb);
252 nest = nla_nest_start(skb, TCA_OPTIONS);
254 goto nla_put_failure;
258 goto nla_put_failure;
260 nla_nest_end(skb, nest);
263 goto nla_put_failure;
274 .init = cls_cgroup_init,
275 .change = cls_cgroup_change,
276 .classify = cls_cgroup_classify,
277 .destroy = cls_cgroup_destroy,
278 .get = cls_cgroup_get,
279 .put = cls_cgroup_put,
280 .delete = cls_cgroup_delete,
281 .walk = cls_cgroup_walk,
282 .dump = cls_cgroup_dump,
286 static int __init init_cgroup_cls(
void)
302 static void __exit exit_cgroup_cls(
void)