From: Florian Obser Subject: dig(1): Implement RESINFO (RFC 9606) To: tech Date: Sun, 08 Dec 2024 09:20:13 +0100 RESINFO is just a weird spelling for txt: | 4. Format of the Resolver Information | | The resolver information record uses the same format as DNS TXT records. It can be tested thusly: $ dig @resolver64.dns4all.eu resolver64.dns4all.eu RESINFO ; <<>> dig 9.10.8-P1 <<>> @resolver64.dns4all.eu resolver64.dns4all.eu RESINFO ; (2 servers found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29370 ;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 1232 ;; QUESTION SECTION: ;resolver64.dns4all.eu. IN RESINFO ;; ANSWER SECTION: resolver64.dns4all.eu. 2551 IN RESINFO "qnamemin temp-dnssecval temp-dns64 infourl=https://dns4all.eu" ;; Query time: 46 msec ;; SERVER: 2001:678:8::64#53(2001:678:8::64) ;; WHEN: Sun Dec 08 09:12:38 CET 2024 ;; MSG SIZE rcvd: 124 btw. I don't think dns4all.eu implements RESINFO correctly. | The DNS client MUST set the Recursion Desired (RD) bit of the query to | 0. The DNS client MUST discard the response if the AA flag in the | response is set to 0, indicating that the DNS resolver is not | authoritative for the response. The answer does not have AA set and if I query with +norec I get REFUSED. But never mind that, that's a problem on the server side. OK? diff --git lib/dns/include/dns/types.h lib/dns/include/dns/types.h index 88dfe4fa312..0efc49d4927 100644 --- lib/dns/include/dns/types.h +++ lib/dns/include/dns/types.h @@ -150,6 +150,7 @@ enum { dns_rdatatype_caa = 257, dns_rdatatype_avc = 258, dns_rdatatype_doa = 259, + dns_rdatatype_resinfo = 261, dns_rdatatype_ta = 32768, dns_rdatatype_dlv = 32769, dns_rdatatype_keydata = 65533, diff --git lib/dns/rdata.c lib/dns/rdata.c index 395f3cf1262..e6d91c67df8 100644 --- lib/dns/rdata.c +++ lib/dns/rdata.c @@ -811,6 +811,7 @@ dns_rdatatype_fromtext(dns_rdatatype_t *typep, isc_textregion_t *source) { {"ptr", 12}, {"px", 26}, {"reserved0", 0}, + {"resinfo", 261}, {"rkey", 57}, {"rp", 17}, {"rrsig", 46}, @@ -1055,6 +1056,8 @@ dns_rdatatype_totext(dns_rdatatype_t type, isc_buffer_t *target) { return (isc_str_tobuffer("AVC", target)); case 259: return (isc_str_tobuffer("DOA", target)); + case 261: + return (isc_str_tobuffer("RESINFO", target)); case 32768: return (isc_str_tobuffer("TA", target)); case 32769: diff --git lib/dns/rdata/generic/resinfo_261.c lib/dns/rdata/generic/resinfo_261.c new file mode 100644 index 00000000000..6ad04d04f2d --- /dev/null +++ lib/dns/rdata/generic/resinfo_261.c @@ -0,0 +1,83 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* RFC 9606, based on txt_16.c */ + +#ifndef RDATA_GENERIC_RESINFO_261_C +#define RDATA_GENERIC_RESINFO_261_C + +static inline isc_result_t +generic_totext_resinfo(ARGS_TOTEXT) { + isc_region_t region; + + UNUSED(tctx); + + dns_rdata_toregion(rdata, ®ion); + + while (region.length > 0) { + RETERR(txt_totext(®ion, 1, target)); + if (region.length > 0) + RETERR(isc_str_tobuffer(" ", target)); + } + + return (ISC_R_SUCCESS); +} + +static inline isc_result_t +generic_fromwire_resinfo(ARGS_FROMWIRE) { + isc_result_t result; + + UNUSED(type); + UNUSED(dctx); + UNUSED(rdclass); + UNUSED(options); + + do { + result = txt_fromwire(source, target); + if (result != ISC_R_SUCCESS) + return (result); + } while (!buffer_empty(source)); + return (ISC_R_SUCCESS); +} + +static inline isc_result_t +totext_resinfo(ARGS_TOTEXT) { + + REQUIRE(rdata->type == dns_rdatatype_resinfo); + + return (generic_totext_resinfo(rdata, tctx, target)); +} + +static inline isc_result_t +fromwire_resinfo(ARGS_FROMWIRE) { + + REQUIRE(type == dns_rdatatype_resinfo); + + return (generic_fromwire_resinfo(rdclass, type, source, dctx, options, + target)); +} + +static inline isc_result_t +towire_resinfo(ARGS_TOWIRE) { + + REQUIRE(rdata->type == dns_rdatatype_resinfo); + + UNUSED(cctx); + + return (isc_mem_tobuffer(target, rdata->data, rdata->length)); +} + +#endif /* RDATA_GENERIC_RESINFO_261_C */ -- In my defence, I have been left unsupervised.