Blame view
net/sched/sch_ingress.c
3.2 KB
10297b993 [NET] SCHED: Fix ... |
1 |
/* net/sched/sch_ingress.c - Ingress qdisc |
1da177e4c Linux-2.6.12-rc2 |
2 3 4 5 6 7 8 |
* This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. * * Authors: Jamal Hadi Salim 1999 */ |
1da177e4c Linux-2.6.12-rc2 |
9 10 |
#include <linux/module.h> #include <linux/types.h> |
0ba480538 [NET_SCHED]: Remo... |
11 |
#include <linux/list.h> |
1da177e4c Linux-2.6.12-rc2 |
12 |
#include <linux/skbuff.h> |
1da177e4c Linux-2.6.12-rc2 |
13 |
#include <linux/rtnetlink.h> |
dc5fc579b [NETLINK]: Use nl... |
14 |
#include <net/netlink.h> |
1da177e4c Linux-2.6.12-rc2 |
15 |
#include <net/pkt_sched.h> |
1da177e4c Linux-2.6.12-rc2 |
16 |
|
1da177e4c Linux-2.6.12-rc2 |
17 |
struct ingress_qdisc_data { |
1da177e4c Linux-2.6.12-rc2 |
18 19 |
struct tcf_proto *filter_list; }; |
1da177e4c Linux-2.6.12-rc2 |
20 |
/* ------------------------- Class/flow operations ------------------------- */ |
1da177e4c Linux-2.6.12-rc2 |
21 22 23 24 |
static struct Qdisc *ingress_leaf(struct Qdisc *sch, unsigned long arg) { return NULL; } |
58f4df423 [NET_SCHED]: sch_... |
25 |
static unsigned long ingress_get(struct Qdisc *sch, u32 classid) |
1da177e4c Linux-2.6.12-rc2 |
26 |
{ |
1da177e4c Linux-2.6.12-rc2 |
27 28 |
return TC_H_MIN(classid) + 1; } |
1da177e4c Linux-2.6.12-rc2 |
29 |
static unsigned long ingress_bind_filter(struct Qdisc *sch, |
58f4df423 [NET_SCHED]: sch_... |
30 |
unsigned long parent, u32 classid) |
1da177e4c Linux-2.6.12-rc2 |
31 32 33 |
{ return ingress_get(sch, classid); } |
1da177e4c Linux-2.6.12-rc2 |
34 35 36 |
static void ingress_put(struct Qdisc *sch, unsigned long cl) { } |
58f4df423 [NET_SCHED]: sch_... |
37 |
static void ingress_walk(struct Qdisc *sch, struct qdisc_walker *walker) |
1da177e4c Linux-2.6.12-rc2 |
38 |
{ |
1da177e4c Linux-2.6.12-rc2 |
39 |
} |
58f4df423 [NET_SCHED]: sch_... |
40 |
static struct tcf_proto **ingress_find_tcf(struct Qdisc *sch, unsigned long cl) |
1da177e4c Linux-2.6.12-rc2 |
41 |
{ |
cb53c0489 [NET_SCHED]: sch_... |
42 |
struct ingress_qdisc_data *p = qdisc_priv(sch); |
1da177e4c Linux-2.6.12-rc2 |
43 44 45 |
return &p->filter_list; } |
1da177e4c Linux-2.6.12-rc2 |
46 |
/* --------------------------- Qdisc operations ---------------------------- */ |
58f4df423 [NET_SCHED]: sch_... |
47 |
static int ingress_enqueue(struct sk_buff *skb, struct Qdisc *sch) |
1da177e4c Linux-2.6.12-rc2 |
48 |
{ |
cb53c0489 [NET_SCHED]: sch_... |
49 |
struct ingress_qdisc_data *p = qdisc_priv(sch); |
1da177e4c Linux-2.6.12-rc2 |
50 51 |
struct tcf_result res; int result; |
1da177e4c Linux-2.6.12-rc2 |
52 |
result = tc_classify(skb, p->filter_list, &res); |
a47812211 [NET_SCHED]: sch_... |
53 |
|
bfe0d0298 net_sched: factor... |
54 |
qdisc_bstats_update(sch, skb); |
1da177e4c Linux-2.6.12-rc2 |
55 |
switch (result) { |
58f4df423 [NET_SCHED]: sch_... |
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
case TC_ACT_SHOT: result = TC_ACT_SHOT; sch->qstats.drops++; break; case TC_ACT_STOLEN: case TC_ACT_QUEUED: result = TC_ACT_STOLEN; break; case TC_ACT_RECLASSIFY: case TC_ACT_OK: skb->tc_index = TC_H_MIN(res.classid); default: result = TC_ACT_OK; break; |
3ff50b799 [NET]: cleanup ex... |
70 |
} |
1da177e4c Linux-2.6.12-rc2 |
71 72 73 |
return result; } |
1da177e4c Linux-2.6.12-rc2 |
74 |
/* ------------------------------------------------------------- */ |
1da177e4c Linux-2.6.12-rc2 |
75 76 |
static void ingress_destroy(struct Qdisc *sch) { |
cb53c0489 [NET_SCHED]: sch_... |
77 |
struct ingress_qdisc_data *p = qdisc_priv(sch); |
1da177e4c Linux-2.6.12-rc2 |
78 |
|
ff31ab56c net-sched: change... |
79 |
tcf_destroy_chain(&p->filter_list); |
1da177e4c Linux-2.6.12-rc2 |
80 |
} |
1da177e4c Linux-2.6.12-rc2 |
81 82 |
static int ingress_dump(struct Qdisc *sch, struct sk_buff *skb) { |
4b3550ef5 [NET_SCHED]: Use ... |
83 |
struct nlattr *nest; |
1da177e4c Linux-2.6.12-rc2 |
84 |
|
4b3550ef5 [NET_SCHED]: Use ... |
85 86 87 88 |
nest = nla_nest_start(skb, TCA_OPTIONS); if (nest == NULL) goto nla_put_failure; nla_nest_end(skb, nest); |
1da177e4c Linux-2.6.12-rc2 |
89 |
return skb->len; |
1e90474c3 [NET_SCHED]: Conv... |
90 |
nla_put_failure: |
4b3550ef5 [NET_SCHED]: Use ... |
91 |
nla_nest_cancel(skb, nest); |
1da177e4c Linux-2.6.12-rc2 |
92 93 |
return -1; } |
20fea08b5 [NET]: Move Qdisc... |
94 |
static const struct Qdisc_class_ops ingress_class_ops = { |
1da177e4c Linux-2.6.12-rc2 |
95 96 97 |
.leaf = ingress_leaf, .get = ingress_get, .put = ingress_put, |
1da177e4c Linux-2.6.12-rc2 |
98 99 100 101 |
.walk = ingress_walk, .tcf_chain = ingress_find_tcf, .bind_tcf = ingress_bind_filter, .unbind_tcf = ingress_put, |
1da177e4c Linux-2.6.12-rc2 |
102 |
}; |
20fea08b5 [NET]: Move Qdisc... |
103 |
static struct Qdisc_ops ingress_qdisc_ops __read_mostly = { |
1da177e4c Linux-2.6.12-rc2 |
104 105 106 107 |
.cl_ops = &ingress_class_ops, .id = "ingress", .priv_size = sizeof(struct ingress_qdisc_data), .enqueue = ingress_enqueue, |
1da177e4c Linux-2.6.12-rc2 |
108 |
.destroy = ingress_destroy, |
1da177e4c Linux-2.6.12-rc2 |
109 110 111 112 113 114 |
.dump = ingress_dump, .owner = THIS_MODULE, }; static int __init ingress_module_init(void) { |
891687649 [NET_SCHED]: sch_... |
115 |
return register_qdisc(&ingress_qdisc_ops); |
1da177e4c Linux-2.6.12-rc2 |
116 |
} |
58f4df423 [NET_SCHED]: sch_... |
117 |
|
10297b993 [NET] SCHED: Fix ... |
118 |
static void __exit ingress_module_exit(void) |
1da177e4c Linux-2.6.12-rc2 |
119 120 |
{ unregister_qdisc(&ingress_qdisc_ops); |
1da177e4c Linux-2.6.12-rc2 |
121 |
} |
58f4df423 [NET_SCHED]: sch_... |
122 |
|
1da177e4c Linux-2.6.12-rc2 |
123 124 125 |
module_init(ingress_module_init) module_exit(ingress_module_exit) MODULE_LICENSE("GPL"); |