From: Aram Sargsyan Date: Mon, 10 Feb 2025 13:11:18 +0000 (+0000) Subject: Use named Service Parameter Keys (SvcParamKeys) by default X-Git-Tag: ondrej/lock-free-qpzone-reads-v1~58^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6e369547860a1dd8e4fd1af53bab182270aa90a;p=thirdparty%2Fbind9.git Use named Service Parameter Keys (SvcParamKeys) by default When converting SVCB records to text representation use named SvcParamKeys values unless backward-compatible mode is activated, in which case the values which were not defined initially in RFC9460 and were added later (see [1]) are converted to opaque "keyN" syntax, like, for example, "key7" instead of "dohpath". [1] https://www.iana.org/assignments/dns-svcb/dns-svcb.xhtml Co-authored-by: sdomi --- diff --git a/lib/dns/include/dns/rdata.h b/lib/dns/include/dns/rdata.h index 2123bbc927a..ac255b2028b 100644 --- a/lib/dns/include/dns/rdata.h +++ b/lib/dns/include/dns/rdata.h @@ -173,6 +173,9 @@ struct dns_rdata { /*% Print AAAA record fully expanded */ #define DNS_STYLEFLAG_EXPANDAAAA 0x00000020ULL +/*% Print non-initial Service Parameter Keys in backward-compatible format */ +#define DNS_STYLEFLAG_SVCPARAMKEYCOMPAT 0x00000040ULL + #define DNS_RDATA_DOWNCASE DNS_NAME_DOWNCASE #define DNS_RDATA_CHECKNAMES DNS_NAME_CHECKNAMES #define DNS_RDATA_CHECKNAMESFAIL DNS_NAME_CHECKNAMESFAIL diff --git a/lib/dns/rdata/in_1/svcb_64.c b/lib/dns/rdata/in_1/svcb_64.c index 8764617688f..b5c431c70bc 100644 --- a/lib/dns/rdata/in_1/svcb_64.c +++ b/lib/dns/rdata/in_1/svcb_64.c @@ -377,12 +377,12 @@ svc_fromtext(isc_textregion_t *region, isc_buffer_t *target) { static const char * svcparamkey(unsigned short value, enum encoding *encoding, char *buf, - size_t len) { + size_t len, bool compat) { size_t i; int n; for (i = 0; i < ARRAY_SIZE(sbpr); i++) { - if (sbpr[i].value == value && sbpr[i].initial) { + if (sbpr[i].value == value && (sbpr[i].initial || !compat)) { *encoding = sbpr[i].encoding; return sbpr[i].name; } @@ -639,6 +639,7 @@ generic_totext_in_svcb(ARGS_TOTEXT) { char buf[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255")]; unsigned short num; int n; + bool compat = (tctx->flags & DNS_STYLEFLAG_SVCPARAMKEYCOMPAT) != 0; REQUIRE(rdata->length != 0); @@ -674,8 +675,9 @@ generic_totext_in_svcb(ARGS_TOTEXT) { INSIST(region.length >= 2); num = uint16_fromregion(®ion); isc_region_consume(®ion, 2); - RETERR(str_totext(svcparamkey(num, &encoding, buf, sizeof(buf)), - target)); + RETERR(str_totext( + svcparamkey(num, &encoding, buf, sizeof(buf), compat), + target)); INSIST(region.length >= 2); num = uint16_fromregion(®ion); @@ -747,7 +749,8 @@ generic_totext_in_svcb(ARGS_TOTEXT) { num = uint16_fromregion(&r); isc_region_consume(&r, 2); RETERR(str_totext(svcparamkey(num, &encoding, - buf, sizeof(buf)), + buf, sizeof(buf), + compat), target)); if (r.length != 0) { RETERR(str_totext(",", target));