Skip to content
Snippets Groups Projects
Commit a0959574 authored by Marek Vavruša's avatar Marek Vavruša
Browse files

layer/pktcache: fixed max-ttl for packet cache

parent 4ba2884d
No related branches found
No related tags found
No related merge requests found
......@@ -135,7 +135,8 @@ static int peek(knot_layer_t *ctx, knot_pkt_t *pkt)
static uint32_t packet_ttl(knot_pkt_t *pkt)
{
uint32_t ttl = DEFAULT_NOTTL;
bool has_ttl = false;
uint32_t ttl = UINT32_MAX;
/* Fetch SOA from authority. */
const knot_pktsection_t *ns = knot_pkt_section(pkt, KNOT_AUTHORITY);
for (unsigned i = 0; i < ns->count; ++i) {
......@@ -158,10 +159,15 @@ static uint32_t packet_ttl(knot_pkt_t *pkt)
knot_rdata_t *rd = knot_rdataset_at(&rr->rrs, i);
if (knot_rdata_ttl(rd) < ttl) {
ttl = knot_rdata_ttl(rd);
has_ttl = true;
}
}
}
}
/* Get default if no valid TTL present */
if (!has_ttl) {
ttl = DEFAULT_NOTTL;
}
return limit_ttl(ttl);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment