Commit b553f58c authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Allow DNS server fallback on invalid IPv6 nameserver.

parent 0b20501c
......@@ -7686,7 +7686,7 @@ exec:
dgoto(R->sp, DNS_R_FOREACH_A);
if ((error = dns_so_check(&R->so)) != 0){
if (error == DNS_ENETUNREACH || error == DNS_ECONNREFUSED){
if (error == DNS_ENETUNREACH || error == DNS_ECONNREFUSED || error == EINVAL){
dgoto(R->sp, DNS_R_FOREACH_A);
}else goto error;
}
......
......@@ -440,15 +440,10 @@ static void set_custom_resolv_conf(belle_sip_stack_t *stack, const char *ns[3]){
free(resolv_file);
}
static void dns_fallback(void) {
static void _dns_fallback(const char *nameservers[]) {
struct addrinfo *ai;
int timeout;
endpoint_t *client = create_endpoint();
const char *nameservers[]={
"94.23.19.176", /*linphone.org ; this is not a name server, it will not respond*/
"8.8.8.8", /* public nameserver, should work*/
NULL
};
if (!BC_ASSERT_PTR_NOT_NULL(client)) return;
timeout = belle_sip_stack_get_dns_timeout(client->stack);
......@@ -471,35 +466,31 @@ static void dns_fallback(void) {
destroy_endpoint(client);
}
static void dns_fallback(void) {
const char *nameservers[]={
"94.23.19.176", /*linphone.org ; this is not a name server, it will not respond*/
"8.8.8.8", /* public nameserver, should work*/
NULL
};
_dns_fallback(nameservers);
}
static void dns_fallback_because_of_scope_link_ipv6(void) {
struct addrinfo *ai;
int timeout;
endpoint_t *client = create_endpoint();
const char *nameservers[]={
"fe80::fdc5:99ef:ac05:5c55%enp0s25", /* Scope link IPv6 name server that will not respond */
"8.8.8.8", /* public nameserver, should work*/
NULL
};
_dns_fallback(nameservers);
}
if (!BC_ASSERT_PTR_NOT_NULL(client)) return;
timeout = belle_sip_stack_get_dns_timeout(client->stack);
set_custom_resolv_conf(client->stack,nameservers);
client->resolver_ctx = belle_sip_stack_resolve_a(client->stack, IPV4_SIP_DOMAIN, SIP_PORT, AF_INET, a_resolve_done, client);
BC_ASSERT_PTR_NOT_NULL(client->resolver_ctx);
BC_ASSERT_TRUE(wait_for(client->stack, &client->resolve_done, 1, timeout));
BC_ASSERT_PTR_NOT_EQUAL(client->ai_list, NULL);
if (client->ai_list) {
struct sockaddr_in *sock_in = (struct sockaddr_in *)client->ai_list->ai_addr;
int ntohsi = (int)ntohs(sock_in->sin_port);
BC_ASSERT_EQUAL(ntohsi, SIP_PORT, int, "%d");
ai = bctbx_ip_address_to_addrinfo(AF_INET, SOCK_STREAM, IPV4_SIP_IP, SIP_PORT);
if (ai) {
BC_ASSERT_EQUAL(sock_in->sin_addr.s_addr, ((struct sockaddr_in *)ai->ai_addr)->sin_addr.s_addr, int, "%d");
bctbx_freeaddrinfo(ai);
}
}
destroy_endpoint(client);
static void dns_fallback_because_of_invalid_ipv6(void) {
const char *nameservers[]={
"fe80::ba26:6cff:feb9:145c", /* Invalid IPv6 name server */
"8.8.8.8", /* public nameserver, should work*/
NULL
};
_dns_fallback(nameservers);
}
static void ipv6_dns_server(void) {
......@@ -591,6 +582,7 @@ test_t resolver_tests[] = {
{ "No query needed", no_query_needed },
{ "DNS fallback", dns_fallback },
{ "DNS fallback because of scope link IPv6", dns_fallback_because_of_scope_link_ipv6 },
{ "DNS fallback because of invalid IPv6", dns_fallback_because_of_invalid_ipv6 },
{ "IPv6 DNS server", ipv6_dns_server },
{ "IPv4 and v6 DNS servers", ipv4_and_ipv6_dns_server }
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment