netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Question]: reqsk table size limited to 16?
@ 2009-10-02  6:11 Gerrit Renker
  2009-10-02  6:25 ` Gerrit Renker
  2009-10-02  6:49 ` Eric Dumazet
  0 siblings, 2 replies; 4+ messages in thread
From: Gerrit Renker @ 2009-10-02  6:11 UTC (permalink / raw)
  To: netdev

Can someone please have a look, it may be that I am missing something?

It seems that in the following the maximum number of table entries is set
to always 16, despite sysctl_max_syn_backlog (tcp_max_syn_backlog), 
overriding the 'backlog' parameter to listen(2).

net/core/request_sock.c
-----------------------

int reqsk_queue_alloc(struct request_sock_queue *queue,
                      unsigned int nr_table_entries)
{
        size_t lopt_size = sizeof(struct listen_sock);
        struct listen_sock *lopt;

	nr_table_entries = min_t(u32, nr_table_entries, sysctl_max_syn_backlog);
        nr_table_entries = max_t(u32, nr_table_entries, 8);
        nr_table_entries = roundup_pow_of_two(nr_table_entries + 1);

	//...
	for (lopt->max_qlen_log = 3;
             (1 << lopt->max_qlen_log) < nr_table_entries;
             lopt->max_qlen_log++);

 	//...
	lopt->nr_table_entries = nr_table_entries;
	
	//...
	return 0
}

The function is called with an argument 'nr_table_entries', which is then clamped as

   sysctl_max_syn_backlog <= nr_table_entries <= 8

If nr_table_entries = 8, then round_pow_of_two(8 + 1) = 16.

The sysctl value is set to a much higher value (default 128 or 1024, net/ipv4/tcp.c).

The reqsk_queue_alloc() gets 'nr_table_entries' passed directly from inet_csk_listen_start(),
which in turn gets its 'nr_table_entries' as the 'backlog' argument to listen(2) via
 * net/dccp/proto.c   (dccp_listen_start) or
 * net/ipv4/af_inet.c (inet_listen).

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Question]: reqsk table size limited to 16?
  2009-10-02  6:11 [Question]: reqsk table size limited to 16? Gerrit Renker
@ 2009-10-02  6:25 ` Gerrit Renker
  2009-10-02  6:50   ` Eric Dumazet
  2009-10-02  6:49 ` Eric Dumazet
  1 sibling, 1 reply; 4+ messages in thread
From: Gerrit Renker @ 2009-10-02  6:25 UTC (permalink / raw)
  To: netdev

Please forget the posting, this is correct; the clamping is

  8 <= nr_table_entries <=  sysctl_max_syn_backlog,

i.e. the minimum table size is 16.

Quoting Gerrit:
| Can someone please have a look, it may be that I am missing something?
| 
| It seems that in the following the maximum number of table entries is set
| to always 16, despite sysctl_max_syn_backlog (tcp_max_syn_backlog), 
| overriding the 'backlog' parameter to listen(2).
| 
| net/core/request_sock.c
| -----------------------
| 
| int reqsk_queue_alloc(struct request_sock_queue *queue,
|                       unsigned int nr_table_entries)
| {
|         size_t lopt_size = sizeof(struct listen_sock);
|         struct listen_sock *lopt;
| 
| 	nr_table_entries = min_t(u32, nr_table_entries, sysctl_max_syn_backlog);
|         nr_table_entries = max_t(u32, nr_table_entries, 8);
|         nr_table_entries = roundup_pow_of_two(nr_table_entries + 1);
| 
| 	//...
| 	for (lopt->max_qlen_log = 3;
|              (1 << lopt->max_qlen_log) < nr_table_entries;
|              lopt->max_qlen_log++);
| 
|  	//...
| 	lopt->nr_table_entries = nr_table_entries;
| 	
| 	//...
| 	return 0
| }
| 
| The function is called with an argument 'nr_table_entries', which is then clamped as
| 
|    sysctl_max_syn_backlog <= nr_table_entries <= 8
| 
| If nr_table_entries = 8, then round_pow_of_two(8 + 1) = 16.
| 
| The sysctl value is set to a much higher value (default 128 or 1024, net/ipv4/tcp.c).
| 
| The reqsk_queue_alloc() gets 'nr_table_entries' passed directly from inet_csk_listen_start(),
| which in turn gets its 'nr_table_entries' as the 'backlog' argument to listen(2) via
|  * net/dccp/proto.c   (dccp_listen_start) or
|  * net/ipv4/af_inet.c (inet_listen).

-- 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Question]: reqsk table size limited to 16?
  2009-10-02  6:11 [Question]: reqsk table size limited to 16? Gerrit Renker
  2009-10-02  6:25 ` Gerrit Renker
@ 2009-10-02  6:49 ` Eric Dumazet
  1 sibling, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2009-10-02  6:49 UTC (permalink / raw)
  To: Gerrit Renker, netdev

Gerrit Renker a écrit :
> Can someone please have a look, it may be that I am missing something?
> 
> It seems that in the following the maximum number of table entries is set
> to always 16, despite sysctl_max_syn_backlog (tcp_max_syn_backlog), 
> overriding the 'backlog' parameter to listen(2).

False alarm ;)

> 
> net/core/request_sock.c
> -----------------------
> 
> int reqsk_queue_alloc(struct request_sock_queue *queue,
>                       unsigned int nr_table_entries)
> {
>         size_t lopt_size = sizeof(struct listen_sock);
>         struct listen_sock *lopt;
> 
> 	nr_table_entries = min_t(u32, nr_table_entries, sysctl_max_syn_backlog);

Here we take the _minimum_ value.
If you have  nr_table_entries=4096 and sysctl_max_syn_backlog=1024,
result is 1024

>         nr_table_entries = max_t(u32, nr_table_entries, 8);

Here we take the _maximum_ value of nr_table_entries and 8

-> 1024

Deal is : We want at least 8 slots, even if users called listen(fd, 1);

(Later, user can change its mind and call listen(fd, 1024).

We dont resize hashtable yet, so we guarantee at least 8 slots fot pathological cases.

>         nr_table_entries = roundup_pow_of_two(nr_table_entries + 1);
> 
> 	//...
> 	for (lopt->max_qlen_log = 3;
>              (1 << lopt->max_qlen_log) < nr_table_entries;
>              lopt->max_qlen_log++);
> 
>  	//...
> 	lopt->nr_table_entries = nr_table_entries;
> 	
> 	//...
> 	return 0
> }
> 
> The function is called with an argument 'nr_table_entries', which is then clamped as
> 
>    sysctl_max_syn_backlog <= nr_table_entries <= 8
> 
> If nr_table_entries = 8, then round_pow_of_two(8 + 1) = 16.
> 
> The sysctl value is set to a much higher value (default 128 or 1024, net/ipv4/tcp.c).
> 
> The reqsk_queue_alloc() gets 'nr_table_entries' passed directly from inet_csk_listen_start(),
> which in turn gets its 'nr_table_entries' as the 'backlog' argument to listen(2) via
>  * net/dccp/proto.c   (dccp_listen_start) or
>  * net/ipv4/af_inet.c (inet_listen).


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Question]: reqsk table size limited to 16?
  2009-10-02  6:25 ` Gerrit Renker
@ 2009-10-02  6:50   ` Eric Dumazet
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2009-10-02  6:50 UTC (permalink / raw)
  To: Gerrit Renker, netdev

Gerrit Renker a écrit :
> Please forget the posting, this is correct; the clamping is
> 
>   8 <= nr_table_entries <=  sysctl_max_syn_backlog,
> 
> i.e. the minimum table size is 16.
>

Yes, agreed, 8+1 -> 16


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-10-02  6:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-02  6:11 [Question]: reqsk table size limited to 16? Gerrit Renker
2009-10-02  6:25 ` Gerrit Renker
2009-10-02  6:50   ` Eric Dumazet
2009-10-02  6:49 ` Eric Dumazet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).