From: Mark Andrews Date: Mon, 6 Nov 2023 13:50:11 +0000 (+1100) Subject: Add minimal EDNS UL option support X-Git-Tag: v9.19.22~73^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8f0f6d05e95acd6d5b19c598f526df99c88ca821;p=thirdparty%2Fbind9.git Add minimal EDNS UL option support This is defined in draft-ietf-dnssd-update-lease. This adds the ability to display the option and teaches dig about the name 'UL'. --- diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index b9ceaa22dd9..a02b4cbff98 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -1388,6 +1388,7 @@ typedef struct dig_ednsoptname { dig_ednsoptname_t optnames[] = { { 1, "LLQ" }, /* draft-sekar-dns-llq */ + { 2, "UL" }, /* draft-ietf-dnssd-update-lease */ { 3, "NSID" }, /* RFC 5001 */ { 5, "DAU" }, /* RFC 6975 */ { 6, "DHU" }, /* RFC 6975 */ diff --git a/lib/dns/include/dns/message.h b/lib/dns/include/dns/message.h index dc0c05846f6..cda53f3c8ce 100644 --- a/lib/dns/include/dns/message.h +++ b/lib/dns/include/dns/message.h @@ -103,6 +103,7 @@ /*%< EDNS0 extended OPT codes */ #define DNS_OPT_LLQ 1 /*%< LLQ opt code */ +#define DNS_OPT_UL 2 /*%< UL opt code */ #define DNS_OPT_NSID 3 /*%< NSID opt code */ #define DNS_OPT_CLIENT_SUBNET 8 /*%< client subnet opt code */ #define DNS_OPT_EXPIRE 9 /*%< EXPIRE opt code */ diff --git a/lib/dns/message.c b/lib/dns/message.c index c85e579b02f..e61f6b6142c 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -3428,7 +3428,7 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section, dns_rdataset_t *ps = NULL; const dns_name_t *name = NULL; isc_result_t result = ISC_R_SUCCESS; - char buf[sizeof("1234567890")]; + char buf[sizeof("/1234567890")]; uint32_t mbz; dns_rdata_t rdata; isc_buffer_t optbuf; @@ -3520,6 +3520,39 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section, ADD_STRING(target, "\n"); continue; } + } else if (optcode == DNS_OPT_UL) { + INDENT(style); + ADD_STRING(target, "UL:"); + if (optlen == 4U || optlen == 8U) { + uint32_t secs, key = 0; + secs = isc_buffer_getuint32(&optbuf); + snprintf(buf, sizeof(buf), " %u", secs); + ADD_STRING(target, buf); + if (optlen == 8U) { + key = isc_buffer_getuint32( + &optbuf); + snprintf(buf, sizeof(buf), + "/%u", key); + ADD_STRING(target, buf); + } + ADD_STRING(target, " ("); + result = dns_ttl_totext(secs, true, + true, target); + if (result != ISC_R_SUCCESS) { + goto cleanup; + } + if (optlen == 8U) { + ADD_STRING(target, "/"); + result = dns_ttl_totext( + key, true, true, + target); + if (result != ISC_R_SUCCESS) { + goto cleanup; + } + } + ADD_STRING(target, ")\n"); + continue; + } } else if (optcode == DNS_OPT_NSID) { INDENT(style); ADD_STRING(target, "NSID:"); @@ -3880,6 +3913,38 @@ dns_message_pseudosectiontotext(dns_message_t *msg, dns_pseudosection_t section, ADD_STRING(target, "\n"); continue; } + } else if (optcode == DNS_OPT_UL) { + ADD_STRING(target, "; UL:"); + if (optlen == 4U || optlen == 8U) { + uint32_t secs, key = 0; + secs = isc_buffer_getuint32(&optbuf); + snprintf(buf, sizeof(buf), " %u", secs); + ADD_STRING(target, buf); + if (optlen == 8U) { + key = isc_buffer_getuint32( + &optbuf); + snprintf(buf, sizeof(buf), + "/%u", key); + ADD_STRING(target, buf); + } + ADD_STRING(target, " ("); + result = dns_ttl_totext(secs, true, + true, target); + if (result != ISC_R_SUCCESS) { + goto cleanup; + } + if (optlen == 8U) { + ADD_STRING(target, "/"); + result = dns_ttl_totext( + key, true, true, + target); + if (result != ISC_R_SUCCESS) { + goto cleanup; + } + } + ADD_STRING(target, ")\n"); + continue; + } } else if (optcode == DNS_OPT_NSID) { ADD_STRING(target, "; NSID:"); } else if (optcode == DNS_OPT_COOKIE) { diff --git a/lib/dns/rdata/generic/opt_41.c b/lib/dns/rdata/generic/opt_41.c index ce22cd9502b..12695d1a501 100644 --- a/lib/dns/rdata/generic/opt_41.c +++ b/lib/dns/rdata/generic/opt_41.c @@ -129,6 +129,12 @@ fromwire_opt(ARGS_FROMWIRE) { } isc_region_consume(&sregion, length); break; + case DNS_OPT_UL: + if (length != 4U && length != 8U) { + return (DNS_R_OPTERR); + } + isc_region_consume(&sregion, length); + break; case DNS_OPT_CLIENT_SUBNET: { uint16_t family; uint8_t addrlen;