linux/net/netfilter/nft_set_hash.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2008-2014 Patrick McHardy <[email protected]>
 *
 * Development of this code funded by Astaro AG (http://www.astaro.com/)
 */

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/list.h>
#include <linux/log2.h>
#include <linux/jhash.h>
#include <linux/netlink.h>
#include <linux/workqueue.h>
#include <linux/rhashtable.h>
#include <linux/netfilter.h>
#include <linux/netfilter/nf_tables.h>
#include <net/netfilter/nf_tables_core.h>

/* We target a hash table size of 4, element hint is 75% of final size */
#define NFT_RHASH_ELEMENT_HINT

struct nft_rhash {};

struct nft_rhash_elem {};

struct nft_rhash_cmp_arg {};

static inline u32 nft_rhash_key(const void *data, u32 len, u32 seed)
{}

static inline u32 nft_rhash_obj(const void *data, u32 len, u32 seed)
{}

static inline int nft_rhash_cmp(struct rhashtable_compare_arg *arg,
				const void *ptr)
{}

static const struct rhashtable_params nft_rhash_params =;

INDIRECT_CALLABLE_SCOPE
bool nft_rhash_lookup(const struct net *net, const struct nft_set *set,
		      const u32 *key, const struct nft_set_ext **ext)
{}

static struct nft_elem_priv *
nft_rhash_get(const struct net *net, const struct nft_set *set,
	      const struct nft_set_elem *elem, unsigned int flags)
{}

static bool nft_rhash_update(struct nft_set *set, const u32 *key,
			     struct nft_elem_priv *
				   (*new)(struct nft_set *,
					  const struct nft_expr *,
					  struct nft_regs *regs),
			     const struct nft_expr *expr,
			     struct nft_regs *regs,
			     const struct nft_set_ext **ext)
{}

static int nft_rhash_insert(const struct net *net, const struct nft_set *set,
			    const struct nft_set_elem *elem,
			    struct nft_elem_priv **elem_priv)
{}

static void nft_rhash_activate(const struct net *net, const struct nft_set *set,
			       struct nft_elem_priv *elem_priv)
{}

static void nft_rhash_flush(const struct net *net,
			    const struct nft_set *set,
			    struct nft_elem_priv *elem_priv)
{}

static struct nft_elem_priv *
nft_rhash_deactivate(const struct net *net, const struct nft_set *set,
		     const struct nft_set_elem *elem)
{}

static void nft_rhash_remove(const struct net *net,
			     const struct nft_set *set,
			     struct nft_elem_priv *elem_priv)
{}

static bool nft_rhash_delete(const struct nft_set *set,
			     const u32 *key)
{}

static void nft_rhash_walk(const struct nft_ctx *ctx, struct nft_set *set,
			   struct nft_set_iter *iter)
{}

static bool nft_rhash_expr_needs_gc_run(const struct nft_set *set,
					struct nft_set_ext *ext)
{}

static void nft_rhash_gc(struct work_struct *work)
{}

static u64 nft_rhash_privsize(const struct nlattr * const nla[],
			      const struct nft_set_desc *desc)
{}

static void nft_rhash_gc_init(const struct nft_set *set)
{}

static int nft_rhash_init(const struct nft_set *set,
			  const struct nft_set_desc *desc,
			  const struct nlattr * const tb[])
{}

struct nft_rhash_ctx {};

static void nft_rhash_elem_destroy(void *ptr, void *arg)
{}

static void nft_rhash_destroy(const struct nft_ctx *ctx,
			      const struct nft_set *set)
{}

/* Number of buckets is stored in u32, so cap our result to 1U<<31 */
#define NFT_MAX_BUCKETS

static u32 nft_hash_buckets(u32 size)
{}

static bool nft_rhash_estimate(const struct nft_set_desc *desc, u32 features,
			       struct nft_set_estimate *est)
{}

struct nft_hash {};

struct nft_hash_elem {};

INDIRECT_CALLABLE_SCOPE
bool nft_hash_lookup(const struct net *net, const struct nft_set *set,
		     const u32 *key, const struct nft_set_ext **ext)
{}

static struct nft_elem_priv *
nft_hash_get(const struct net *net, const struct nft_set *set,
	     const struct nft_set_elem *elem, unsigned int flags)
{}

INDIRECT_CALLABLE_SCOPE
bool nft_hash_lookup_fast(const struct net *net,
			  const struct nft_set *set,
			  const u32 *key, const struct nft_set_ext **ext)
{}

static u32 nft_jhash(const struct nft_set *set, const struct nft_hash *priv,
		     const struct nft_set_ext *ext)
{}

static int nft_hash_insert(const struct net *net, const struct nft_set *set,
			   const struct nft_set_elem *elem,
			   struct nft_elem_priv **elem_priv)
{}

static void nft_hash_activate(const struct net *net, const struct nft_set *set,
			      struct nft_elem_priv *elem_priv)
{}

static void nft_hash_flush(const struct net *net,
			   const struct nft_set *set,
			   struct nft_elem_priv *elem_priv)
{}

static struct nft_elem_priv *
nft_hash_deactivate(const struct net *net, const struct nft_set *set,
		    const struct nft_set_elem *elem)
{}

static void nft_hash_remove(const struct net *net,
			    const struct nft_set *set,
			    struct nft_elem_priv *elem_priv)
{}

static void nft_hash_walk(const struct nft_ctx *ctx, struct nft_set *set,
			  struct nft_set_iter *iter)
{}

static u64 nft_hash_privsize(const struct nlattr * const nla[],
			     const struct nft_set_desc *desc)
{}

static int nft_hash_init(const struct nft_set *set,
			 const struct nft_set_desc *desc,
			 const struct nlattr * const tb[])
{}

static void nft_hash_destroy(const struct nft_ctx *ctx,
			     const struct nft_set *set)
{}

static bool nft_hash_estimate(const struct nft_set_desc *desc, u32 features,
			      struct nft_set_estimate *est)
{}

static bool nft_hash_fast_estimate(const struct nft_set_desc *desc, u32 features,
				   struct nft_set_estimate *est)
{}

const struct nft_set_type nft_set_rhash_type =;

const struct nft_set_type nft_set_hash_type =;

const struct nft_set_type nft_set_hash_fast_type =;