From: Marek VavruĊĦa Date: Fri, 29 May 2015 00:53:42 +0000 (+0200) Subject: layer/pktcache: fixed max-ttl for packet cache X-Git-Tag: v1.0.0-beta1~125^2~3^2~4^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a0959574c8a342310c62cde8a480516d0a41285a;p=thirdparty%2Fknot-resolver.git layer/pktcache: fixed max-ttl for packet cache --- diff --git a/lib/layer/pktcache.c b/lib/layer/pktcache.c index fe88de016..14d7ff5c5 100644 --- a/lib/layer/pktcache.c +++ b/lib/layer/pktcache.c @@ -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); }