From: Carlos O'Donell <carlos@redhat.com>
To: Florian Weimer <fweimer@redhat.com>, libc-alpha@sourceware.org
Subject: Re: [PATCH v2 1/2] support: Change non-address output format of support_format_dns_packet
Date: Fri, 24 Jun 2022 11:46:17 -0400 [thread overview]
Message-ID: <fc31bc2a-28a2-5775-0290-140c4a887939@redhat.com> (raw)
In-Reply-To: <8df136914557c843ebc4f05fe3e423a8e610e077.1654633752.git.fweimer@redhat.com>
On 6/7/22 16:29, Florian Weimer via Libc-alpha wrote:
> It makes sense to include the owner name (LHS) and record type in the
> output, so that they can be checked for correctness.
LGTM.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
> ---
> v2: New patch.
> support/support_format_dns_packet.c | 22 +++++++++++++++-------
> support/tst-support_format_dns_packet.c | 4 ++--
> 2 files changed, 17 insertions(+), 9 deletions(-)
>
> diff --git a/support/support_format_dns_packet.c b/support/support_format_dns_packet.c
> index e8b3c125e3..14344bc1bf 100644
> --- a/support/support_format_dns_packet.c
> +++ b/support/support_format_dns_packet.c
> @@ -90,6 +90,17 @@ extract_name (struct in_buffer full, struct in_buffer *in, struct dname *value)
> return true;
> }
>
> +static void
> +extract_name_data (struct in_buffer full, struct in_buffer *rdata,
> + const struct dname *owner, const char *typename, FILE *out)
> +{
> + struct dname name;
> + if (extract_name (full, rdata, &name))
OK. extract_name() is just above which uses dn_expand() API.
> + fprintf (out, "data: %s %s %s\n", owner->name, typename, name.name);
> + else
> + fprintf (out, "error: malformed CNAME/PTR record\n");
> +}
> +
> char *
> support_format_dns_packet (const unsigned char *buffer, size_t length)
> {
> @@ -195,14 +206,11 @@ support_format_dns_packet (const unsigned char *buffer, size_t length)
> }
> break;
> case T_CNAME:
> + extract_name_data (full, &rdata, &rname, "CNAME", mem.out);
> + break;
OK. The split here allows you to distinguish in the logs if it was a CNAME or PTR that failed.
This allows checking for exact CNAME or PTR message in the logs.
> case T_PTR:
> - {
> - struct dname name;
> - if (extract_name (full, &rdata, &name))
> - fprintf (mem.out, "name: %s\n", name.name);
> - else
> - fprintf (mem.out, "error: malformed CNAME/PTR record\n");
> - }
> + extract_name_data (full, &rdata, &rname, "PTR", mem.out);
> + break;
> }
> }
>
> diff --git a/support/tst-support_format_dns_packet.c b/support/tst-support_format_dns_packet.c
> index cb7ff53b87..9839aa767e 100644
> --- a/support/tst-support_format_dns_packet.c
> +++ b/support/tst-support_format_dns_packet.c
> @@ -85,8 +85,8 @@ test_multiple_cnames (void)
> "\xc0\x00\x02\x01";
> check_packet (packet, sizeof (packet) - 1, __func__,
> "name: www.example\n"
> - "name: www1.example\n"
> - "name: www2.example\n"
> + "data: www.example CNAME www1.example\n"
> + "data: www1.example CNAME www2.example\n"
OK. Data adjusted.
> "address: 192.0.2.1\n");
> }
>
>
> base-commit: 5082a287d5e9a1f9cb98b7c982a708a3684f1d5c
--
Cheers,
Carlos.
prev parent reply other threads:[~2022-06-24 15:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-07 20:29 Florian Weimer
2022-06-07 20:30 ` [PATCH v2 2/2] resolv: Implement no-aaaa stub resolver option Florian Weimer
2022-06-24 15:42 ` Carlos O'Donell
2022-06-24 15:46 ` Carlos O'Donell [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fc31bc2a-28a2-5775-0290-140c4a887939@redhat.com \
--to=carlos@redhat.com \
--cc=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).