aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched
diff options
context:
space:
mode:
authorDaniel Borkmann <daniel@iogearbox.net>2015-07-15 08:21:41 -0400
committerDavid S. Miller <davem@davemloft.net>2015-07-20 15:41:30 -0400
commitb87a173e25d6bf5c26f13d329cdddf57dbd4061a (patch)
treeed2f43c4b6058bf7ca91676afc320757fe277a15 /net/sched
parentd9382bda4ef97d73c77ecaed7a8d5df20da8b8dd (diff)
cls_cgroup: factor out classid retrieval
Split out retrieving the cgroups net_cls classid retrieval into its own function, so that it can be reused later on from other parts of the traffic control subsystem. If there's no skb->sk, then the small helper returns 0 as well, which in cls_cgroup terms means 'could not classify'. Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Cc: Thomas Graf <tgraf@suug.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched')
-rw-r--r--net/sched/cls_cgroup.c23
1 files changed, 2 insertions, 21 deletions
diff --git a/net/sched/cls_cgroup.c b/net/sched/cls_cgroup.c
index ea611b216412..4c85bd3a750c 100644
--- a/net/sched/cls_cgroup.c
+++ b/net/sched/cls_cgroup.c
@@ -30,35 +30,16 @@ static int cls_cgroup_classify(struct sk_buff *skb, const struct tcf_proto *tp,
30 struct tcf_result *res) 30 struct tcf_result *res)
31{ 31{
32 struct cls_cgroup_head *head = rcu_dereference_bh(tp->root); 32 struct cls_cgroup_head *head = rcu_dereference_bh(tp->root);
33 u32 classid; 33 u32 classid = task_get_classid(skb);
34
35 classid = task_cls_state(current)->classid;
36
37 /*
38 * Due to the nature of the classifier it is required to ignore all
39 * packets originating from softirq context as accessing `current'
40 * would lead to false results.
41 *
42 * This test assumes that all callers of dev_queue_xmit() explicitely
43 * disable bh. Knowing this, it is possible to detect softirq based
44 * calls by looking at the number of nested bh disable calls because
45 * softirqs always disables bh.
46 */
47 if (in_serving_softirq()) {
48 /* If there is an sk_classid we'll use that. */
49 if (!skb->sk)
50 return -1;
51 classid = skb->sk->sk_classid;
52 }
53 34
54 if (!classid) 35 if (!classid)
55 return -1; 36 return -1;
56
57 if (!tcf_em_tree_match(skb, &head->ematches, NULL)) 37 if (!tcf_em_tree_match(skb, &head->ematches, NULL))
58 return -1; 38 return -1;
59 39
60 res->classid = classid; 40 res->classid = classid;
61 res->class = 0; 41 res->class = 0;
42
62 return tcf_exts_exec(skb, &head->exts, res); 43 return tcf_exts_exec(skb, &head->exts, res);
63} 44}
64 45