]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Change the name and YAML format of EDNS UL
authorMark Andrews <marka@isc.org>
Tue, 29 Oct 2024 03:32:54 +0000 (14:32 +1100)
committerEvan Hunt <each@isc.org>
Wed, 7 May 2025 07:00:10 +0000 (00:00 -0700)
The offical EDNS option name for "UL" is "UPDATE-LEASE".  We now
emit "UPDATE-LEASE" instead of "UL", when printing messages, but
"UL" has been retained as an alias on the command line.

Update leases consist of 1 or 2 values, LEASE and KEY-LEASE.  These
components are now emitted separately so they can be easily extracted
from YAML output.  Tests have been added to check YAML correctness.

(cherry picked from commit 68cdc4774c53fb439ebb0dca4e6fc98ba69577d5)

bin/dig/dighost.c
bin/tests/system/digdelv/tests.sh
lib/dns/message.c

index 3cd19f11ce98f015c1fda2e4db6bf58e33d0f858..b7e3c52b9e3a1747596d9bcadf1eab1d5baa2497 100644 (file)
@@ -1391,6 +1391,7 @@ typedef struct dig_ednsoptname {
 
 dig_ednsoptname_t optnames[] = {
        { 1, "LLQ" },             /* draft-sekar-dns-llq */
+       { 2, "UPDATE-LEASE" },    /* draft-ietf-dnssd-update-lease */
        { 2, "UL" },              /* draft-ietf-dnssd-update-lease */
        { 3, "NSID" },            /* RFC 5001 */
        { 5, "DAU" },             /* RFC 6975 */
index ca84b32ef8a600e4bdd60d0111ebf90160892ae9..7702e88177e3e3f5491a55631258c239922cb173 100644 (file)
@@ -562,24 +562,50 @@ if [ -x "$DIG" ]; then
   status=$((status + ret))
 
   n=$((n + 1))
-  echo_i "checking ednsopt UL prints as expected (single lease) ($n)"
+  echo_i "checking ednsopt UPDATE-LEASE prints as expected (single lease) ($n)"
   ret=0
-  dig_with_opts @10.53.0.3 +ednsopt=UL:00000e10 +qr a.example >dig.out.test$n 2>&1 || ret=1
-  pat='UL: 3600 (1 hour)'
+  dig_with_opts @10.53.0.3 +ednsopt=UPDATE-LEASE:00000e10 +qr a.example >dig.out.test$n 2>&1 || ret=1
+  pat='UPDATE-LEASE: 3600 (1 hour)'
   grep "$pat" dig.out.test$n >/dev/null || ret=1
   if [ $ret -ne 0 ]; then echo_i "failed"; fi
   status=$((status + ret))
   n=$((n + 1))
 
+  if [ $HAS_PYYAML -ne 0 ]; then
+    n=$((n + 1))
+    echo_i "checking ednsopt UPDATE-LEASE prints as expected (single lease) +yaml ($n)"
+    ret=0
+    dig_with_opts @10.53.0.3 +yaml +ednsopt=UPDATE-LEASE:00000e10 +qr a.example >dig.out.test$n 2>&1 || ret=1
+    $PYTHON yamlget.py dig.out.test$n 0 message query_message_data OPT_PSEUDOSECTION EDNS UPDATE-LEASE LEASE >yamlget.out.test$n 2>&1 || ret=1
+    read -r value <yamlget.out.test$n
+    [ "$value" = "3600 (1 hour)" ] || ret=1
+    if [ $ret -ne 0 ]; then echo_i "failed"; fi
+    status=$((status + ret))
+  fi
+
   n=$((n + 1))
-  echo_i "checking ednsopt UL prints as expected (split lease) ($n)"
+  echo_i "checking ednsopt UPDATE-LEASE prints as expected (split lease) ($n)"
   ret=0
-  dig_with_opts @10.53.0.3 +ednsopt=UL:00000e1000127500 +qr a.example >dig.out.test$n 2>&1 || ret=1
-  pat='UL: 3600/1209600 (1 hour/2 weeks)'
+  dig_with_opts @10.53.0.3 +ednsopt=UPDATE-LEASE:00000e1000127500 +qr a.example >dig.out.test$n 2>&1 || ret=1
+  pat='UPDATE-LEASE: 3600/1209600 (1 hour/2 weeks)'
   grep "$pat" dig.out.test$n >/dev/null || ret=1
   if [ $ret -ne 0 ]; then echo_i "failed"; fi
   status=$((status + ret))
-  n=$((n + 1))
+
+  if [ $HAS_PYYAML -ne 0 ]; then
+    n=$((n + 1))
+    echo_i "checking ednsopt UPDATE-LEASE prints as expected (split lease) +yaml ($n)"
+    ret=0
+    dig_with_opts @10.53.0.3 +yaml +ednsopt=UPDATE-LEASE:00000e1000127500 +qr a.example >dig.out.test$n 2>&1 || ret=1
+    $PYTHON yamlget.py dig.out.test$n 0 message query_message_data OPT_PSEUDOSECTION EDNS UPDATE-LEASE LEASE >yamlget.out.test$n 2>&1 || ret=1
+    read -r value <yamlget.out.test$n
+    [ "$value" = "3600 (1 hour)" ] || ret=1
+    $PYTHON yamlget.py dig.out.test$n 0 message query_message_data OPT_PSEUDOSECTION EDNS UPDATE-LEASE KEY-LEASE >yamlget.out.test$n 2>&1 || ret=1
+    read -r value <yamlget.out.test$n
+    [ "$value" = "1209600 (2 weeks)" ] || ret=1
+    if [ $ret -ne 0 ]; then echo_i "failed"; fi
+    status=$((status + ret))
+  fi
 
   echo_i "checking ednsopt LLQ prints as expected ($n)"
   ret=0
index cf8fef754c0402894a2178ef97cb8d35cafe0236..038fbca7cf73e60e4a02d25109ef156bad55ede2 100644 (file)
@@ -3617,7 +3617,7 @@ cleanup:
 
 static const char *option_names[] = {
        [DNS_OPT_LLQ] = "LLQ",
-       [DNS_OPT_UL] = "UL",
+       [DNS_OPT_UL] = "UPDATE-LEASE",
        [DNS_OPT_NSID] = "NSID",
        [DNS_OPT_DAU] = "DAU",
        [DNS_OPT_DHU] = "DHU",
@@ -3754,32 +3754,44 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section,
                        case DNS_OPT_UL:
                                if (optlen == 4U || optlen == 8U) {
                                        uint32_t secs, key = 0;
+                                       msg->indent.count++;
+
                                        secs = isc_buffer_getuint32(&optbuf);
+                                       ADD_STRING(target, "\n");
+                                       INDENT(style);
+                                       ADD_STRING(target, "LEASE:");
                                        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;
                                        }
+                                       ADD_STRING(target, ")");
+
                                        if (optlen == 8U) {
-                                               ADD_STRING(target, "/");
+                                               key = isc_buffer_getuint32(
+                                                       &optbuf);
+                                               ADD_STRING(target, "\n");
+                                               INDENT(style);
+                                               ADD_STRING(target,
+                                                          "KEY-LEASE:");
+                                               snprintf(buf, sizeof(buf),
+                                                        " %u", key);
+                                               ADD_STRING(target, buf);
+
+                                               ADD_STRING(target, " (");
                                                result = dns_ttl_totext(
                                                        key, true, true,
                                                        target);
                                                if (result != ISC_R_SUCCESS) {
                                                        goto cleanup;
                                                }
+                                               ADD_STRING(target, ")");
                                        }
-                                       ADD_STRING(target, ")\n");
+                                       ADD_STRING(target, "\n");
                                        continue;
                                }
                                break;