badcache.c revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 2014-2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/*! \file */
#include <config.h>
#include <isc/platform.h>
#include <dns/badcache.h>
#include <dns/rdatatype.h>
typedef struct dns_bcentry dns_bcentry_t;
struct dns_badcache {
unsigned int magic;
unsigned int count;
unsigned int minsize;
unsigned int size;
unsigned int sweep;
};
struct dns_bcentry {
unsigned int hashval;
};
static isc_result_t
return (ISC_R_NOMEMORY);
if (result != ISC_R_SUCCESS)
goto cleanup;
goto destroy_lock;
}
return (ISC_R_SUCCESS);
return (result);
}
void
}
static isc_result_t
unsigned int newsize, i;
if (grow)
else
return (ISC_R_NOMEMORY);
} else {
}
}
}
return (ISC_R_SUCCESS);
}
void
{
unsigned int i, hashval;
if (result != ISC_R_SUCCESS)
if (update) {
}
break;
}
else
} else
}
goto cleanup;
} else
}
{
unsigned int i;
/*
* XXXMUKS: dns_name_equal() is expensive as it does a
* octet-by-octet comparison, and it can be made better in two
* ways here. First, lowercase the names (use
* dns_name_downcase() instead of dns_name_copy() in
* dns_badcache_add()) so that dns_name_caseequal() can be used
* which the compiler will emit as SIMD instructions. Second,
* don't put multiple copies of the same name in the chain (or
* multiple names will have to be matched for equality), but use
* name->link to store the type specific part.
*/
goto skip;
/*
* Search the hash list. Clean out expired records as we go.
*/
else
continue;
}
break;
}
}
skip:
/*
* Slow sweep to clean out stale records.
*/
}
return (answer);
}
void
unsigned int i;
}
}
}
void
unsigned int i;
if (result != ISC_R_SUCCESS)
int n;
else
} else
}
}
void
unsigned int i;
int n;
if (result != ISC_R_SUCCESS)
else
} else
}
}
}
void
char namebuf[DNS_NAME_FORMATSIZE];
char typebuf[DNS_RDATATYPE_FORMATSIZE];
unsigned int i;
isc_uint64_t t;
else
continue;
}
sizeof(typebuf));
t /= 1000;
}
}
}