mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-21 08:53:41 +00:00
ba13c98405
In 295f7324ff
I moved defer_accept from
tcp_sock to request_queue and mistakingly reset it at reqsl_queue_alloc, causing
calls to setsockopt(TCP_DEFER_ACCEPT ) to be lost after bind, the fix is to
remove the zeroing of rskq_defer_accept from reqsl_queue_alloc.
Thanks to Alexandra N. Kossovsky <Alexandra.Kossovsky@oktetlabs.ru> for
reporting and testing the suggested fix.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
90 lines
2.5 KiB
C
90 lines
2.5 KiB
C
/*
|
|
* NET Generic infrastructure for Network protocols.
|
|
*
|
|
* Authors: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
|
|
*
|
|
* From code originally in include/net/tcp.h
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version
|
|
* 2 of the License, or (at your option) any later version.
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/random.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/string.h>
|
|
|
|
#include <net/request_sock.h>
|
|
|
|
/*
|
|
* Maximum number of SYN_RECV sockets in queue per LISTEN socket.
|
|
* One SYN_RECV socket costs about 80bytes on a 32bit machine.
|
|
* It would be better to replace it with a global counter for all sockets
|
|
* but then some measure against one socket starving all other sockets
|
|
* would be needed.
|
|
*
|
|
* It was 128 by default. Experiments with real servers show, that
|
|
* it is absolutely not enough even at 100conn/sec. 256 cures most
|
|
* of problems. This value is adjusted to 128 for very small machines
|
|
* (<=32Mb of memory) and to 1024 on normal or better ones (>=256Mb).
|
|
* Further increasing requires to change hash table size.
|
|
*/
|
|
int sysctl_max_syn_backlog = 256;
|
|
|
|
int reqsk_queue_alloc(struct request_sock_queue *queue,
|
|
const int nr_table_entries)
|
|
{
|
|
const int lopt_size = sizeof(struct listen_sock) +
|
|
nr_table_entries * sizeof(struct request_sock *);
|
|
struct listen_sock *lopt = kmalloc(lopt_size, GFP_KERNEL);
|
|
|
|
if (lopt == NULL)
|
|
return -ENOMEM;
|
|
|
|
memset(lopt, 0, lopt_size);
|
|
|
|
for (lopt->max_qlen_log = 6;
|
|
(1 << lopt->max_qlen_log) < sysctl_max_syn_backlog;
|
|
lopt->max_qlen_log++);
|
|
|
|
get_random_bytes(&lopt->hash_rnd, sizeof(lopt->hash_rnd));
|
|
rwlock_init(&queue->syn_wait_lock);
|
|
queue->rskq_accept_head = queue->rskq_accept_head = NULL;
|
|
lopt->nr_table_entries = nr_table_entries;
|
|
|
|
write_lock_bh(&queue->syn_wait_lock);
|
|
queue->listen_opt = lopt;
|
|
write_unlock_bh(&queue->syn_wait_lock);
|
|
|
|
return 0;
|
|
}
|
|
|
|
EXPORT_SYMBOL(reqsk_queue_alloc);
|
|
|
|
void reqsk_queue_destroy(struct request_sock_queue *queue)
|
|
{
|
|
/* make all the listen_opt local to us */
|
|
struct listen_sock *lopt = reqsk_queue_yank_listen_sk(queue);
|
|
|
|
if (lopt->qlen != 0) {
|
|
int i;
|
|
|
|
for (i = 0; i < lopt->nr_table_entries; i++) {
|
|
struct request_sock *req;
|
|
|
|
while ((req = lopt->syn_table[i]) != NULL) {
|
|
lopt->syn_table[i] = req->dl_next;
|
|
lopt->qlen--;
|
|
reqsk_free(req);
|
|
}
|
|
}
|
|
}
|
|
|
|
BUG_TRAP(lopt->qlen == 0);
|
|
kfree(lopt);
|
|
}
|
|
|
|
EXPORT_SYMBOL(reqsk_queue_destroy);
|