"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/dns.c" between
haproxy-2.2.1.tar.gz and haproxy-2.2.2.tar.gz

About: HAProxy is a TCP/HTTP reverse proxy which is particularly suited for high availability environments.

dns.c  (haproxy-2.2.1):dns.c  (haproxy-2.2.2)
skipping to change at line 1035 skipping to change at line 1035
LIST_ADDQ(&dns_p->answer_list, &dns_answer_record->list); LIST_ADDQ(&dns_p->answer_list, &dns_answer_record->list);
} }
} /* for i 0 to ancount */ } /* for i 0 to ancount */
/* Save the number of records we really own */ /* Save the number of records we really own */
dns_p->header.ancount = nb_saved_records; dns_p->header.ancount = nb_saved_records;
/* now parsing additional records for SRV queries only */ /* now parsing additional records for SRV queries only */
if (dns_query->type != DNS_RTYPE_SRV) if (dns_query->type != DNS_RTYPE_SRV)
goto skip_parsing_additional_records; goto skip_parsing_additional_records;
/* if we find Authority records, just skip them */
for (i = 0; i < dns_p->header.nscount; i++) {
offset = 0;
len = dns_read_name(resp, bufend, reader, tmpname, DNS_MAX_NAME_S
IZE,
&offset, 0);
if (len == 0)
continue;
if (reader + offset + 10 >= bufend)
return DNS_RESP_INVALID;
reader += offset;
/* skip 2 bytes for class */
reader += 2;
/* skip 2 bytes for type */
reader += 2;
/* skip 4 bytes for ttl */
reader += 4;
/* read data len */
len = reader[0] * 256 + reader[1];
reader += 2;
if (reader + len >= bufend)
return DNS_RESP_INVALID;
reader += len;
}
nb_saved_records = 0; nb_saved_records = 0;
for (i = 0; i < dns_p->header.arcount; i++) { for (i = 0; i < dns_p->header.arcount; i++) {
if (reader >= bufend) if (reader >= bufend)
return DNS_RESP_INVALID; return DNS_RESP_INVALID;
dns_answer_record = pool_alloc(dns_answer_item_pool); dns_answer_record = pool_alloc(dns_answer_item_pool);
if (dns_answer_record == NULL) if (dns_answer_record == NULL)
return (DNS_RESP_INVALID); return (DNS_RESP_INVALID);
offset = 0; offset = 0;
skipping to change at line 2416 skipping to change at line 2445
/* we have a response to our DNS resolution */ /* we have a response to our DNS resolution */
use_cache: use_cache:
if (s->dns_ctx.dns_requester && s->dns_ctx.dns_requester->resolution != N ULL) { if (s->dns_ctx.dns_requester && s->dns_ctx.dns_requester->resolution != N ULL) {
resolution = s->dns_ctx.dns_requester->resolution; resolution = s->dns_ctx.dns_requester->resolution;
if (!locked) { if (!locked) {
HA_SPIN_LOCK(DNS_LOCK, &resolvers->lock); HA_SPIN_LOCK(DNS_LOCK, &resolvers->lock);
locked = 1; locked = 1;
} }
if (resolution->step == RSLV_STEP_RUNNING) { if (resolution->step == RSLV_STEP_RUNNING)
ret = ACT_RET_YIELD; goto yield;
goto end;
}
if (resolution->step == RSLV_STEP_NONE) { if (resolution->step == RSLV_STEP_NONE) {
/* We update the variable only if we have a valid respons e. */ /* We update the variable only if we have a valid respons e. */
if (resolution->status == RSLV_STATUS_VALID) { if (resolution->status == RSLV_STATUS_VALID) {
struct sample smp; struct sample smp;
short ip_sin_family = 0; short ip_sin_family = 0;
void *ip = NULL; void *ip = NULL;
dns_get_ip_from_response(&resolution->response, r ule->arg.dns.dns_opts, NULL, dns_get_ip_from_response(&resolution->response, r ule->arg.dns.dns_opts, NULL,
0, &ip, &ip_sin_family, NULL); 0, &ip, &ip_sin_family, NULL);
skipping to change at line 2453 skipping to change at line 2480
if (ip) { if (ip) {
smp.px = px; smp.px = px;
smp.sess = sess; smp.sess = sess;
smp.strm = s; smp.strm = s;
vars_set_by_name(rule->arg.dns.varname, s trlen(rule->arg.dns.varname), &smp); vars_set_by_name(rule->arg.dns.varname, s trlen(rule->arg.dns.varname), &smp);
} }
} }
} }
free(s->dns_ctx.hostname_dn); s->dns_ctx.hostname_dn = NULL; goto release_requester;
s->dns_ctx.hostname_dn_len = 0;
dns_unlink_resolution(s->dns_ctx.dns_requester);
pool_free(dns_requester_pool, s->dns_ctx.dns_requester);
s->dns_ctx.dns_requester = NULL;
goto end;
} }
/* need to configure and start a new DNS resolution */ /* need to configure and start a new DNS resolution */
smp = sample_fetch_as_type(px, sess, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, ru le->arg.dns.expr, SMP_T_STR); smp = sample_fetch_as_type(px, sess, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, ru le->arg.dns.expr, SMP_T_STR);
if (smp == NULL) if (smp == NULL)
goto end; goto end;
fqdn = smp->data.u.str.area; fqdn = smp->data.u.str.area;
if (action_prepare_for_resolution(s, fqdn) == -1) if (action_prepare_for_resolution(s, fqdn) == -1)
goto end; /* on error, ignore the action */ goto end; /* on error, ignore the action */
s->dns_ctx.parent = rule; s->dns_ctx.parent = rule;
HA_SPIN_LOCK(DNS_LOCK, &resolvers->lock); HA_SPIN_LOCK(DNS_LOCK, &resolvers->lock);
locked = 1; locked = 1;
dns_link_resolution(s, OBJ_TYPE_STREAM, 0); dns_link_resolution(s, OBJ_TYPE_STREAM, 0);
/* Check if there is a fresh enough response in the cache of our associat ed resolution */ /* Check if there is a fresh enough response in the cache of our associat ed resolution */
req = s->dns_ctx.dns_requester; req = s->dns_ctx.dns_requester;
if (!req || !req->resolution) { if (!req || !req->resolution)
dns_trigger_resolution(s->dns_ctx.dns_requester); goto release_requester; /* on error, ignore the action */
ret = ACT_RET_YIELD;
goto end;
}
res = req->resolution; res = req->resolution;
exp = tick_add(res->last_resolution, resolvers->hold.valid); exp = tick_add(res->last_resolution, resolvers->hold.valid);
if (resolvers->t && res->status == RSLV_STATUS_VALID && tick_isset(res->l ast_resolution) if (resolvers->t && res->status == RSLV_STATUS_VALID && tick_isset(res->l ast_resolution)
&& !tick_is_expired(exp, now_ms)) { && !tick_is_expired(exp, now_ms)) {
goto use_cache; goto use_cache;
} }
dns_trigger_resolution(s->dns_ctx.dns_requester); dns_trigger_resolution(s->dns_ctx.dns_requester);
yield:
if (flags & ACT_OPT_FINAL)
goto release_requester;
ret = ACT_RET_YIELD; ret = ACT_RET_YIELD;
end: end:
if (locked) if (locked)
HA_SPIN_UNLOCK(DNS_LOCK, &resolvers->lock); HA_SPIN_UNLOCK(DNS_LOCK, &resolvers->lock);
return ret; return ret;
release_requester:
free(s->dns_ctx.hostname_dn);
s->dns_ctx.hostname_dn = NULL;
s->dns_ctx.hostname_dn_len = 0;
if (s->dns_ctx.dns_requester) {
dns_unlink_resolution(s->dns_ctx.dns_requester);
pool_free(dns_requester_pool, s->dns_ctx.dns_requester);
s->dns_ctx.dns_requester = NULL;
}
goto end;
} }
static void release_dns_action(struct act_rule *rule) static void release_dns_action(struct act_rule *rule)
{ {
release_sample_expr(rule->arg.dns.expr); release_sample_expr(rule->arg.dns.expr);
free(rule->arg.dns.varname); free(rule->arg.dns.varname);
free(rule->arg.dns.resolvers_id); free(rule->arg.dns.resolvers_id);
free(rule->arg.dns.dns_opts); free(rule->arg.dns.dns_opts);
} }
 End of changes. 7 change blocks. 
18 lines changed or deleted 51 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)