/[smeserver]/rpms/djbdns/sme9/250-dnscache-slogging.patch
ViewVC logotype

Annotation of /rpms/djbdns/sme9/250-dnscache-slogging.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Wed Jul 12 04:56:18 2017 UTC (7 years, 4 months ago) by unnilennium
Branch: MAIN
CVS Tags: djbdns-1_05-11_el6_sme, djbdns-1_05-9_el6_sme, djbdns-1_05-10_el6_sme, HEAD
* Tue Jul 11 2017 Jean-Philipe Pialasse <tests@pialasse.com> 1.05-9.sme
-- backport SME10 fixes [SME: 10381]
--import patches from openwrt and rename already applied patches
--fix security issues [SME: 10374]
- 020-dnsroots-update.patch: update list of root DNS servers
- 070-dnscache-dpos-tcp-servfail.patch: SERVFAIL rename previous patch dns_transmit-bug.patch
- 210-dnscache-strict-forwardonly.patch: rename previous patch dnscache-strict-forwardonly.patch
- 270-dnscache-sigpipe-fix.patch: SIGPIPE
- 300-bugfix-dnscache-dempsky-poison.patch: CVE-2009-0858
- 310-bugfix-dnscache-merge-outgoing-requests.patch: CVE-2008-4392
- 320-bugfix-dnscache-cache-soa-records.patch: CVE-2008-4392
- 450-dnscache-ghost-domain-CVE-2012-1191.patch: CVE-2012-1191 http://marc.info/?l=djbdns&m=134190748729079&w=2
--bug fixes [SME: 10374]
- 060-dnscache-big-udp-packets.patch: accept and handle longer than 512 bytes UDP packets
- 230-tinydns-data-semantic-error.patch: handle semantic error to avoid publishing false dns records
- 240-tinydns-alias-chain-truncation.patch: rename previous patch tinydns-alias-chain-truncation.patch
--fix issue with short ttl cname like akamaid [SME: 8362]
- 200-dnscache-cname-handling.patch: rename previous patch dnscache-cname-handling.patch
- 330-fix-dnscache-cname-handling.patch: fix dnscache cname for short ttl
- 500-cutom-dnscache-maxloop.patch: set max loop to 200
--needed for previous patches to apply cleanly
- 030-srv-records-and-axfrget.patch: add SRV record type and axfr-get decompose SRC and PTR records (for 230-*.patch)
- 080-dnscache-cache-negatives.patch: rfc2308 ? (for 200-*.patch)
- 090-tinydns-one-second.patch: improve tinydns with 8 or more  concurent connections (for 240-*.patch)
- 120-compiler-temporary-filename.patch: change tmp filename to avoid conflicts (for 230-*.patch)
--not backported from SME10 branch
- 050-tinydns-mmap-leak.patch: report cdb leak

1 unnilennium 1.1 --- a/server.c
2     +++ b/server.c
3     @@ -25,12 +25,63 @@ static int len;
4    
5     static char *q;
6    
7     +static uint64 stats_numq;
8     +static uint64 stats_plus;
9     +static uint64 stats_minus;
10     +static uint64 stats_nx;
11     +static uint64 stats_notimp;
12     +static uint64 stats_weird;
13     +static uint64 stats_noq;
14     +
15     +/* work around gcc 2.95.2 bug */
16     +#define number(x) ( (u64 = (x)), u64_print() )
17     +static uint64 u64;
18     +static void u64_print(void)
19     +{
20     + char ubuf[20];
21     + unsigned int pos;
22     +
23     + pos = sizeof ubuf;
24     + do {
25     + if (!pos) break;
26     + ubuf[--pos] = '0' + (u64 % 10);
27     + u64 /= 10;
28     + } while(u64);
29     +
30     + buffer_put(buffer_2,ubuf + pos,sizeof ubuf - pos);
31     +}
32     +
33     +static void string(const char *s)
34     +{
35     + buffer_puts(buffer_2,s);
36     +}
37     +
38     +static void line(void)
39     +{
40     + string("\n");
41     + buffer_flush(buffer_2);
42     +}
43     +
44     +static void log_stats(void)
45     +{
46     + string("stats ");
47     + number(stats_numq); string(" ");
48     + number(stats_plus); string(" ");
49     + number(stats_minus); string(" ");
50     + number(stats_nx); string(" ");
51     + number(stats_notimp); string(" ");
52     + number(stats_weird); string(" ");
53     + number(stats_noq);
54     + line();
55     +}
56     +
57     static int doit(void)
58     {
59     unsigned int pos;
60     char header[12];
61     char qtype[2];
62     char qclass[2];
63     + stats_numq++;
64    
65     if (len >= sizeof buf) goto NOQ;
66     pos = dns_packet_copy(buf,len,0,header,12); if (!pos) goto NOQ;
67     @@ -56,25 +107,37 @@ static int doit(void)
68    
69     case_lowerb(q,dns_domain_length(q));
70     if (!respond(q,qtype,ip)) {
71     + stats_minus++;
72     qlog(ip,port,header,q,qtype," - ");
73     return 0;
74     }
75     - qlog(ip,port,header,q,qtype," + ");
76     +
77     + if ((response[2] & 4) && (response[3] & 3)) {
78     + stats_nx++;
79     + qlog(ip,port,header,q,qtype," N ");
80     + }
81     + else {
82     + stats_plus++;
83     + qlog(ip,port,header,q,qtype," + ");
84     + }
85     return 1;
86    
87     NOTIMP:
88     + stats_notimp++;
89     response[3] &= ~15;
90     response[3] |= 4;
91     qlog(ip,port,header,q,qtype," I ");
92     return 1;
93    
94     WEIRDCLASS:
95     + stats_weird++;
96     response[3] &= ~15;
97     response[3] |= 1;
98     qlog(ip,port,header,q,qtype," C ");
99     return 1;
100    
101     NOQ:
102     + stats_noq++;
103     qlog(ip,port,"\0\0","","\0\0"," / ");
104     return 0;
105     }
106     @@ -83,6 +146,7 @@ int main()
107     {
108     char *x;
109     int udp53;
110     + unsigned char flag=0;
111    
112     x = env_get("IP");
113     if (!x)
114     @@ -106,6 +170,8 @@ int main()
115     buffer_putsflush(buffer_2,starting);
116    
117     for (;;) {
118     + if ((flag++)%32==1)
119     + log_stats();
120     len = socket_recv4(udp53,buf,sizeof buf,ip,&port);
121     if (len < 0) continue;
122     if (!doit()) continue;

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed