static int dns_cache_put_positive(
DnsCache *c,
+ DnsProtocol protocol,
DnsResourceRecord *rr,
DnsAnswer *answer,
DnsPacket *full_packet,
return 0;
}
+ /* Do not cache mDNS goodbye packet. */
+ if (protocol == DNS_PROTOCOL_MDNS && rr->ttl <= 1)
+ return 0;
+
/* Otherwise, add the new RR */
r = dns_cache_init(c);
if (r < 0)
int dns_cache_put(
DnsCache *c,
DnsCacheMode cache_mode,
+ DnsProtocol protocol,
DnsResourceKey *key,
int rcode,
DnsAnswer *answer,
r = dns_cache_put_positive(
c,
+ protocol,
item->rr,
primary ? answer : NULL,
primary ? full_packet : NULL,
}
}
- dns_cache_put(&scope->cache, scope->manager->enable_cache, NULL, DNS_PACKET_RCODE(p), p->answer, NULL, false, _DNSSEC_RESULT_INVALID, UINT32_MAX, p->family, &p->sender);
+ dns_cache_put(
+ &scope->cache,
+ scope->manager->enable_cache,
+ DNS_PROTOCOL_MDNS,
+ NULL,
+ DNS_PACKET_RCODE(p),
+ p->answer,
+ NULL,
+ false,
+ _DNSSEC_RESULT_INVALID,
+ UINT32_MAX,
+ p->family,
+ &p->sender);
} else if (dns_packet_validate_query(p) > 0) {
log_debug("Got mDNS query packet for id %u", DNS_PACKET_ID(p));