Commit c0956bd25161bff45304d482cda51ca4b3b572f1

Authored by Ralf Hildebrandt
Committed by David S. Miller
1 parent b9c6e3e966

[PKT_SCHED] cls_u32: Fix typo.

Signed-off-by: Ralf Hildebrandt <Ralf.Hildebrandt@charite.de>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 1 changed file with 1 additions and 1 deletions Inline Diff

1 /* 1 /*
2 * net/sched/cls_u32.c Ugly (or Universal) 32bit key Packet Classifier. 2 * net/sched/cls_u32.c Ugly (or Universal) 32bit key Packet Classifier.
3 * 3 *
4 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License 5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version. 7 * 2 of the License, or (at your option) any later version.
8 * 8 *
9 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> 9 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
10 * 10 *
11 * The filters are packed to hash tables of key nodes 11 * The filters are packed to hash tables of key nodes
12 * with a set of 32bit key/mask pairs at every node. 12 * with a set of 32bit key/mask pairs at every node.
13 * Nodes reference next level hash tables etc. 13 * Nodes reference next level hash tables etc.
14 * 14 *
15 * This scheme is the best universal classifier I managed to 15 * This scheme is the best universal classifier I managed to
16 * invent; it is not super-fast, but it is not slow (provided you 16 * invent; it is not super-fast, but it is not slow (provided you
17 * program it correctly), and general enough. And its relative 17 * program it correctly), and general enough. And its relative
18 * speed grows as the number of rules becomes larger. 18 * speed grows as the number of rules becomes larger.
19 * 19 *
20 * It seems that it represents the best middle point between 20 * It seems that it represents the best middle point between
21 * speed and manageability both by human and by machine. 21 * speed and manageability both by human and by machine.
22 * 22 *
23 * It is especially useful for link sharing combined with QoS; 23 * It is especially useful for link sharing combined with QoS;
24 * pure RSVP doesn't need such a general approach and can use 24 * pure RSVP doesn't need such a general approach and can use
25 * much simpler (and faster) schemes, sort of cls_rsvp.c. 25 * much simpler (and faster) schemes, sort of cls_rsvp.c.
26 * 26 *
27 * JHS: We should remove the CONFIG_NET_CLS_IND from here 27 * JHS: We should remove the CONFIG_NET_CLS_IND from here
28 * eventually when the meta match extension is made available 28 * eventually when the meta match extension is made available
29 * 29 *
30 * nfmark match added by Catalin(ux aka Dino) BOIE <catab at umbrella.ro> 30 * nfmark match added by Catalin(ux aka Dino) BOIE <catab at umbrella.ro>
31 */ 31 */
32 32
33 #include <asm/uaccess.h> 33 #include <asm/uaccess.h>
34 #include <asm/system.h> 34 #include <asm/system.h>
35 #include <linux/bitops.h> 35 #include <linux/bitops.h>
36 #include <linux/module.h> 36 #include <linux/module.h>
37 #include <linux/types.h> 37 #include <linux/types.h>
38 #include <linux/kernel.h> 38 #include <linux/kernel.h>
39 #include <linux/sched.h> 39 #include <linux/sched.h>
40 #include <linux/string.h> 40 #include <linux/string.h>
41 #include <linux/mm.h> 41 #include <linux/mm.h>
42 #include <linux/socket.h> 42 #include <linux/socket.h>
43 #include <linux/sockios.h> 43 #include <linux/sockios.h>
44 #include <linux/in.h> 44 #include <linux/in.h>
45 #include <linux/errno.h> 45 #include <linux/errno.h>
46 #include <linux/interrupt.h> 46 #include <linux/interrupt.h>
47 #include <linux/if_ether.h> 47 #include <linux/if_ether.h>
48 #include <linux/inet.h> 48 #include <linux/inet.h>
49 #include <linux/netdevice.h> 49 #include <linux/netdevice.h>
50 #include <linux/etherdevice.h> 50 #include <linux/etherdevice.h>
51 #include <linux/notifier.h> 51 #include <linux/notifier.h>
52 #include <linux/rtnetlink.h> 52 #include <linux/rtnetlink.h>
53 #include <net/ip.h> 53 #include <net/ip.h>
54 #include <net/route.h> 54 #include <net/route.h>
55 #include <linux/skbuff.h> 55 #include <linux/skbuff.h>
56 #include <net/sock.h> 56 #include <net/sock.h>
57 #include <net/act_api.h> 57 #include <net/act_api.h>
58 #include <net/pkt_cls.h> 58 #include <net/pkt_cls.h>
59 59
60 struct tc_u_knode 60 struct tc_u_knode
61 { 61 {
62 struct tc_u_knode *next; 62 struct tc_u_knode *next;
63 u32 handle; 63 u32 handle;
64 struct tc_u_hnode *ht_up; 64 struct tc_u_hnode *ht_up;
65 struct tcf_exts exts; 65 struct tcf_exts exts;
66 #ifdef CONFIG_NET_CLS_IND 66 #ifdef CONFIG_NET_CLS_IND
67 char indev[IFNAMSIZ]; 67 char indev[IFNAMSIZ];
68 #endif 68 #endif
69 u8 fshift; 69 u8 fshift;
70 struct tcf_result res; 70 struct tcf_result res;
71 struct tc_u_hnode *ht_down; 71 struct tc_u_hnode *ht_down;
72 #ifdef CONFIG_CLS_U32_PERF 72 #ifdef CONFIG_CLS_U32_PERF
73 struct tc_u32_pcnt *pf; 73 struct tc_u32_pcnt *pf;
74 #endif 74 #endif
75 #ifdef CONFIG_CLS_U32_MARK 75 #ifdef CONFIG_CLS_U32_MARK
76 struct tc_u32_mark mark; 76 struct tc_u32_mark mark;
77 #endif 77 #endif
78 struct tc_u32_sel sel; 78 struct tc_u32_sel sel;
79 }; 79 };
80 80
81 struct tc_u_hnode 81 struct tc_u_hnode
82 { 82 {
83 struct tc_u_hnode *next; 83 struct tc_u_hnode *next;
84 u32 handle; 84 u32 handle;
85 u32 prio; 85 u32 prio;
86 struct tc_u_common *tp_c; 86 struct tc_u_common *tp_c;
87 int refcnt; 87 int refcnt;
88 unsigned divisor; 88 unsigned divisor;
89 struct tc_u_knode *ht[1]; 89 struct tc_u_knode *ht[1];
90 }; 90 };
91 91
92 struct tc_u_common 92 struct tc_u_common
93 { 93 {
94 struct tc_u_common *next; 94 struct tc_u_common *next;
95 struct tc_u_hnode *hlist; 95 struct tc_u_hnode *hlist;
96 struct Qdisc *q; 96 struct Qdisc *q;
97 int refcnt; 97 int refcnt;
98 u32 hgenerator; 98 u32 hgenerator;
99 }; 99 };
100 100
101 static struct tcf_ext_map u32_ext_map = { 101 static struct tcf_ext_map u32_ext_map = {
102 .action = TCA_U32_ACT, 102 .action = TCA_U32_ACT,
103 .police = TCA_U32_POLICE 103 .police = TCA_U32_POLICE
104 }; 104 };
105 105
106 static struct tc_u_common *u32_list; 106 static struct tc_u_common *u32_list;
107 107
108 static __inline__ unsigned u32_hash_fold(u32 key, struct tc_u32_sel *sel, u8 fshift) 108 static __inline__ unsigned u32_hash_fold(u32 key, struct tc_u32_sel *sel, u8 fshift)
109 { 109 {
110 unsigned h = (key & sel->hmask)>>fshift; 110 unsigned h = (key & sel->hmask)>>fshift;
111 111
112 return h; 112 return h;
113 } 113 }
114 114
115 static int u32_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_result *res) 115 static int u32_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_result *res)
116 { 116 {
117 struct { 117 struct {
118 struct tc_u_knode *knode; 118 struct tc_u_knode *knode;
119 u8 *ptr; 119 u8 *ptr;
120 } stack[TC_U32_MAXDEPTH]; 120 } stack[TC_U32_MAXDEPTH];
121 121
122 struct tc_u_hnode *ht = (struct tc_u_hnode*)tp->root; 122 struct tc_u_hnode *ht = (struct tc_u_hnode*)tp->root;
123 u8 *ptr = skb->nh.raw; 123 u8 *ptr = skb->nh.raw;
124 struct tc_u_knode *n; 124 struct tc_u_knode *n;
125 int sdepth = 0; 125 int sdepth = 0;
126 int off2 = 0; 126 int off2 = 0;
127 int sel = 0; 127 int sel = 0;
128 #ifdef CONFIG_CLS_U32_PERF 128 #ifdef CONFIG_CLS_U32_PERF
129 int j; 129 int j;
130 #endif 130 #endif
131 int i, r; 131 int i, r;
132 132
133 next_ht: 133 next_ht:
134 n = ht->ht[sel]; 134 n = ht->ht[sel];
135 135
136 next_knode: 136 next_knode:
137 if (n) { 137 if (n) {
138 struct tc_u32_key *key = n->sel.keys; 138 struct tc_u32_key *key = n->sel.keys;
139 139
140 #ifdef CONFIG_CLS_U32_PERF 140 #ifdef CONFIG_CLS_U32_PERF
141 n->pf->rcnt +=1; 141 n->pf->rcnt +=1;
142 j = 0; 142 j = 0;
143 #endif 143 #endif
144 144
145 #ifdef CONFIG_CLS_U32_MARK 145 #ifdef CONFIG_CLS_U32_MARK
146 if ((skb->nfmark & n->mark.mask) != n->mark.val) { 146 if ((skb->nfmark & n->mark.mask) != n->mark.val) {
147 n = n->next; 147 n = n->next;
148 goto next_knode; 148 goto next_knode;
149 } else { 149 } else {
150 n->mark.success++; 150 n->mark.success++;
151 } 151 }
152 #endif 152 #endif
153 153
154 for (i = n->sel.nkeys; i>0; i--, key++) { 154 for (i = n->sel.nkeys; i>0; i--, key++) {
155 155
156 if ((*(u32*)(ptr+key->off+(off2&key->offmask))^key->val)&key->mask) { 156 if ((*(u32*)(ptr+key->off+(off2&key->offmask))^key->val)&key->mask) {
157 n = n->next; 157 n = n->next;
158 goto next_knode; 158 goto next_knode;
159 } 159 }
160 #ifdef CONFIG_CLS_U32_PERF 160 #ifdef CONFIG_CLS_U32_PERF
161 n->pf->kcnts[j] +=1; 161 n->pf->kcnts[j] +=1;
162 j++; 162 j++;
163 #endif 163 #endif
164 } 164 }
165 if (n->ht_down == NULL) { 165 if (n->ht_down == NULL) {
166 check_terminal: 166 check_terminal:
167 if (n->sel.flags&TC_U32_TERMINAL) { 167 if (n->sel.flags&TC_U32_TERMINAL) {
168 168
169 *res = n->res; 169 *res = n->res;
170 #ifdef CONFIG_NET_CLS_IND 170 #ifdef CONFIG_NET_CLS_IND
171 if (!tcf_match_indev(skb, n->indev)) { 171 if (!tcf_match_indev(skb, n->indev)) {
172 n = n->next; 172 n = n->next;
173 goto next_knode; 173 goto next_knode;
174 } 174 }
175 #endif 175 #endif
176 #ifdef CONFIG_CLS_U32_PERF 176 #ifdef CONFIG_CLS_U32_PERF
177 n->pf->rhit +=1; 177 n->pf->rhit +=1;
178 #endif 178 #endif
179 r = tcf_exts_exec(skb, &n->exts, res); 179 r = tcf_exts_exec(skb, &n->exts, res);
180 if (r < 0) { 180 if (r < 0) {
181 n = n->next; 181 n = n->next;
182 goto next_knode; 182 goto next_knode;
183 } 183 }
184 184
185 return r; 185 return r;
186 } 186 }
187 n = n->next; 187 n = n->next;
188 goto next_knode; 188 goto next_knode;
189 } 189 }
190 190
191 /* PUSH */ 191 /* PUSH */
192 if (sdepth >= TC_U32_MAXDEPTH) 192 if (sdepth >= TC_U32_MAXDEPTH)
193 goto deadloop; 193 goto deadloop;
194 stack[sdepth].knode = n; 194 stack[sdepth].knode = n;
195 stack[sdepth].ptr = ptr; 195 stack[sdepth].ptr = ptr;
196 sdepth++; 196 sdepth++;
197 197
198 ht = n->ht_down; 198 ht = n->ht_down;
199 sel = 0; 199 sel = 0;
200 if (ht->divisor) 200 if (ht->divisor)
201 sel = ht->divisor&u32_hash_fold(*(u32*)(ptr+n->sel.hoff), &n->sel,n->fshift); 201 sel = ht->divisor&u32_hash_fold(*(u32*)(ptr+n->sel.hoff), &n->sel,n->fshift);
202 202
203 if (!(n->sel.flags&(TC_U32_VAROFFSET|TC_U32_OFFSET|TC_U32_EAT))) 203 if (!(n->sel.flags&(TC_U32_VAROFFSET|TC_U32_OFFSET|TC_U32_EAT)))
204 goto next_ht; 204 goto next_ht;
205 205
206 if (n->sel.flags&(TC_U32_OFFSET|TC_U32_VAROFFSET)) { 206 if (n->sel.flags&(TC_U32_OFFSET|TC_U32_VAROFFSET)) {
207 off2 = n->sel.off + 3; 207 off2 = n->sel.off + 3;
208 if (n->sel.flags&TC_U32_VAROFFSET) 208 if (n->sel.flags&TC_U32_VAROFFSET)
209 off2 += ntohs(n->sel.offmask & *(u16*)(ptr+n->sel.offoff)) >>n->sel.offshift; 209 off2 += ntohs(n->sel.offmask & *(u16*)(ptr+n->sel.offoff)) >>n->sel.offshift;
210 off2 &= ~3; 210 off2 &= ~3;
211 } 211 }
212 if (n->sel.flags&TC_U32_EAT) { 212 if (n->sel.flags&TC_U32_EAT) {
213 ptr += off2; 213 ptr += off2;
214 off2 = 0; 214 off2 = 0;
215 } 215 }
216 216
217 if (ptr < skb->tail) 217 if (ptr < skb->tail)
218 goto next_ht; 218 goto next_ht;
219 } 219 }
220 220
221 /* POP */ 221 /* POP */
222 if (sdepth--) { 222 if (sdepth--) {
223 n = stack[sdepth].knode; 223 n = stack[sdepth].knode;
224 ht = n->ht_up; 224 ht = n->ht_up;
225 ptr = stack[sdepth].ptr; 225 ptr = stack[sdepth].ptr;
226 goto check_terminal; 226 goto check_terminal;
227 } 227 }
228 return -1; 228 return -1;
229 229
230 deadloop: 230 deadloop:
231 if (net_ratelimit()) 231 if (net_ratelimit())
232 printk("cls_u32: dead loop\n"); 232 printk("cls_u32: dead loop\n");
233 return -1; 233 return -1;
234 } 234 }
235 235
236 static __inline__ struct tc_u_hnode * 236 static __inline__ struct tc_u_hnode *
237 u32_lookup_ht(struct tc_u_common *tp_c, u32 handle) 237 u32_lookup_ht(struct tc_u_common *tp_c, u32 handle)
238 { 238 {
239 struct tc_u_hnode *ht; 239 struct tc_u_hnode *ht;
240 240
241 for (ht = tp_c->hlist; ht; ht = ht->next) 241 for (ht = tp_c->hlist; ht; ht = ht->next)
242 if (ht->handle == handle) 242 if (ht->handle == handle)
243 break; 243 break;
244 244
245 return ht; 245 return ht;
246 } 246 }
247 247
248 static __inline__ struct tc_u_knode * 248 static __inline__ struct tc_u_knode *
249 u32_lookup_key(struct tc_u_hnode *ht, u32 handle) 249 u32_lookup_key(struct tc_u_hnode *ht, u32 handle)
250 { 250 {
251 unsigned sel; 251 unsigned sel;
252 struct tc_u_knode *n = NULL; 252 struct tc_u_knode *n = NULL;
253 253
254 sel = TC_U32_HASH(handle); 254 sel = TC_U32_HASH(handle);
255 if (sel > ht->divisor) 255 if (sel > ht->divisor)
256 goto out; 256 goto out;
257 257
258 for (n = ht->ht[sel]; n; n = n->next) 258 for (n = ht->ht[sel]; n; n = n->next)
259 if (n->handle == handle) 259 if (n->handle == handle)
260 break; 260 break;
261 out: 261 out:
262 return n; 262 return n;
263 } 263 }
264 264
265 265
266 static unsigned long u32_get(struct tcf_proto *tp, u32 handle) 266 static unsigned long u32_get(struct tcf_proto *tp, u32 handle)
267 { 267 {
268 struct tc_u_hnode *ht; 268 struct tc_u_hnode *ht;
269 struct tc_u_common *tp_c = tp->data; 269 struct tc_u_common *tp_c = tp->data;
270 270
271 if (TC_U32_HTID(handle) == TC_U32_ROOT) 271 if (TC_U32_HTID(handle) == TC_U32_ROOT)
272 ht = tp->root; 272 ht = tp->root;
273 else 273 else
274 ht = u32_lookup_ht(tp_c, TC_U32_HTID(handle)); 274 ht = u32_lookup_ht(tp_c, TC_U32_HTID(handle));
275 275
276 if (!ht) 276 if (!ht)
277 return 0; 277 return 0;
278 278
279 if (TC_U32_KEY(handle) == 0) 279 if (TC_U32_KEY(handle) == 0)
280 return (unsigned long)ht; 280 return (unsigned long)ht;
281 281
282 return (unsigned long)u32_lookup_key(ht, handle); 282 return (unsigned long)u32_lookup_key(ht, handle);
283 } 283 }
284 284
285 static void u32_put(struct tcf_proto *tp, unsigned long f) 285 static void u32_put(struct tcf_proto *tp, unsigned long f)
286 { 286 {
287 } 287 }
288 288
289 static u32 gen_new_htid(struct tc_u_common *tp_c) 289 static u32 gen_new_htid(struct tc_u_common *tp_c)
290 { 290 {
291 int i = 0x800; 291 int i = 0x800;
292 292
293 do { 293 do {
294 if (++tp_c->hgenerator == 0x7FF) 294 if (++tp_c->hgenerator == 0x7FF)
295 tp_c->hgenerator = 1; 295 tp_c->hgenerator = 1;
296 } while (--i>0 && u32_lookup_ht(tp_c, (tp_c->hgenerator|0x800)<<20)); 296 } while (--i>0 && u32_lookup_ht(tp_c, (tp_c->hgenerator|0x800)<<20));
297 297
298 return i > 0 ? (tp_c->hgenerator|0x800)<<20 : 0; 298 return i > 0 ? (tp_c->hgenerator|0x800)<<20 : 0;
299 } 299 }
300 300
301 static int u32_init(struct tcf_proto *tp) 301 static int u32_init(struct tcf_proto *tp)
302 { 302 {
303 struct tc_u_hnode *root_ht; 303 struct tc_u_hnode *root_ht;
304 struct tc_u_common *tp_c; 304 struct tc_u_common *tp_c;
305 305
306 for (tp_c = u32_list; tp_c; tp_c = tp_c->next) 306 for (tp_c = u32_list; tp_c; tp_c = tp_c->next)
307 if (tp_c->q == tp->q) 307 if (tp_c->q == tp->q)
308 break; 308 break;
309 309
310 root_ht = kzalloc(sizeof(*root_ht), GFP_KERNEL); 310 root_ht = kzalloc(sizeof(*root_ht), GFP_KERNEL);
311 if (root_ht == NULL) 311 if (root_ht == NULL)
312 return -ENOBUFS; 312 return -ENOBUFS;
313 313
314 root_ht->divisor = 0; 314 root_ht->divisor = 0;
315 root_ht->refcnt++; 315 root_ht->refcnt++;
316 root_ht->handle = tp_c ? gen_new_htid(tp_c) : 0x80000000; 316 root_ht->handle = tp_c ? gen_new_htid(tp_c) : 0x80000000;
317 root_ht->prio = tp->prio; 317 root_ht->prio = tp->prio;
318 318
319 if (tp_c == NULL) { 319 if (tp_c == NULL) {
320 tp_c = kzalloc(sizeof(*tp_c), GFP_KERNEL); 320 tp_c = kzalloc(sizeof(*tp_c), GFP_KERNEL);
321 if (tp_c == NULL) { 321 if (tp_c == NULL) {
322 kfree(root_ht); 322 kfree(root_ht);
323 return -ENOBUFS; 323 return -ENOBUFS;
324 } 324 }
325 tp_c->q = tp->q; 325 tp_c->q = tp->q;
326 tp_c->next = u32_list; 326 tp_c->next = u32_list;
327 u32_list = tp_c; 327 u32_list = tp_c;
328 } 328 }
329 329
330 tp_c->refcnt++; 330 tp_c->refcnt++;
331 root_ht->next = tp_c->hlist; 331 root_ht->next = tp_c->hlist;
332 tp_c->hlist = root_ht; 332 tp_c->hlist = root_ht;
333 root_ht->tp_c = tp_c; 333 root_ht->tp_c = tp_c;
334 334
335 tp->root = root_ht; 335 tp->root = root_ht;
336 tp->data = tp_c; 336 tp->data = tp_c;
337 return 0; 337 return 0;
338 } 338 }
339 339
340 static int u32_destroy_key(struct tcf_proto *tp, struct tc_u_knode *n) 340 static int u32_destroy_key(struct tcf_proto *tp, struct tc_u_knode *n)
341 { 341 {
342 tcf_unbind_filter(tp, &n->res); 342 tcf_unbind_filter(tp, &n->res);
343 tcf_exts_destroy(tp, &n->exts); 343 tcf_exts_destroy(tp, &n->exts);
344 if (n->ht_down) 344 if (n->ht_down)
345 n->ht_down->refcnt--; 345 n->ht_down->refcnt--;
346 #ifdef CONFIG_CLS_U32_PERF 346 #ifdef CONFIG_CLS_U32_PERF
347 kfree(n->pf); 347 kfree(n->pf);
348 #endif 348 #endif
349 kfree(n); 349 kfree(n);
350 return 0; 350 return 0;
351 } 351 }
352 352
353 static int u32_delete_key(struct tcf_proto *tp, struct tc_u_knode* key) 353 static int u32_delete_key(struct tcf_proto *tp, struct tc_u_knode* key)
354 { 354 {
355 struct tc_u_knode **kp; 355 struct tc_u_knode **kp;
356 struct tc_u_hnode *ht = key->ht_up; 356 struct tc_u_hnode *ht = key->ht_up;
357 357
358 if (ht) { 358 if (ht) {
359 for (kp = &ht->ht[TC_U32_HASH(key->handle)]; *kp; kp = &(*kp)->next) { 359 for (kp = &ht->ht[TC_U32_HASH(key->handle)]; *kp; kp = &(*kp)->next) {
360 if (*kp == key) { 360 if (*kp == key) {
361 tcf_tree_lock(tp); 361 tcf_tree_lock(tp);
362 *kp = key->next; 362 *kp = key->next;
363 tcf_tree_unlock(tp); 363 tcf_tree_unlock(tp);
364 364
365 u32_destroy_key(tp, key); 365 u32_destroy_key(tp, key);
366 return 0; 366 return 0;
367 } 367 }
368 } 368 }
369 } 369 }
370 BUG_TRAP(0); 370 BUG_TRAP(0);
371 return 0; 371 return 0;
372 } 372 }
373 373
374 static void u32_clear_hnode(struct tcf_proto *tp, struct tc_u_hnode *ht) 374 static void u32_clear_hnode(struct tcf_proto *tp, struct tc_u_hnode *ht)
375 { 375 {
376 struct tc_u_knode *n; 376 struct tc_u_knode *n;
377 unsigned h; 377 unsigned h;
378 378
379 for (h=0; h<=ht->divisor; h++) { 379 for (h=0; h<=ht->divisor; h++) {
380 while ((n = ht->ht[h]) != NULL) { 380 while ((n = ht->ht[h]) != NULL) {
381 ht->ht[h] = n->next; 381 ht->ht[h] = n->next;
382 382
383 u32_destroy_key(tp, n); 383 u32_destroy_key(tp, n);
384 } 384 }
385 } 385 }
386 } 386 }
387 387
388 static int u32_destroy_hnode(struct tcf_proto *tp, struct tc_u_hnode *ht) 388 static int u32_destroy_hnode(struct tcf_proto *tp, struct tc_u_hnode *ht)
389 { 389 {
390 struct tc_u_common *tp_c = tp->data; 390 struct tc_u_common *tp_c = tp->data;
391 struct tc_u_hnode **hn; 391 struct tc_u_hnode **hn;
392 392
393 BUG_TRAP(!ht->refcnt); 393 BUG_TRAP(!ht->refcnt);
394 394
395 u32_clear_hnode(tp, ht); 395 u32_clear_hnode(tp, ht);
396 396
397 for (hn = &tp_c->hlist; *hn; hn = &(*hn)->next) { 397 for (hn = &tp_c->hlist; *hn; hn = &(*hn)->next) {
398 if (*hn == ht) { 398 if (*hn == ht) {
399 *hn = ht->next; 399 *hn = ht->next;
400 kfree(ht); 400 kfree(ht);
401 return 0; 401 return 0;
402 } 402 }
403 } 403 }
404 404
405 BUG_TRAP(0); 405 BUG_TRAP(0);
406 return -ENOENT; 406 return -ENOENT;
407 } 407 }
408 408
409 static void u32_destroy(struct tcf_proto *tp) 409 static void u32_destroy(struct tcf_proto *tp)
410 { 410 {
411 struct tc_u_common *tp_c = tp->data; 411 struct tc_u_common *tp_c = tp->data;
412 struct tc_u_hnode *root_ht = xchg(&tp->root, NULL); 412 struct tc_u_hnode *root_ht = xchg(&tp->root, NULL);
413 413
414 BUG_TRAP(root_ht != NULL); 414 BUG_TRAP(root_ht != NULL);
415 415
416 if (root_ht && --root_ht->refcnt == 0) 416 if (root_ht && --root_ht->refcnt == 0)
417 u32_destroy_hnode(tp, root_ht); 417 u32_destroy_hnode(tp, root_ht);
418 418
419 if (--tp_c->refcnt == 0) { 419 if (--tp_c->refcnt == 0) {
420 struct tc_u_hnode *ht; 420 struct tc_u_hnode *ht;
421 struct tc_u_common **tp_cp; 421 struct tc_u_common **tp_cp;
422 422
423 for (tp_cp = &u32_list; *tp_cp; tp_cp = &(*tp_cp)->next) { 423 for (tp_cp = &u32_list; *tp_cp; tp_cp = &(*tp_cp)->next) {
424 if (*tp_cp == tp_c) { 424 if (*tp_cp == tp_c) {
425 *tp_cp = tp_c->next; 425 *tp_cp = tp_c->next;
426 break; 426 break;
427 } 427 }
428 } 428 }
429 429
430 for (ht=tp_c->hlist; ht; ht = ht->next) 430 for (ht=tp_c->hlist; ht; ht = ht->next)
431 u32_clear_hnode(tp, ht); 431 u32_clear_hnode(tp, ht);
432 432
433 while ((ht = tp_c->hlist) != NULL) { 433 while ((ht = tp_c->hlist) != NULL) {
434 tp_c->hlist = ht->next; 434 tp_c->hlist = ht->next;
435 435
436 BUG_TRAP(ht->refcnt == 0); 436 BUG_TRAP(ht->refcnt == 0);
437 437
438 kfree(ht); 438 kfree(ht);
439 }; 439 };
440 440
441 kfree(tp_c); 441 kfree(tp_c);
442 } 442 }
443 443
444 tp->data = NULL; 444 tp->data = NULL;
445 } 445 }
446 446
447 static int u32_delete(struct tcf_proto *tp, unsigned long arg) 447 static int u32_delete(struct tcf_proto *tp, unsigned long arg)
448 { 448 {
449 struct tc_u_hnode *ht = (struct tc_u_hnode*)arg; 449 struct tc_u_hnode *ht = (struct tc_u_hnode*)arg;
450 450
451 if (ht == NULL) 451 if (ht == NULL)
452 return 0; 452 return 0;
453 453
454 if (TC_U32_KEY(ht->handle)) 454 if (TC_U32_KEY(ht->handle))
455 return u32_delete_key(tp, (struct tc_u_knode*)ht); 455 return u32_delete_key(tp, (struct tc_u_knode*)ht);
456 456
457 if (tp->root == ht) 457 if (tp->root == ht)
458 return -EINVAL; 458 return -EINVAL;
459 459
460 if (--ht->refcnt == 0) 460 if (--ht->refcnt == 0)
461 u32_destroy_hnode(tp, ht); 461 u32_destroy_hnode(tp, ht);
462 462
463 return 0; 463 return 0;
464 } 464 }
465 465
466 static u32 gen_new_kid(struct tc_u_hnode *ht, u32 handle) 466 static u32 gen_new_kid(struct tc_u_hnode *ht, u32 handle)
467 { 467 {
468 struct tc_u_knode *n; 468 struct tc_u_knode *n;
469 unsigned i = 0x7FF; 469 unsigned i = 0x7FF;
470 470
471 for (n=ht->ht[TC_U32_HASH(handle)]; n; n = n->next) 471 for (n=ht->ht[TC_U32_HASH(handle)]; n; n = n->next)
472 if (i < TC_U32_NODE(n->handle)) 472 if (i < TC_U32_NODE(n->handle))
473 i = TC_U32_NODE(n->handle); 473 i = TC_U32_NODE(n->handle);
474 i++; 474 i++;
475 475
476 return handle|(i>0xFFF ? 0xFFF : i); 476 return handle|(i>0xFFF ? 0xFFF : i);
477 } 477 }
478 478
479 static int u32_set_parms(struct tcf_proto *tp, unsigned long base, 479 static int u32_set_parms(struct tcf_proto *tp, unsigned long base,
480 struct tc_u_hnode *ht, 480 struct tc_u_hnode *ht,
481 struct tc_u_knode *n, struct rtattr **tb, 481 struct tc_u_knode *n, struct rtattr **tb,
482 struct rtattr *est) 482 struct rtattr *est)
483 { 483 {
484 int err; 484 int err;
485 struct tcf_exts e; 485 struct tcf_exts e;
486 486
487 err = tcf_exts_validate(tp, tb, est, &e, &u32_ext_map); 487 err = tcf_exts_validate(tp, tb, est, &e, &u32_ext_map);
488 if (err < 0) 488 if (err < 0)
489 return err; 489 return err;
490 490
491 err = -EINVAL; 491 err = -EINVAL;
492 if (tb[TCA_U32_LINK-1]) { 492 if (tb[TCA_U32_LINK-1]) {
493 u32 handle = *(u32*)RTA_DATA(tb[TCA_U32_LINK-1]); 493 u32 handle = *(u32*)RTA_DATA(tb[TCA_U32_LINK-1]);
494 struct tc_u_hnode *ht_down = NULL; 494 struct tc_u_hnode *ht_down = NULL;
495 495
496 if (TC_U32_KEY(handle)) 496 if (TC_U32_KEY(handle))
497 goto errout; 497 goto errout;
498 498
499 if (handle) { 499 if (handle) {
500 ht_down = u32_lookup_ht(ht->tp_c, handle); 500 ht_down = u32_lookup_ht(ht->tp_c, handle);
501 501
502 if (ht_down == NULL) 502 if (ht_down == NULL)
503 goto errout; 503 goto errout;
504 ht_down->refcnt++; 504 ht_down->refcnt++;
505 } 505 }
506 506
507 tcf_tree_lock(tp); 507 tcf_tree_lock(tp);
508 ht_down = xchg(&n->ht_down, ht_down); 508 ht_down = xchg(&n->ht_down, ht_down);
509 tcf_tree_unlock(tp); 509 tcf_tree_unlock(tp);
510 510
511 if (ht_down) 511 if (ht_down)
512 ht_down->refcnt--; 512 ht_down->refcnt--;
513 } 513 }
514 if (tb[TCA_U32_CLASSID-1]) { 514 if (tb[TCA_U32_CLASSID-1]) {
515 n->res.classid = *(u32*)RTA_DATA(tb[TCA_U32_CLASSID-1]); 515 n->res.classid = *(u32*)RTA_DATA(tb[TCA_U32_CLASSID-1]);
516 tcf_bind_filter(tp, &n->res, base); 516 tcf_bind_filter(tp, &n->res, base);
517 } 517 }
518 518
519 #ifdef CONFIG_NET_CLS_IND 519 #ifdef CONFIG_NET_CLS_IND
520 if (tb[TCA_U32_INDEV-1]) { 520 if (tb[TCA_U32_INDEV-1]) {
521 int err = tcf_change_indev(tp, n->indev, tb[TCA_U32_INDEV-1]); 521 int err = tcf_change_indev(tp, n->indev, tb[TCA_U32_INDEV-1]);
522 if (err < 0) 522 if (err < 0)
523 goto errout; 523 goto errout;
524 } 524 }
525 #endif 525 #endif
526 tcf_exts_change(tp, &n->exts, &e); 526 tcf_exts_change(tp, &n->exts, &e);
527 527
528 return 0; 528 return 0;
529 errout: 529 errout:
530 tcf_exts_destroy(tp, &e); 530 tcf_exts_destroy(tp, &e);
531 return err; 531 return err;
532 } 532 }
533 533
534 static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle, 534 static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle,
535 struct rtattr **tca, 535 struct rtattr **tca,
536 unsigned long *arg) 536 unsigned long *arg)
537 { 537 {
538 struct tc_u_common *tp_c = tp->data; 538 struct tc_u_common *tp_c = tp->data;
539 struct tc_u_hnode *ht; 539 struct tc_u_hnode *ht;
540 struct tc_u_knode *n; 540 struct tc_u_knode *n;
541 struct tc_u32_sel *s; 541 struct tc_u32_sel *s;
542 struct rtattr *opt = tca[TCA_OPTIONS-1]; 542 struct rtattr *opt = tca[TCA_OPTIONS-1];
543 struct rtattr *tb[TCA_U32_MAX]; 543 struct rtattr *tb[TCA_U32_MAX];
544 u32 htid; 544 u32 htid;
545 int err; 545 int err;
546 546
547 if (opt == NULL) 547 if (opt == NULL)
548 return handle ? -EINVAL : 0; 548 return handle ? -EINVAL : 0;
549 549
550 if (rtattr_parse_nested(tb, TCA_U32_MAX, opt) < 0) 550 if (rtattr_parse_nested(tb, TCA_U32_MAX, opt) < 0)
551 return -EINVAL; 551 return -EINVAL;
552 552
553 if ((n = (struct tc_u_knode*)*arg) != NULL) { 553 if ((n = (struct tc_u_knode*)*arg) != NULL) {
554 if (TC_U32_KEY(n->handle) == 0) 554 if (TC_U32_KEY(n->handle) == 0)
555 return -EINVAL; 555 return -EINVAL;
556 556
557 return u32_set_parms(tp, base, n->ht_up, n, tb, tca[TCA_RATE-1]); 557 return u32_set_parms(tp, base, n->ht_up, n, tb, tca[TCA_RATE-1]);
558 } 558 }
559 559
560 if (tb[TCA_U32_DIVISOR-1]) { 560 if (tb[TCA_U32_DIVISOR-1]) {
561 unsigned divisor = *(unsigned*)RTA_DATA(tb[TCA_U32_DIVISOR-1]); 561 unsigned divisor = *(unsigned*)RTA_DATA(tb[TCA_U32_DIVISOR-1]);
562 562
563 if (--divisor > 0x100) 563 if (--divisor > 0x100)
564 return -EINVAL; 564 return -EINVAL;
565 if (TC_U32_KEY(handle)) 565 if (TC_U32_KEY(handle))
566 return -EINVAL; 566 return -EINVAL;
567 if (handle == 0) { 567 if (handle == 0) {
568 handle = gen_new_htid(tp->data); 568 handle = gen_new_htid(tp->data);
569 if (handle == 0) 569 if (handle == 0)
570 return -ENOMEM; 570 return -ENOMEM;
571 } 571 }
572 ht = kzalloc(sizeof(*ht) + divisor*sizeof(void*), GFP_KERNEL); 572 ht = kzalloc(sizeof(*ht) + divisor*sizeof(void*), GFP_KERNEL);
573 if (ht == NULL) 573 if (ht == NULL)
574 return -ENOBUFS; 574 return -ENOBUFS;
575 ht->tp_c = tp_c; 575 ht->tp_c = tp_c;
576 ht->refcnt = 0; 576 ht->refcnt = 0;
577 ht->divisor = divisor; 577 ht->divisor = divisor;
578 ht->handle = handle; 578 ht->handle = handle;
579 ht->prio = tp->prio; 579 ht->prio = tp->prio;
580 ht->next = tp_c->hlist; 580 ht->next = tp_c->hlist;
581 tp_c->hlist = ht; 581 tp_c->hlist = ht;
582 *arg = (unsigned long)ht; 582 *arg = (unsigned long)ht;
583 return 0; 583 return 0;
584 } 584 }
585 585
586 if (tb[TCA_U32_HASH-1]) { 586 if (tb[TCA_U32_HASH-1]) {
587 htid = *(unsigned*)RTA_DATA(tb[TCA_U32_HASH-1]); 587 htid = *(unsigned*)RTA_DATA(tb[TCA_U32_HASH-1]);
588 if (TC_U32_HTID(htid) == TC_U32_ROOT) { 588 if (TC_U32_HTID(htid) == TC_U32_ROOT) {
589 ht = tp->root; 589 ht = tp->root;
590 htid = ht->handle; 590 htid = ht->handle;
591 } else { 591 } else {
592 ht = u32_lookup_ht(tp->data, TC_U32_HTID(htid)); 592 ht = u32_lookup_ht(tp->data, TC_U32_HTID(htid));
593 if (ht == NULL) 593 if (ht == NULL)
594 return -EINVAL; 594 return -EINVAL;
595 } 595 }
596 } else { 596 } else {
597 ht = tp->root; 597 ht = tp->root;
598 htid = ht->handle; 598 htid = ht->handle;
599 } 599 }
600 600
601 if (ht->divisor < TC_U32_HASH(htid)) 601 if (ht->divisor < TC_U32_HASH(htid))
602 return -EINVAL; 602 return -EINVAL;
603 603
604 if (handle) { 604 if (handle) {
605 if (TC_U32_HTID(handle) && TC_U32_HTID(handle^htid)) 605 if (TC_U32_HTID(handle) && TC_U32_HTID(handle^htid))
606 return -EINVAL; 606 return -EINVAL;
607 handle = htid | TC_U32_NODE(handle); 607 handle = htid | TC_U32_NODE(handle);
608 } else 608 } else
609 handle = gen_new_kid(ht, htid); 609 handle = gen_new_kid(ht, htid);
610 610
611 if (tb[TCA_U32_SEL-1] == 0 || 611 if (tb[TCA_U32_SEL-1] == 0 ||
612 RTA_PAYLOAD(tb[TCA_U32_SEL-1]) < sizeof(struct tc_u32_sel)) 612 RTA_PAYLOAD(tb[TCA_U32_SEL-1]) < sizeof(struct tc_u32_sel))
613 return -EINVAL; 613 return -EINVAL;
614 614
615 s = RTA_DATA(tb[TCA_U32_SEL-1]); 615 s = RTA_DATA(tb[TCA_U32_SEL-1]);
616 616
617 n = kzalloc(sizeof(*n) + s->nkeys*sizeof(struct tc_u32_key), GFP_KERNEL); 617 n = kzalloc(sizeof(*n) + s->nkeys*sizeof(struct tc_u32_key), GFP_KERNEL);
618 if (n == NULL) 618 if (n == NULL)
619 return -ENOBUFS; 619 return -ENOBUFS;
620 620
621 #ifdef CONFIG_CLS_U32_PERF 621 #ifdef CONFIG_CLS_U32_PERF
622 n->pf = kzalloc(sizeof(struct tc_u32_pcnt) + s->nkeys*sizeof(u64), GFP_KERNEL); 622 n->pf = kzalloc(sizeof(struct tc_u32_pcnt) + s->nkeys*sizeof(u64), GFP_KERNEL);
623 if (n->pf == NULL) { 623 if (n->pf == NULL) {
624 kfree(n); 624 kfree(n);
625 return -ENOBUFS; 625 return -ENOBUFS;
626 } 626 }
627 #endif 627 #endif
628 628
629 memcpy(&n->sel, s, sizeof(*s) + s->nkeys*sizeof(struct tc_u32_key)); 629 memcpy(&n->sel, s, sizeof(*s) + s->nkeys*sizeof(struct tc_u32_key));
630 n->ht_up = ht; 630 n->ht_up = ht;
631 n->handle = handle; 631 n->handle = handle;
632 { 632 {
633 u8 i = 0; 633 u8 i = 0;
634 u32 mask = s->hmask; 634 u32 mask = s->hmask;
635 if (mask) { 635 if (mask) {
636 while (!(mask & 1)) { 636 while (!(mask & 1)) {
637 i++; 637 i++;
638 mask>>=1; 638 mask>>=1;
639 } 639 }
640 } 640 }
641 n->fshift = i; 641 n->fshift = i;
642 } 642 }
643 643
644 #ifdef CONFIG_CLS_U32_MARK 644 #ifdef CONFIG_CLS_U32_MARK
645 if (tb[TCA_U32_MARK-1]) { 645 if (tb[TCA_U32_MARK-1]) {
646 struct tc_u32_mark *mark; 646 struct tc_u32_mark *mark;
647 647
648 if (RTA_PAYLOAD(tb[TCA_U32_MARK-1]) < sizeof(struct tc_u32_mark)) { 648 if (RTA_PAYLOAD(tb[TCA_U32_MARK-1]) < sizeof(struct tc_u32_mark)) {
649 #ifdef CONFIG_CLS_U32_PERF 649 #ifdef CONFIG_CLS_U32_PERF
650 kfree(n->pf); 650 kfree(n->pf);
651 #endif 651 #endif
652 kfree(n); 652 kfree(n);
653 return -EINVAL; 653 return -EINVAL;
654 } 654 }
655 mark = RTA_DATA(tb[TCA_U32_MARK-1]); 655 mark = RTA_DATA(tb[TCA_U32_MARK-1]);
656 memcpy(&n->mark, mark, sizeof(struct tc_u32_mark)); 656 memcpy(&n->mark, mark, sizeof(struct tc_u32_mark));
657 n->mark.success = 0; 657 n->mark.success = 0;
658 } 658 }
659 #endif 659 #endif
660 660
661 err = u32_set_parms(tp, base, ht, n, tb, tca[TCA_RATE-1]); 661 err = u32_set_parms(tp, base, ht, n, tb, tca[TCA_RATE-1]);
662 if (err == 0) { 662 if (err == 0) {
663 struct tc_u_knode **ins; 663 struct tc_u_knode **ins;
664 for (ins = &ht->ht[TC_U32_HASH(handle)]; *ins; ins = &(*ins)->next) 664 for (ins = &ht->ht[TC_U32_HASH(handle)]; *ins; ins = &(*ins)->next)
665 if (TC_U32_NODE(handle) < TC_U32_NODE((*ins)->handle)) 665 if (TC_U32_NODE(handle) < TC_U32_NODE((*ins)->handle))
666 break; 666 break;
667 667
668 n->next = *ins; 668 n->next = *ins;
669 wmb(); 669 wmb();
670 *ins = n; 670 *ins = n;
671 671
672 *arg = (unsigned long)n; 672 *arg = (unsigned long)n;
673 return 0; 673 return 0;
674 } 674 }
675 #ifdef CONFIG_CLS_U32_PERF 675 #ifdef CONFIG_CLS_U32_PERF
676 kfree(n->pf); 676 kfree(n->pf);
677 #endif 677 #endif
678 kfree(n); 678 kfree(n);
679 return err; 679 return err;
680 } 680 }
681 681
682 static void u32_walk(struct tcf_proto *tp, struct tcf_walker *arg) 682 static void u32_walk(struct tcf_proto *tp, struct tcf_walker *arg)
683 { 683 {
684 struct tc_u_common *tp_c = tp->data; 684 struct tc_u_common *tp_c = tp->data;
685 struct tc_u_hnode *ht; 685 struct tc_u_hnode *ht;
686 struct tc_u_knode *n; 686 struct tc_u_knode *n;
687 unsigned h; 687 unsigned h;
688 688
689 if (arg->stop) 689 if (arg->stop)
690 return; 690 return;
691 691
692 for (ht = tp_c->hlist; ht; ht = ht->next) { 692 for (ht = tp_c->hlist; ht; ht = ht->next) {
693 if (ht->prio != tp->prio) 693 if (ht->prio != tp->prio)
694 continue; 694 continue;
695 if (arg->count >= arg->skip) { 695 if (arg->count >= arg->skip) {
696 if (arg->fn(tp, (unsigned long)ht, arg) < 0) { 696 if (arg->fn(tp, (unsigned long)ht, arg) < 0) {
697 arg->stop = 1; 697 arg->stop = 1;
698 return; 698 return;
699 } 699 }
700 } 700 }
701 arg->count++; 701 arg->count++;
702 for (h = 0; h <= ht->divisor; h++) { 702 for (h = 0; h <= ht->divisor; h++) {
703 for (n = ht->ht[h]; n; n = n->next) { 703 for (n = ht->ht[h]; n; n = n->next) {
704 if (arg->count < arg->skip) { 704 if (arg->count < arg->skip) {
705 arg->count++; 705 arg->count++;
706 continue; 706 continue;
707 } 707 }
708 if (arg->fn(tp, (unsigned long)n, arg) < 0) { 708 if (arg->fn(tp, (unsigned long)n, arg) < 0) {
709 arg->stop = 1; 709 arg->stop = 1;
710 return; 710 return;
711 } 711 }
712 arg->count++; 712 arg->count++;
713 } 713 }
714 } 714 }
715 } 715 }
716 } 716 }
717 717
718 static int u32_dump(struct tcf_proto *tp, unsigned long fh, 718 static int u32_dump(struct tcf_proto *tp, unsigned long fh,
719 struct sk_buff *skb, struct tcmsg *t) 719 struct sk_buff *skb, struct tcmsg *t)
720 { 720 {
721 struct tc_u_knode *n = (struct tc_u_knode*)fh; 721 struct tc_u_knode *n = (struct tc_u_knode*)fh;
722 unsigned char *b = skb->tail; 722 unsigned char *b = skb->tail;
723 struct rtattr *rta; 723 struct rtattr *rta;
724 724
725 if (n == NULL) 725 if (n == NULL)
726 return skb->len; 726 return skb->len;
727 727
728 t->tcm_handle = n->handle; 728 t->tcm_handle = n->handle;
729 729
730 rta = (struct rtattr*)b; 730 rta = (struct rtattr*)b;
731 RTA_PUT(skb, TCA_OPTIONS, 0, NULL); 731 RTA_PUT(skb, TCA_OPTIONS, 0, NULL);
732 732
733 if (TC_U32_KEY(n->handle) == 0) { 733 if (TC_U32_KEY(n->handle) == 0) {
734 struct tc_u_hnode *ht = (struct tc_u_hnode*)fh; 734 struct tc_u_hnode *ht = (struct tc_u_hnode*)fh;
735 u32 divisor = ht->divisor+1; 735 u32 divisor = ht->divisor+1;
736 RTA_PUT(skb, TCA_U32_DIVISOR, 4, &divisor); 736 RTA_PUT(skb, TCA_U32_DIVISOR, 4, &divisor);
737 } else { 737 } else {
738 RTA_PUT(skb, TCA_U32_SEL, 738 RTA_PUT(skb, TCA_U32_SEL,
739 sizeof(n->sel) + n->sel.nkeys*sizeof(struct tc_u32_key), 739 sizeof(n->sel) + n->sel.nkeys*sizeof(struct tc_u32_key),
740 &n->sel); 740 &n->sel);
741 if (n->ht_up) { 741 if (n->ht_up) {
742 u32 htid = n->handle & 0xFFFFF000; 742 u32 htid = n->handle & 0xFFFFF000;
743 RTA_PUT(skb, TCA_U32_HASH, 4, &htid); 743 RTA_PUT(skb, TCA_U32_HASH, 4, &htid);
744 } 744 }
745 if (n->res.classid) 745 if (n->res.classid)
746 RTA_PUT(skb, TCA_U32_CLASSID, 4, &n->res.classid); 746 RTA_PUT(skb, TCA_U32_CLASSID, 4, &n->res.classid);
747 if (n->ht_down) 747 if (n->ht_down)
748 RTA_PUT(skb, TCA_U32_LINK, 4, &n->ht_down->handle); 748 RTA_PUT(skb, TCA_U32_LINK, 4, &n->ht_down->handle);
749 749
750 #ifdef CONFIG_CLS_U32_MARK 750 #ifdef CONFIG_CLS_U32_MARK
751 if (n->mark.val || n->mark.mask) 751 if (n->mark.val || n->mark.mask)
752 RTA_PUT(skb, TCA_U32_MARK, sizeof(n->mark), &n->mark); 752 RTA_PUT(skb, TCA_U32_MARK, sizeof(n->mark), &n->mark);
753 #endif 753 #endif
754 754
755 if (tcf_exts_dump(skb, &n->exts, &u32_ext_map) < 0) 755 if (tcf_exts_dump(skb, &n->exts, &u32_ext_map) < 0)
756 goto rtattr_failure; 756 goto rtattr_failure;
757 757
758 #ifdef CONFIG_NET_CLS_IND 758 #ifdef CONFIG_NET_CLS_IND
759 if(strlen(n->indev)) 759 if(strlen(n->indev))
760 RTA_PUT(skb, TCA_U32_INDEV, IFNAMSIZ, n->indev); 760 RTA_PUT(skb, TCA_U32_INDEV, IFNAMSIZ, n->indev);
761 #endif 761 #endif
762 #ifdef CONFIG_CLS_U32_PERF 762 #ifdef CONFIG_CLS_U32_PERF
763 RTA_PUT(skb, TCA_U32_PCNT, 763 RTA_PUT(skb, TCA_U32_PCNT,
764 sizeof(struct tc_u32_pcnt) + n->sel.nkeys*sizeof(u64), 764 sizeof(struct tc_u32_pcnt) + n->sel.nkeys*sizeof(u64),
765 n->pf); 765 n->pf);
766 #endif 766 #endif
767 } 767 }
768 768
769 rta->rta_len = skb->tail - b; 769 rta->rta_len = skb->tail - b;
770 if (TC_U32_KEY(n->handle)) 770 if (TC_U32_KEY(n->handle))
771 if (tcf_exts_dump_stats(skb, &n->exts, &u32_ext_map) < 0) 771 if (tcf_exts_dump_stats(skb, &n->exts, &u32_ext_map) < 0)
772 goto rtattr_failure; 772 goto rtattr_failure;
773 return skb->len; 773 return skb->len;
774 774
775 rtattr_failure: 775 rtattr_failure:
776 skb_trim(skb, b - skb->data); 776 skb_trim(skb, b - skb->data);
777 return -1; 777 return -1;
778 } 778 }
779 779
780 static struct tcf_proto_ops cls_u32_ops = { 780 static struct tcf_proto_ops cls_u32_ops = {
781 .next = NULL, 781 .next = NULL,
782 .kind = "u32", 782 .kind = "u32",
783 .classify = u32_classify, 783 .classify = u32_classify,
784 .init = u32_init, 784 .init = u32_init,
785 .destroy = u32_destroy, 785 .destroy = u32_destroy,
786 .get = u32_get, 786 .get = u32_get,
787 .put = u32_put, 787 .put = u32_put,
788 .change = u32_change, 788 .change = u32_change,
789 .delete = u32_delete, 789 .delete = u32_delete,
790 .walk = u32_walk, 790 .walk = u32_walk,
791 .dump = u32_dump, 791 .dump = u32_dump,
792 .owner = THIS_MODULE, 792 .owner = THIS_MODULE,
793 }; 793 };
794 794
795 static int __init init_u32(void) 795 static int __init init_u32(void)
796 { 796 {
797 printk("u32 classifier\n"); 797 printk("u32 classifier\n");
798 #ifdef CONFIG_CLS_U32_PERF 798 #ifdef CONFIG_CLS_U32_PERF
799 printk(" Perfomance counters on\n"); 799 printk(" Performance counters on\n");
800 #endif 800 #endif
801 #ifdef CONFIG_NET_CLS_POLICE 801 #ifdef CONFIG_NET_CLS_POLICE
802 printk(" OLD policer on \n"); 802 printk(" OLD policer on \n");
803 #endif 803 #endif
804 #ifdef CONFIG_NET_CLS_IND 804 #ifdef CONFIG_NET_CLS_IND
805 printk(" input device check on \n"); 805 printk(" input device check on \n");
806 #endif 806 #endif
807 #ifdef CONFIG_NET_CLS_ACT 807 #ifdef CONFIG_NET_CLS_ACT
808 printk(" Actions configured \n"); 808 printk(" Actions configured \n");
809 #endif 809 #endif
810 return register_tcf_proto_ops(&cls_u32_ops); 810 return register_tcf_proto_ops(&cls_u32_ops);
811 } 811 }
812 812
813 static void __exit exit_u32(void) 813 static void __exit exit_u32(void)
814 { 814 {
815 unregister_tcf_proto_ops(&cls_u32_ops); 815 unregister_tcf_proto_ops(&cls_u32_ops);
816 } 816 }
817 817
818 module_init(init_u32) 818 module_init(init_u32)
819 module_exit(exit_u32) 819 module_exit(exit_u32)
820 MODULE_LICENSE("GPL"); 820 MODULE_LICENSE("GPL");
821 821