dnsmasq: fix ipv6 ipset bug
[oweals/openwrt.git] / package / network / services / dnsmasq / patches / 0004-Don-t-forward-.bind-.server-queries-upstream.patch
1 From cf5984367bc6a949e3803a576512c5a7bc48ebab Mon Sep 17 00:00:00 2001
2 From: Vladislav Grishenko <themiron@mail.ru>
3 Date: Thu, 18 Oct 2018 04:55:21 +0500
4 Subject: [PATCH 04/11] Don't forward *.bind/*.server queries upstream
5
6 Chaos .bind and .server (RFC4892) zones are local, therefore
7 don't forward queries upstream to avoid mixing with supported
8 locally and false replies with NO_ID enabled.
9
10 Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
11 ---
12  src/rfc1035.c | 15 ++++++++++++++-
13  1 file changed, 14 insertions(+), 1 deletion(-)
14
15 --- a/src/rfc1035.c
16 +++ b/src/rfc1035.c
17 @@ -1276,7 +1276,7 @@ size_t answer_request(struct dns_header
18    int q, ans, anscount = 0, addncount = 0;
19    int dryrun = 0;
20    struct crec *crecp;
21 -  int nxdomain = 0, auth = 1, trunc = 0, sec_data = 1;
22 +  int nxdomain = 0, notimp = 0, auth = 1, trunc = 0, sec_data = 1;
23    struct mx_srv_record *rec;
24    size_t len;
25  
26 @@ -1355,6 +1355,17 @@ size_t answer_request(struct dns_header
27             }
28         }
29  
30 +      if (qclass == C_CHAOS)
31 +       {
32 +         /* don't forward *.bind and *.server chaos queries */
33 +         if (hostname_issubdomain("bind", name) || hostname_issubdomain("server", name))
34 +           {
35 +             if (!ans)
36 +               notimp = 1, auth = 0;
37 +             ans = 1;
38 +           }
39 +       }
40 +
41        if (qclass == C_IN)
42         {
43           struct txt_record *t;
44 @@ -1903,6 +1914,8 @@ size_t answer_request(struct dns_header
45    
46    if (nxdomain)
47      SET_RCODE(header, NXDOMAIN);
48 +  else if (notimp)
49 +    SET_RCODE(header, NOTIMP);
50    else
51      SET_RCODE(header, NOERROR); /* no error */
52    header->ancount = htons(anscount);