diff options
author | Simon Kelley <simon@thekelleys.org.uk> | 2022-09-12 15:28:46 +0100 |
---|---|---|
committer | Simon Kelley <simon@thekelleys.org.uk> | 2022-09-12 15:28:46 +0100 |
commit | 92eab03b122358bf9bbd657bbb175bb3d2e22ab8 (patch) | |
tree | 86a1ee2ed39308f8bfc15fe99127826253b8b97e | |
parent | 1ba4ae28303b90ebd14b2dd9cda7a01f79e370ee (diff) | |
download | dnsmasq-92eab03b122358bf9bbd657bbb175bb3d2e22ab8.tar.gz |
Return EDE_STALE extended error when returning stale data from cache.
-rw-r--r-- | src/forward.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/forward.c b/src/forward.c index f1d8f7d..7d85cf7 100644 --- a/src/forward.c +++ b/src/forward.c @@ -596,7 +596,7 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr, } /* Check if any frecs need to do a retry, and action that if so. - Return time in milliseconds until he next retyr will be required, + Return time in milliseconds until he next retry will be required, or -1 if none. */ int fast_retry(time_t now) { @@ -1790,6 +1790,13 @@ void receive_query(struct listener *listen, time_t now) if (m >= 1) { + if (stale && have_pseudoheader) + { + u16 swap = htons(EDE_STALE); + + m = add_pseudoheader(header, m, ((unsigned char *) header) + udp_size, daemon->edns_pktsz, + EDNS0_OPTION_EDE, (unsigned char *)&swap, 2, do_bit, 0); + } #ifdef HAVE_DUMPFILE dump_packet_udp(DUMP_REPLY, daemon->packet, m, NULL, &source_addr, listen->fd); #endif @@ -2390,6 +2397,12 @@ unsigned char *tcp_request(int confd, time_t now, m = add_pseudoheader(header, m, ((unsigned char *) header) + 65536, daemon->edns_pktsz, 0, NULL, 0, do_bit, 0); } } + else if (stale) + { + u16 swap = htons((u16)EDE_STALE); + + m = add_pseudoheader(header, m, ((unsigned char *) header) + 65536, daemon->edns_pktsz, EDNS0_OPTION_EDE, (unsigned char *)&swap, 2, do_bit, 0); + } check_log_writer(1); |