From 0432fe37c45ac4f0ca31d150a2759cfe63c1bce7 Mon Sep 17 00:00:00 2001 From: Sara Dickinson Date: Thu, 21 Jul 2016 19:24:18 +0200 Subject: [PATCH 1/5] Tinker with upstream keepalive --- src/context.c | 2 ++ src/context.h | 1 + src/stub.c | 15 +++++++++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/context.c b/src/context.c index 847fb041..5439a7a9 100644 --- a/src/context.c +++ b/src/context.c @@ -711,6 +711,7 @@ _getdns_upstream_shutdown(getdns_upstream *upstream) upstream->responses_received = 0; upstream->responses_timeouts = 0; upstream->keepalive_timeout = 0; + upstream->keepalive_shutdown = 0; /* Now TLS stuff*/ upstream->tls_auth_state = GETDNS_AUTH_NONE; @@ -836,6 +837,7 @@ upstream_init(getdns_upstream *upstream, upstream->queries_sent = 0; upstream->responses_received = 0; upstream->responses_timeouts = 0; + upstream->keepalive_shutdown = 0; upstream->keepalive_timeout = 0; upstream->to_retry = 2; upstream->back_off = 1; diff --git a/src/context.h b/src/context.h index 84a2c40c..c2e91f3d 100644 --- a/src/context.h +++ b/src/context.h @@ -148,6 +148,7 @@ typedef struct getdns_upstream { size_t queries_sent; size_t responses_received; size_t responses_timeouts; + size_t keepalive_shutdown; uint64_t keepalive_timeout; /* Management of outstanding requests on stateful transports */ diff --git a/src/stub.c b/src/stub.c index 2b6f9c36..54fb4b76 100644 --- a/src/stub.c +++ b/src/stub.c @@ -342,9 +342,17 @@ process_keepalive( /* Use server sent value unless the client specified a shorter one. Convert to ms first (wire value has units of 100ms) */ uint64_t server_keepalive = ((uint64_t)gldns_read_uint16(position))*100; + DEBUG_STUB("%s %-35s: FD: %d Server Keepalive recived: %d ms\n", + STUB_DEBUG_READ, __FUNCTION__, upstream->fd, + (int)server_keepalive); if (netreq->owner->context->idle_timeout < server_keepalive) upstream->keepalive_timeout = netreq->owner->context->idle_timeout; else { + if (server_keepalive == 0) { + /* This means the server wants us to shut the connection (sending no + more queries). */ + upstream->keepalive_shutdown = 1; + } upstream->keepalive_timeout = server_keepalive; DEBUG_STUB("%s %-35s: FD: %d Server Keepalive used: %d ms\n", STUB_DEBUG_READ, __FUNCTION__, upstream->fd, @@ -1551,8 +1559,11 @@ upstream_working_ok(getdns_upstream *upstream) static int upstream_active(getdns_upstream *upstream) { - return ((upstream->conn_state == GETDNS_CONN_SETUP || - upstream->conn_state == GETDNS_CONN_OPEN) ? 1 : 0); + if ((upstream->conn_state == GETDNS_CONN_SETUP || + upstream->conn_state == GETDNS_CONN_OPEN) && + upstream->keepalive_shutdown == 0) + return 1; + return 0; } static int From a1461d51eceedbd6cfa7567fa1659be4724ed876 Mon Sep 17 00:00:00 2001 From: Sara Dickinson Date: Fri, 5 Aug 2016 14:10:55 +0100 Subject: [PATCH 2/5] Add abbreviated logging mode for daemon --- configure.ac | 9 +++++++++ src/context.c | 37 ++++++++++++++++++++++++------------- src/context.h | 3 +++ src/debug.h | 8 ++++++++ src/stub.c | 15 ++++++++++++--- src/types-internal.h | 11 +++++++++++ 6 files changed, 67 insertions(+), 16 deletions(-) diff --git a/configure.ac b/configure.ac index 73150114..efcf7ce0 100644 --- a/configure.ac +++ b/configure.ac @@ -144,6 +144,7 @@ ACX_ARG_RPATH AC_ARG_ENABLE(debug-sched, AC_HELP_STRING([--enable-debug-sched], [Enable scheduling debugging messages])) AC_ARG_ENABLE(debug-stub, AC_HELP_STRING([--enable-debug-stub], [Enable stub debugging messages])) +AC_ARG_ENABLE(debug-daemon, AC_HELP_STRING([--enable-debug-daemon], [Enable daemon debugging messages])) AC_ARG_ENABLE(debug-sec, AC_HELP_STRING([--enable-debug-sec], [Enable dnssec debugging messages])) AC_ARG_ENABLE(debug-server, AC_HELP_STRING([--enable-debug-server], [Enable server debugging messages])) AC_ARG_ENABLE(all-debugging, AC_HELP_STRING([--enable-all-debugging], [Enable scheduling, stub and dnssec debugging])) @@ -151,6 +152,7 @@ case "$enable_all_debugging" in yes) enable_debug_sched=yes enable_debug_stub=yes + enable_debug_daemon=yes enable_debug_sec=yes enable_debug_server=yes ;; @@ -171,6 +173,13 @@ case "$enable_debug_stub" in no|*) ;; esac +case "$enable_debug_daemon" in + yes) + AC_DEFINE_UNQUOTED([DAEMON_DEBUG], [1], [Define this to enable printing of daemon debugging messages.]) + ;; + no|*) + ;; +esac case "$enable_debug_sec" in yes) AC_DEFINE_UNQUOTED([SEC_DEBUG], [1], [Define this to enable printing of dnssec debugging messages.]) diff --git a/src/context.c b/src/context.c index 5439a7a9..1c851e64 100644 --- a/src/context.c +++ b/src/context.c @@ -224,6 +224,14 @@ add_WIN_cacerts_to_openssl_store(SSL_CTX* tls_ctx) } #endif +static uint8_t* +upstream_addr(getdns_upstream *upstream) +{ + return upstream->addr.ss_family == AF_INET + ? (void *)&((struct sockaddr_in*)&upstream->addr)->sin_addr + : (void *)&((struct sockaddr_in6*)&upstream->addr)->sin6_addr; +} + static void destroy_local_host(_getdns_rbnode_t * node, void *arg) { getdns_context *context = (getdns_context *)arg; @@ -683,11 +691,17 @@ _getdns_upstream_shutdown(getdns_upstream *upstream) if (upstream->tls_auth_state != GETDNS_AUTH_NONE) upstream->past_tls_auth_state = upstream->tls_auth_state; - DEBUG_STUB("%s %-35s: FD: %d Upstream Stats: Resp=%d,Timeouts=%d,Conns=%d,Conn_fails=%d,Conn_shutdowns=%d,Auth=%d\n", - STUB_DEBUG_CLEANUP, __FUNCTION__, upstream->fd, - (int)upstream->total_responses, (int)upstream->total_timeouts, - (int)upstream->conn_completed, (int)upstream->conn_setup_failed, - (int)upstream->conn_shutdowns, upstream->past_tls_auth_state); +#if defined(DAEMON_DEBUG) && DAEMON_DEBUG + DEBUG_DAEMON("%s Upstream %s : Connection closed: Connection stats - Resp=%d,Timeouts=%d,Keepalive(ms)=%d,Auth=%s\n", + STUB_DEBUG_DAEMON, upstream->addr_str, + (int)upstream->responses_received, (int)upstream->responses_timeouts, + (int)upstream->keepalive_timeout, getdns_auth_str_array[upstream->tls_auth_state]); + DEBUG_DAEMON("%s Upstream %s : Connection closed: Upstream stats - Resp=%d,Timeouts=%d,Conns=%d,Conn_fails=%d,Conn_shutdowns=%d,Auth=%s\n", + STUB_DEBUG_DAEMON, upstream->addr_str, + (int)upstream->total_responses, (int)upstream->total_timeouts, + (int)upstream->conn_completed, (int)upstream->conn_setup_failed, + (int)upstream->conn_shutdowns, getdns_auth_str_array[upstream->tls_auth_state]); +#endif /* Back off connections that never got up service at all (probably no TCP service or incompatible TLS version/cipher). @@ -829,6 +843,10 @@ upstream_init(getdns_upstream *upstream, upstream->addr_len = ai->ai_addrlen; (void) memcpy(&upstream->addr, ai->ai_addr, ai->ai_addrlen); +#if defined(DAEMON_DEBUG) && DAEMON_DEBUG + inet_ntop(upstream->addr.ss_family, upstream_addr(upstream), + upstream->addr_str, INET6_ADDRSTRLEN); +#endif /* How is this upstream doing? */ upstream->conn_setup_failed = 0; @@ -2831,15 +2849,8 @@ getdns_cancel_callback(getdns_context *context, return r; } /* getdns_cancel_callback */ -#ifndef STUB_NATIVE_DNSSEC -static uint8_t* -upstream_addr(getdns_upstream *upstream) -{ - return upstream->addr.ss_family == AF_INET - ? (void *)&((struct sockaddr_in*)&upstream->addr)->sin_addr - : (void *)&((struct sockaddr_in6*)&upstream->addr)->sin6_addr; -} +#ifndef STUB_NATIVE_DNSSEC static in_port_t upstream_port(getdns_upstream *upstream) { diff --git a/src/context.h b/src/context.h index c2e91f3d..9caf458d 100644 --- a/src/context.h +++ b/src/context.h @@ -124,6 +124,9 @@ typedef struct getdns_upstream { socklen_t addr_len; struct sockaddr_storage addr; +#if defined(DAEMON_DEBUG) && DAEMON_DEBUG + char addr_str[INET6_ADDRSTRLEN]; +#endif /* How is this upstream doing over UDP? */ int to_retry; diff --git a/src/debug.h b/src/debug.h index 91051435..643b198d 100644 --- a/src/debug.h +++ b/src/debug.h @@ -45,6 +45,7 @@ #define STUB_DEBUG_READ "------- READ: " #define STUB_DEBUG_WRITE "------- WRITE: " #define STUB_DEBUG_CLEANUP "--- CLEANUP: " +#define STUB_DEBUG_DAEMON "GETDNS_DAEMON: " #define DEBUG_ON(...) do { \ struct timeval tv; \ @@ -88,6 +89,13 @@ #define DEBUG_STUB(...) DEBUG_OFF(__VA_ARGS__) #endif +#if defined(DAEMON_DEBUG) && DAEMON_DEBUG +#include +#define DEBUG_DAEMON(...) DEBUG_ON(__VA_ARGS__) +#else +#define DEBUG_DAEMON(...) DEBUG_OFF(__VA_ARGS__) +#endif + #if defined(SEC_DEBUG) && SEC_DEBUG #include #define DEBUG_SEC(...) DEBUG_ON(__VA_ARGS__) diff --git a/src/stub.c b/src/stub.c index 54fb4b76..74f25d39 100644 --- a/src/stub.c +++ b/src/stub.c @@ -522,9 +522,14 @@ upstream_failed(getdns_upstream *upstream, int during_setup) if (during_setup) { /* Reset timeout on setup failure to trigger fallback handling.*/ GETDNS_CLEAR_EVENT(upstream->loop, &upstream->event); - GETDNS_SCHEDULE_EVENT(upstream->loop, upstream->fd, TIMEOUT_FOREVER, - getdns_eventloop_event_init(&upstream->event, upstream, - NULL, upstream_write_cb, NULL)); + /* Need this check because if the setup failed because the interface is + not up we get -1 and then a seg fault. Found when using IPv6 address + but IPv6 interface not enabled.*/ + if (upstream->fd != -1) { + GETDNS_SCHEDULE_EVENT(upstream->loop, upstream->fd, TIMEOUT_FOREVER, + getdns_eventloop_event_init(&upstream->event, upstream, + NULL, upstream_write_cb, NULL)); + } /* Special case if failure was due to authentication issues since this upstream could be used oppotunistically with no problem.*/ if (!(upstream->transport == GETDNS_TRANSPORT_TLS && @@ -1739,6 +1744,10 @@ upstream_connect(getdns_upstream *upstream, getdns_transport_list_t transport, return -1; /* Nothing to do*/ } +#if defined(DAEMON_DEBUG) && DAEMON_DEBUG + DEBUG_DAEMON("%s Upstream %s : Connection initialised\n", + STUB_DEBUG_DAEMON, upstream->addr_str); +#endif return fd; } diff --git a/src/types-internal.h b/src/types-internal.h index f6c3cf5b..5f67f7cd 100644 --- a/src/types-internal.h +++ b/src/types-internal.h @@ -63,6 +63,17 @@ typedef enum getdns_auth_state { GETDNS_AUTH_OK, /* Tried and worked (Strict) */ } getdns_auth_state_t; +#define GETDNS_STR_AUTH_NONE "N/A" +#define GETDNS_STR_AUTH_FAILED "Failed or not tried" +#define GETDNS_STR_AUTH_OK "Success" + +static char* +getdns_auth_str_array[] = { + GETDNS_STR_AUTH_NONE, + GETDNS_STR_AUTH_FAILED, + GETDNS_STR_AUTH_OK +}; + struct getdns_context; struct getdns_upstreams; struct getdns_upstream; From fdbefa17ecc10aa735776a87b02d1e6ac9013865 Mon Sep 17 00:00:00 2001 From: Sara Dickinson Date: Fri, 5 Aug 2016 17:25:27 +0100 Subject: [PATCH 3/5] Add timer for back off on upstream (use 1 hr). Reset as new upstream when re-instated. --- src/context.c | 38 ++++++++++++++++++++++++++++---------- src/context.h | 2 ++ src/stub.c | 14 +++++++++++--- src/types-internal.h | 4 ++-- 4 files changed, 43 insertions(+), 15 deletions(-) diff --git a/src/context.c b/src/context.c index 1c851e64..5e120317 100644 --- a/src/context.c +++ b/src/context.c @@ -84,6 +84,9 @@ typedef unsigned short in_port_t; #define GETDNS_STR_PORT_ZERO "0" #define GETDNS_STR_PORT_DNS "53" #define GETDNS_STR_PORT_DNS_OVER_TLS "853" +/* How long to wait in seconds before re-trying a connection based backed-off + upstream. Using 1 hour for all transports - based on RFC7858 value for for TLS.*/ +#define BACKOFF_RETRY 3600 void *plain_mem_funcs_user_arg = MF_PLAIN; @@ -692,15 +695,16 @@ _getdns_upstream_shutdown(getdns_upstream *upstream) upstream->past_tls_auth_state = upstream->tls_auth_state; #if defined(DAEMON_DEBUG) && DAEMON_DEBUG - DEBUG_DAEMON("%s Upstream %s : Connection closed: Connection stats - Resp=%d,Timeouts=%d,Keepalive(ms)=%d,Auth=%s\n", + DEBUG_DAEMON("%s %s : Conn closed: Conn stats - Resp=%d,Timeouts=%d,Auth=%s,Keepalive(ms)=%d\n", STUB_DEBUG_DAEMON, upstream->addr_str, (int)upstream->responses_received, (int)upstream->responses_timeouts, - (int)upstream->keepalive_timeout, getdns_auth_str_array[upstream->tls_auth_state]); - DEBUG_DAEMON("%s Upstream %s : Connection closed: Upstream stats - Resp=%d,Timeouts=%d,Conns=%d,Conn_fails=%d,Conn_shutdowns=%d,Auth=%s\n", + getdns_auth_str_array[upstream->tls_auth_state], (int)upstream->keepalive_timeout); + DEBUG_DAEMON("%s %s : Upstream stats - Resp=%d,Timeouts=%d,Auth=%s,Conns=%d,Conn_fails=%d,Conn_shutdowns=%d,Backoffs=%d\n", STUB_DEBUG_DAEMON, upstream->addr_str, (int)upstream->total_responses, (int)upstream->total_timeouts, - (int)upstream->conn_completed, (int)upstream->conn_setup_failed, - (int)upstream->conn_shutdowns, getdns_auth_str_array[upstream->tls_auth_state]); + getdns_auth_str_array[upstream->tls_auth_state], + (int)upstream->conn_completed, (int)upstream->conn_setup_failed, + (int)upstream->conn_shutdowns, (int)upstream->conn_backoffs); #endif /* Back off connections that never got up service at all (probably no @@ -716,10 +720,18 @@ _getdns_upstream_shutdown(getdns_upstream *upstream) (upstream->conn_completed >= GETDNS_CONN_ATTEMPTS && upstream->total_responses == 0 && upstream->total_timeouts > GETDNS_TRANSPORT_FAIL_MULT)) { - DEBUG_STUB("%s %-35s: FD: %d BACKING OFF THIS UPSTREAM! \n", - STUB_DEBUG_CLEANUP, __FUNCTION__, upstream->fd); upstream->conn_state = GETDNS_CONN_BACKOFF; - } + upstream->conn_retry_time = time(NULL) + BACKOFF_RETRY; + upstream->total_responses = 0; + upstream->total_timeouts = 0; + upstream->conn_completed = 0; + upstream->conn_setup_failed = 0; + upstream->conn_shutdowns = 0; + upstream->conn_backoffs++; + DEBUG_DAEMON("%s %s : !Backing off this upstream - will retry as new upstream at %s\n", + STUB_DEBUG_DAEMON, upstream->addr_str, + asctime(gmtime(&upstream->conn_retry_time))); + } // Reset per connection counters upstream->queries_sent = 0; upstream->responses_received = 0; @@ -848,15 +860,21 @@ upstream_init(getdns_upstream *upstream, upstream->addr_str, INET6_ADDRSTRLEN); #endif - /* How is this upstream doing? */ - upstream->conn_setup_failed = 0; + /* How is this upstream doing on connections? */ + upstream->conn_completed = 0; upstream->conn_shutdowns = 0; + upstream->conn_setup_failed = 0; + upstream->conn_retry_time = 0; + upstream->conn_backoffs = 0; + upstream->total_responses = 0; + upstream->total_timeouts = 0; upstream->conn_state = GETDNS_CONN_CLOSED; upstream->queries_sent = 0; upstream->responses_received = 0; upstream->responses_timeouts = 0; upstream->keepalive_shutdown = 0; upstream->keepalive_timeout = 0; + /* How is this upstream doing on UDP? */ upstream->to_retry = 2; upstream->back_off = 1; diff --git a/src/context.h b/src/context.h index 9caf458d..8d192d39 100644 --- a/src/context.h +++ b/src/context.h @@ -143,6 +143,8 @@ typedef struct getdns_upstream { size_t conn_completed; size_t conn_shutdowns; size_t conn_setup_failed; + time_t conn_retry_time; + size_t conn_backoffs; size_t total_responses; size_t total_timeouts; getdns_auth_state_t past_tls_auth_state; diff --git a/src/stub.c b/src/stub.c index 74f25d39..5fd5e9d4 100644 --- a/src/stub.c +++ b/src/stub.c @@ -1626,12 +1626,20 @@ upstream_select_stateful(getdns_network_req *netreq, getdns_transport_list_t tra getdns_upstream *upstream = NULL; getdns_upstreams *upstreams = netreq->owner->upstreams; size_t i; + time_t now = time(NULL); if (!upstreams->count) return NULL; - /* [TLS1]TODO: Add check to re-instate backed-off upstreams after X amount - of time*/ + /* A check to re-instate backed-off upstreams after X amount of time*/ + for (i = 0; i < upstreams->count; i++) { + if (upstreams->upstreams[i].conn_state == GETDNS_CONN_BACKOFF && + upstreams->upstreams[i].conn_retry_time < now) { + upstreams->upstreams[i].conn_state = GETDNS_CONN_CLOSED; + DEBUG_DAEMON("%s %s : Re-instating upstream\n", + STUB_DEBUG_DAEMON, upstreams->upstreams[i].addr_str); + } + } /* First find if an open upstream has the correct properties and use that*/ for (i = 0; i < upstreams->count; i++) { @@ -1745,7 +1753,7 @@ upstream_connect(getdns_upstream *upstream, getdns_transport_list_t transport, /* Nothing to do*/ } #if defined(DAEMON_DEBUG) && DAEMON_DEBUG - DEBUG_DAEMON("%s Upstream %s : Connection initialised\n", + DEBUG_DAEMON("%s %s : Conn init\n", STUB_DEBUG_DAEMON, upstream->addr_str); #endif return fd; diff --git a/src/types-internal.h b/src/types-internal.h index 5f67f7cd..bd1f993c 100644 --- a/src/types-internal.h +++ b/src/types-internal.h @@ -63,8 +63,8 @@ typedef enum getdns_auth_state { GETDNS_AUTH_OK, /* Tried and worked (Strict) */ } getdns_auth_state_t; -#define GETDNS_STR_AUTH_NONE "N/A" -#define GETDNS_STR_AUTH_FAILED "Failed or not tried" +#define GETDNS_STR_AUTH_NONE "None" +#define GETDNS_STR_AUTH_FAILED "Failed" #define GETDNS_STR_AUTH_OK "Success" static char* From 6f9bfffe9f3461287889f4e97f8e08e4201830c1 Mon Sep 17 00:00:00 2001 From: Sara Dickinson Date: Mon, 8 Aug 2016 16:12:33 +0100 Subject: [PATCH 4/5] Catch another error path for failed connections --- src/stub.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/stub.c b/src/stub.c index 5fd5e9d4..bef5bf9d 100644 --- a/src/stub.c +++ b/src/stub.c @@ -1764,21 +1764,28 @@ upstream_find_for_transport(getdns_network_req *netreq, getdns_transport_list_t transport, int *fd) { - /* [TLS1]TODO: Don't currently loop over upstreams here as UDP will timeout - and stateful will fallback. But there is a case where connect returns -1 - that we need to deal with!!!! so add a while loop to test fd*/ getdns_upstream *upstream = NULL; + + /* UDP always returns an upstream, the only reason this will fail is if + no socket is available, in which case that is an error.*/ if (transport == GETDNS_TRANSPORT_UDP) { upstream = upstream_select(netreq); + *fd = upstream_connect(upstream, transport, netreq->owner); + return upstream; } - else - upstream = upstream_select_stateful(netreq, transport); - if (!upstream) - return NULL; - *fd = upstream_connect(upstream, transport, netreq->owner); - DEBUG_STUB("%s %-35s: FD: %d Connecting to upstream: %p No: %d\n", + else { + /* For stateful transport we should keep trying until all our transports + are exhausted/backed-off (no upstream)*/ + do { + upstream = upstream_select_stateful(netreq, transport); + if (!upstream) + return NULL; + *fd = upstream_connect(upstream, transport, netreq->owner); + } while (*fd == -1); + DEBUG_STUB("%s %-35s: FD: %d Connecting to upstream: %p No: %d\n", STUB_DEBUG_SETUP, __FUNCTION__, *fd, upstream, (int)(upstream - netreq->owner->context->upstreams->upstreams)); + } return upstream; } From f156f2f24ae1140ce875a0a4b262a463057cc151 Mon Sep 17 00:00:00 2001 From: Sara Dickinson Date: Mon, 8 Aug 2016 17:07:46 +0100 Subject: [PATCH 5/5] Had to change some preprocessor checks to get all the options to compile --- src/context.c | 28 +++++++++++++--------------- src/dnssec.c | 2 ++ src/stub.c | 4 +++- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/context.c b/src/context.c index 5e120317..58abcd77 100644 --- a/src/context.c +++ b/src/context.c @@ -227,6 +227,7 @@ add_WIN_cacerts_to_openssl_store(SSL_CTX* tls_ctx) } #endif +#if !defined(STUB_NATIVE_DNSSEC) || (defined(DAEMON_DEBUG) && DAEMON_DEBUG) static uint8_t* upstream_addr(getdns_upstream *upstream) { @@ -234,6 +235,16 @@ upstream_addr(getdns_upstream *upstream) ? (void *)&((struct sockaddr_in*)&upstream->addr)->sin_addr : (void *)&((struct sockaddr_in6*)&upstream->addr)->sin6_addr; } +#endif + + +static in_port_t +upstream_port(getdns_upstream *upstream) +{ + return ntohs(upstream->addr.ss_family == AF_INET + ? ((struct sockaddr_in *)&upstream->addr)->sin_port + : ((struct sockaddr_in6*)&upstream->addr)->sin6_port); +} static void destroy_local_host(_getdns_rbnode_t * node, void *arg) { @@ -728,9 +739,11 @@ _getdns_upstream_shutdown(getdns_upstream *upstream) upstream->conn_setup_failed = 0; upstream->conn_shutdowns = 0; upstream->conn_backoffs++; +#if defined(DAEMON_DEBUG) && DAEMON_DEBUG DEBUG_DAEMON("%s %s : !Backing off this upstream - will retry as new upstream at %s\n", STUB_DEBUG_DAEMON, upstream->addr_str, asctime(gmtime(&upstream->conn_retry_time))); +#endif } // Reset per connection counters upstream->queries_sent = 0; @@ -2869,13 +2882,6 @@ getdns_cancel_callback(getdns_context *context, #ifndef STUB_NATIVE_DNSSEC -static in_port_t -upstream_port(getdns_upstream *upstream) -{ - return ntohs(upstream->addr.ss_family == AF_INET - ? ((struct sockaddr_in *)&upstream->addr)->sin_port - : ((struct sockaddr_in6*)&upstream->addr)->sin6_port); -} static uint32_t * upstream_scope_id(getdns_upstream *upstream) @@ -3371,14 +3377,6 @@ getdns_context_get_eventloop(getdns_context *context, getdns_eventloop **loop) return GETDNS_RETURN_GOOD; } -static in_port_t -upstream_port(getdns_upstream *upstream) -{ - return ntohs(upstream->addr.ss_family == AF_INET - ? ((struct sockaddr_in *)&upstream->addr)->sin_port - : ((struct sockaddr_in6*)&upstream->addr)->sin6_port); -} - static getdns_dict* _get_context_settings(getdns_context* context) { diff --git a/src/dnssec.c b/src/dnssec.c index f567b96b..6152782a 100644 --- a/src/dnssec.c +++ b/src/dnssec.c @@ -2687,6 +2687,7 @@ static int chain_head_validate(struct mem_funcs *mf, time_t now, uint32_t skew, * evaluated by processing each head in turn. The worst outcome per network request * is the dnssec status for that network request. */ +#ifdef STUB_NATIVE_DNSSEC static void chain_set_netreq_dnssec_status(chain_head *chain, _getdns_rrset_iter *tas) { chain_head *head; @@ -2723,6 +2724,7 @@ static void chain_set_netreq_dnssec_status(chain_head *chain, _getdns_rrset_iter } } } +#endif /* The DNSSEC status of all heads for a chain structure is evaluated by * processing each head in turn. The worst outcome is the dnssec status for diff --git a/src/stub.c b/src/stub.c index bef5bf9d..e496d61d 100644 --- a/src/stub.c +++ b/src/stub.c @@ -342,7 +342,7 @@ process_keepalive( /* Use server sent value unless the client specified a shorter one. Convert to ms first (wire value has units of 100ms) */ uint64_t server_keepalive = ((uint64_t)gldns_read_uint16(position))*100; - DEBUG_STUB("%s %-35s: FD: %d Server Keepalive recived: %d ms\n", + DEBUG_STUB("%s %-35s: FD: %d Server Keepalive recieved: %d ms\n", STUB_DEBUG_READ, __FUNCTION__, upstream->fd, (int)server_keepalive); if (netreq->owner->context->idle_timeout < server_keepalive) @@ -1636,8 +1636,10 @@ upstream_select_stateful(getdns_network_req *netreq, getdns_transport_list_t tra if (upstreams->upstreams[i].conn_state == GETDNS_CONN_BACKOFF && upstreams->upstreams[i].conn_retry_time < now) { upstreams->upstreams[i].conn_state = GETDNS_CONN_CLOSED; +#if defined(DAEMON_DEBUG) && DAEMON_DEBUG DEBUG_DAEMON("%s %s : Re-instating upstream\n", STUB_DEBUG_DAEMON, upstreams->upstreams[i].addr_str); +#endif } }