mirror of
https://github.com/NLnetLabs/unbound.git
synced 2026-02-18 10:09:27 -05:00
faster message parse.
git-svn-id: file:///svn/unbound/trunk@985 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
fa368eff78
commit
99dfad38b2
3 changed files with 33 additions and 5 deletions
|
|
@ -7,6 +7,7 @@
|
|||
not needed for regular installs, only for very large port ranges.
|
||||
- loop check different speedup pkt-dname-reading, 1% faster for
|
||||
nocache-recursion check.
|
||||
- less hashing during msg parse, 4% for recursion.
|
||||
|
||||
21 February 2008: Wouter
|
||||
- speedup of root-delegation message encoding by 15%.
|
||||
|
|
|
|||
|
|
@ -160,13 +160,39 @@ pkt_hash_rrset(ldns_buffer* pkt, uint8_t* dname, uint16_t type,
|
|||
/* note this MUST be identical to rrset_key_hash in packed_rrset.c */
|
||||
/* this routine handles compressed names */
|
||||
hashvalue_t h = 0xab;
|
||||
h = dname_pkt_hash(pkt, dname, h);
|
||||
h = hashlittle(&type, sizeof(type), h); /* host order */
|
||||
h = hashlittle(&dclass, sizeof(dclass), h); /* netw order */
|
||||
h = hashlittle(&rrset_flags, sizeof(uint32_t), h);
|
||||
return h;
|
||||
}
|
||||
|
||||
/** create partial dname hash for rrset hash */
|
||||
static hashvalue_t
|
||||
pkt_hash_rrset_first(ldns_buffer* pkt, uint8_t* dname)
|
||||
{
|
||||
/* works together with pkt_hash_rrset_rest */
|
||||
/* note this MUST be identical to rrset_key_hash in packed_rrset.c */
|
||||
/* this routine handles compressed names */
|
||||
hashvalue_t h = 0xab;
|
||||
h = dname_pkt_hash(pkt, dname, h);
|
||||
return h;
|
||||
}
|
||||
|
||||
/** create a rrset hash from a partial dname hash */
|
||||
static hashvalue_t
|
||||
pkt_hash_rrset_rest(hashvalue_t dname_h, uint16_t type, uint16_t dclass,
|
||||
uint32_t rrset_flags)
|
||||
{
|
||||
/* works together with pkt_hash_rrset_first */
|
||||
/* note this MUST be identical to rrset_key_hash in packed_rrset.c */
|
||||
hashvalue_t h;
|
||||
h = hashlittle(&type, sizeof(type), dname_h); /* host order */
|
||||
h = hashlittle(&dclass, sizeof(dclass), h); /* netw order */
|
||||
h = hashlittle(&rrset_flags, sizeof(uint32_t), h);
|
||||
return h;
|
||||
}
|
||||
|
||||
/** compare rrset_parse with data */
|
||||
static int
|
||||
rrset_parse_equals(struct rrset_parse* p, ldns_buffer* pkt, hashvalue_t h,
|
||||
|
|
@ -423,6 +449,7 @@ find_rrset(struct msg_parse* msg, ldns_buffer* pkt, uint8_t* dname,
|
|||
uint16_t* prev_dclass, struct rrset_parse** rrset_prev,
|
||||
ldns_pkt_section section, struct regional* region)
|
||||
{
|
||||
hashvalue_t dname_h = pkt_hash_rrset_first(pkt, dname);
|
||||
uint16_t covtype;
|
||||
if(*rrset_prev) {
|
||||
/* check if equal to previous item */
|
||||
|
|
@ -451,14 +478,14 @@ find_rrset(struct msg_parse* msg, ldns_buffer* pkt, uint8_t* dname,
|
|||
/* if rrsig - try to lookup matching data set first */
|
||||
if(type == LDNS_RR_TYPE_RRSIG && pkt_rrsig_covered(pkt,
|
||||
ldns_buffer_current(pkt), &covtype)) {
|
||||
*hash = pkt_hash_rrset(pkt, dname, covtype, dclass,
|
||||
*hash = pkt_hash_rrset_rest(dname_h, covtype, dclass,
|
||||
*rrset_flags);
|
||||
*rrset_prev = msgparse_hashtable_lookup(msg, pkt, *hash,
|
||||
*rrset_flags, dname, dnamelen, covtype, dclass);
|
||||
if(!*rrset_prev && covtype == LDNS_RR_TYPE_NSEC) {
|
||||
/* if NSEC try with NSEC apex bit twiddled */
|
||||
*rrset_flags ^= PACKED_RRSET_NSEC_AT_APEX;
|
||||
*hash = pkt_hash_rrset(pkt, dname, covtype, dclass,
|
||||
*hash = pkt_hash_rrset_rest(dname_h, covtype, dclass,
|
||||
*rrset_flags);
|
||||
*rrset_prev = msgparse_hashtable_lookup(msg, pkt,
|
||||
*hash, *rrset_flags, dname, dnamelen, covtype,
|
||||
|
|
@ -476,7 +503,7 @@ find_rrset(struct msg_parse* msg, ldns_buffer* pkt, uint8_t* dname,
|
|||
if(type != LDNS_RR_TYPE_RRSIG) {
|
||||
int hasother = 0;
|
||||
/* find matching rrsig */
|
||||
*hash = pkt_hash_rrset(pkt, dname, LDNS_RR_TYPE_RRSIG,
|
||||
*hash = pkt_hash_rrset_rest(dname_h, LDNS_RR_TYPE_RRSIG,
|
||||
dclass, *rrset_flags);
|
||||
*rrset_prev = msgparse_hashtable_lookup(msg, pkt, *hash,
|
||||
*rrset_flags, dname, dnamelen, LDNS_RR_TYPE_RRSIG,
|
||||
|
|
@ -497,7 +524,7 @@ find_rrset(struct msg_parse* msg, ldns_buffer* pkt, uint8_t* dname,
|
|||
}
|
||||
}
|
||||
|
||||
*hash = pkt_hash_rrset(pkt, dname, type, dclass, *rrset_flags);
|
||||
*hash = pkt_hash_rrset_rest(dname_h, type, dclass, *rrset_flags);
|
||||
*rrset_prev = msgparse_hashtable_lookup(msg, pkt, *hash, *rrset_flags,
|
||||
dname, dnamelen, type, dclass);
|
||||
if(*rrset_prev)
|
||||
|
|
|
|||
|
|
@ -163,10 +163,10 @@ rrset_key_hash(struct packed_rrset_key* key)
|
|||
/* Note this MUST be identical to pkt_hash_rrset in msgparse.c */
|
||||
/* this routine does not have a compressed name */
|
||||
hashvalue_t h = 0xab;
|
||||
h = dname_query_hash(key->dname, h);
|
||||
h = hashlittle(&t, sizeof(t), h);
|
||||
h = hashlittle(&key->rrset_class, sizeof(uint16_t), h);
|
||||
h = hashlittle(&key->flags, sizeof(uint32_t), h);
|
||||
h = dname_query_hash(key->dname, h);
|
||||
return h;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue