}
/** Compute rank appropriate for RRs present in the packet.
- * @param answer whether the RR is from answer or authority section */
+ * @param answer whether the RR is from answer or authority section
+ * @param is_nonauth: from referral or forwarding (etc.) */
static uint8_t get_initial_rank(const knot_rrset_t *rr, const struct kr_query *qry,
- const bool answer, const bool is_referral)
+ const bool answer, const bool is_nonauth)
{
/* For RRSIGs, ensure the KR_RANK_AUTH flag corresponds to the signed RR. */
uint16_t type = kr_rrset_type_maysig(rr);
* in future. Still, it might theoretically cause some problems:
* https://mailarchive.ietf.org/arch/msg/dnsop/CYjPDlwtpxzdQV_qycB-WfnW6CI
*/
- if (!is_referral && knot_dname_is_equal(qry->zone_cut.name, rr->owner)) {
+ if (!is_nonauth && knot_dname_is_equal(qry->zone_cut.name, rr->owner)) {
return KR_RANK_INITIAL | KR_RANK_AUTH;
} else {
return KR_RANK_OMIT;
if (!knot_dname_in(zonecut_name, rr->owner)) {
continue;
}
- uint8_t rank = get_initial_rank(rr, qry, false, referral);
+ uint8_t rank = get_initial_rank(rr, qry, false,
+ qry->flags.FORWARD || referral);
int ret = kr_ranked_rrarray_add(&req->auth_selected, rr,
rank, to_wire, qry->uid, &req->pool);
if (ret != kr_ok()) {
return state;
}
}
- uint8_t rank = get_initial_rank(rr, query, true, referral);
+ uint8_t rank = get_initial_rank(rr, query, true,
+ query->flags.FORWARD || referral);
state = kr_ranked_rrarray_add(&req->answ_selected, rr,
rank, to_wire, query->uid, &req->pool);
if (state != kr_ok()) {