aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched
diff options
context:
space:
mode:
Diffstat (limited to 'net/sched')
-rw-r--r--net/sched/sch_ingress.c103
1 files changed, 39 insertions, 64 deletions
diff --git a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c
index 89c32a9bcc5e..4880d44ee978 100644
--- a/net/sched/sch_ingress.c
+++ b/net/sched/sch_ingress.c
@@ -22,23 +22,20 @@
22#undef DEBUG_INGRESS 22#undef DEBUG_INGRESS
23 23
24#ifdef DEBUG_INGRESS /* control */ 24#ifdef DEBUG_INGRESS /* control */
25#define DPRINTK(format,args...) printk(KERN_DEBUG format,##args) 25#define DPRINTK(format, args...) printk(KERN_DEBUG format,##args)
26#else 26#else
27#define DPRINTK(format,args...) 27#define DPRINTK(format, args...)
28#endif 28#endif
29 29
30#if 0 /* data */ 30#if 0 /* data */
31#define D2PRINTK(format,args...) printk(KERN_DEBUG format,##args) 31#define D2PRINTK(format, args...) printk(KERN_DEBUG format,##args)
32#else 32#else
33#define D2PRINTK(format,args...) 33#define D2PRINTK(format, args...)
34#endif 34#endif
35 35
36
37#define PRIV(sch) qdisc_priv(sch) 36#define PRIV(sch) qdisc_priv(sch)
38 37
39 38/* Thanks to Doron Oz for this hack */
40/* Thanks to Doron Oz for this hack
41*/
42#ifndef CONFIG_NET_CLS_ACT 39#ifndef CONFIG_NET_CLS_ACT
43#ifdef CONFIG_NETFILTER 40#ifdef CONFIG_NETFILTER
44static int nf_registered; 41static int nf_registered;
@@ -50,12 +47,10 @@ struct ingress_qdisc_data {
50 struct tcf_proto *filter_list; 47 struct tcf_proto *filter_list;
51}; 48};
52 49
53
54/* ------------------------- Class/flow operations ------------------------- */ 50/* ------------------------- Class/flow operations ------------------------- */
55 51
56 52static int ingress_graft(struct Qdisc *sch, unsigned long arg,
57static int ingress_graft(struct Qdisc *sch,unsigned long arg, 53 struct Qdisc *new, struct Qdisc **old)
58 struct Qdisc *new,struct Qdisc **old)
59{ 54{
60#ifdef DEBUG_INGRESS 55#ifdef DEBUG_INGRESS
61 struct ingress_qdisc_data *p = PRIV(sch); 56 struct ingress_qdisc_data *p = PRIV(sch);
@@ -67,37 +62,33 @@ static int ingress_graft(struct Qdisc *sch,unsigned long arg,
67 return 1; 62 return 1;
68} 63}
69 64
70
71static struct Qdisc *ingress_leaf(struct Qdisc *sch, unsigned long arg) 65static struct Qdisc *ingress_leaf(struct Qdisc *sch, unsigned long arg)
72{ 66{
73 return NULL; 67 return NULL;
74} 68}
75 69
76 70static unsigned long ingress_get(struct Qdisc *sch, u32 classid)
77static unsigned long ingress_get(struct Qdisc *sch,u32 classid)
78{ 71{
79#ifdef DEBUG_INGRESS 72#ifdef DEBUG_INGRESS
80 struct ingress_qdisc_data *p = PRIV(sch); 73 struct ingress_qdisc_data *p = PRIV(sch);
81#endif 74#endif
82 DPRINTK("ingress_get(sch %p,[qdisc %p],classid %x)\n", sch, p, classid); 75 DPRINTK("ingress_get(sch %p,[qdisc %p],classid %x)\n",
76 sch, p, classid);
83 return TC_H_MIN(classid) + 1; 77 return TC_H_MIN(classid) + 1;
84} 78}
85 79
86
87static unsigned long ingress_bind_filter(struct Qdisc *sch, 80static unsigned long ingress_bind_filter(struct Qdisc *sch,
88 unsigned long parent, u32 classid) 81 unsigned long parent, u32 classid)
89{ 82{
90 return ingress_get(sch, classid); 83 return ingress_get(sch, classid);
91} 84}
92 85
93
94static void ingress_put(struct Qdisc *sch, unsigned long cl) 86static void ingress_put(struct Qdisc *sch, unsigned long cl)
95{ 87{
96} 88}
97 89
98
99static int ingress_change(struct Qdisc *sch, u32 classid, u32 parent, 90static int ingress_change(struct Qdisc *sch, u32 classid, u32 parent,
100 struct rtattr **tca, unsigned long *arg) 91 struct rtattr **tca, unsigned long *arg)
101{ 92{
102#ifdef DEBUG_INGRESS 93#ifdef DEBUG_INGRESS
103 struct ingress_qdisc_data *p = PRIV(sch); 94 struct ingress_qdisc_data *p = PRIV(sch);
@@ -108,9 +99,7 @@ static int ingress_change(struct Qdisc *sch, u32 classid, u32 parent,
108 return 0; 99 return 0;
109} 100}
110 101
111 102static void ingress_walk(struct Qdisc *sch, struct qdisc_walker *walker)
112
113static void ingress_walk(struct Qdisc *sch,struct qdisc_walker *walker)
114{ 103{
115#ifdef DEBUG_INGRESS 104#ifdef DEBUG_INGRESS
116 struct ingress_qdisc_data *p = PRIV(sch); 105 struct ingress_qdisc_data *p = PRIV(sch);
@@ -119,19 +108,16 @@ static void ingress_walk(struct Qdisc *sch,struct qdisc_walker *walker)
119 DPRINTK("No effect. sch_ingress doesn't maintain classes at the moment"); 108 DPRINTK("No effect. sch_ingress doesn't maintain classes at the moment");
120} 109}
121 110
122 111static struct tcf_proto **ingress_find_tcf(struct Qdisc *sch, unsigned long cl)
123static struct tcf_proto **ingress_find_tcf(struct Qdisc *sch,unsigned long cl)
124{ 112{
125 struct ingress_qdisc_data *p = PRIV(sch); 113 struct ingress_qdisc_data *p = PRIV(sch);
126 114
127 return &p->filter_list; 115 return &p->filter_list;
128} 116}
129 117
130
131/* --------------------------- Qdisc operations ---------------------------- */ 118/* --------------------------- Qdisc operations ---------------------------- */
132 119
133 120static int ingress_enqueue(struct sk_buff *skb, struct Qdisc *sch)
134static int ingress_enqueue(struct sk_buff *skb,struct Qdisc *sch)
135{ 121{
136 struct ingress_qdisc_data *p = PRIV(sch); 122 struct ingress_qdisc_data *p = PRIV(sch);
137 struct tcf_result res; 123 struct tcf_result res;
@@ -148,20 +134,20 @@ static int ingress_enqueue(struct sk_buff *skb,struct Qdisc *sch)
148 sch->bstats.packets++; 134 sch->bstats.packets++;
149 sch->bstats.bytes += skb->len; 135 sch->bstats.bytes += skb->len;
150 switch (result) { 136 switch (result) {
151 case TC_ACT_SHOT: 137 case TC_ACT_SHOT:
152 result = TC_ACT_SHOT; 138 result = TC_ACT_SHOT;
153 sch->qstats.drops++; 139 sch->qstats.drops++;
154 break; 140 break;
155 case TC_ACT_STOLEN: 141 case TC_ACT_STOLEN:
156 case TC_ACT_QUEUED: 142 case TC_ACT_QUEUED:
157 result = TC_ACT_STOLEN; 143 result = TC_ACT_STOLEN;
158 break; 144 break;
159 case TC_ACT_RECLASSIFY: 145 case TC_ACT_RECLASSIFY:
160 case TC_ACT_OK: 146 case TC_ACT_OK:
161 skb->tc_index = TC_H_MIN(res.classid); 147 skb->tc_index = TC_H_MIN(res.classid);
162 default: 148 default:
163 result = TC_ACT_OK; 149 result = TC_ACT_OK;
164 break; 150 break;
165 } 151 }
166#else 152#else
167 D2PRINTK("Overriding result to ACCEPT\n"); 153 D2PRINTK("Overriding result to ACCEPT\n");
@@ -173,7 +159,6 @@ static int ingress_enqueue(struct sk_buff *skb,struct Qdisc *sch)
173 return result; 159 return result;
174} 160}
175 161
176
177static struct sk_buff *ingress_dequeue(struct Qdisc *sch) 162static struct sk_buff *ingress_dequeue(struct Qdisc *sch)
178{ 163{
179/* 164/*
@@ -183,8 +168,7 @@ static struct sk_buff *ingress_dequeue(struct Qdisc *sch)
183 return NULL; 168 return NULL;
184} 169}
185 170
186 171static int ingress_requeue(struct sk_buff *skb, struct Qdisc *sch)
187static int ingress_requeue(struct sk_buff *skb,struct Qdisc *sch)
188{ 172{
189/* 173/*
190 struct ingress_qdisc_data *p = PRIV(sch); 174 struct ingress_qdisc_data *p = PRIV(sch);
@@ -204,8 +188,7 @@ static unsigned int ingress_drop(struct Qdisc *sch)
204 188
205#ifndef CONFIG_NET_CLS_ACT 189#ifndef CONFIG_NET_CLS_ACT
206#ifdef CONFIG_NETFILTER 190#ifdef CONFIG_NETFILTER
207static unsigned int 191static unsigned int ing_hook(unsigned int hook, struct sk_buff *skb,
208ing_hook(unsigned int hook, struct sk_buff *skb,
209 const struct net_device *indev, 192 const struct net_device *indev,
210 const struct net_device *outdev, 193 const struct net_device *outdev,
211 int (*okfn)(struct sk_buff *)) 194 int (*okfn)(struct sk_buff *))
@@ -213,7 +196,7 @@ ing_hook(unsigned int hook, struct sk_buff *skb,
213 196
214 struct Qdisc *q; 197 struct Qdisc *q;
215 struct net_device *dev = skb->dev; 198 struct net_device *dev = skb->dev;
216 int fwres=NF_ACCEPT; 199 int fwres = NF_ACCEPT;
217 200
218 DPRINTK("ing_hook: skb %s dev=%s len=%u\n", 201 DPRINTK("ing_hook: skb %s dev=%s len=%u\n",
219 skb->sk ? "(owned)" : "(unowned)", 202 skb->sk ? "(owned)" : "(unowned)",
@@ -247,16 +230,15 @@ static struct nf_hook_ops ing_ops[] __read_mostly = {
247 .priority = NF_IP6_PRI_FILTER + 1, 230 .priority = NF_IP6_PRI_FILTER + 1,
248 }, 231 },
249}; 232};
250
251#endif 233#endif
252#endif 234#endif
253 235
254static int ingress_init(struct Qdisc *sch,struct rtattr *opt) 236static int ingress_init(struct Qdisc *sch, struct rtattr *opt)
255{ 237{
256 struct ingress_qdisc_data *p = PRIV(sch); 238 struct ingress_qdisc_data *p = PRIV(sch);
257 239
258/* Make sure either netfilter or preferably CLS_ACT is 240 /* Make sure either netfilter or preferably CLS_ACT is
259* compiled in */ 241 * compiled in */
260#ifndef CONFIG_NET_CLS_ACT 242#ifndef CONFIG_NET_CLS_ACT
261#ifndef CONFIG_NETFILTER 243#ifndef CONFIG_NETFILTER
262 printk("You MUST compile classifier actions into the kernel\n"); 244 printk("You MUST compile classifier actions into the kernel\n");
@@ -278,12 +260,11 @@ static int ingress_init(struct Qdisc *sch,struct rtattr *opt)
278#endif 260#endif
279#endif 261#endif
280 262
281 DPRINTK("ingress_init(sch %p,[qdisc %p],opt %p)\n",sch,p,opt); 263 DPRINTK("ingress_init(sch %p,[qdisc %p],opt %p)\n", sch, p, opt);
282 p->q = &noop_qdisc; 264 p->q = &noop_qdisc;
283 return 0; 265 return 0;
284} 266}
285 267
286
287static void ingress_reset(struct Qdisc *sch) 268static void ingress_reset(struct Qdisc *sch)
288{ 269{
289 struct ingress_qdisc_data *p = PRIV(sch); 270 struct ingress_qdisc_data *p = PRIV(sch);
@@ -302,9 +283,6 @@ static void ingress_reset(struct Qdisc *sch)
302 283
303/* ------------------------------------------------------------- */ 284/* ------------------------------------------------------------- */
304 285
305
306/* ------------------------------------------------------------- */
307
308static void ingress_destroy(struct Qdisc *sch) 286static void ingress_destroy(struct Qdisc *sch)
309{ 287{
310 struct ingress_qdisc_data *p = PRIV(sch); 288 struct ingress_qdisc_data *p = PRIV(sch);
@@ -317,13 +295,12 @@ static void ingress_destroy(struct Qdisc *sch)
317#endif 295#endif
318} 296}
319 297
320
321static int ingress_dump(struct Qdisc *sch, struct sk_buff *skb) 298static int ingress_dump(struct Qdisc *sch, struct sk_buff *skb)
322{ 299{
323 unsigned char *b = skb_tail_pointer(skb); 300 unsigned char *b = skb_tail_pointer(skb);
324 struct rtattr *rta; 301 struct rtattr *rta;
325 302
326 rta = (struct rtattr *) b; 303 rta = (struct rtattr *)b;
327 RTA_PUT(skb, TCA_OPTIONS, 0, NULL); 304 RTA_PUT(skb, TCA_OPTIONS, 0, NULL);
328 rta->rta_len = skb_tail_pointer(skb) - b; 305 rta->rta_len = skb_tail_pointer(skb) - b;
329 return skb->len; 306 return skb->len;
@@ -339,16 +316,13 @@ static const struct Qdisc_class_ops ingress_class_ops = {
339 .get = ingress_get, 316 .get = ingress_get,
340 .put = ingress_put, 317 .put = ingress_put,
341 .change = ingress_change, 318 .change = ingress_change,
342 .delete = NULL,
343 .walk = ingress_walk, 319 .walk = ingress_walk,
344 .tcf_chain = ingress_find_tcf, 320 .tcf_chain = ingress_find_tcf,
345 .bind_tcf = ingress_bind_filter, 321 .bind_tcf = ingress_bind_filter,
346 .unbind_tcf = ingress_put, 322 .unbind_tcf = ingress_put,
347 .dump = NULL,
348}; 323};
349 324
350static struct Qdisc_ops ingress_qdisc_ops __read_mostly = { 325static struct Qdisc_ops ingress_qdisc_ops __read_mostly = {
351 .next = NULL,
352 .cl_ops = &ingress_class_ops, 326 .cl_ops = &ingress_class_ops,
353 .id = "ingress", 327 .id = "ingress",
354 .priv_size = sizeof(struct ingress_qdisc_data), 328 .priv_size = sizeof(struct ingress_qdisc_data),
@@ -359,7 +333,6 @@ static struct Qdisc_ops ingress_qdisc_ops __read_mostly = {
359 .init = ingress_init, 333 .init = ingress_init,
360 .reset = ingress_reset, 334 .reset = ingress_reset,
361 .destroy = ingress_destroy, 335 .destroy = ingress_destroy,
362 .change = NULL,
363 .dump = ingress_dump, 336 .dump = ingress_dump,
364 .owner = THIS_MODULE, 337 .owner = THIS_MODULE,
365}; 338};
@@ -375,6 +348,7 @@ static int __init ingress_module_init(void)
375 348
376 return ret; 349 return ret;
377} 350}
351
378static void __exit ingress_module_exit(void) 352static void __exit ingress_module_exit(void)
379{ 353{
380 unregister_qdisc(&ingress_qdisc_ops); 354 unregister_qdisc(&ingress_qdisc_ops);
@@ -385,6 +359,7 @@ static void __exit ingress_module_exit(void)
385#endif 359#endif
386#endif 360#endif
387} 361}
362
388module_init(ingress_module_init) 363module_init(ingress_module_init)
389module_exit(ingress_module_exit) 364module_exit(ingress_module_exit)
390MODULE_LICENSE("GPL"); 365MODULE_LICENSE("GPL");