summaryrefslogtreecommitdiff
path: root/tools/hv/hv_kvp_daemon.c
diff options
context:
space:
mode:
authorOlaf Hering <olaf@aepfle.de>2013-08-01 16:34:26 +0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-02 07:44:18 +0400
commitb4919a5f95c09992f66d4b7cbe392c33731a5cec (patch)
tree2e5cece4cb4167d5e99e804cd10c54601ac3a1d0 /tools/hv/hv_kvp_daemon.c
parentcfc25993e81f3fa68481d062be634d33184d5eae (diff)
downloadlinux-b4919a5f95c09992f66d4b7cbe392c33731a5cec.tar.xz
Tools: hv: fix send/recv buffer allocation
hv_kvp_daemon fails to start in current openSuSE 13.1 snapshots because the kvp_send_buffer is too small to hold cn_msg+hv_kvp_msg, the very first sendmsg returns with EFAULT. In addition it fixes the Network info tab in Windows Server 2012R2 in SLES11. Adjust the code in kvp and vss daemon to allocate the needed buffers at runtime. To keep the code simple, the buffer_len includes also the nlmsghdr, although only the recv_buffer needs this extra space. Signed-off-by: Olaf Hering <olaf@aepfle.de> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools/hv/hv_kvp_daemon.c')
-rw-r--r--tools/hv/hv_kvp_daemon.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
index 07819bfa7dba..657c1d27e02e 100644
--- a/tools/hv/hv_kvp_daemon.c
+++ b/tools/hv/hv_kvp_daemon.c
@@ -79,8 +79,6 @@ enum {
DNS
};
-static char kvp_send_buffer[4096];
-static char kvp_recv_buffer[4096 * 2];
static struct sockaddr_nl addr;
static int in_hand_shake = 1;
@@ -1437,10 +1435,21 @@ 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;
daemon(1, 0);
openlog("KVP", 0, LOG_USER);
syslog(LOG_INFO, "KVP starting; pid is:%d", getpid());
+
+ 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_send_buffer && kvp_recv_buffer)) {
+ syslog(LOG_ERR, "Failed to allocate netlink buffers");
+ exit(EXIT_FAILURE);
+ }
/*
* Retrieve OS release information.
*/
@@ -1514,7 +1523,7 @@ int main(void)
continue;
}
- len = recvfrom(fd, kvp_recv_buffer, sizeof(kvp_recv_buffer), 0,
+ len = recvfrom(fd, kvp_recv_buffer, kvp_recv_buffer_len, 0,
addr_p, &addr_l);
if (len < 0) {