summaryrefslogtreecommitdiff
path: root/tools/hv/hv_vss_daemon.c
diff options
context:
space:
mode:
authorOlaf Hering <olaf@aepfle.de>2013-08-06 20:55:38 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-09-26 12:03:31 -0700
commit269ce62bbc00c4e80bf3ca2aa21823f20625bcf6 (patch)
tree357ff8f61092daf5c861ce13f7d1ec0a647a95d9 /tools/hv/hv_vss_daemon.c
parent58125210ab3b202917c04fca014317944d464ea0 (diff)
Tools: hv: use single send+recv buffer
send_buffer is used only once during registration. To reduce runtime memory usage reuse the recv_buffer for registration. Also use NLMSG_LENGTH instead of NLMSG_HDRLEN to take alignment into account. Signed-off-by: Olaf Hering <olaf@aepfle.de> 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.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c
index 8611962c672c..8bcb04096eb2 100644
--- a/tools/hv/hv_vss_daemon.c
+++ b/tools/hv/hv_vss_daemon.c
@@ -140,7 +140,6 @@ 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;
@@ -150,10 +149,9 @@ 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_len = NLMSG_LENGTH(0) + sizeof(struct cn_msg) + sizeof(struct hv_vss_msg);
vss_recv_buffer = calloc(1, vss_recv_buffer_len);
- if (!(vss_send_buffer && vss_recv_buffer)) {
+ if (!vss_recv_buffer) {
syslog(LOG_ERR, "Failed to allocate netlink buffers");
exit(EXIT_FAILURE);
}
@@ -185,7 +183,7 @@ int main(void)
/*
* Register ourselves with the kernel.
*/
- message = (struct cn_msg *)vss_send_buffer;
+ message = (struct cn_msg *)vss_recv_buffer;
message->id.idx = CN_VSS_IDX;
message->id.val = CN_VSS_VAL;
message->ack = 0;