summaryrefslogtreecommitdiff
path: root/proto/rpki
diff options
context:
space:
mode:
Diffstat (limited to 'proto/rpki')
-rw-r--r--proto/rpki/transport.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/proto/rpki/transport.c b/proto/rpki/transport.c
index 9dcb7c5c..a1ac7587 100644
--- a/proto/rpki/transport.c
+++ b/proto/rpki/transport.c
@@ -19,12 +19,13 @@
/**
* rpki_hostname_autoresolv - auto-resolve an IP address from a hostname
* @host: domain name of host, e.g. "rpki-validator.realmv6.org"
+ * @err_msg: error message returned in case of errors
*
* This function resolves an IP address from a hostname.
* Returns &ip_addr structure with IP address or |IPA_NONE|.
*/
static ip_addr
-rpki_hostname_autoresolv(const char *host)
+rpki_hostname_autoresolv(const char *host, const char **err_msg)
{
struct addrinfo *res;
struct addrinfo hints = {
@@ -33,13 +34,15 @@ rpki_hostname_autoresolv(const char *host)
.ai_flags = AI_ADDRCONFIG,
};
+ *err_msg = NULL;
+
if (!host)
return IPA_NONE;
int err_code = getaddrinfo(host, NULL, &hints, &res);
if (err_code != 0)
{
- log(L_DEBUG "getaddrinfo failed: %s", gai_strerror(err_code));
+ *err_msg = gai_strerror(err_code);
return IPA_NONE;
}
@@ -83,12 +86,15 @@ rpki_tr_open(struct rpki_tr_sock *tr)
sk->tbsize = RPKI_TX_BUFFER_SIZE;
sk->tos = IP_PREC_INTERNET_CONTROL;
- if (ipa_zero2(sk->daddr) && sk->host)
+ if (ipa_zero(sk->daddr) && sk->host)
{
- sk->daddr = rpki_hostname_autoresolv(sk->host);
+ const char *err_msg;
+
+ sk->daddr = rpki_hostname_autoresolv(sk->host, &err_msg);
if (ipa_zero(sk->daddr))
{
- CACHE_TRACE(D_EVENTS, cache, "Cannot resolve the hostname '%s'", sk->host);
+ log(L_ERR "%s: Cannot resolve hostname '%s': %s",
+ cache->p->p.name, sk->host, err_msg);
return RPKI_TR_ERROR;
}
}