-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
netns: introduce the net_hash_mix "salt" for hashes
There are many possible ways to add this "salt", thus I made this patch to be the last in the series to change it if required. Currently I propose to use the struct net pointer itself as this salt, but since this pointer is most often cache-line aligned, shift this right to eliminate the bits, that are most often zeroed. After this, simply add this mix to prepared hashfn-s. For CONFIG_NET_NS=n case this salt is 0 and no changes in hashfn appear. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Pavel Emelyanov
authored and
David S. Miller
committed
Jun 17, 2008
1 parent
33de014
commit 0b44191
Showing
5 changed files
with
30 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef __NET_NS_HASH_H__ | ||
#define __NET_NS_HASH_H__ | ||
|
||
#include <asm/cache.h> | ||
|
||
struct net; | ||
|
||
static inline unsigned net_hash_mix(struct net *net) | ||
{ | ||
#ifdef CONFIG_NET_NS | ||
/* | ||
* shift this right to eliminate bits, that are | ||
* always zeroed | ||
*/ | ||
|
||
return (unsigned)(((unsigned long)net) >> L1_CACHE_SHIFT); | ||
#else | ||
return 0; | ||
#endif | ||
} | ||
#endif |