1 From a0088e83640d7d1544127dd668660462e9f78e52 Mon Sep 17 00:00:00 2001
2 From: Simon Kelley <simon@thekelleys.org.uk>
3 Date: Thu, 10 May 2018 21:43:14 +0100
4 Subject: [PATCH 06/17] Handle query retry on REFUSED or SERVFAIL for
5 DNSSEC-generated queries.
7 Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
9 src/forward.c | 46 ++++++++++++++++++++++++++++++++++++++++------
10 1 file changed, 40 insertions(+), 6 deletions(-)
14 @@ -298,9 +298,9 @@ static int forward_query(int udpfd, unio
15 fd = forward->rfd4->fd;
18 - while (retry_send( sendto(fd, (char *)header, plen, 0,
19 - &forward->sentto->addr.sa,
20 - sa_len(&forward->sentto->addr))));
21 + while (retry_send(sendto(fd, (char *)header, plen, 0,
22 + &forward->sentto->addr.sa,
23 + sa_len(&forward->sentto->addr))));
27 @@ -804,8 +804,7 @@ void reply_query(int fd, int family, tim
28 dump_packet((forward->flags & (FREC_DNSKEY_QUERY | FREC_DS_QUERY)) ? DUMP_SEC_REPLY : DUMP_UP_REPLY,
29 (void *)header, n, &serveraddr, NULL);
34 /* log_query gets called indirectly all over the place, so
35 pass these in global variables - sorry. */
36 daemon->log_display_id = forward->log_id;
37 @@ -826,6 +825,40 @@ void reply_query(int fd, int family, tim
41 + /* For DNSSEC originated queries, just retry the query to the same server. */
42 + if (forward->flags & (FREC_DNSKEY_QUERY | FREC_DS_QUERY))
44 + blockdata_retrieve(forward->stash, forward->stash_len, (void *)header);
45 + plen = forward->stash_len;
47 + forward->forwardall = 2; /* only retry once */
49 + if (forward->sentto->addr.sa.sa_family == AF_INET)
50 + log_query(F_NOEXTRA | F_DNSSEC | F_IPV4, "retry", (struct all_addr *)&forward->sentto->addr.in.sin_addr, "dnssec");
53 + log_query(F_NOEXTRA | F_DNSSEC | F_IPV6, "retry", (struct all_addr *)&forward->sentto->addr.in6.sin6_addr, "dnssec");
56 + if (forward->sentto->sfd)
57 + fd = forward->sentto->sfd->fd;
61 + if (forward->sentto->addr.sa.sa_family == AF_INET6)
62 + fd = forward->rfd6->fd;
65 + fd = forward->rfd4->fd;
68 + while (retry_send(sendto(fd, (char *)header, plen, 0,
69 + &forward->sentto->addr.sa,
70 + sa_len(&forward->sentto->addr))));
75 /* In strict order mode, there must be a server later in the chain
76 left to send to, otherwise without the forwardall mechanism,
77 code further on will cycle around the list forwever if they
78 @@ -1017,7 +1050,8 @@ void reply_query(int fd, int family, tim
82 - new->flags &= ~(FREC_DNSKEY_QUERY | FREC_DS_QUERY);
83 + new->flags &= ~(FREC_DNSKEY_QUERY | FREC_DS_QUERY | FREC_HAS_EXTRADATA);
84 + new->forwardall = 0;
86 new->dependent = forward; /* to find query awaiting new one. */
87 forward->blocking_query = new; /* for garbage cleaning */