Change the name and YAML format of EDNS UL

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 68cdc4774c)
This commit is contained in:
Mark Andrews 2024-10-29 14:32:54 +11:00 committed by Evan Hunt
parent 44fc37033e
commit 09893287c2
3 changed files with 56 additions and 17 deletions

View 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 */

View 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

View 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;