Commit 64d03716 authored by Vladimír Čunát's avatar Vladimír Čunát

knot_dname_is_sub(): replace

parent 87911236
......@@ -258,8 +258,8 @@ struct kr_context {
const char *knot_strerror(int);
knot_dname_t *knot_dname_copy(const knot_dname_t *, knot_mm_t *);
knot_dname_t *knot_dname_from_str(uint8_t *, const char *, size_t);
int knot_dname_in_bailiwick(const knot_dname_t *, const knot_dname_t *);
_Bool knot_dname_is_equal(const knot_dname_t *, const knot_dname_t *);
_Bool knot_dname_is_sub(const knot_dname_t *, const knot_dname_t *);
size_t knot_dname_labels(const uint8_t *, const uint8_t *);
size_t knot_dname_size(const knot_dname_t *);
char *knot_dname_to_str(char *, const knot_dname_t *, size_t);
......
......@@ -104,8 +104,8 @@ printf "\tchar _stub[];\n};\n"
# Domain names
knot_dname_copy
knot_dname_from_str
knot_dname_in_bailiwick
knot_dname_is_equal
knot_dname_is_sub
knot_dname_labels
knot_dname_size
knot_dname_to_str
......
......@@ -78,7 +78,7 @@ static int nsec_covers(const knot_rrset_t *nsec, const knot_dname_t *sname)
* sname might be under delegation from owner and thus
* not in the zone of this NSEC at all.
*/
if (!knot_dname_is_sub(sname, nsec->owner)) {
if (knot_dname_in_bailiwick(sname, nsec->owner) <= 0) {
return kr_ok();
}
const uint8_t *bm = knot_nsec_bitmap(nsec->rrs.rdata);
......
......@@ -433,8 +433,10 @@ static int process_authority(knot_pkt_t *pkt, struct kr_request *req)
case KR_STATE_FAIL: return state; break;
default: /* continue */ break;
}
} else if (rr->type == KNOT_RRTYPE_SOA && knot_dname_is_sub(rr->owner, qry->zone_cut.name)) {
/* SOA below cut in authority indicates different authority, but same NS set. */
} else if (rr->type == KNOT_RRTYPE_SOA
&& knot_dname_in_bailiwick(rr->owner, qry->zone_cut.name) > 0) {
/* SOA below cut in authority indicates different authority,
* but same NS set. */
qry->zone_cut.name = knot_dname_copy(rr->owner, &req->pool);
}
}
......@@ -445,8 +447,10 @@ static int process_authority(knot_pkt_t *pkt, struct kr_request *req)
if (!ns_record_exists && knot_wire_get_aa(pkt->wire)) {
for (unsigned i = 0; i < an->count; ++i) {
const knot_rrset_t *rr = knot_pkt_rr(an, i);
if (rr->type == KNOT_RRTYPE_NS && knot_dname_is_sub(rr->owner, qry->zone_cut.name)) {
/* NS below cut in authority indicates different authority, but same NS set. */
if (rr->type == KNOT_RRTYPE_NS
&& knot_dname_in_bailiwick(rr->owner, qry->zone_cut.name) > 0) {
/* NS below cut in authority indicates different authority,
* but same NS set. */
qry->zone_cut.name = knot_dname_copy(rr->owner, &req->pool);
}
}
......
......@@ -568,7 +568,7 @@ static int check_validation_result(kr_layer_t *ctx, ranked_rr_array_t *arr)
const knot_rrset_t *rr = invalid_entry->rr;
if (kr_rank_test(invalid_entry->rank, KR_RANK_MISMATCH)) {
const knot_dname_t *signer_name = knot_rrsig_signer_name(rr->rrs.rdata);
if (knot_dname_is_sub(signer_name, qry->zone_cut.name)) {
if (knot_dname_in_bailiwick(signer_name, qry->zone_cut.name) > 0) {
qry->zone_cut.name = knot_dname_copy(signer_name, &req->pool);
qry->flags.AWAIT_CUT = true;
} else if (!knot_dname_is_equal(signer_name, qry->zone_cut.name)) {
......@@ -710,13 +710,13 @@ static int check_signer(kr_layer_t *ctx, knot_pkt_t *pkt)
const uint16_t qtype = knot_pkt_qtype(pkt);
const knot_dname_t *qname = knot_pkt_qname(pkt);
if (qtype == KNOT_RRTYPE_NS &&
knot_dname_is_sub(qname, qry->zone_cut.name)) {
knot_dname_in_bailiwick(qname, qry->zone_cut.name) > 0) {
/* Server is authoritative
* for both parent and child,
* and child zone is not signed. */
qry->zone_cut.name = knot_dname_copy(qname, &req->pool);
}
} else if (knot_dname_is_sub(signer, qry->zone_cut.name)) {
} else if (knot_dname_in_bailiwick(signer, qry->zone_cut.name) > 0) {
if (!(qry->flags.FORWARD)) {
/* Key signer is below current cut, advance and refetch keys. */
qry->zone_cut.name = knot_dname_copy(signer, &req->pool);
......
......@@ -333,7 +333,7 @@ local function localhost_reversed(_, req)
local is_exact -- exact dname for localhost
local is_apex -- apex of a locally-served localhost zone
local is_nonterm -- empty non-terminal name
if ffi.C.knot_dname_is_sub(qry.sname, todname('ip6.arpa.')) then
if ffi.C.knot_dname_in_bailiwick(qry.sname, todname('ip6.arpa.')) > 0 then
-- exact ::1 query (relying on the calling rule)
is_exact = true
is_apex = true
......@@ -349,7 +349,7 @@ local function localhost_reversed(_, req)
else
is_exact = false
is_apex = false
is_nonterm = ffi.C.knot_dname_is_sub(dname_rev4_localhost, qry.sname)
is_nonterm = ffi.C.knot_dname_in_bailiwick(dname_rev4_localhost, qry.sname) > 0
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment