diff options
author | Olaf Hering <olaf@aepfle.de> | 2013-08-01 14:34:26 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-02 11:44:18 +0800 |
commit | b4919a5f95c09992f66d4b7cbe392c33731a5cec (patch) | |
tree | 2e5cece4cb4167d5e99e804cd10c54601ac3a1d0 /tools/hv/hv_vss_daemon.c | |
parent | cfc25993e81f3fa68481d062be634d33184d5eae (diff) | |
download | lwn-b4919a5f95c09992f66d4b7cbe392c33731a5cec.tar.gz lwn-b4919a5f95c09992f66d4b7cbe392c33731a5cec.zip |
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_vss_daemon.c')
-rw-r--r-- | tools/hv/hv_vss_daemon.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c index 826d499dc354..4213d0e3083f 100644 --- a/tools/hv/hv_vss_daemon.c +++ b/tools/hv/hv_vss_daemon.c @@ -38,8 +38,6 @@ #include <linux/netlink.h> #include <syslog.h> -static char vss_recv_buffer[4096]; -static char vss_send_buffer[4096]; static struct sockaddr_nl addr; #ifndef SOL_NETLINK @@ -147,6 +145,9 @@ int main(void) struct cn_msg *incoming_cn_msg; int op; struct hv_vss_msg *vss_msg; + char *vss_send_buffer; + char *vss_recv_buffer; + size_t vss_recv_buffer_len; if (daemon(1, 0)) return 1; @@ -154,6 +155,14 @@ int main(void) openlog("Hyper-V VSS", 0, LOG_USER); syslog(LOG_INFO, "VSS starting; pid is:%d", getpid()); + vss_recv_buffer_len = NLMSG_HDRLEN + sizeof(struct cn_msg) + sizeof(struct hv_vss_msg); + vss_send_buffer = calloc(1, vss_recv_buffer_len); + vss_recv_buffer = calloc(1, vss_recv_buffer_len); + if (!(vss_send_buffer && vss_recv_buffer)) { + syslog(LOG_ERR, "Failed to allocate netlink buffers"); + exit(EXIT_FAILURE); + } + fd = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR); if (fd < 0) { syslog(LOG_ERR, "netlink socket creation failed; error:%d %s", @@ -215,7 +224,7 @@ int main(void) continue; } - len = recvfrom(fd, vss_recv_buffer, sizeof(vss_recv_buffer), 0, + len = recvfrom(fd, vss_recv_buffer, vss_recv_buffer_len, 0, addr_p, &addr_l); if (len < 0) { |