]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add minimal EDNS UL option support
authorMark Andrews <marka@isc.org>
Mon, 6 Nov 2023 13:50:11 +0000 (00:50 +1100)
committerMark Andrews <marka@isc.org>
Mon, 22 Jan 2024 23:47:31 +0000 (10:47 +1100)
This is defined in draft-ietf-dnssd-update-lease.  This adds the
ability to display the option and teaches dig about the name 'UL'.

bin/dig/dighost.c
lib/dns/include/dns/message.h
lib/dns/message.c
lib/dns/rdata/generic/opt_41.c

index b9ceaa22dd97aac4ff327a9ab8cbad9fcf3f3d19..a02b4cbff989291dbca2a58bdec89bcb4225376d 100644 (file)
@@ -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 */
index dc0c05846f6d3609ca3f72beb4caccc55c9aa6de..cda53f3c8ceb80eb5de4b523d299c1116bc3e1d3 100644 (file)
 
 /*%< 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 */
index c85e579b02ff8bd2fa15309b23aa9462cca83bbc..e61f6b6142c62aa3129688ca6af44371bde68b26 100644 (file)
@@ -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) {
index ce22cd9502b47c0f64f5fe53c9119a5247451ec4..12695d1a5011e1ece623f85f77a2eaecbda93b60 100644 (file)
@@ -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;