knot_pkt_t *answer = request->answer;
/* Always set SERVFAIL for bogus answers. */
- if (state == KR_STATE_FAIL && rplan->pending.len > 0) {
+ if ((state & KR_STATE_FAIL) && rplan->pending.len > 0) {
struct kr_query *last = array_tail(rplan->pending);
if ((last->flags.DNSSEC_WANT) && (last->flags.DNSSEC_BOGUS)) {
return answer_fail(request);
{
struct kr_context *ctx = request->ctx;
/* On successful answer, update preference list RTT and penalise timer */
- if (request->state != KR_STATE_FAIL) {
+ if (!(request->state & KR_STATE_FAIL)) {
/* Update RTT information for preference list */
update_nslist_rtt(ctx, qry, src);
/* Do not complete NS address resolution on soft-fail. */
update_nslist_score(request, qry, src, packet);
}
/* Resolution failed, invalidate current NS. */
- if (request->state == KR_STATE_FAIL) {
+ if (request->state & KR_STATE_FAIL) {
invalidate_ns(rplan, qry);
qry->flags.RESOLVED = false;
}
int state = KR_STATE_FAIL;
do {
state = ns_fetch_cut(qry, requested_name, request, packet);
- if (state == KR_STATE_DONE || state == KR_STATE_FAIL) {
+ if (state == KR_STATE_DONE || (state & KR_STATE_FAIL)) {
return state;
} else if (state == KR_STATE_CONSUME) {
requested_name = knot_wire_next_label(requested_name, NULL);
/* Resolve current query and produce dependent or finish */
request->state = KR_STATE_PRODUCE;
ITERATE_LAYERS(request, qry, produce, packet);
- if (request->state != KR_STATE_FAIL && knot_wire_get_qr(packet->wire)) {
+ if (!(request->state & KR_STATE_FAIL) && knot_wire_get_qr(packet->wire)) {
/* Produced an answer from cache, consume it. */
qry->secret = 0;
request->state = KR_STATE_CONSUME;
* don't affect the resolution or rest of the processing. */
int state = request->state;
ITERATE_LAYERS(request, qry, checkout, packet, dst, type);
- if (request->state == KR_STATE_FAIL) {
+ if (request->state & KR_STATE_FAIL) {
request->state = state; /* Restore */
return kr_error(ECANCELED);
}
{
/* Finalize answer and construct wire-buffer. */
ITERATE_LAYERS(request, NULL, answer_finalize);
- if (request->state == KR_STATE_FAIL) {
+ if (request->state & KR_STATE_FAIL) {
state = KR_STATE_FAIL;
} else if (answer_finalize(request, state) != 0) {
state = KR_STATE_FAIL;
/* Request has no server cookie. */
return_state = invalid_sc_status(return_state, false,
ignore_badcookie, req, answer);
- if (return_state == KR_STATE_FAIL) {
+ if (return_state & KR_STATE_FAIL) {
return return_state;
}
goto answer_add_cookies;
/* Invalid server cookie. */
return_state = invalid_sc_status(return_state, true,
ignore_badcookie, req, answer);
- if (return_state == KR_STATE_FAIL) {
+ if (return_state & KR_STATE_FAIL) {
return return_state;
}
goto answer_add_cookies;