From: Yuri Schaeffer Date: Tue, 18 Sep 2012 14:37:00 +0000 (+0000) Subject: mark mesh entry with subnet info. And match that info when looking up mesh entry. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0af8bc80222120930c7fe066aa6db91a4eb7828c;p=thirdparty%2Funbound.git mark mesh entry with subnet info. And match that info when looking up mesh entry. git-svn-id: file:///svn/unbound/branches/edns-subnet@2762 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/services/mesh.h b/services/mesh.h index 8291fc4bb..5f109779a 100644 --- a/services/mesh.h +++ b/services/mesh.h @@ -182,12 +182,6 @@ struct mesh_state { /** true if replies have been sent out (at end for alignment) */ uint8_t replies_sent; - - /* YBS */ - int subnet_option_expect; - uint16_t subnet_addr_fam; - uint8_t subnet_source_mask; - uint8_t subnet_addr[16]; }; /** diff --git a/services/outside_network.c b/services/outside_network.c index 3da40d9dc..e51b87e5b 100644 --- a/services/outside_network.c +++ b/services/outside_network.c @@ -1357,10 +1357,12 @@ serviced_encode(struct serviced_query* sq, ldns_buffer* buff, int with_edns) #endif edns.subnet_scope_mask = 0; //YBS add addr,fam,mask to mesh. - sq->mesh_info->subnet_option_expect = 1; - sq->mesh_info->subnet_addr_fam = edns.subnet_addr_fam; - sq->mesh_info->subnet_source_mask = edns.subnet_source_mask; - memcpy(sq->mesh_info->subnet_addr, (uint8_t *)sinaddr, INET6_SIZE); + sq->mesh_info->s.qinfo.subnet_option = 1; + sq->mesh_info->s.qinfo.subnet_addr_fam = edns.subnet_addr_fam; + sq->mesh_info->s.qinfo.subnet_source_mask = edns.subnet_source_mask; + memcpy(sq->mesh_info->s.qinfo.subnet_addr, (uint8_t *)sinaddr, INET6_SIZE); + } else { + sq->mesh_info->s.qinfo.subnet_option = 0; } if(sq->status == serviced_query_UDP_EDNS_FRAG) { if(addr_is_ip6(&sq->addr, sq->addrlen)) { diff --git a/util/data/msgreply.c b/util/data/msgreply.c index 6d711fff3..f87e0a8fe 100644 --- a/util/data/msgreply.c +++ b/util/data/msgreply.c @@ -529,11 +529,22 @@ query_info_compare(void* m1, void* m2) struct query_info* msg2 = (struct query_info*)m2; int mc; /* from most different to least different for speed */ + if(m1 == m2) return 0; COMPARE_IT(msg1->qtype, msg2->qtype); if((mc = query_dname_compare(msg1->qname, msg2->qname)) != 0) return mc; log_assert(msg1->qname_len == msg2->qname_len); COMPARE_IT(msg1->qclass, msg2->qclass); + /* If the reply has subnet and we expect subnet, whole option must + * match. Otherwise be lenient.*/ + if(msg1->subnet_option && msg2->subnet_option) { + COMPARE_IT(msg1->subnet_addr_fam, msg2->subnet_addr_fam); + COMPARE_IT(msg1->subnet_source_mask, msg2->subnet_source_mask); + if((mc = memcmp(msg1->subnet_addr, + msg2->subnet_addr, INET6_SIZE)) != 0) + return mc; + } + return 0; #undef COMPARE_IT } diff --git a/util/data/msgreply.h b/util/data/msgreply.h index a32f2b1ed..e8fa8bec6 100644 --- a/util/data/msgreply.h +++ b/util/data/msgreply.h @@ -43,6 +43,7 @@ #define UTIL_DATA_MSGREPLY_H #include "util/storage/lruhash.h" #include "util/data/packed_rrset.h" +#include "util/net_help.h" struct comm_reply; struct alloc_cache; struct iovec; @@ -72,6 +73,11 @@ struct query_info { uint16_t qtype; /** qclass, host byte order */ uint16_t qclass; + /* YBS */ + int subnet_option; + uint16_t subnet_addr_fam; + uint8_t subnet_source_mask; + uint8_t subnet_addr[INET6_SIZE]; }; /**