diff options
author | Arnaldo Carvalho de Melo <acme@ghostprotocols.net> | 2005-08-09 22:59:20 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2005-08-29 18:38:22 -0400 |
commit | 304a16180fb6d2b153b45f6fbbcec1fa814496e5 (patch) | |
tree | 3cf82b06fcf12480a49d89ead016cb60e50c36b3 /include/net | |
parent | 0597f2680d666a3bcf101ac0c771ba7e50016bbd (diff) |
[INET]: Move the TCP ehash functions to include/net/inet_hashtables.h
To be shared with DCCP (and others), this is the start of a series of patches
that will expose the already generic TCP hash table routines.
The few changes noticed when calling gcc -S before/after on a pentium4 were of
this type:
movl 40(%esp), %edx
cmpl %esi, 472(%edx)
je .L168
- pushl $291
+ pushl $272
pushl $.LC0
pushl $.LC1
pushl $.LC2
[acme@toy net-2.6.14]$ size net/ipv4/tcp_ipv4.before.o net/ipv4/tcp_ipv4.after.o
text data bss dec hex filename
17804 516 140 18460 481c net/ipv4/tcp_ipv4.before.o
17804 516 140 18460 481c net/ipv4/tcp_ipv4.after.o
Holler if some weird architecture has issues with things like this 8)
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/inet_hashtables.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h new file mode 100644 index 000000000000..c4c9e39f4505 --- /dev/null +++ b/include/net/inet_hashtables.h | |||
@@ -0,0 +1,40 @@ | |||
1 | /* | ||
2 | * INET An implementation of the TCP/IP protocol suite for the LINUX | ||
3 | * operating system. INET is implemented using the BSD Socket | ||
4 | * interface as the means of communication with the user level. | ||
5 | * | ||
6 | * Authors: Lotsa people, from code originally in tcp | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License | ||
10 | * as published by the Free Software Foundation; either version | ||
11 | * 2 of the License, or (at your option) any later version. | ||
12 | */ | ||
13 | |||
14 | #ifndef _INET_HASHTABLES_H | ||
15 | #define _INET_HASHTABLES_H | ||
16 | |||
17 | #include <linux/types.h> | ||
18 | |||
19 | static inline int inet_ehashfn(const __u32 laddr, const __u16 lport, | ||
20 | const __u32 faddr, const __u16 fport, | ||
21 | const int ehash_size) | ||
22 | { | ||
23 | int h = (laddr ^ lport) ^ (faddr ^ fport); | ||
24 | h ^= h >> 16; | ||
25 | h ^= h >> 8; | ||
26 | return h & (ehash_size - 1); | ||
27 | } | ||
28 | |||
29 | static inline int inet_sk_ehashfn(const struct sock *sk, const int ehash_size) | ||
30 | { | ||
31 | const struct inet_sock *inet = inet_sk(sk); | ||
32 | const __u32 laddr = inet->rcv_saddr; | ||
33 | const __u16 lport = inet->num; | ||
34 | const __u32 faddr = inet->daddr; | ||
35 | const __u16 fport = inet->dport; | ||
36 | |||
37 | return inet_ehashfn(laddr, lport, faddr, fport, ehash_size); | ||
38 | } | ||
39 | |||
40 | #endif /* _INET_HASHTABLES_H */ | ||