Hi David,
This one completes the last changeset, moving the renamed functions
to inet_hashtables.[ch], if you agree on the two last ones pull this one +
the others from:
rsync://rsync.kernel.org/pub/scm/linux/kernel/git/acme/net-2.6.14-2.git
The last two ones are still at:
rsync://rsync.kernel.org/pub/scm/linux/kernel/git/acme/net-2.6.14.git
- Arnaldo
tree 710e860893e851f8a1d67226eff976bf3fc5284a
parent d34ba5a1e4806bba06e16b19e1ea13131c2a45aa
author Arnaldo Carvalho de Melo <[EMAIL PROTECTED]> 1122864914 -0300
committer Arnaldo Carvalho de Melo <[EMAIL PROTECTED]> 1122864914 -0300
[INET] Move the TCP hashtable functions/structs to inet_hashtables.[ch]
Signed-off-by: Arnaldo Carvalho de Melo <[EMAIL PROTECTED]>
Signed-off-by: David S. Miller <[EMAIL PROTECTED]>
--
include/net/inet_common.h |5 +
include/net/inet_hashtables.h | 122 ++
include/net/tcp.h | 120 -
net/ipv4/Makefile |2
net/ipv4/inet_hashtables.c| 51 +
net/ipv4/tcp_ipv4.c | 26
6 files changed, 181 insertions(+), 145 deletions(-)
--
diff --git a/include/net/inet_common.h b/include/net/inet_common.h
--- a/include/net/inet_common.h
+++ b/include/net/inet_common.h
@@ -8,6 +8,11 @@ extern struct proto_opsinet_dgram_ops;
* INET4 prototypes used by INET6
*/
+struct msghdr;
+struct sock;
+struct sockaddr;
+struct socket;
+
extern voidinet_remove_sock(struct sock *sk1);
extern voidinet_put_sock(unsigned short num,
struct sock *sk);
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h
--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -14,8 +14,107 @@
#ifndef _INET_HASHTABLES_H
#define _INET_HASHTABLES_H
+#include
+#include
+#include
+#include
#include
+/* This is for all connections with a full identity, no wildcards.
+ * New scheme, half the table is for TIME_WAIT, the other half is
+ * for the rest. I'll experiment with dynamic table growth later.
+ */
+struct inet_ehash_bucket {
+ rwlock_t lock;
+ struct hlist_head chain;
+} __attribute__((__aligned__(8)));
+
+/* There are a few simple rules, which allow for local port reuse by
+ * an application. In essence:
+ *
+ * 1) Sockets bound to different interfaces may share a local port.
+ *Failing that, goto test 2.
+ * 2) If all sockets have sk->sk_reuse set, and none of them are in
+ *TCP_LISTEN state, the port may be shared.
+ *Failing that, goto test 3.
+ * 3) If all sockets are bound to a specific inet_sk(sk)->rcv_saddr local
+ *address, and none of them are the same, the port may be
+ *shared.
+ *Failing this, the port cannot be shared.
+ *
+ * The interesting point, is test #2. This is what an FTP server does
+ * all day. To optimize this case we use a specific flag bit defined
+ * below. As we add sockets to a bind bucket list, we perform a
+ * check of: (newsk->sk_reuse && (newsk->sk_state != TCP_LISTEN))
+ * As long as all sockets added to a bind bucket pass this test,
+ * the flag bit will be set.
+ * The resulting situation is that tcp_v[46]_verify_bind() can just check
+ * for this flag bit, if it is set and the socket trying to bind has
+ * sk->sk_reuse set, we don't even have to walk the owners list at all,
+ * we return that it is ok to bind this socket to the requested local port.
+ *
+ * Sounds like a lot of work, but it is worth it. In a more naive
+ * implementation (ie. current FreeBSD etc.) the entire list of ports
+ * must be walked for each data port opened by an ftp server. Needless
+ * to say, this does not scale at all. With a couple thousand FTP
+ * users logged onto your box, isn't it nice to know that new data
+ * ports are created in O(1) time? I thought so. ;-) -DaveM
+ */
+struct inet_bind_bucket {
+ unsigned short port;
+ signed shortfastreuse;
+ struct hlist_node node;
+ struct hlist_head owners;
+};
+
+#define inet_bind_bucket_for_each(tb, node, head) \
+ hlist_for_each_entry(tb, node, head, node)
+
+struct inet_bind_hashbucket {
+ spinlock_t lock;
+ struct hlist_head chain;
+};
+
+/* This is for listening sockets, thus all sockets which possess wildcards. */
+#define INET_LHTABLE_SIZE 32 /* Yes, really, this is all you need. */
+
+struct inet_hashinfo {
+ /* This is for sockets with full identity only. Sockets here will
+* always be without wildcards and will have the following invariant:
+*
+* TCP_ESTABLIS