<div dir="ltr"><div>Of course patch is tested ;-)<br></div>Some output:<br>% ./src/dnsmasq --port 1025 --listen-backlog 100<br>% ss -ntl sport = :1025<br>Recv-Q Send-Q Local Address:Port Peer Address:Port<br>0 100 :::1025 :::*<br>0 100 *:1025<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 7, 2016 at 3:28 PM, Albert ARIBAUD <span dir="ltr"><<a href="mailto:albert.aribaud@free.fr" target="_blank">albert.aribaud@free.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Donatas,<br>
<br>
Le Wed, 7 Dec 2016 14:43:22 +0200<br>
Donatas Abraitis <<a href="mailto:donatas.abraitis@gmail.com">donatas.abraitis@gmail.com</a>> a écrit:<br>
<div><div class="h5"><br>
> Hi folks,<br>
><br>
> for our case at Hostinger, we have a problem while too much<br>
> TcpListenOverflows:<br>
> [root@us-imm-dns1 ~]# nstat -az | grep TcpExtListenOverflows<br>
> TcpExtListenOverflows 299 0.0<br>
> [root@us-imm-dns1 ~]# ss -ntl sport = :53<br>
> State Recv-Q Send-Q<br>
> Local<br>
> Address:Port<br>
> Peer Address:Port LISTEN 0<br>
> 5<br>
> *:53<br>
> *:*<br>
> LISTEN 0<br>
> 5<br>
> :::53<br>
> :::*<br>
><br>
> probe kernel.function("tcp_check_<wbr>req")<br>
> {<br>
> tcphdr = __get_skb_tcphdr($skb);<br>
> dport = __tcp_skb_dport(tcphdr)<br>
> if ($sk->sk_ack_backlog > $sk->sk_max_ack_backlog)<br>
> printf("listen queue for port(%d): %d/%d\n",<br>
> dport,<br>
> $sk->sk_ack_backlog,<br>
> $sk->sk_max_ack_backlog);<br>
> }<br>
><br>
> [root@us-imm-dns1 ~]# staprun overflow.ko<br>
> listen queue for port(53): 13/5<br>
> listen queue for port(53): 13/5<br>
> listen queue for port(53): 14/5<br>
><br>
> here is the proposed patch:<br>
><br>
> commit fa610cd424b905720832afc8636373<wbr>bb132f49c1<br>
> Author: Donatas Abraitis <<a href="mailto:donatas.abraitis@gmail.com">donatas.abraitis@gmail.com</a>><br>
> Date: Sun Dec 9 09:58:51 2012 +0200<br>
><br>
> Add `listen-backlog` option to override default 5 (too small)<br>
><br>
> diff --git a/src/dnsmasq.h b/src/dnsmasq.h<br>
> index 4b55bb5..b717df3 100644<br>
> --- a/src/dnsmasq.h<br>
> +++ b/src/dnsmasq.h<br>
> @@ -980,6 +980,7 @@ extern struct daemon {<br>
> struct dhcp_netid_list *force_broadcast, *bootp_dynamic;<br>
> struct hostsfile *dhcp_hosts_file, *dhcp_opts_file, *dynamic_dirs;<br>
> int dhcp_max, tftp_max, tftp_mtu;<br>
> + int listen_backlog;<br>
> int dhcp_server_port, dhcp_client_port;<br>
> int start_tftp_port, end_tftp_port;<br>
> unsigned int min_leasetime;<br>
> diff --git a/src/network.c b/src/network.c<br>
> index d87d08f..1e9d188 100644<br>
> --- a/src/network.c<br>
> +++ b/src/network.c<br>
> @@ -746,7 +746,7 @@ static int make_sock(union mysockaddr *addr, int<br>
> type, int dienow)<br>
><br>
> if (type == SOCK_STREAM)<br>
> {<br>
> - if (listen(fd, 5) == -1)<br>
> + if (listen(fd, daemon->listen_backlog) == -1)<br>
> goto err;<br>
> }<br>
> else if (family == AF_INET)<br>
> diff --git a/src/option.c b/src/option.c<br>
> index d0d9509..220303e 100644<br>
> --- a/src/option.c<br>
> +++ b/src/option.c<br>
> @@ -159,6 +159,7 @@ struct myoption {<br>
> #define LOPT_SCRIPT_ARP 347<br>
> #define LOPT_DHCPTTL 348<br>
> #define LOPT_TFTP_MTU 349<br>
> +#define LOPT_BACKLOG 350<br>
><br>
> #ifdef HAVE_GETOPT_LONG<br>
> static const struct option opts[] =<br>
> @@ -190,6 +191,7 @@ static const struct myoption opts[] =<br>
> { "domain-suffix", 1, 0, 's' },<br>
> { "interface", 1, 0, 'i' },<br>
> { "listen-address", 1, 0, 'a' },<br>
> + { "listen-backlog", 1, 0, LOPT_BACKLOG },<br>
> { "local-service", 0, 0, LOPT_LOCAL_SERVICE },<br>
> { "bogus-priv", 0, 0, 'b' },<br>
> { "bogus-nxdomain", 1, 0, 'B' },<br>
> @@ -394,6 +396,7 @@ static struct {<br>
> { 't', ARG_ONE, "<host_name>", gettext_noop("Specify default<br>
> target in an MX record."), NULL },<br>
> { 'T', ARG_ONE, "<integer>", gettext_noop("Specify time-to-live in<br>
> seconds for replies from /etc/hosts."), NULL },<br>
> { LOPT_NEGTTL, ARG_ONE, "<integer>", gettext_noop("Specify<br>
> time-to-live in seconds for negative caching."), NULL },<br>
> + { LOPT_BACKLOG, ARG_ONE, "<integer>", gettext_noop("Set the backlog<br>
> queue limit."), NULL },<br>
> { LOPT_MAXTTL, ARG_ONE, "<integer>", gettext_noop("Specify<br>
> time-to-live in seconds for maximum TTL to send to clients."), NULL },<br>
> { LOPT_MAXCTTL, ARG_ONE, "<integer>", gettext_noop("Specify<br>
> time-to-live ceiling for cache."), NULL },<br>
> { LOPT_MINCTTL, ARG_ONE, "<integer>", gettext_noop("Specify<br>
> time-to-live floor for cache."), NULL },<br>
> @@ -2286,7 +2289,11 @@ static int one_opt(int option, char *arg, char<br>
> *errstr, char *gen_err, int comma<br>
> ret_err(gen_err); /* error */<br>
> break;<br>
> }<br>
> -<br>
> +<br>
> + case LOPT_BACKLOG: /* --listen-backlog */<br>
> + if (!atoi_check(arg, &daemon->listen_backlog))<br>
> + ret_err(gen_err);<br>
> + break;<br>
> case 'a': /* --listen-address */<br>
> case LOPT_AUTHPEER: /* --auth-peer */<br>
> do {<br>
> @@ -4517,6 +4524,7 @@ void read_opts(int argc, char **argv, char<br>
> *compile_opts)<br>
> daemon->cachesize = CACHESIZ;<br>
> daemon->ftabsize = FTABSIZ;<br>
> daemon->port = NAMESERVER_PORT;<br>
> + daemon->listen_backlog = 5;<br>
> daemon->dhcp_client_port = DHCP_CLIENT_PORT;<br>
> daemon->dhcp_server_port = DHCP_SERVER_PORT;<br>
> daemon->default_resolv.is_<wbr>default = 1;<br>
<br>
</div></div>I am not qualified to determine if your patch is the right solution to<br>
your problem, but FWIW, I find this patch clear enough and I assume you<br>
have tested it :) and that it actually solves the issue for you. The<br>
only two remarks I have are:<br>
<br>
- it would be nice to also add a description for the option<br>
and its rationale to the manpage;<br>
<br>
- is there a way for dnsmasq to detect excessive backlog and emit a<br>
diagnostic message pointing the operator to the existence and use of<br>
the listen-backlog option, and if so, could you add this to the patch?<br>
<br>
Note that I am in no way a maintainer of dnsmasq, so neither my review<br>
nor my questions should be mistaken for an acceptation of the patch --<br>
only Simon can accept patches.<br>
<br>
Amicalement,<br>
<span class="HOEnZb"><font color="#888888">--<br>
Albert.<br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Donatas<br></div>
</div>