netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nf-next 8/9] netfilter: nft_set_hash: add non-resizable hashtable implementation
Date: Wed, 24 May 2017 12:14:52 +0200	[thread overview]
Message-ID: <20170524101452.GA23010@salvia> (raw)
In-Reply-To: <1495619453-22307-9-git-send-email-pablo@netfilter.org>

On Wed, May 24, 2017 at 11:50:52AM +0200, Pablo Neira Ayuso wrote:
> +static bool nft_hash_lookup(const struct net *net, const struct nft_set *set,
> +			    const u32 *key, const struct nft_set_ext **ext)
> +{
> +	struct nft_hash *priv = nft_set_priv(set);
> +	u8 genmask = nft_genmask_cur(net);
> +	const struct nft_hash_elem *he;
> +	u32 hash;
> +
> +	hash = jhash(key, set->klen, priv->seed);
> +	hash = reciprocal_scale(hash, priv->buckets);
> +	hlist_for_each_entry(he, &priv->table[hash], node) {

Hm. I just noticed _rcu is missing here and everywhere in this code.
Will send a v2.

> +		if (!memcmp(nft_set_ext_key(&he->ext), key, set->klen) &&
> +		    nft_set_elem_active(&he->ext, genmask)) {
> +			*ext = &he->ext;
> +			return true;
> +		}
> +	}
> +	return false;
> +}

  reply	other threads:[~2017-05-24 10:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-24  9:50 [PATCH nf-next 0/9] nf_tables set updates Pablo Neira Ayuso
2017-05-24  9:50 ` [PATCH nf-next 1/9] netfilter: nft_set_hash: unnecessary forward declaration Pablo Neira Ayuso
2017-05-24  9:50 ` [PATCH nf-next 2/9] netfilter: nf_tables: no size estimation if number of set elements is unknown Pablo Neira Ayuso
2017-05-24  9:50 ` [PATCH nf-next 3/9] netfilter: nft_set_hash: use nft_rhash prefix for resizable set backend Pablo Neira Ayuso
2017-05-24  9:50 ` [PATCH nf-next 4/9] netfilter: nf_tables: select set backend flavour depending on description Pablo Neira Ayuso
2017-05-24  9:50 ` [PATCH nf-next 5/9] netfilter: nf_tables: pass set description to ->privsize Pablo Neira Ayuso
2017-05-24  9:50 ` [PATCH nf-next 6/9] netfilter: nft_set_hash: add nft_hash_buckets() Pablo Neira Ayuso
2017-05-24  9:50 ` [PATCH nf-next 7/9] netfilter: nf_tables: allow large allocations for new sets Pablo Neira Ayuso
2017-05-26 10:02   ` Liping Zhang
2017-05-26 10:18     ` Pablo Neira Ayuso
2017-05-26 10:33       ` Liping Zhang
2017-05-24  9:50 ` [PATCH nf-next 8/9] netfilter: nft_set_hash: add non-resizable hashtable implementation Pablo Neira Ayuso
2017-05-24 10:14   ` Pablo Neira Ayuso [this message]
2017-05-24  9:50 ` [PATCH nf-next 9/9] netfilter: nft_set_hash: add lookup variant for fixed size hashtable Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170524101452.GA23010@salvia \
    --to=pablo@netfilter.org \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).