Add extra logging around network issues (EDE: network error)
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
parent
485faaceb5
commit
ed41584c92
|
@ -105,7 +105,12 @@ int send_from(int fd, int nowild, char *packet, size_t len,
|
|||
#ifdef HAVE_LINUX_NETWORK
|
||||
/* If interface is still in DAD, EINVAL results - ignore that. */
|
||||
if (errno != EINVAL)
|
||||
my_syslog(LOG_ERR, _("failed to send packet: %s"), strerror(errno));
|
||||
{
|
||||
my_syslog(LOG_ERR, _("failed to send packet: %s"), strerror(errno));
|
||||
/********** Pi-hole modification **********/
|
||||
FTL_connection_error("failed to send UDP reply", to);
|
||||
/******************************************/
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@ -567,6 +572,12 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr,
|
|||
break;
|
||||
forward->forwardall++;
|
||||
}
|
||||
/**** Pi-hole modification ****/
|
||||
else
|
||||
{
|
||||
FTL_connection_error("failed to send UDP request", &srv->addr);
|
||||
}
|
||||
/******************************/
|
||||
}
|
||||
|
||||
if (++start == last)
|
||||
|
@ -2087,12 +2098,19 @@ static ssize_t tcp_talk(int first, int last, int start, unsigned char *packet,
|
|||
data_sent = 1;
|
||||
else if (errno == ETIMEDOUT || errno == EHOSTUNREACH)
|
||||
timedout = 1;
|
||||
/**** Pi-hole modification ****/
|
||||
if (errno != 0)
|
||||
FTL_connection_error("failed to send TCP(fast-open) packet", &serv->addr);
|
||||
/******************************/
|
||||
#endif
|
||||
|
||||
/* If fastopen failed due to lack of reply, then there's no point in
|
||||
trying again in non-FASTOPEN mode. */
|
||||
if (timedout || (!data_sent && connect(serv->tcpfd, &serv->addr.sa, sa_len(&serv->addr)) == -1))
|
||||
{
|
||||
/**** Pi-hole modification ****/
|
||||
FTL_connection_error("failed to send TCP(connect) packet", &serv->addr);
|
||||
/******************************/
|
||||
close(serv->tcpfd);
|
||||
serv->tcpfd = -1;
|
||||
continue;
|
||||
|
@ -2107,6 +2125,10 @@ static ssize_t tcp_talk(int first, int last, int start, unsigned char *packet,
|
|||
!read_write(serv->tcpfd, &c2, 1, 1) ||
|
||||
!read_write(serv->tcpfd, payload, (rsize = (c1 << 8) | c2), 1))
|
||||
{
|
||||
/**** Pi-hole modification ****/
|
||||
FTL_connection_error("failed to send TCP(read_write) packet", &serv->addr);
|
||||
/******************************/
|
||||
|
||||
close(serv->tcpfd);
|
||||
serv->tcpfd = -1;
|
||||
/* We get data then EOF, reopen connection to same server,
|
||||
|
|
|
@ -72,7 +72,7 @@ static void FTL_forwarded(const unsigned int flags, const char *name, const unio
|
|||
static void FTL_reply(const unsigned int flags, const char *name, const union all_addr *addr, const char* arg, const int id, const char* file, const int line);
|
||||
static void FTL_upstream_error(const union all_addr *addr, const unsigned int flags, const int id, const char* file, const int line);
|
||||
static void FTL_dnssec(const char *result, const union all_addr *addr, const int id, const char* file, const int line);
|
||||
static void mysockaddr_extract_ip_port(union mysockaddr *server, char ip[ADDRSTRLEN+1], in_port_t *port);
|
||||
static void mysockaddr_extract_ip_port(const union mysockaddr *server, char ip[ADDRSTRLEN+1], in_port_t *port);
|
||||
static void alladdr_extract_ip(union all_addr *addr, const sa_family_t family, char ip[ADDRSTRLEN+1]);
|
||||
static void check_pihole_PTR(char *domain);
|
||||
#define query_set_dnssec(query, dnssec) _query_set_dnssec(query, dnssec, __FILE__, __LINE__)
|
||||
|
@ -1829,7 +1829,7 @@ static void alladdr_extract_ip(union all_addr *addr, const sa_family_t family, c
|
|||
inet_ntop(family, addr, ip, ADDRSTRLEN);
|
||||
}
|
||||
|
||||
static void mysockaddr_extract_ip_port(union mysockaddr *server, char ip[ADDRSTRLEN+1], in_port_t *port)
|
||||
static void mysockaddr_extract_ip_port(const union mysockaddr *server, char ip[ADDRSTRLEN+1], in_port_t *port)
|
||||
{
|
||||
// Extract IP address
|
||||
inet_ntop(server->sa.sa_family,
|
||||
|
@ -3507,4 +3507,27 @@ void get_dnsmasq_metrics_obj(cJSON *json)
|
|||
{
|
||||
for (unsigned int i = 0; i < __METRIC_MAX; i++)
|
||||
cJSON_AddNumberToObject(json, get_metric_name(i), daemon->metrics[i]);
|
||||
}
|
||||
|
||||
void FTL_connection_error(const char *reason, const union mysockaddr *addr)
|
||||
{
|
||||
// Make a private copy of the error
|
||||
const char *error = strerror(errno);
|
||||
|
||||
if(config.debug.queries.v.b)
|
||||
{
|
||||
const int id = daemon->log_display_id;
|
||||
|
||||
// Format the address into a string (if available)
|
||||
in_port_t port = 0;
|
||||
char ip[ADDRSTRLEN] = { 0 };
|
||||
if(addr != NULL)
|
||||
mysockaddr_extract_ip_port(addr, ip, &port);
|
||||
|
||||
// Log to FTL.log
|
||||
log_debug(DEBUG_QUERIES, "Connection error: %s (%s) for %s#%u (ID %d)", reason, error, ip, port, id);
|
||||
}
|
||||
|
||||
// Log to pihole.log
|
||||
my_syslog(LOG_ERR, "%s: %s", reason, error);
|
||||
}
|
|
@ -48,6 +48,8 @@ void FTL_TCP_worker_terminating(bool finished);
|
|||
|
||||
bool FTL_unlink_DHCP_lease(const char *ipaddr, const char **hint);
|
||||
|
||||
void FTL_connection_error(const char *reason, const union mysockaddr *addr);
|
||||
|
||||
// defined in src/dnsmasq/cache.c
|
||||
extern char *querystr(char *desc, unsigned short type);
|
||||
|
||||
|
|
Loading…
Reference in New Issue