diff options
author | Arnaldo Carvalho de Melo <acme@ghostprotocols.net> | 2005-08-09 23:09:30 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2005-08-29 18:42:13 -0400 |
commit | 8feaf0c0a5488b3d898a9c207eb6678f44ba3f26 (patch) | |
tree | ddd004afe2f7c8295f6fdb94d34f78a42b5961cb /include/net/inet_hashtables.h | |
parent | 33b62231908c58ae04185e4f1063d1e35a7c8576 (diff) |
[INET]: Generalise tcp_tw_bucket, aka TIME_WAIT sockets
This paves the way to generalise the rest of the sock ID lookup
routines and saves some bytes in TCPv4 TIME_WAIT sockets on distro
kernels (where IPv6 is always built as a module):
[root@qemu ~]# grep tw_sock /proc/slabinfo
tw_sock_TCPv6 0 0 128 31 1
tw_sock_TCP 0 0 96 41 1
[root@qemu ~]#
Now if a protocol wants to use the TIME_WAIT generic infrastructure it
only has to set the sk_prot->twsk_obj_size field with the size of its
inet_timewait_sock derived sock and proto_register will create
sk_prot->twsk_slab, for now its only for INET sockets, but we can
introduce timewait_sock later if some non INET transport protocolo
wants to use this stuff.
Next changesets will take advantage of this new infrastructure to
generalise even more TCP code.
[acme@toy net-2.6.14]$ grep built-in /tmp/before.size /tmp/after.size
/tmp/before.size: 188646 11764 5068 205478 322a6 net/ipv4/built-in.o
/tmp/after.size: 188144 11764 5068 204976 320b0 net/ipv4/built-in.o
[acme@toy net-2.6.14]$
Tested with both IPv4 & IPv6 (::1 (localhost) & ::ffff:172.20.0.1
(qemu host)).
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/inet_hashtables.h')
-rw-r--r-- | include/net/inet_hashtables.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h index 1c4fa0065a8e..c38c637e0734 100644 --- a/include/net/inet_hashtables.h +++ b/include/net/inet_hashtables.h | |||
@@ -14,6 +14,8 @@ | |||
14 | #ifndef _INET_HASHTABLES_H | 14 | #ifndef _INET_HASHTABLES_H |
15 | #define _INET_HASHTABLES_H | 15 | #define _INET_HASHTABLES_H |
16 | 16 | ||
17 | #include <linux/config.h> | ||
18 | |||
17 | #include <linux/interrupt.h> | 19 | #include <linux/interrupt.h> |
18 | #include <linux/ip.h> | 20 | #include <linux/ip.h> |
19 | #include <linux/ipv6.h> | 21 | #include <linux/ipv6.h> |
@@ -310,4 +312,43 @@ sherry_cache: | |||
310 | read_unlock(&hashinfo->lhash_lock); | 312 | read_unlock(&hashinfo->lhash_lock); |
311 | return sk; | 313 | return sk; |
312 | } | 314 | } |
315 | |||
316 | /* Socket demux engine toys. */ | ||
317 | #ifdef __BIG_ENDIAN | ||
318 | #define INET_COMBINED_PORTS(__sport, __dport) \ | ||
319 | (((__u32)(__sport) << 16) | (__u32)(__dport)) | ||
320 | #else /* __LITTLE_ENDIAN */ | ||
321 | #define INET_COMBINED_PORTS(__sport, __dport) \ | ||
322 | (((__u32)(__dport) << 16) | (__u32)(__sport)) | ||
323 | #endif | ||
324 | |||
325 | #if (BITS_PER_LONG == 64) | ||
326 | #ifdef __BIG_ENDIAN | ||
327 | #define INET_ADDR_COOKIE(__name, __saddr, __daddr) \ | ||
328 | const __u64 __name = (((__u64)(__saddr)) << 32) | ((__u64)(__daddr)); | ||
329 | #else /* __LITTLE_ENDIAN */ | ||
330 | #define INET_ADDR_COOKIE(__name, __saddr, __daddr) \ | ||
331 | const __u64 __name = (((__u64)(__daddr)) << 32) | ((__u64)(__saddr)); | ||
332 | #endif /* __BIG_ENDIAN */ | ||
333 | #define INET_MATCH(__sk, __cookie, __saddr, __daddr, __ports, __dif)\ | ||
334 | (((*((__u64 *)&(inet_sk(__sk)->daddr))) == (__cookie)) && \ | ||
335 | ((*((__u32 *)&(inet_sk(__sk)->dport))) == (__ports)) && \ | ||
336 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) | ||
337 | #define INET_TW_MATCH(__sk, __cookie, __saddr, __daddr, __ports, __dif)\ | ||
338 | (((*((__u64 *)&(inet_twsk(__sk)->tw_daddr))) == (__cookie)) && \ | ||
339 | ((*((__u32 *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ | ||
340 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) | ||
341 | #else /* 32-bit arch */ | ||
342 | #define INET_ADDR_COOKIE(__name, __saddr, __daddr) | ||
343 | #define INET_MATCH(__sk, __cookie, __saddr, __daddr, __ports, __dif) \ | ||
344 | ((inet_sk(__sk)->daddr == (__saddr)) && \ | ||
345 | (inet_sk(__sk)->rcv_saddr == (__daddr)) && \ | ||
346 | ((*((__u32 *)&(inet_sk(__sk)->dport))) == (__ports)) && \ | ||
347 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) | ||
348 | #define INET_TW_MATCH(__sk, __cookie, __saddr, __daddr, __ports, __dif) \ | ||
349 | ((inet_twsk(__sk)->tw_daddr == (__saddr)) && \ | ||
350 | (inet_twsk(__sk)->tw_rcv_saddr == (__daddr)) && \ | ||
351 | ((*((__u32 *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ | ||
352 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) | ||
353 | #endif /* 64-bit arch */ | ||
313 | #endif /* _INET_HASHTABLES_H */ | 354 | #endif /* _INET_HASHTABLES_H */ |