]> Git Repo - J-linux.git/blob - net/sched/cls_tcindex.c
scsi: zfcp: Trace when request remove fails after qdio send fails
[J-linux.git] / net / sched / cls_tcindex.c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * net/sched/cls_tcindex.c      Packet classifier for skb->tc_index
4  *
5  * Written 1998,1999 by Werner Almesberger, EPFL ICA
6  */
7
8 #include <linux/module.h>
9 #include <linux/types.h>
10 #include <linux/kernel.h>
11 #include <linux/skbuff.h>
12 #include <linux/errno.h>
13 #include <linux/slab.h>
14 #include <linux/refcount.h>
15 #include <net/act_api.h>
16 #include <net/netlink.h>
17 #include <net/pkt_cls.h>
18 #include <net/sch_generic.h>
19 #include <net/tc_wrapper.h>
20
21 /*
22  * Passing parameters to the root seems to be done more awkwardly than really
23  * necessary. At least, u32 doesn't seem to use such dirty hacks. To be
24  * verified. FIXME.
25  */
26
27 #define PERFECT_HASH_THRESHOLD  64      /* use perfect hash if not bigger */
28 #define DEFAULT_HASH_SIZE       64      /* optimized for diffserv */
29
30
31 struct tcindex_data;
32
33 struct tcindex_filter_result {
34         struct tcf_exts         exts;
35         struct tcf_result       res;
36         struct tcindex_data     *p;
37         struct rcu_work         rwork;
38 };
39
40 struct tcindex_filter {
41         u16 key;
42         struct tcindex_filter_result result;
43         struct tcindex_filter __rcu *next;
44         struct rcu_work rwork;
45 };
46
47
48 struct tcindex_data {
49         struct tcindex_filter_result *perfect; /* perfect hash; NULL if none */
50         struct tcindex_filter __rcu **h; /* imperfect hash; */
51         struct tcf_proto *tp;
52         u16 mask;               /* AND key with mask */
53         u32 shift;              /* shift ANDed key to the right */
54         u32 hash;               /* hash table size; 0 if undefined */
55         u32 alloc_hash;         /* allocated size */
56         u32 fall_through;       /* 0: only classify if explicit match */
57         refcount_t refcnt;      /* a temporary refcnt for perfect hash */
58         struct rcu_work rwork;
59 };
60
61 static inline int tcindex_filter_is_set(struct tcindex_filter_result *r)
62 {
63         return tcf_exts_has_actions(&r->exts) || r->res.classid;
64 }
65
66 static void tcindex_data_get(struct tcindex_data *p)
67 {
68         refcount_inc(&p->refcnt);
69 }
70
71 static void tcindex_data_put(struct tcindex_data *p)
72 {
73         if (refcount_dec_and_test(&p->refcnt)) {
74                 kfree(p->perfect);
75                 kfree(p->h);
76                 kfree(p);
77         }
78 }
79
80 static struct tcindex_filter_result *tcindex_lookup(struct tcindex_data *p,
81                                                     u16 key)
82 {
83         if (p->perfect) {
84                 struct tcindex_filter_result *f = p->perfect + key;
85
86                 return tcindex_filter_is_set(f) ? f : NULL;
87         } else if (p->h) {
88                 struct tcindex_filter __rcu **fp;
89                 struct tcindex_filter *f;
90
91                 fp = &p->h[key % p->hash];
92                 for (f = rcu_dereference_bh_rtnl(*fp);
93                      f;
94                      fp = &f->next, f = rcu_dereference_bh_rtnl(*fp))
95                         if (f->key == key)
96                                 return &f->result;
97         }
98
99         return NULL;
100 }
101
102 TC_INDIRECT_SCOPE int tcindex_classify(struct sk_buff *skb,
103                                        const struct tcf_proto *tp,
104                                        struct tcf_result *res)
105 {
106         struct tcindex_data *p = rcu_dereference_bh(tp->root);
107         struct tcindex_filter_result *f;
108         int key = (skb->tc_index & p->mask) >> p->shift;
109
110         pr_debug("tcindex_classify(skb %p,tp %p,res %p),p %p\n",
111                  skb, tp, res, p);
112
113         f = tcindex_lookup(p, key);
114         if (!f) {
115                 struct Qdisc *q = tcf_block_q(tp->chain->block);
116
117                 if (!p->fall_through)
118                         return -1;
119                 res->classid = TC_H_MAKE(TC_H_MAJ(q->handle), key);
120                 res->class = 0;
121                 pr_debug("alg 0x%x\n", res->classid);
122                 return 0;
123         }
124         *res = f->res;
125         pr_debug("map 0x%x\n", res->classid);
126
127         return tcf_exts_exec(skb, &f->exts, res);
128 }
129
130
131 static void *tcindex_get(struct tcf_proto *tp, u32 handle)
132 {
133         struct tcindex_data *p = rtnl_dereference(tp->root);
134         struct tcindex_filter_result *r;
135
136         pr_debug("tcindex_get(tp %p,handle 0x%08x)\n", tp, handle);
137         if (p->perfect && handle >= p->alloc_hash)
138                 return NULL;
139         r = tcindex_lookup(p, handle);
140         return r && tcindex_filter_is_set(r) ? r : NULL;
141 }
142
143 static int tcindex_init(struct tcf_proto *tp)
144 {
145         struct tcindex_data *p;
146
147         pr_debug("tcindex_init(tp %p)\n", tp);
148         p = kzalloc(sizeof(struct tcindex_data), GFP_KERNEL);
149         if (!p)
150                 return -ENOMEM;
151
152         p->mask = 0xffff;
153         p->hash = DEFAULT_HASH_SIZE;
154         p->fall_through = 1;
155         refcount_set(&p->refcnt, 1); /* Paired with tcindex_destroy_work() */
156
157         rcu_assign_pointer(tp->root, p);
158         return 0;
159 }
160
161 static void __tcindex_destroy_rexts(struct tcindex_filter_result *r)
162 {
163         tcf_exts_destroy(&r->exts);
164         tcf_exts_put_net(&r->exts);
165         tcindex_data_put(r->p);
166 }
167
168 static void tcindex_destroy_rexts_work(struct work_struct *work)
169 {
170         struct tcindex_filter_result *r;
171
172         r = container_of(to_rcu_work(work),
173                          struct tcindex_filter_result,
174                          rwork);
175         rtnl_lock();
176         __tcindex_destroy_rexts(r);
177         rtnl_unlock();
178 }
179
180 static void __tcindex_destroy_fexts(struct tcindex_filter *f)
181 {
182         tcf_exts_destroy(&f->result.exts);
183         tcf_exts_put_net(&f->result.exts);
184         kfree(f);
185 }
186
187 static void tcindex_destroy_fexts_work(struct work_struct *work)
188 {
189         struct tcindex_filter *f = container_of(to_rcu_work(work),
190                                                 struct tcindex_filter,
191                                                 rwork);
192
193         rtnl_lock();
194         __tcindex_destroy_fexts(f);
195         rtnl_unlock();
196 }
197
198 static int tcindex_delete(struct tcf_proto *tp, void *arg, bool *last,
199                           bool rtnl_held, struct netlink_ext_ack *extack)
200 {
201         struct tcindex_data *p = rtnl_dereference(tp->root);
202         struct tcindex_filter_result *r = arg;
203         struct tcindex_filter __rcu **walk;
204         struct tcindex_filter *f = NULL;
205
206         pr_debug("tcindex_delete(tp %p,arg %p),p %p\n", tp, arg, p);
207         if (p->perfect) {
208                 if (!r->res.class)
209                         return -ENOENT;
210         } else {
211                 int i;
212
213                 for (i = 0; i < p->hash; i++) {
214                         walk = p->h + i;
215                         for (f = rtnl_dereference(*walk); f;
216                              walk = &f->next, f = rtnl_dereference(*walk)) {
217                                 if (&f->result == r)
218                                         goto found;
219                         }
220                 }
221                 return -ENOENT;
222
223 found:
224                 rcu_assign_pointer(*walk, rtnl_dereference(f->next));
225         }
226         tcf_unbind_filter(tp, &r->res);
227         /* all classifiers are required to call tcf_exts_destroy() after rcu
228          * grace period, since converted-to-rcu actions are relying on that
229          * in cleanup() callback
230          */
231         if (f) {
232                 if (tcf_exts_get_net(&f->result.exts))
233                         tcf_queue_work(&f->rwork, tcindex_destroy_fexts_work);
234                 else
235                         __tcindex_destroy_fexts(f);
236         } else {
237                 tcindex_data_get(p);
238
239                 if (tcf_exts_get_net(&r->exts))
240                         tcf_queue_work(&r->rwork, tcindex_destroy_rexts_work);
241                 else
242                         __tcindex_destroy_rexts(r);
243         }
244
245         *last = false;
246         return 0;
247 }
248
249 static void tcindex_destroy_work(struct work_struct *work)
250 {
251         struct tcindex_data *p = container_of(to_rcu_work(work),
252                                               struct tcindex_data,
253                                               rwork);
254
255         tcindex_data_put(p);
256 }
257
258 static inline int
259 valid_perfect_hash(struct tcindex_data *p)
260 {
261         return  p->hash > (p->mask >> p->shift);
262 }
263
264 static const struct nla_policy tcindex_policy[TCA_TCINDEX_MAX + 1] = {
265         [TCA_TCINDEX_HASH]              = { .type = NLA_U32 },
266         [TCA_TCINDEX_MASK]              = { .type = NLA_U16 },
267         [TCA_TCINDEX_SHIFT]             = { .type = NLA_U32 },
268         [TCA_TCINDEX_FALL_THROUGH]      = { .type = NLA_U32 },
269         [TCA_TCINDEX_CLASSID]           = { .type = NLA_U32 },
270 };
271
272 static int tcindex_filter_result_init(struct tcindex_filter_result *r,
273                                       struct tcindex_data *p,
274                                       struct net *net)
275 {
276         memset(r, 0, sizeof(*r));
277         r->p = p;
278         return tcf_exts_init(&r->exts, net, TCA_TCINDEX_ACT,
279                              TCA_TCINDEX_POLICE);
280 }
281
282 static void tcindex_free_perfect_hash(struct tcindex_data *cp);
283
284 static void tcindex_partial_destroy_work(struct work_struct *work)
285 {
286         struct tcindex_data *p = container_of(to_rcu_work(work),
287                                               struct tcindex_data,
288                                               rwork);
289
290         rtnl_lock();
291         if (p->perfect)
292                 tcindex_free_perfect_hash(p);
293         kfree(p);
294         rtnl_unlock();
295 }
296
297 static void tcindex_free_perfect_hash(struct tcindex_data *cp)
298 {
299         int i;
300
301         for (i = 0; i < cp->hash; i++)
302                 tcf_exts_destroy(&cp->perfect[i].exts);
303         kfree(cp->perfect);
304 }
305
306 static int tcindex_alloc_perfect_hash(struct net *net, struct tcindex_data *cp)
307 {
308         int i, err = 0;
309
310         cp->perfect = kcalloc(cp->hash, sizeof(struct tcindex_filter_result),
311                               GFP_KERNEL | __GFP_NOWARN);
312         if (!cp->perfect)
313                 return -ENOMEM;
314
315         for (i = 0; i < cp->hash; i++) {
316                 err = tcf_exts_init(&cp->perfect[i].exts, net,
317                                     TCA_TCINDEX_ACT, TCA_TCINDEX_POLICE);
318                 if (err < 0)
319                         goto errout;
320                 cp->perfect[i].p = cp;
321         }
322
323         return 0;
324
325 errout:
326         tcindex_free_perfect_hash(cp);
327         return err;
328 }
329
330 static int
331 tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
332                   u32 handle, struct tcindex_data *p,
333                   struct tcindex_filter_result *r, struct nlattr **tb,
334                   struct nlattr *est, u32 flags, struct netlink_ext_ack *extack)
335 {
336         struct tcindex_filter_result new_filter_result, *old_r = r;
337         struct tcindex_data *cp = NULL, *oldp;
338         struct tcindex_filter *f = NULL; /* make gcc behave */
339         struct tcf_result cr = {};
340         int err, balloc = 0;
341         struct tcf_exts e;
342
343         err = tcf_exts_init(&e, net, TCA_TCINDEX_ACT, TCA_TCINDEX_POLICE);
344         if (err < 0)
345                 return err;
346         err = tcf_exts_validate(net, tp, tb, est, &e, flags, extack);
347         if (err < 0)
348                 goto errout;
349
350         err = -ENOMEM;
351         /* tcindex_data attributes must look atomic to classifier/lookup so
352          * allocate new tcindex data and RCU assign it onto root. Keeping
353          * perfect hash and hash pointers from old data.
354          */
355         cp = kzalloc(sizeof(*cp), GFP_KERNEL);
356         if (!cp)
357                 goto errout;
358
359         cp->mask = p->mask;
360         cp->shift = p->shift;
361         cp->hash = p->hash;
362         cp->alloc_hash = p->alloc_hash;
363         cp->fall_through = p->fall_through;
364         cp->tp = tp;
365         refcount_set(&cp->refcnt, 1); /* Paired with tcindex_destroy_work() */
366
367         if (tb[TCA_TCINDEX_HASH])
368                 cp->hash = nla_get_u32(tb[TCA_TCINDEX_HASH]);
369
370         if (tb[TCA_TCINDEX_MASK])
371                 cp->mask = nla_get_u16(tb[TCA_TCINDEX_MASK]);
372
373         if (tb[TCA_TCINDEX_SHIFT]) {
374                 cp->shift = nla_get_u32(tb[TCA_TCINDEX_SHIFT]);
375                 if (cp->shift > 16) {
376                         err = -EINVAL;
377                         goto errout;
378                 }
379         }
380         if (!cp->hash) {
381                 /* Hash not specified, use perfect hash if the upper limit
382                  * of the hashing index is below the threshold.
383                  */
384                 if ((cp->mask >> cp->shift) < PERFECT_HASH_THRESHOLD)
385                         cp->hash = (cp->mask >> cp->shift) + 1;
386                 else
387                         cp->hash = DEFAULT_HASH_SIZE;
388         }
389
390         if (p->perfect) {
391                 int i;
392
393                 if (tcindex_alloc_perfect_hash(net, cp) < 0)
394                         goto errout;
395                 cp->alloc_hash = cp->hash;
396                 for (i = 0; i < min(cp->hash, p->hash); i++)
397                         cp->perfect[i].res = p->perfect[i].res;
398                 balloc = 1;
399         }
400         cp->h = p->h;
401
402         err = tcindex_filter_result_init(&new_filter_result, cp, net);
403         if (err < 0)
404                 goto errout_alloc;
405         if (old_r)
406                 cr = r->res;
407
408         err = -EBUSY;
409
410         /* Hash already allocated, make sure that we still meet the
411          * requirements for the allocated hash.
412          */
413         if (cp->perfect) {
414                 if (!valid_perfect_hash(cp) ||
415                     cp->hash > cp->alloc_hash)
416                         goto errout_alloc;
417         } else if (cp->h && cp->hash != cp->alloc_hash) {
418                 goto errout_alloc;
419         }
420
421         err = -EINVAL;
422         if (tb[TCA_TCINDEX_FALL_THROUGH])
423                 cp->fall_through = nla_get_u32(tb[TCA_TCINDEX_FALL_THROUGH]);
424
425         if (!cp->perfect && !cp->h)
426                 cp->alloc_hash = cp->hash;
427
428         /* Note: this could be as restrictive as if (handle & ~(mask >> shift))
429          * but then, we'd fail handles that may become valid after some future
430          * mask change. While this is extremely unlikely to ever matter,
431          * the check below is safer (and also more backwards-compatible).
432          */
433         if (cp->perfect || valid_perfect_hash(cp))
434                 if (handle >= cp->alloc_hash)
435                         goto errout_alloc;
436
437
438         err = -ENOMEM;
439         if (!cp->perfect && !cp->h) {
440                 if (valid_perfect_hash(cp)) {
441                         if (tcindex_alloc_perfect_hash(net, cp) < 0)
442                                 goto errout_alloc;
443                         balloc = 1;
444                 } else {
445                         struct tcindex_filter __rcu **hash;
446
447                         hash = kcalloc(cp->hash,
448                                        sizeof(struct tcindex_filter *),
449                                        GFP_KERNEL);
450
451                         if (!hash)
452                                 goto errout_alloc;
453
454                         cp->h = hash;
455                         balloc = 2;
456                 }
457         }
458
459         if (cp->perfect)
460                 r = cp->perfect + handle;
461         else
462                 r = tcindex_lookup(cp, handle) ? : &new_filter_result;
463
464         if (r == &new_filter_result) {
465                 f = kzalloc(sizeof(*f), GFP_KERNEL);
466                 if (!f)
467                         goto errout_alloc;
468                 f->key = handle;
469                 f->next = NULL;
470                 err = tcindex_filter_result_init(&f->result, cp, net);
471                 if (err < 0) {
472                         kfree(f);
473                         goto errout_alloc;
474                 }
475         }
476
477         if (tb[TCA_TCINDEX_CLASSID]) {
478                 cr.classid = nla_get_u32(tb[TCA_TCINDEX_CLASSID]);
479                 tcf_bind_filter(tp, &cr, base);
480         }
481
482         if (old_r && old_r != r) {
483                 err = tcindex_filter_result_init(old_r, cp, net);
484                 if (err < 0) {
485                         kfree(f);
486                         goto errout_alloc;
487                 }
488         }
489
490         oldp = p;
491         r->res = cr;
492         tcf_exts_change(&r->exts, &e);
493
494         rcu_assign_pointer(tp->root, cp);
495
496         if (r == &new_filter_result) {
497                 struct tcindex_filter *nfp;
498                 struct tcindex_filter __rcu **fp;
499
500                 f->result.res = r->res;
501                 tcf_exts_change(&f->result.exts, &r->exts);
502
503                 fp = cp->h + (handle % cp->hash);
504                 for (nfp = rtnl_dereference(*fp);
505                      nfp;
506                      fp = &nfp->next, nfp = rtnl_dereference(*fp))
507                                 ; /* nothing */
508
509                 rcu_assign_pointer(*fp, f);
510         } else {
511                 tcf_exts_destroy(&new_filter_result.exts);
512         }
513
514         if (oldp)
515                 tcf_queue_work(&oldp->rwork, tcindex_partial_destroy_work);
516         return 0;
517
518 errout_alloc:
519         if (balloc == 1)
520                 tcindex_free_perfect_hash(cp);
521         else if (balloc == 2)
522                 kfree(cp->h);
523         tcf_exts_destroy(&new_filter_result.exts);
524 errout:
525         kfree(cp);
526         tcf_exts_destroy(&e);
527         return err;
528 }
529
530 static int
531 tcindex_change(struct net *net, struct sk_buff *in_skb,
532                struct tcf_proto *tp, unsigned long base, u32 handle,
533                struct nlattr **tca, void **arg, u32 flags,
534                struct netlink_ext_ack *extack)
535 {
536         struct nlattr *opt = tca[TCA_OPTIONS];
537         struct nlattr *tb[TCA_TCINDEX_MAX + 1];
538         struct tcindex_data *p = rtnl_dereference(tp->root);
539         struct tcindex_filter_result *r = *arg;
540         int err;
541
542         pr_debug("tcindex_change(tp %p,handle 0x%08x,tca %p,arg %p),opt %p,"
543             "p %p,r %p,*arg %p\n",
544             tp, handle, tca, arg, opt, p, r, *arg);
545
546         if (!opt)
547                 return 0;
548
549         err = nla_parse_nested_deprecated(tb, TCA_TCINDEX_MAX, opt,
550                                           tcindex_policy, NULL);
551         if (err < 0)
552                 return err;
553
554         return tcindex_set_parms(net, tp, base, handle, p, r, tb,
555                                  tca[TCA_RATE], flags, extack);
556 }
557
558 static void tcindex_walk(struct tcf_proto *tp, struct tcf_walker *walker,
559                          bool rtnl_held)
560 {
561         struct tcindex_data *p = rtnl_dereference(tp->root);
562         struct tcindex_filter *f, *next;
563         int i;
564
565         pr_debug("tcindex_walk(tp %p,walker %p),p %p\n", tp, walker, p);
566         if (p->perfect) {
567                 for (i = 0; i < p->hash; i++) {
568                         if (!p->perfect[i].res.class)
569                                 continue;
570                         if (!tc_cls_stats_dump(tp, walker, p->perfect + i))
571                                 return;
572                 }
573         }
574         if (!p->h)
575                 return;
576         for (i = 0; i < p->hash; i++) {
577                 for (f = rtnl_dereference(p->h[i]); f; f = next) {
578                         next = rtnl_dereference(f->next);
579                         if (!tc_cls_stats_dump(tp, walker, &f->result))
580                                 return;
581                 }
582         }
583 }
584
585 static void tcindex_destroy(struct tcf_proto *tp, bool rtnl_held,
586                             struct netlink_ext_ack *extack)
587 {
588         struct tcindex_data *p = rtnl_dereference(tp->root);
589         int i;
590
591         pr_debug("tcindex_destroy(tp %p),p %p\n", tp, p);
592
593         if (p->perfect) {
594                 for (i = 0; i < p->hash; i++) {
595                         struct tcindex_filter_result *r = p->perfect + i;
596
597                         /* tcf_queue_work() does not guarantee the ordering we
598                          * want, so we have to take this refcnt temporarily to
599                          * ensure 'p' is freed after all tcindex_filter_result
600                          * here. Imperfect hash does not need this, because it
601                          * uses linked lists rather than an array.
602                          */
603                         tcindex_data_get(p);
604
605                         tcf_unbind_filter(tp, &r->res);
606                         if (tcf_exts_get_net(&r->exts))
607                                 tcf_queue_work(&r->rwork,
608                                                tcindex_destroy_rexts_work);
609                         else
610                                 __tcindex_destroy_rexts(r);
611                 }
612         }
613
614         for (i = 0; p->h && i < p->hash; i++) {
615                 struct tcindex_filter *f, *next;
616                 bool last;
617
618                 for (f = rtnl_dereference(p->h[i]); f; f = next) {
619                         next = rtnl_dereference(f->next);
620                         tcindex_delete(tp, &f->result, &last, rtnl_held, NULL);
621                 }
622         }
623
624         tcf_queue_work(&p->rwork, tcindex_destroy_work);
625 }
626
627
628 static int tcindex_dump(struct net *net, struct tcf_proto *tp, void *fh,
629                         struct sk_buff *skb, struct tcmsg *t, bool rtnl_held)
630 {
631         struct tcindex_data *p = rtnl_dereference(tp->root);
632         struct tcindex_filter_result *r = fh;
633         struct nlattr *nest;
634
635         pr_debug("tcindex_dump(tp %p,fh %p,skb %p,t %p),p %p,r %p\n",
636                  tp, fh, skb, t, p, r);
637         pr_debug("p->perfect %p p->h %p\n", p->perfect, p->h);
638
639         nest = nla_nest_start_noflag(skb, TCA_OPTIONS);
640         if (nest == NULL)
641                 goto nla_put_failure;
642
643         if (!fh) {
644                 t->tcm_handle = ~0; /* whatever ... */
645                 if (nla_put_u32(skb, TCA_TCINDEX_HASH, p->hash) ||
646                     nla_put_u16(skb, TCA_TCINDEX_MASK, p->mask) ||
647                     nla_put_u32(skb, TCA_TCINDEX_SHIFT, p->shift) ||
648                     nla_put_u32(skb, TCA_TCINDEX_FALL_THROUGH, p->fall_through))
649                         goto nla_put_failure;
650                 nla_nest_end(skb, nest);
651         } else {
652                 if (p->perfect) {
653                         t->tcm_handle = r - p->perfect;
654                 } else {
655                         struct tcindex_filter *f;
656                         struct tcindex_filter __rcu **fp;
657                         int i;
658
659                         t->tcm_handle = 0;
660                         for (i = 0; !t->tcm_handle && i < p->hash; i++) {
661                                 fp = &p->h[i];
662                                 for (f = rtnl_dereference(*fp);
663                                      !t->tcm_handle && f;
664                                      fp = &f->next, f = rtnl_dereference(*fp)) {
665                                         if (&f->result == r)
666                                                 t->tcm_handle = f->key;
667                                 }
668                         }
669                 }
670                 pr_debug("handle = %d\n", t->tcm_handle);
671                 if (r->res.class &&
672                     nla_put_u32(skb, TCA_TCINDEX_CLASSID, r->res.classid))
673                         goto nla_put_failure;
674
675                 if (tcf_exts_dump(skb, &r->exts) < 0)
676                         goto nla_put_failure;
677                 nla_nest_end(skb, nest);
678
679                 if (tcf_exts_dump_stats(skb, &r->exts) < 0)
680                         goto nla_put_failure;
681         }
682
683         return skb->len;
684
685 nla_put_failure:
686         nla_nest_cancel(skb, nest);
687         return -1;
688 }
689
690 static void tcindex_bind_class(void *fh, u32 classid, unsigned long cl,
691                                void *q, unsigned long base)
692 {
693         struct tcindex_filter_result *r = fh;
694
695         tc_cls_bind_class(classid, cl, q, &r->res, base);
696 }
697
698 static struct tcf_proto_ops cls_tcindex_ops __read_mostly = {
699         .kind           =       "tcindex",
700         .classify       =       tcindex_classify,
701         .init           =       tcindex_init,
702         .destroy        =       tcindex_destroy,
703         .get            =       tcindex_get,
704         .change         =       tcindex_change,
705         .delete         =       tcindex_delete,
706         .walk           =       tcindex_walk,
707         .dump           =       tcindex_dump,
708         .bind_class     =       tcindex_bind_class,
709         .owner          =       THIS_MODULE,
710 };
711
712 static int __init init_tcindex(void)
713 {
714         return register_tcf_proto_ops(&cls_tcindex_ops);
715 }
716
717 static void __exit exit_tcindex(void)
718 {
719         unregister_tcf_proto_ops(&cls_tcindex_ops);
720 }
721
722 module_init(init_tcindex)
723 module_exit(exit_tcindex)
724 MODULE_LICENSE("GPL");
This page took 0.073579 seconds and 4 git commands to generate.