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