diff options
| author | Arnaldo Carvalho de Melo <acme@ghostprotocols.net> | 2005-06-19 01:47:59 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2005-06-19 01:47:59 -0400 |
| commit | 0e87506fcc734647c7b2497eee4eb81e785c857a (patch) | |
| tree | bb8863c59fdef2628f17b6773c52801792a57722 /net/core | |
| parent | 60236fdd08b2169045a3bbfc5ffe1576e6c3c17b (diff) | |
[NET] Generalise tcp_listen_opt
This chunks out the accept_queue and tcp_listen_opt code and moves
them to net/core/request_sock.c and include/net/request_sock.h, to
make it useful for other transport protocols, DCCP being the first one
to use it.
Next patches will rename tcp_listen_opt to accept_sock and remove the
inline tcp functions that just call a reqsk_queue_ function.
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
| -rw-r--r-- | net/core/Makefile | 3 | ||||
| -rw-r--r-- | net/core/request_sock.c | 48 |
2 files changed, 50 insertions, 1 deletions
diff --git a/net/core/Makefile b/net/core/Makefile index 81f03243fe2f..5e0c56b7f607 100644 --- a/net/core/Makefile +++ b/net/core/Makefile | |||
| @@ -2,7 +2,8 @@ | |||
| 2 | # Makefile for the Linux networking core. | 2 | # Makefile for the Linux networking core. |
| 3 | # | 3 | # |
| 4 | 4 | ||
| 5 | obj-y := sock.o skbuff.o iovec.o datagram.o stream.o scm.o gen_stats.o gen_estimator.o | 5 | obj-y := sock.o request_sock.o skbuff.o iovec.o datagram.o stream.o scm.o \ |
| 6 | gen_stats.o gen_estimator.o | ||
| 6 | 7 | ||
| 7 | obj-$(CONFIG_SYSCTL) += sysctl_net_core.o | 8 | obj-$(CONFIG_SYSCTL) += sysctl_net_core.o |
| 8 | 9 | ||
diff --git a/net/core/request_sock.c b/net/core/request_sock.c new file mode 100644 index 000000000000..1258333ca007 --- /dev/null +++ b/net/core/request_sock.c | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | /* | ||
| 2 | * NET Generic infrastructure for Network protocols. | ||
| 3 | * | ||
| 4 | * Authors: Arnaldo Carvalho de Melo <acme@conectiva.com.br> | ||
| 5 | * | ||
| 6 | * From code originally in include/net/tcp.h | ||
| 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 | #include <linux/module.h> | ||
| 15 | #include <linux/random.h> | ||
| 16 | #include <linux/slab.h> | ||
| 17 | #include <linux/string.h> | ||
| 18 | |||
| 19 | #include <net/request_sock.h> | ||
| 20 | |||
| 21 | int reqsk_queue_alloc(struct request_sock_queue *queue, | ||
| 22 | const int nr_table_entries) | ||
| 23 | { | ||
| 24 | const int lopt_size = sizeof(struct tcp_listen_opt) + | ||
| 25 | nr_table_entries * sizeof(struct request_sock *); | ||
| 26 | struct tcp_listen_opt *lopt = kmalloc(lopt_size, GFP_KERNEL); | ||
| 27 | |||
| 28 | if (lopt == NULL) | ||
| 29 | return -ENOMEM; | ||
| 30 | |||
| 31 | memset(lopt, 0, lopt_size); | ||
| 32 | |||
| 33 | for (lopt->max_qlen_log = 6; | ||
| 34 | (1 << lopt->max_qlen_log) < sysctl_max_syn_backlog; | ||
| 35 | lopt->max_qlen_log++); | ||
| 36 | |||
| 37 | get_random_bytes(&lopt->hash_rnd, sizeof(lopt->hash_rnd)); | ||
| 38 | rwlock_init(&queue->syn_wait_lock); | ||
| 39 | queue->rskq_accept_head = queue->rskq_accept_head = NULL; | ||
| 40 | |||
| 41 | write_lock_bh(&queue->syn_wait_lock); | ||
| 42 | queue->listen_opt = lopt; | ||
| 43 | write_unlock_bh(&queue->syn_wait_lock); | ||
| 44 | |||
| 45 | return 0; | ||
| 46 | } | ||
| 47 | |||
| 48 | EXPORT_SYMBOL(reqsk_queue_alloc); | ||
