/*
* Log the outgoing query via dnstap.
*/
- if ((fctx->qmessage->flags & DNS_MESSAGEFLAG_RD) != 0) {
+ if (ISFORWARDER(query->addrinfo)) {
dtmsgtype = DNS_DTTYPE_FQ;
} else {
dtmsgtype = DNS_DTTYPE_RQ;
}
dns_compress_invalidate(&cctx);
- if ((fctx->qmessage->flags & DNS_MESSAGEFLAG_RD) != 0) {
+ /*
+ * Check if the response came from a forwarder to correctly
+ * classify as Forward Response (FR) vs Recursive Response (RR)
+ * for DNSTAP logging. This is more accurate than using the RD
+ * flag which only indicates the original query intent.
+ */
+ if (ISFORWARDER(rctx->query->addrinfo)) {
dtmsgtype = DNS_DTTYPE_FR;
} else {
dtmsgtype = DNS_DTTYPE_RR;