Merge tag 'dmaengine-5.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul...
[linux-2.6-microblaze.git] / net / netfilter / nft_set_hash.c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Copyright (c) 2008-2014 Patrick McHardy <kaber@trash.net>
4  *
5  * Development of this code funded by Astaro AG (http://www.astaro.com/)
6  */
7
8 #include <linux/kernel.h>
9 #include <linux/init.h>
10 #include <linux/module.h>
11 #include <linux/list.h>
12 #include <linux/log2.h>
13 #include <linux/jhash.h>
14 #include <linux/netlink.h>
15 #include <linux/workqueue.h>
16 #include <linux/rhashtable.h>
17 #include <linux/netfilter.h>
18 #include <linux/netfilter/nf_tables.h>
19 #include <net/netfilter/nf_tables_core.h>
20
21 /* We target a hash table size of 4, element hint is 75% of final size */
22 #define NFT_RHASH_ELEMENT_HINT 3
23
24 struct nft_rhash {
25         struct rhashtable               ht;
26         struct delayed_work             gc_work;
27 };
28
29 struct nft_rhash_elem {
30         struct rhash_head               node;
31         struct nft_set_ext              ext;
32 };
33
34 struct nft_rhash_cmp_arg {
35         const struct nft_set            *set;
36         const u32                       *key;
37         u8                              genmask;
38 };
39
40 static inline u32 nft_rhash_key(const void *data, u32 len, u32 seed)
41 {
42         const struct nft_rhash_cmp_arg *arg = data;
43
44         return jhash(arg->key, len, seed);
45 }
46
47 static inline u32 nft_rhash_obj(const void *data, u32 len, u32 seed)
48 {
49         const struct nft_rhash_elem *he = data;
50
51         return jhash(nft_set_ext_key(&he->ext), len, seed);
52 }
53
54 static inline int nft_rhash_cmp(struct rhashtable_compare_arg *arg,
55                                 const void *ptr)
56 {
57         const struct nft_rhash_cmp_arg *x = arg->key;
58         const struct nft_rhash_elem *he = ptr;
59
60         if (memcmp(nft_set_ext_key(&he->ext), x->key, x->set->klen))
61                 return 1;
62         if (nft_set_elem_expired(&he->ext))
63                 return 1;
64         if (!nft_set_elem_active(&he->ext, x->genmask))
65                 return 1;
66         return 0;
67 }
68
69 static const struct rhashtable_params nft_rhash_params = {
70         .head_offset            = offsetof(struct nft_rhash_elem, node),
71         .hashfn                 = nft_rhash_key,
72         .obj_hashfn             = nft_rhash_obj,
73         .obj_cmpfn              = nft_rhash_cmp,
74         .automatic_shrinking    = true,
75 };
76
77 static bool nft_rhash_lookup(const struct net *net, const struct nft_set *set,
78                              const u32 *key, const struct nft_set_ext **ext)
79 {
80         struct nft_rhash *priv = nft_set_priv(set);
81         const struct nft_rhash_elem *he;
82         struct nft_rhash_cmp_arg arg = {
83                 .genmask = nft_genmask_cur(net),
84                 .set     = set,
85                 .key     = key,
86         };
87
88         he = rhashtable_lookup(&priv->ht, &arg, nft_rhash_params);
89         if (he != NULL)
90                 *ext = &he->ext;
91
92         return !!he;
93 }
94
95 static void *nft_rhash_get(const struct net *net, const struct nft_set *set,
96                            const struct nft_set_elem *elem, unsigned int flags)
97 {
98         struct nft_rhash *priv = nft_set_priv(set);
99         struct nft_rhash_elem *he;
100         struct nft_rhash_cmp_arg arg = {
101                 .genmask = nft_genmask_cur(net),
102                 .set     = set,
103                 .key     = elem->key.val.data,
104         };
105
106         he = rhashtable_lookup(&priv->ht, &arg, nft_rhash_params);
107         if (he != NULL)
108                 return he;
109
110         return ERR_PTR(-ENOENT);
111 }
112
113 static bool nft_rhash_update(struct nft_set *set, const u32 *key,
114                              void *(*new)(struct nft_set *,
115                                           const struct nft_expr *,
116                                           struct nft_regs *regs),
117                              const struct nft_expr *expr,
118                              struct nft_regs *regs,
119                              const struct nft_set_ext **ext)
120 {
121         struct nft_rhash *priv = nft_set_priv(set);
122         struct nft_rhash_elem *he, *prev;
123         struct nft_rhash_cmp_arg arg = {
124                 .genmask = NFT_GENMASK_ANY,
125                 .set     = set,
126                 .key     = key,
127         };
128
129         he = rhashtable_lookup(&priv->ht, &arg, nft_rhash_params);
130         if (he != NULL)
131                 goto out;
132
133         he = new(set, expr, regs);
134         if (he == NULL)
135                 goto err1;
136
137         prev = rhashtable_lookup_get_insert_key(&priv->ht, &arg, &he->node,
138                                                 nft_rhash_params);
139         if (IS_ERR(prev))
140                 goto err2;
141
142         /* Another cpu may race to insert the element with the same key */
143         if (prev) {
144                 nft_set_elem_destroy(set, he, true);
145                 he = prev;
146         }
147
148 out:
149         *ext = &he->ext;
150         return true;
151
152 err2:
153         nft_set_elem_destroy(set, he, true);
154 err1:
155         return false;
156 }
157
158 static int nft_rhash_insert(const struct net *net, const struct nft_set *set,
159                             const struct nft_set_elem *elem,
160                             struct nft_set_ext **ext)
161 {
162         struct nft_rhash *priv = nft_set_priv(set);
163         struct nft_rhash_elem *he = elem->priv;
164         struct nft_rhash_cmp_arg arg = {
165                 .genmask = nft_genmask_next(net),
166                 .set     = set,
167                 .key     = elem->key.val.data,
168         };
169         struct nft_rhash_elem *prev;
170
171         prev = rhashtable_lookup_get_insert_key(&priv->ht, &arg, &he->node,
172                                                 nft_rhash_params);
173         if (IS_ERR(prev))
174                 return PTR_ERR(prev);
175         if (prev) {
176                 *ext = &prev->ext;
177                 return -EEXIST;
178         }
179         return 0;
180 }
181
182 static void nft_rhash_activate(const struct net *net, const struct nft_set *set,
183                                const struct nft_set_elem *elem)
184 {
185         struct nft_rhash_elem *he = elem->priv;
186
187         nft_set_elem_change_active(net, set, &he->ext);
188         nft_set_elem_clear_busy(&he->ext);
189 }
190
191 static bool nft_rhash_flush(const struct net *net,
192                             const struct nft_set *set, void *priv)
193 {
194         struct nft_rhash_elem *he = priv;
195
196         if (!nft_set_elem_mark_busy(&he->ext) ||
197             !nft_is_active(net, &he->ext)) {
198                 nft_set_elem_change_active(net, set, &he->ext);
199                 return true;
200         }
201         return false;
202 }
203
204 static void *nft_rhash_deactivate(const struct net *net,
205                                   const struct nft_set *set,
206                                   const struct nft_set_elem *elem)
207 {
208         struct nft_rhash *priv = nft_set_priv(set);
209         struct nft_rhash_elem *he;
210         struct nft_rhash_cmp_arg arg = {
211                 .genmask = nft_genmask_next(net),
212                 .set     = set,
213                 .key     = elem->key.val.data,
214         };
215
216         rcu_read_lock();
217         he = rhashtable_lookup(&priv->ht, &arg, nft_rhash_params);
218         if (he != NULL &&
219             !nft_rhash_flush(net, set, he))
220                 he = NULL;
221
222         rcu_read_unlock();
223
224         return he;
225 }
226
227 static void nft_rhash_remove(const struct net *net,
228                              const struct nft_set *set,
229                              const struct nft_set_elem *elem)
230 {
231         struct nft_rhash *priv = nft_set_priv(set);
232         struct nft_rhash_elem *he = elem->priv;
233
234         rhashtable_remove_fast(&priv->ht, &he->node, nft_rhash_params);
235 }
236
237 static bool nft_rhash_delete(const struct nft_set *set,
238                              const u32 *key)
239 {
240         struct nft_rhash *priv = nft_set_priv(set);
241         struct nft_rhash_cmp_arg arg = {
242                 .genmask = NFT_GENMASK_ANY,
243                 .set = set,
244                 .key = key,
245         };
246         struct nft_rhash_elem *he;
247
248         he = rhashtable_lookup(&priv->ht, &arg, nft_rhash_params);
249         if (he == NULL)
250                 return false;
251
252         return rhashtable_remove_fast(&priv->ht, &he->node, nft_rhash_params) == 0;
253 }
254
255 static void nft_rhash_walk(const struct nft_ctx *ctx, struct nft_set *set,
256                            struct nft_set_iter *iter)
257 {
258         struct nft_rhash *priv = nft_set_priv(set);
259         struct nft_rhash_elem *he;
260         struct rhashtable_iter hti;
261         struct nft_set_elem elem;
262
263         rhashtable_walk_enter(&priv->ht, &hti);
264         rhashtable_walk_start(&hti);
265
266         while ((he = rhashtable_walk_next(&hti))) {
267                 if (IS_ERR(he)) {
268                         if (PTR_ERR(he) != -EAGAIN) {
269                                 iter->err = PTR_ERR(he);
270                                 break;
271                         }
272
273                         continue;
274                 }
275
276                 if (iter->count < iter->skip)
277                         goto cont;
278                 if (nft_set_elem_expired(&he->ext))
279                         goto cont;
280                 if (!nft_set_elem_active(&he->ext, iter->genmask))
281                         goto cont;
282
283                 elem.priv = he;
284
285                 iter->err = iter->fn(ctx, set, iter, &elem);
286                 if (iter->err < 0)
287                         break;
288
289 cont:
290                 iter->count++;
291         }
292         rhashtable_walk_stop(&hti);
293         rhashtable_walk_exit(&hti);
294 }
295
296 static bool nft_rhash_expr_needs_gc_run(const struct nft_set *set,
297                                         struct nft_set_ext *ext)
298 {
299         struct nft_set_elem_expr *elem_expr = nft_set_ext_expr(ext);
300         struct nft_expr *expr;
301         u32 size;
302
303         nft_setelem_expr_foreach(expr, elem_expr, size) {
304                 if (expr->ops->gc &&
305                     expr->ops->gc(read_pnet(&set->net), expr))
306                         return true;
307         }
308
309         return false;
310 }
311
312 static void nft_rhash_gc(struct work_struct *work)
313 {
314         struct nft_set *set;
315         struct nft_rhash_elem *he;
316         struct nft_rhash *priv;
317         struct nft_set_gc_batch *gcb = NULL;
318         struct rhashtable_iter hti;
319
320         priv = container_of(work, struct nft_rhash, gc_work.work);
321         set  = nft_set_container_of(priv);
322
323         rhashtable_walk_enter(&priv->ht, &hti);
324         rhashtable_walk_start(&hti);
325
326         while ((he = rhashtable_walk_next(&hti))) {
327                 if (IS_ERR(he)) {
328                         if (PTR_ERR(he) != -EAGAIN)
329                                 break;
330                         continue;
331                 }
332
333                 if (nft_set_ext_exists(&he->ext, NFT_SET_EXT_EXPRESSIONS) &&
334                     nft_rhash_expr_needs_gc_run(set, &he->ext))
335                         goto needs_gc_run;
336
337                 if (!nft_set_elem_expired(&he->ext))
338                         continue;
339 needs_gc_run:
340                 if (nft_set_elem_mark_busy(&he->ext))
341                         continue;
342
343                 gcb = nft_set_gc_batch_check(set, gcb, GFP_ATOMIC);
344                 if (gcb == NULL)
345                         break;
346                 rhashtable_remove_fast(&priv->ht, &he->node, nft_rhash_params);
347                 atomic_dec(&set->nelems);
348                 nft_set_gc_batch_add(gcb, he);
349         }
350         rhashtable_walk_stop(&hti);
351         rhashtable_walk_exit(&hti);
352
353         he = nft_set_catchall_gc(set);
354         if (he) {
355                 gcb = nft_set_gc_batch_check(set, gcb, GFP_ATOMIC);
356                 if (gcb)
357                         nft_set_gc_batch_add(gcb, he);
358         }
359         nft_set_gc_batch_complete(gcb);
360         queue_delayed_work(system_power_efficient_wq, &priv->gc_work,
361                            nft_set_gc_interval(set));
362 }
363
364 static u64 nft_rhash_privsize(const struct nlattr * const nla[],
365                               const struct nft_set_desc *desc)
366 {
367         return sizeof(struct nft_rhash);
368 }
369
370 static void nft_rhash_gc_init(const struct nft_set *set)
371 {
372         struct nft_rhash *priv = nft_set_priv(set);
373
374         queue_delayed_work(system_power_efficient_wq, &priv->gc_work,
375                            nft_set_gc_interval(set));
376 }
377
378 static int nft_rhash_init(const struct nft_set *set,
379                           const struct nft_set_desc *desc,
380                           const struct nlattr * const tb[])
381 {
382         struct nft_rhash *priv = nft_set_priv(set);
383         struct rhashtable_params params = nft_rhash_params;
384         int err;
385
386         params.nelem_hint = desc->size ?: NFT_RHASH_ELEMENT_HINT;
387         params.key_len    = set->klen;
388
389         err = rhashtable_init(&priv->ht, &params);
390         if (err < 0)
391                 return err;
392
393         INIT_DEFERRABLE_WORK(&priv->gc_work, nft_rhash_gc);
394         if (set->flags & NFT_SET_TIMEOUT)
395                 nft_rhash_gc_init(set);
396
397         return 0;
398 }
399
400 static void nft_rhash_elem_destroy(void *ptr, void *arg)
401 {
402         nft_set_elem_destroy(arg, ptr, true);
403 }
404
405 static void nft_rhash_destroy(const struct nft_set *set)
406 {
407         struct nft_rhash *priv = nft_set_priv(set);
408
409         cancel_delayed_work_sync(&priv->gc_work);
410         rcu_barrier();
411         rhashtable_free_and_destroy(&priv->ht, nft_rhash_elem_destroy,
412                                     (void *)set);
413 }
414
415 static u32 nft_hash_buckets(u32 size)
416 {
417         return roundup_pow_of_two(size * 4 / 3);
418 }
419
420 static bool nft_rhash_estimate(const struct nft_set_desc *desc, u32 features,
421                                struct nft_set_estimate *est)
422 {
423         est->size   = ~0;
424         est->lookup = NFT_SET_CLASS_O_1;
425         est->space  = NFT_SET_CLASS_O_N;
426
427         return true;
428 }
429
430 struct nft_hash {
431         u32                             seed;
432         u32                             buckets;
433         struct hlist_head               table[];
434 };
435
436 struct nft_hash_elem {
437         struct hlist_node               node;
438         struct nft_set_ext              ext;
439 };
440
441 static bool nft_hash_lookup(const struct net *net, const struct nft_set *set,
442                             const u32 *key, const struct nft_set_ext **ext)
443 {
444         struct nft_hash *priv = nft_set_priv(set);
445         u8 genmask = nft_genmask_cur(net);
446         const struct nft_hash_elem *he;
447         u32 hash;
448
449         hash = jhash(key, set->klen, priv->seed);
450         hash = reciprocal_scale(hash, priv->buckets);
451         hlist_for_each_entry_rcu(he, &priv->table[hash], node) {
452                 if (!memcmp(nft_set_ext_key(&he->ext), key, set->klen) &&
453                     nft_set_elem_active(&he->ext, genmask)) {
454                         *ext = &he->ext;
455                         return true;
456                 }
457         }
458         return false;
459 }
460
461 static void *nft_hash_get(const struct net *net, const struct nft_set *set,
462                           const struct nft_set_elem *elem, unsigned int flags)
463 {
464         struct nft_hash *priv = nft_set_priv(set);
465         u8 genmask = nft_genmask_cur(net);
466         struct nft_hash_elem *he;
467         u32 hash;
468
469         hash = jhash(elem->key.val.data, set->klen, priv->seed);
470         hash = reciprocal_scale(hash, priv->buckets);
471         hlist_for_each_entry_rcu(he, &priv->table[hash], node) {
472                 if (!memcmp(nft_set_ext_key(&he->ext), elem->key.val.data, set->klen) &&
473                     nft_set_elem_active(&he->ext, genmask))
474                         return he;
475         }
476         return ERR_PTR(-ENOENT);
477 }
478
479 static bool nft_hash_lookup_fast(const struct net *net,
480                                  const struct nft_set *set,
481                                  const u32 *key, const struct nft_set_ext **ext)
482 {
483         struct nft_hash *priv = nft_set_priv(set);
484         u8 genmask = nft_genmask_cur(net);
485         const struct nft_hash_elem *he;
486         u32 hash, k1, k2;
487
488         k1 = *key;
489         hash = jhash_1word(k1, priv->seed);
490         hash = reciprocal_scale(hash, priv->buckets);
491         hlist_for_each_entry_rcu(he, &priv->table[hash], node) {
492                 k2 = *(u32 *)nft_set_ext_key(&he->ext)->data;
493                 if (k1 == k2 &&
494                     nft_set_elem_active(&he->ext, genmask)) {
495                         *ext = &he->ext;
496                         return true;
497                 }
498         }
499         return false;
500 }
501
502 static u32 nft_jhash(const struct nft_set *set, const struct nft_hash *priv,
503                      const struct nft_set_ext *ext)
504 {
505         const struct nft_data *key = nft_set_ext_key(ext);
506         u32 hash, k1;
507
508         if (set->klen == 4) {
509                 k1 = *(u32 *)key;
510                 hash = jhash_1word(k1, priv->seed);
511         } else {
512                 hash = jhash(key, set->klen, priv->seed);
513         }
514         hash = reciprocal_scale(hash, priv->buckets);
515
516         return hash;
517 }
518
519 static int nft_hash_insert(const struct net *net, const struct nft_set *set,
520                            const struct nft_set_elem *elem,
521                            struct nft_set_ext **ext)
522 {
523         struct nft_hash_elem *this = elem->priv, *he;
524         struct nft_hash *priv = nft_set_priv(set);
525         u8 genmask = nft_genmask_next(net);
526         u32 hash;
527
528         hash = nft_jhash(set, priv, &this->ext);
529         hlist_for_each_entry(he, &priv->table[hash], node) {
530                 if (!memcmp(nft_set_ext_key(&this->ext),
531                             nft_set_ext_key(&he->ext), set->klen) &&
532                     nft_set_elem_active(&he->ext, genmask)) {
533                         *ext = &he->ext;
534                         return -EEXIST;
535                 }
536         }
537         hlist_add_head_rcu(&this->node, &priv->table[hash]);
538         return 0;
539 }
540
541 static void nft_hash_activate(const struct net *net, const struct nft_set *set,
542                               const struct nft_set_elem *elem)
543 {
544         struct nft_hash_elem *he = elem->priv;
545
546         nft_set_elem_change_active(net, set, &he->ext);
547 }
548
549 static bool nft_hash_flush(const struct net *net,
550                            const struct nft_set *set, void *priv)
551 {
552         struct nft_hash_elem *he = priv;
553
554         nft_set_elem_change_active(net, set, &he->ext);
555         return true;
556 }
557
558 static void *nft_hash_deactivate(const struct net *net,
559                                  const struct nft_set *set,
560                                  const struct nft_set_elem *elem)
561 {
562         struct nft_hash *priv = nft_set_priv(set);
563         struct nft_hash_elem *this = elem->priv, *he;
564         u8 genmask = nft_genmask_next(net);
565         u32 hash;
566
567         hash = nft_jhash(set, priv, &this->ext);
568         hlist_for_each_entry(he, &priv->table[hash], node) {
569                 if (!memcmp(nft_set_ext_key(&he->ext), &elem->key.val,
570                             set->klen) &&
571                     nft_set_elem_active(&he->ext, genmask)) {
572                         nft_set_elem_change_active(net, set, &he->ext);
573                         return he;
574                 }
575         }
576         return NULL;
577 }
578
579 static void nft_hash_remove(const struct net *net,
580                             const struct nft_set *set,
581                             const struct nft_set_elem *elem)
582 {
583         struct nft_hash_elem *he = elem->priv;
584
585         hlist_del_rcu(&he->node);
586 }
587
588 static void nft_hash_walk(const struct nft_ctx *ctx, struct nft_set *set,
589                           struct nft_set_iter *iter)
590 {
591         struct nft_hash *priv = nft_set_priv(set);
592         struct nft_hash_elem *he;
593         struct nft_set_elem elem;
594         int i;
595
596         for (i = 0; i < priv->buckets; i++) {
597                 hlist_for_each_entry_rcu(he, &priv->table[i], node) {
598                         if (iter->count < iter->skip)
599                                 goto cont;
600                         if (!nft_set_elem_active(&he->ext, iter->genmask))
601                                 goto cont;
602
603                         elem.priv = he;
604
605                         iter->err = iter->fn(ctx, set, iter, &elem);
606                         if (iter->err < 0)
607                                 return;
608 cont:
609                         iter->count++;
610                 }
611         }
612 }
613
614 static u64 nft_hash_privsize(const struct nlattr * const nla[],
615                              const struct nft_set_desc *desc)
616 {
617         return sizeof(struct nft_hash) +
618                nft_hash_buckets(desc->size) * sizeof(struct hlist_head);
619 }
620
621 static int nft_hash_init(const struct nft_set *set,
622                          const struct nft_set_desc *desc,
623                          const struct nlattr * const tb[])
624 {
625         struct nft_hash *priv = nft_set_priv(set);
626
627         priv->buckets = nft_hash_buckets(desc->size);
628         get_random_bytes(&priv->seed, sizeof(priv->seed));
629
630         return 0;
631 }
632
633 static void nft_hash_destroy(const struct nft_set *set)
634 {
635         struct nft_hash *priv = nft_set_priv(set);
636         struct nft_hash_elem *he;
637         struct hlist_node *next;
638         int i;
639
640         for (i = 0; i < priv->buckets; i++) {
641                 hlist_for_each_entry_safe(he, next, &priv->table[i], node) {
642                         hlist_del_rcu(&he->node);
643                         nft_set_elem_destroy(set, he, true);
644                 }
645         }
646 }
647
648 static bool nft_hash_estimate(const struct nft_set_desc *desc, u32 features,
649                               struct nft_set_estimate *est)
650 {
651         if (!desc->size)
652                 return false;
653
654         if (desc->klen == 4)
655                 return false;
656
657         est->size   = sizeof(struct nft_hash) +
658                       nft_hash_buckets(desc->size) * sizeof(struct hlist_head) +
659                       desc->size * sizeof(struct nft_hash_elem);
660         est->lookup = NFT_SET_CLASS_O_1;
661         est->space  = NFT_SET_CLASS_O_N;
662
663         return true;
664 }
665
666 static bool nft_hash_fast_estimate(const struct nft_set_desc *desc, u32 features,
667                                    struct nft_set_estimate *est)
668 {
669         if (!desc->size)
670                 return false;
671
672         if (desc->klen != 4)
673                 return false;
674
675         est->size   = sizeof(struct nft_hash) +
676                       nft_hash_buckets(desc->size) * sizeof(struct hlist_head) +
677                       desc->size * sizeof(struct nft_hash_elem);
678         est->lookup = NFT_SET_CLASS_O_1;
679         est->space  = NFT_SET_CLASS_O_N;
680
681         return true;
682 }
683
684 const struct nft_set_type nft_set_rhash_type = {
685         .features       = NFT_SET_MAP | NFT_SET_OBJECT |
686                           NFT_SET_TIMEOUT | NFT_SET_EVAL,
687         .ops            = {
688                 .privsize       = nft_rhash_privsize,
689                 .elemsize       = offsetof(struct nft_rhash_elem, ext),
690                 .estimate       = nft_rhash_estimate,
691                 .init           = nft_rhash_init,
692                 .gc_init        = nft_rhash_gc_init,
693                 .destroy        = nft_rhash_destroy,
694                 .insert         = nft_rhash_insert,
695                 .activate       = nft_rhash_activate,
696                 .deactivate     = nft_rhash_deactivate,
697                 .flush          = nft_rhash_flush,
698                 .remove         = nft_rhash_remove,
699                 .lookup         = nft_rhash_lookup,
700                 .update         = nft_rhash_update,
701                 .delete         = nft_rhash_delete,
702                 .walk           = nft_rhash_walk,
703                 .get            = nft_rhash_get,
704         },
705 };
706
707 const struct nft_set_type nft_set_hash_type = {
708         .features       = NFT_SET_MAP | NFT_SET_OBJECT,
709         .ops            = {
710                 .privsize       = nft_hash_privsize,
711                 .elemsize       = offsetof(struct nft_hash_elem, ext),
712                 .estimate       = nft_hash_estimate,
713                 .init           = nft_hash_init,
714                 .destroy        = nft_hash_destroy,
715                 .insert         = nft_hash_insert,
716                 .activate       = nft_hash_activate,
717                 .deactivate     = nft_hash_deactivate,
718                 .flush          = nft_hash_flush,
719                 .remove         = nft_hash_remove,
720                 .lookup         = nft_hash_lookup,
721                 .walk           = nft_hash_walk,
722                 .get            = nft_hash_get,
723         },
724 };
725
726 const struct nft_set_type nft_set_hash_fast_type = {
727         .features       = NFT_SET_MAP | NFT_SET_OBJECT,
728         .ops            = {
729                 .privsize       = nft_hash_privsize,
730                 .elemsize       = offsetof(struct nft_hash_elem, ext),
731                 .estimate       = nft_hash_fast_estimate,
732                 .init           = nft_hash_init,
733                 .destroy        = nft_hash_destroy,
734                 .insert         = nft_hash_insert,
735                 .activate       = nft_hash_activate,
736                 .deactivate     = nft_hash_deactivate,
737                 .flush          = nft_hash_flush,
738                 .remove         = nft_hash_remove,
739                 .lookup         = nft_hash_lookup_fast,
740                 .walk           = nft_hash_walk,
741                 .get            = nft_hash_get,
742         },
743 };