mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 10:18:25 +00:00
Remove code for caching SRV.
Function replaced by the ability to cache any RR type. For backwards compatibilty SRV records are always on the list of cacheable RR-types.
This commit is contained in:
43
src/cache.c
43
src/cache.c
@@ -136,7 +136,7 @@ static void cache_hash(struct crec *crecp);
|
||||
|
||||
unsigned short rrtype(char *in)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < (sizeof(typestr)/sizeof(typestr[0])); i++)
|
||||
if (strcasecmp(in, typestr[i].name) == 0)
|
||||
@@ -275,9 +275,7 @@ static void cache_blockdata_free(struct crec *crecp)
|
||||
{
|
||||
if (!(crecp->flags & F_NEG))
|
||||
{
|
||||
if (crecp->flags & F_SRV)
|
||||
blockdata_free(crecp->addr.srv.target);
|
||||
else if (crecp->flags & F_RR)
|
||||
if (crecp->flags & F_RR)
|
||||
blockdata_free(crecp->addr.rr.rrdata);
|
||||
#ifdef HAVE_DNSSEC
|
||||
else if (crecp->flags & F_DNSKEY)
|
||||
@@ -472,7 +470,7 @@ static struct crec *cache_scan_free(char *name, union all_addr *addr, unsigned s
|
||||
if ((crecp->flags & F_FORWARD) && hostname_isequal(cache_get_name(crecp), name))
|
||||
{
|
||||
/* Don't delete DNSSEC in favour of a CNAME, they can co-exist */
|
||||
if ((flags & crecp->flags & (F_IPV4 | F_IPV6 | F_SRV | F_NXDOMAIN)) ||
|
||||
if ((flags & crecp->flags & (F_IPV4 | F_IPV6 | F_RR | F_NXDOMAIN)) ||
|
||||
(((crecp->flags | flags) & F_CNAME) && !(crecp->flags & (F_DNSKEY | F_DS))) ||
|
||||
((crecp->flags & flags & F_RR) && addr->rr.rrtype == crecp->addr.rr.rrtype))
|
||||
{
|
||||
@@ -791,14 +789,9 @@ void cache_end_insert(void)
|
||||
read_write(daemon->pipe_to_parent, (unsigned char *)&new_chain->ttd, sizeof(new_chain->ttd), 0);
|
||||
read_write(daemon->pipe_to_parent, (unsigned char *)&flags, sizeof(flags), 0);
|
||||
|
||||
if (flags & (F_IPV4 | F_IPV6 | F_DNSKEY | F_DS | F_SRV | F_RR))
|
||||
if (flags & (F_IPV4 | F_IPV6 | F_DNSKEY | F_DS | F_RR))
|
||||
read_write(daemon->pipe_to_parent, (unsigned char *)&new_chain->addr, sizeof(new_chain->addr), 0);
|
||||
if (flags & F_SRV)
|
||||
{
|
||||
/* A negative SRV entry is possible and has no data, obviously. */
|
||||
if (!(flags & F_NEG))
|
||||
blockdata_write(new_chain->addr.srv.target, new_chain->addr.srv.targetlen, daemon->pipe_to_parent);
|
||||
}
|
||||
|
||||
if (flags & F_RR)
|
||||
{
|
||||
/* A negative RR entry is possible and has no data, obviously. */
|
||||
@@ -869,16 +862,13 @@ int cache_recv_insert(time_t now, int fd)
|
||||
|
||||
ttl = difftime(ttd, now);
|
||||
|
||||
if (flags & (F_IPV4 | F_IPV6 | F_DNSKEY | F_DS | F_SRV | F_RR))
|
||||
if (flags & (F_IPV4 | F_IPV6 | F_DNSKEY | F_DS | F_RR))
|
||||
{
|
||||
unsigned short class = C_IN;
|
||||
|
||||
if (!read_write(fd, (unsigned char *)&addr, sizeof(addr), 1))
|
||||
return 0;
|
||||
|
||||
if ((flags & F_SRV) && !(flags & F_NEG) && !(addr.srv.target = blockdata_read(fd, addr.srv.targetlen)))
|
||||
return 0;
|
||||
|
||||
if ((flags & F_RR) && !(flags & F_NEG) && !(addr.rr.rrdata = blockdata_read(fd, addr.rr.datalen)))
|
||||
return 0;
|
||||
#ifdef HAVE_DNSSEC
|
||||
@@ -1610,7 +1600,7 @@ static void make_non_terminals(struct crec *source)
|
||||
if (!is_outdated_cname_pointer(crecp) &&
|
||||
(crecp->flags & F_FORWARD) &&
|
||||
(crecp->flags & type) &&
|
||||
!(crecp->flags & (F_IPV4 | F_IPV6 | F_CNAME | F_SRV | F_DNSKEY | F_DS | F_RR)) &&
|
||||
!(crecp->flags & (F_IPV4 | F_IPV6 | F_CNAME | F_DNSKEY | F_DS | F_RR)) &&
|
||||
hostname_isequal(name, cache_get_name(crecp)))
|
||||
{
|
||||
*up = crecp->hash_next;
|
||||
@@ -1667,7 +1657,7 @@ static void make_non_terminals(struct crec *source)
|
||||
|
||||
if (crecp)
|
||||
{
|
||||
crecp->flags = (source->flags | F_NAMEP) & ~(F_IPV4 | F_IPV6 | F_CNAME | F_SRV | F_RR | F_DNSKEY | F_DS | F_REVERSE);
|
||||
crecp->flags = (source->flags | F_NAMEP) & ~(F_IPV4 | F_IPV6 | F_CNAME | F_RR | F_DNSKEY | F_DS | F_REVERSE);
|
||||
if (!(crecp->flags & F_IMMORTAL))
|
||||
crecp->ttd = source->ttd;
|
||||
crecp->name.namep = name;
|
||||
@@ -1804,17 +1794,6 @@ static void dump_cache_entry(struct crec *cache, time_t now)
|
||||
p += sprintf(p, "%-30.30s ", sanitise(n));
|
||||
if ((cache->flags & F_CNAME) && !is_outdated_cname_pointer(cache))
|
||||
a = sanitise(cache_get_cname_target(cache));
|
||||
else if ((cache->flags & F_SRV) && !(cache->flags & F_NEG))
|
||||
{
|
||||
int targetlen = cache->addr.srv.targetlen;
|
||||
ssize_t len = sprintf(a, "%u %u %u ", cache->addr.srv.priority,
|
||||
cache->addr.srv.weight, cache->addr.srv.srvport);
|
||||
|
||||
if (targetlen > (40 - len))
|
||||
targetlen = 40 - len;
|
||||
blockdata_retrieve(cache->addr.srv.target, targetlen, a + len);
|
||||
a[len + targetlen] = 0;
|
||||
}
|
||||
else if (cache->flags & F_RR)
|
||||
sprintf(a, "%s", querystr(NULL, cache->addr.rr.rrtype));
|
||||
#ifdef HAVE_DNSSEC
|
||||
@@ -1843,8 +1822,6 @@ static void dump_cache_entry(struct crec *cache, time_t now)
|
||||
t = "6";
|
||||
else if (cache->flags & F_CNAME)
|
||||
t = "C";
|
||||
else if (cache->flags & F_SRV)
|
||||
t = "V";
|
||||
else if (cache->flags & F_RR)
|
||||
t = "T";
|
||||
#ifdef HAVE_DNSSEC
|
||||
@@ -2133,8 +2110,6 @@ void log_query(unsigned int flags, char *name, union all_addr *addr, char *arg,
|
||||
}
|
||||
else if (flags & F_CNAME)
|
||||
dest = "<CNAME>";
|
||||
else if (flags & F_SRV)
|
||||
dest = "<SRV>";
|
||||
else if (flags & F_RRNAME)
|
||||
dest = arg;
|
||||
|
||||
@@ -2158,7 +2133,7 @@ void log_query(unsigned int flags, char *name, union all_addr *addr, char *arg,
|
||||
}
|
||||
else if (flags & F_AUTH)
|
||||
source = "auth";
|
||||
else if (flags & F_NOERR)
|
||||
else if (flags & F_DNSSEC)
|
||||
{
|
||||
source = arg;
|
||||
verb = "to";
|
||||
|
||||
Reference in New Issue
Block a user