fix: usr: AMTRELAY type 0 presentation format handling was wrong

RFC 8777 specifies a placeholder value of "." for the gateway field when the
gateway type is 0 (no gateway).  This was not being checked for nor emitted
when displaying the record. This has been corrected.

Instances of this record will need the placeholder period added to them when upgrading.

Closes #5639

Merge branch '5639-fix-atmrelay-type-0-support' into 'main'

See merge request isc-projects/bind9!11240
This commit is contained in:
Mark Andrews 2025-11-20 19:46:10 +11:00
commit d091771b42
8 changed files with 30 additions and 28 deletions

View file

@ -13,5 +13,5 @@ $TTL 600
@ SOA ns hostmaster 2011012708 3600 1200 604800 1200
NS ns
ns A 192.0.2.1
bad ATMRELAY 0 0 0
bad AMTRELAY 0 0 0 .
bad CNAME @

View file

@ -11,8 +11,8 @@ aaaa01.example. 3600 IN AAAA ::1
aaaa02.example. 3600 IN AAAA fd92:7065:b8e:ffff::5
afsdb01.example. 3600 IN AFSDB 0 hostname.example.
afsdb02.example. 3600 IN AFSDB 65535 .
amtrelay01.example. 3600 IN AMTRELAY 0 0 0
amtrelay02.example. 3600 IN AMTRELAY 0 1 0
amtrelay01.example. 3600 IN AMTRELAY 0 0 0 .
amtrelay02.example. 3600 IN AMTRELAY 0 1 0 .
amtrelay03.example. 3600 IN AMTRELAY 0 0 1 0.0.0.0
amtrelay04.example. 3600 IN AMTRELAY 0 0 2 ::
amtrelay05.example. 3600 IN AMTRELAY 0 0 3 example.net.

View file

@ -11,8 +11,8 @@ aaaa01.example8. 3600 IN AAAA ::1
aaaa02.example8. 3600 IN AAAA fd92:7065:b8e:ffff::5
afsdb01.example8. 3600 IN AFSDB 0 hostname.example8.
afsdb02.example8. 3600 IN AFSDB 65535 .
amtrelay01.example8. 3600 IN AMTRELAY 0 0 0
amtrelay02.example8. 3600 IN AMTRELAY 0 1 0
amtrelay01.example8. 3600 IN AMTRELAY 0 0 0 .
amtrelay02.example8. 3600 IN AMTRELAY 0 1 0 .
amtrelay03.example8. 3600 IN AMTRELAY 0 0 1 0.0.0.0
amtrelay04.example8. 3600 IN AMTRELAY 0 0 2 ::
amtrelay05.example8. 3600 IN AMTRELAY 0 0 3 example.net.

View file

@ -487,8 +487,8 @@ doa01 DOA ( 1234567890 1234567890 1 "image/gif"
doa02 DOA 0 1 2 "" aHR0cHM6Ly93d3cuaXNjLm9yZy8=
; type 260
amtrelay01 AMTRELAY 0 0 0
amtrelay02 AMTRELAY 0 1 0
amtrelay01 AMTRELAY 0 0 0 .
amtrelay02 AMTRELAY 0 1 0 .
amtrelay03 AMTRELAY 0 0 1 0.0.0.0
amtrelay04 AMTRELAY 0 0 2 ::
amtrelay05 AMTRELAY 0 0 3 example.net.

View file

@ -12,8 +12,8 @@ aaaa01.example. 3600 IN AAAA ::1
aaaa02.example. 3600 IN AAAA fd92:7065:b8e:ffff::5
afsdb01.example. 3600 IN AFSDB 0 hostname.example.
afsdb02.example. 3600 IN AFSDB 65535 .
amtrelay01.example. 3600 IN AMTRELAY 0 0 0
amtrelay02.example. 3600 IN AMTRELAY 0 1 0
amtrelay01.example. 3600 IN AMTRELAY 0 0 0 .
amtrelay02.example. 3600 IN AMTRELAY 0 1 0 .
amtrelay03.example. 3600 IN AMTRELAY 0 0 1 0.0.0.0
amtrelay04.example. 3600 IN AMTRELAY 0 0 2 ::
amtrelay05.example. 3600 IN AMTRELAY 0 0 3 example.net.

View file

@ -12,8 +12,8 @@ aaaa01.example. 3600 IN AAAA ::1
aaaa02.example. 3600 IN AAAA fd92:7065:b8e:ffff::5
afsdb01.example. 3600 IN AFSDB 0 hostname.example.
afsdb02.example. 3600 IN AFSDB 65535 .
amtrelay01.example. 3600 IN AMTRELAY 0 0 0
amtrelay02.example. 3600 IN AMTRELAY 0 1 0
amtrelay01.example. 3600 IN AMTRELAY 0 0 0 .
amtrelay02.example. 3600 IN AMTRELAY 0 1 0 .
amtrelay03.example. 3600 IN AMTRELAY 0 0 1 0.0.0.1
amtrelay04.example. 3600 IN AMTRELAY 0 0 2 ::
amtrelay05.example. 3600 IN AMTRELAY 0 0 3 example.net.

View file

@ -67,21 +67,22 @@ fromtext_amtrelay(ARGS_FROMTEXT) {
RETERR(uint8_tobuffer(token.value.as_ulong | (discovery << 7), target));
gateway = token.value.as_ulong;
if (gateway == 0) {
return ISC_R_SUCCESS;
}
/*
* Gateway (must exist).
*/
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
false));
if (gateway > 3) {
return ISC_R_NOTIMPLEMENTED;
}
/*
* Gateway.
*/
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
false));
switch (gateway) {
case 0:
if (strcmp(DNS_AS_STR(token), ".") != 0) {
RETTOK(DNS_R_SYNTAX);
}
return ISC_R_SUCCESS;
case 1:
if (inet_pton(AF_INET, DNS_AS_STR(token), &addr) != 1) {
RETTOK(DNS_R_BADDOTTEDQUAD);
@ -125,7 +126,6 @@ totext_amtrelay(ARGS_TOTEXT) {
unsigned char precedence;
unsigned char discovery;
unsigned char gateway;
const char *space;
UNUSED(tctx);
@ -151,9 +151,8 @@ totext_amtrelay(ARGS_TOTEXT) {
gateway = uint8_fromregion(&region);
discovery = gateway >> 7;
gateway &= 0x7f;
space = (gateway != 0U) ? " " : "";
isc_region_consume(&region, 1);
snprintf(buf, sizeof(buf), "%u %u%s", discovery, gateway, space);
snprintf(buf, sizeof(buf), "%u %u ", discovery, gateway);
RETERR(str_totext(buf, target));
/*
@ -161,7 +160,8 @@ totext_amtrelay(ARGS_TOTEXT) {
*/
switch (gateway) {
case 0:
break;
return str_totext(".", target);
case 1:
return inet_totext(AF_INET, tctx->flags, &region, target);

View file

@ -1029,11 +1029,13 @@ ISC_RUN_TEST_IMPL(atma) {
ISC_RUN_TEST_IMPL(amtrelay) {
text_ok_t text_ok[] = {
TEXT_INVALID(""), TEXT_INVALID("0"), TEXT_INVALID("0 0"),
TEXT_INVALID("0 0 0"),
/* gateway type 0 */
TEXT_VALID("0 0 0"), TEXT_VALID("0 1 0"),
TEXT_INVALID("0 2 0"), /* discovery out of range */
TEXT_VALID("255 1 0"), /* max precedence */
TEXT_INVALID("256 1 0"), /* precedence out of range */
TEXT_INVALID("0 0 0 x"), /* bad placeholder */
TEXT_VALID("0 0 0 ."), TEXT_VALID("0 1 0 ."),
TEXT_INVALID("0 2 0 ."), /* discovery out of range */
TEXT_VALID("255 1 0 ."), /* max precedence */
TEXT_INVALID("256 1 0 ."), /* precedence out of range */
/* IPv4 gateway */
TEXT_INVALID("0 0 1"), /* no address */