1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

RFC 6762 section 7.1: a Multicast DNS querier SHOULD NOT include records in the

Known-Answer list whose remaining TTL is less than half of their original TTL

(cherry picked from commit f941c12427)
(cherry picked from commit ef6c379089)
This commit is contained in:
Vishal Chillara Srinivas 2022-06-15 18:16:06 +05:30 committed by Zbigniew Jędrzejewski-Szmek
parent d935dd7e9d
commit fb48f600cf

View File

@ -1261,11 +1261,14 @@ int dns_cache_check_conflicts(DnsCache *cache, DnsResourceRecord *rr, int owner_
int dns_cache_export_shared_to_packet(DnsCache *cache, DnsPacket *p) {
unsigned ancount = 0;
DnsCacheItem *i;
usec_t t;
int r;
assert(cache);
assert(p);
t = now(CLOCK_BOOTTIME);
HASHMAP_FOREACH(i, cache->by_key) {
DnsCacheItem *j;
@ -1276,6 +1279,11 @@ int dns_cache_export_shared_to_packet(DnsCache *cache, DnsPacket *p) {
if (!j->shared_owner)
continue;
/* RFC6762 7.1: Don't append records with less than half the TTL remaining
* as known answers. */
if (usec_sub_unsigned(j->until, t) < j->rr->ttl * USEC_PER_SEC / 2)
continue;
r = dns_packet_append_rr(p, j->rr, 0, NULL, NULL);
if (r == -EMSGSIZE && p->protocol == DNS_PROTOCOL_MDNS) {
/* For mDNS, if we're unable to stuff all known answers into the given packet,