opkg: fix handling conffiles in status lists
[openwrt/staging/yousong.git] / package / network / services / dnsmasq / patches / 010-reduce-logging.patch
1 From 3e2496fb16fb78cb95fffdac80f967310a34b1fa Mon Sep 17 00:00:00 2001
2 From: Hannu Nyman <hannu.nyman@iki.fi>
3 Date: Sat, 11 Feb 2017 13:44:08 +0000
4 Subject: [PATCH] Decrease the number of individual sites listed in log.
5
6 By default 30 first servers are listed individually to system log, and
7 then a count of the remaining items. With e.g. a NXDOMAIN based adblock
8 service, dnsmasq lists 30 unnecessary ad sites every time when dnsmasq
9 evaluates the list. But the actual nameservers in use are evaluated last
10 and are not displayed as they get included in the "remaining items" total.
11
12 Handle the "local addresses only" separately and list only a few of them.
13 Remove the "local addresses only" from the general count.
14 ---
15 CHANGELOG | 4 ++++
16 src/config.h | 1 +
17 src/network.c | 9 ++++++++-
18 3 files changed, 13 insertions(+), 1 deletion(-)
19
20 diff --git a/CHANGELOG b/CHANGELOG
21 index 788aaf9..f7f5125 100644
22 --- a/CHANGELOG
23 +++ b/CHANGELOG
24 @@ -69,6 +69,10 @@ version 2.77
25 servers. Specifically, be prepared to open a new TCP
26 connection when we want to make multiple queries
27 but the upstream server accepts fewer queries per connection.
28 +
29 + Improve logging of upstream servers when there are a lot
30 + of "local addresses only" entries. Thanks to Hannu Nyman for
31 + the patch.
32
33
34 version 2.76
35 diff --git a/src/config.h b/src/config.h
36 index be9cf05..cf527b3 100644
37 --- a/src/config.h
38 +++ b/src/config.h
39 @@ -27,6 +27,7 @@
40 #define FORWARD_TEST 50 /* try all servers every 50 queries */
41 #define FORWARD_TIME 20 /* or 20 seconds */
42 #define SERVERS_LOGGED 30 /* Only log this many servers when logging state */
43 +#define LOCALS_LOGGED 8 /* Only log this many local addresses when logging state */
44 #define RANDOM_SOCKS 64 /* max simultaneous random ports */
45 #define LEASE_RETRY 60 /* on error, retry writing leasefile after LEASE_RETRY seconds */
46 #define CACHESIZ 150 /* default cache size */
47 diff --git a/src/network.c b/src/network.c
48 index 770558a..eb41624 100644
49 --- a/src/network.c
50 +++ b/src/network.c
51 @@ -1438,6 +1438,7 @@ void check_servers(void)
52 struct server *serv;
53 struct serverfd *sfd, *tmp, **up;
54 int port = 0, count;
55 + int locals = 0;
56
57 /* interface may be new since startup */
58 if (!option_bool(OPT_NOWILD))
59 @@ -1541,7 +1542,11 @@ void check_servers(void)
60 s1 = _("domain"), s2 = serv->domain;
61
62 if (serv->flags & SERV_NO_ADDR)
63 - my_syslog(LOG_INFO, _("using local addresses only for %s %s"), s1, s2);
64 + {
65 + count--;
66 + if (++locals <= LOCALS_LOGGED)
67 + my_syslog(LOG_INFO, _("using local addresses only for %s %s"), s1, s2);
68 + }
69 else if (serv->flags & SERV_USE_RESOLV)
70 my_syslog(LOG_INFO, _("using standard nameservers for %s %s"), s1, s2);
71 else
72 @@ -1558,6 +1563,8 @@ void check_servers(void)
73 }
74 }
75
76 + if (locals > LOCALS_LOGGED)
77 + my_syslog(LOG_INFO, _("using %d more local addresses"), locals - LOCALS_LOGGED);
78 if (count - 1 > SERVERS_LOGGED)
79 my_syslog(LOG_INFO, _("using %d more nameservers"), count - SERVERS_LOGGED - 1);
80
81 --
82 1.7.10.4
83