netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][CIPSO]: Relax too much careful cipso hash function.
@ 2008-05-13 13:11 Pavel Emelyanov
  2008-05-13 18:34 ` Paul Moore
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Emelyanov @ 2008-05-13 13:11 UTC (permalink / raw)
  To: David Miller, Paul Moore; +Cc: Linux Netdev List

The cipso_v4_cache is allocated to contain CIPSO_V4_CACHE_BUCKETS
buckets. The CIPSO_V4_CACHE_BUCKETS = 1 << CIPSO_V4_CACHE_BUCKETBITS,
where CIPSO_V4_CACHE_BUCKETBITS = 7.

The bucket-selection function for this hash is calculated like this:

  bkt = hash & (CIPSO_V4_CACHE_BUCKETBITS - 1);
                                     ^^^

i.e. picking only 4 buckets of possible 128 :)

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

---
 net/ipv4/cipso_ipv4.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
index 05afb57..2c0e457 100644
--- a/net/ipv4/cipso_ipv4.c
+++ b/net/ipv4/cipso_ipv4.c
@@ -338,7 +338,7 @@ static int cipso_v4_cache_check(const unsigned char *key,
 		return -ENOENT;
 
 	hash = cipso_v4_map_cache_hash(key, key_len);
-	bkt = hash & (CIPSO_V4_CACHE_BUCKETBITS - 1);
+	bkt = hash & (CIPSO_V4_CACHE_BUCKETS - 1);
 	spin_lock_bh(&cipso_v4_cache[bkt].lock);
 	list_for_each_entry(entry, &cipso_v4_cache[bkt].list, list) {
 		if (entry->hash == hash &&
@@ -417,7 +417,7 @@ int cipso_v4_cache_add(const struct sk_buff *skb,
 	atomic_inc(&secattr->cache->refcount);
 	entry->lsm_data = secattr->cache;
 
-	bkt = entry->hash & (CIPSO_V4_CACHE_BUCKETBITS - 1);
+	bkt = entry->hash & (CIPSO_V4_CACHE_BUCKETS - 1);
 	spin_lock_bh(&cipso_v4_cache[bkt].lock);
 	if (cipso_v4_cache[bkt].size < cipso_v4_cache_bucketsize) {
 		list_add(&entry->list, &cipso_v4_cache[bkt].list);

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH][CIPSO]: Relax too much careful cipso hash function.
  2008-05-13 13:11 [PATCH][CIPSO]: Relax too much careful cipso hash function Pavel Emelyanov
@ 2008-05-13 18:34 ` Paul Moore
  2008-05-14  6:24   ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Moore @ 2008-05-13 18:34 UTC (permalink / raw)
  To: Pavel Emelyanov; +Cc: David Miller, Linux Netdev List

On Tuesday 13 May 2008 9:11:25 am Pavel Emelyanov wrote:
> The cipso_v4_cache is allocated to contain CIPSO_V4_CACHE_BUCKETS
> buckets. The CIPSO_V4_CACHE_BUCKETS = 1 << CIPSO_V4_CACHE_BUCKETBITS,
> where CIPSO_V4_CACHE_BUCKETBITS = 7.
>
> The bucket-selection function for this hash is calculated like this:
>
>   bkt = hash & (CIPSO_V4_CACHE_BUCKETBITS - 1);
>                                      ^^^
>
> i.e. picking only 4 buckets of possible 128 :)
>
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

Thanks Pavel, braino on my part.

Acked-by: Paul Moore <paul.moore@hp.com>

> ---
>  net/ipv4/cipso_ipv4.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
> index 05afb57..2c0e457 100644
> --- a/net/ipv4/cipso_ipv4.c
> +++ b/net/ipv4/cipso_ipv4.c
> @@ -338,7 +338,7 @@ static int cipso_v4_cache_check(const unsigned
> char *key, return -ENOENT;
>
>  	hash = cipso_v4_map_cache_hash(key, key_len);
> -	bkt = hash & (CIPSO_V4_CACHE_BUCKETBITS - 1);
> +	bkt = hash & (CIPSO_V4_CACHE_BUCKETS - 1);
>  	spin_lock_bh(&cipso_v4_cache[bkt].lock);
>  	list_for_each_entry(entry, &cipso_v4_cache[bkt].list, list) {
>  		if (entry->hash == hash &&
> @@ -417,7 +417,7 @@ int cipso_v4_cache_add(const struct sk_buff *skb,
>  	atomic_inc(&secattr->cache->refcount);
>  	entry->lsm_data = secattr->cache;
>
> -	bkt = entry->hash & (CIPSO_V4_CACHE_BUCKETBITS - 1);
> +	bkt = entry->hash & (CIPSO_V4_CACHE_BUCKETS - 1);
>  	spin_lock_bh(&cipso_v4_cache[bkt].lock);
>  	if (cipso_v4_cache[bkt].size < cipso_v4_cache_bucketsize) {
>  		list_add(&entry->list, &cipso_v4_cache[bkt].list);



-- 
paul moore
linux @ hp

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][CIPSO]: Relax too much careful cipso hash function.
  2008-05-13 18:34 ` Paul Moore
@ 2008-05-14  6:24   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2008-05-14  6:24 UTC (permalink / raw)
  To: paul.moore; +Cc: xemul, netdev

From: Paul Moore <paul.moore@hp.com>
Date: Tue, 13 May 2008 14:34:44 -0400

> On Tuesday 13 May 2008 9:11:25 am Pavel Emelyanov wrote:
> > The cipso_v4_cache is allocated to contain CIPSO_V4_CACHE_BUCKETS
> > buckets. The CIPSO_V4_CACHE_BUCKETS = 1 << CIPSO_V4_CACHE_BUCKETBITS,
> > where CIPSO_V4_CACHE_BUCKETBITS = 7.
> >
> > The bucket-selection function for this hash is calculated like this:
> >
> >   bkt = hash & (CIPSO_V4_CACHE_BUCKETBITS - 1);
> >                                      ^^^
> >
> > i.e. picking only 4 buckets of possible 128 :)
> >
> > Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
> 
> Thanks Pavel, braino on my part.
> 
> Acked-by: Paul Moore <paul.moore@hp.com>

Applied, thanks everyone.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-05-14  6:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-13 13:11 [PATCH][CIPSO]: Relax too much careful cipso hash function Pavel Emelyanov
2008-05-13 18:34 ` Paul Moore
2008-05-14  6:24   ` David Miller

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).