diff options
author | Scott Wood <scottwood@freescale.com> | 2014-04-07 23:49:35 (GMT) |
---|---|---|
committer | Scott Wood <scottwood@freescale.com> | 2014-04-07 23:49:35 (GMT) |
commit | 62b8c978ee6b8d135d9e7953221de58000dba986 (patch) | |
tree | 683b04b2e627f6710c22c151b23c8cc9a165315e /tools/hv/hv_kvp_daemon.c | |
parent | 78fd82238d0e5716578c326404184a27ba67fd6e (diff) | |
download | linux-fsl-qoriq-62b8c978ee6b8d135d9e7953221de58000dba986.tar.xz |
Rewind v3.13-rc3+ (78fd82238d0e5716) to v3.12
Diffstat (limited to 'tools/hv/hv_kvp_daemon.c')
-rw-r--r-- | tools/hv/hv_kvp_daemon.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c index b8d6d54..8fd9ec6 100644 --- a/tools/hv/hv_kvp_daemon.c +++ b/tools/hv/hv_kvp_daemon.c @@ -89,7 +89,6 @@ static char *processor_arch; static char *os_build; static char *os_version; static char *lic_version = "Unknown version"; -static char full_domain_name[HV_KVP_EXCHANGE_MAX_VALUE_SIZE]; static struct utsname uts_buf; /* @@ -1368,7 +1367,7 @@ setval_error: } -static void +static int kvp_get_domain_name(char *buffer, int length) { struct addrinfo hints, *info ; @@ -1382,12 +1381,12 @@ kvp_get_domain_name(char *buffer, int length) error = getaddrinfo(buffer, NULL, &hints, &info); if (error != 0) { - snprintf(buffer, length, "getaddrinfo failed: 0x%x %s", - error, gai_strerror(error)); - return; + strcpy(buffer, "getaddrinfo failed\n"); + return error; } - snprintf(buffer, length, "%s", info->ai_canonname); + strcpy(buffer, info->ai_canonname); freeaddrinfo(info); + return error; } static int @@ -1434,6 +1433,7 @@ int main(void) int pool; char *if_name; struct hv_kvp_ipaddr_value *kvp_ip_val; + char *kvp_send_buffer; char *kvp_recv_buffer; size_t kvp_recv_buffer_len; @@ -1442,21 +1442,17 @@ int main(void) openlog("KVP", 0, LOG_USER); syslog(LOG_INFO, "KVP starting; pid is:%d", getpid()); - kvp_recv_buffer_len = NLMSG_LENGTH(0) + sizeof(struct cn_msg) + sizeof(struct hv_kvp_msg); + kvp_recv_buffer_len = NLMSG_HDRLEN + sizeof(struct cn_msg) + sizeof(struct hv_kvp_msg); + kvp_send_buffer = calloc(1, kvp_recv_buffer_len); kvp_recv_buffer = calloc(1, kvp_recv_buffer_len); - if (!kvp_recv_buffer) { - syslog(LOG_ERR, "Failed to allocate netlink buffer"); + if (!(kvp_send_buffer && kvp_recv_buffer)) { + syslog(LOG_ERR, "Failed to allocate netlink buffers"); exit(EXIT_FAILURE); } /* * Retrieve OS release information. */ kvp_get_os_info(); - /* - * Cache Fully Qualified Domain Name because getaddrinfo takes an - * unpredictable amount of time to finish. - */ - kvp_get_domain_name(full_domain_name, sizeof(full_domain_name)); if (kvp_file_init()) { syslog(LOG_ERR, "Failed to initialize the pools"); @@ -1492,7 +1488,7 @@ int main(void) /* * Register ourselves with the kernel. */ - message = (struct cn_msg *)kvp_recv_buffer; + message = (struct cn_msg *)kvp_send_buffer; message->id.idx = CN_KVP_IDX; message->id.val = CN_KVP_VAL; @@ -1675,7 +1671,8 @@ int main(void) switch (hv_msg->body.kvp_enum_data.index) { case FullyQualifiedDomainName: - strcpy(key_value, full_domain_name); + kvp_get_domain_name(key_value, + HV_KVP_EXCHANGE_MAX_VALUE_SIZE); strcpy(key_name, "FullyQualifiedDomainName"); break; case IntegrationServicesVersion: |