]> 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)
committerMark Andrews <marka@isc.org>
Mon, 21 Apr 2025 23:24:18 +0000 (09:24 +1000)
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.

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

index e9696ab1d2c184dc59d744fbcd3a85a4e611f380..05693cdfe21196872cc4fedf7c762c383502df46 100644 (file)
@@ -1363,6 +1363,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 55de3f12a5692440368d8dc5d60b8609831534bd..207e407c5a0103fc0f174941ceef184743bcc621 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 311241856414007599a1f7eac949ac6fdb1bf07f..6762e2e397a080bc6942dadd95f56cdc11eb87c4 100644 (file)
@@ -3476,7 +3476,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",
@@ -3711,32 +3711,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;