2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-03 16:15:27 +00:00

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.
This commit is contained in:
Mark Andrews
2024-10-29 14:32:54 +11:00
parent 280e9b7cf4
commit 68cdc4774c
3 changed files with 56 additions and 17 deletions

View File

@@ -1363,6 +1363,7 @@ typedef struct dig_ednsoptname {
dig_ednsoptname_t optnames[] = { dig_ednsoptname_t optnames[] = {
{ 1, "LLQ" }, /* draft-sekar-dns-llq */ { 1, "LLQ" }, /* draft-sekar-dns-llq */
{ 2, "UPDATE-LEASE" }, /* draft-ietf-dnssd-update-lease */
{ 2, "UL" }, /* draft-ietf-dnssd-update-lease */ { 2, "UL" }, /* draft-ietf-dnssd-update-lease */
{ 3, "NSID" }, /* RFC 5001 */ { 3, "NSID" }, /* RFC 5001 */
{ 5, "DAU" }, /* RFC 6975 */ { 5, "DAU" }, /* RFC 6975 */

View File

@@ -562,24 +562,50 @@ if [ -x "$DIG" ]; then
status=$((status + ret)) status=$((status + ret))
n=$((n + 1)) 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 ret=0
dig_with_opts @10.53.0.3 +ednsopt=UL:00000e10 +qr a.example >dig.out.test$n 2>&1 || ret=1 dig_with_opts @10.53.0.3 +ednsopt=UPDATE-LEASE:00000e10 +qr a.example >dig.out.test$n 2>&1 || ret=1
pat='UL: 3600 (1 hour)' pat='UPDATE-LEASE: 3600 (1 hour)'
grep "$pat" dig.out.test$n >/dev/null || ret=1 grep "$pat" dig.out.test$n >/dev/null || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret)) status=$((status + ret))
n=$((n + 1)) 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)) 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 ret=0
dig_with_opts @10.53.0.3 +ednsopt=UL:00000e1000127500 +qr a.example >dig.out.test$n 2>&1 || ret=1 dig_with_opts @10.53.0.3 +ednsopt=UPDATE-LEASE:00000e1000127500 +qr a.example >dig.out.test$n 2>&1 || ret=1
pat='UL: 3600/1209600 (1 hour/2 weeks)' pat='UPDATE-LEASE: 3600/1209600 (1 hour/2 weeks)'
grep "$pat" dig.out.test$n >/dev/null || ret=1 grep "$pat" dig.out.test$n >/dev/null || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret)) 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)" echo_i "checking ednsopt LLQ prints as expected ($n)"
ret=0 ret=0

View File

@@ -3476,7 +3476,7 @@ cleanup:
static const char *option_names[] = { static const char *option_names[] = {
[DNS_OPT_LLQ] = "LLQ", [DNS_OPT_LLQ] = "LLQ",
[DNS_OPT_UL] = "UL", [DNS_OPT_UL] = "UPDATE-LEASE",
[DNS_OPT_NSID] = "NSID", [DNS_OPT_NSID] = "NSID",
[DNS_OPT_DAU] = "DAU", [DNS_OPT_DAU] = "DAU",
[DNS_OPT_DHU] = "DHU", [DNS_OPT_DHU] = "DHU",
@@ -3711,32 +3711,44 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section,
case DNS_OPT_UL: case DNS_OPT_UL:
if (optlen == 4U || optlen == 8U) { if (optlen == 4U || optlen == 8U) {
uint32_t secs, key = 0; uint32_t secs, key = 0;
msg->indent.count++;
secs = isc_buffer_getuint32(&optbuf); secs = isc_buffer_getuint32(&optbuf);
ADD_STRING(target, "\n");
INDENT(style);
ADD_STRING(target, "LEASE:");
snprintf(buf, sizeof(buf), " %u", secs); snprintf(buf, sizeof(buf), " %u", secs);
ADD_STRING(target, buf); 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, " ("); ADD_STRING(target, " (");
result = dns_ttl_totext(secs, true, result = dns_ttl_totext(secs, true,
true, target); true, target);
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
goto cleanup; goto cleanup;
} }
ADD_STRING(target, ")");
if (optlen == 8U) { 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( result = dns_ttl_totext(
key, true, true, key, true, true,
target); target);
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
goto cleanup; goto cleanup;
} }
ADD_STRING(target, ")");
} }
ADD_STRING(target, ")\n"); ADD_STRING(target, "\n");
continue; continue;
} }
break; break;