Skip to content

Commit

Permalink
Tools: hv: use full nlmsghdr in netlink_send
Browse files Browse the repository at this point in the history
There is no need to have a nlmsghdr pointer to another temporary buffer.
Instead use a full struct nlmsghdr.

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>
  • Loading branch information
olafhering authored and gregkh committed Aug 12, 2013
1 parent 2bc41ea commit b4fb0ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
15 changes: 5 additions & 10 deletions tools/hv/hv_kvp_daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -1392,23 +1392,18 @@ kvp_get_domain_name(char *buffer, int length)
static int
netlink_send(int fd, struct cn_msg *msg)
{
struct nlmsghdr *nlh;
struct nlmsghdr nlh = { .nlmsg_type = NLMSG_DONE };
unsigned int size;
struct msghdr message;
char buffer[64];
struct iovec iov[2];

size = sizeof(struct cn_msg) + msg->len;

nlh = (struct nlmsghdr *)buffer;
nlh->nlmsg_seq = 0;
nlh->nlmsg_pid = getpid();
nlh->nlmsg_type = NLMSG_DONE;
nlh->nlmsg_len = NLMSG_LENGTH(size - sizeof(*nlh));
nlh->nlmsg_flags = 0;
nlh.nlmsg_pid = getpid();
nlh.nlmsg_len = NLMSG_LENGTH(size);

iov[0].iov_base = nlh;
iov[0].iov_len = sizeof(*nlh);
iov[0].iov_base = &nlh;
iov[0].iov_len = sizeof(nlh);

iov[1].iov_base = msg;
iov[1].iov_len = size;
Expand Down
15 changes: 5 additions & 10 deletions tools/hv/hv_vss_daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,23 +105,18 @@ static int vss_operate(int operation)

static int netlink_send(int fd, struct cn_msg *msg)
{
struct nlmsghdr *nlh;
struct nlmsghdr nlh = { .nlmsg_type = NLMSG_DONE };
unsigned int size;
struct msghdr message;
char buffer[64];
struct iovec iov[2];

size = sizeof(struct cn_msg) + msg->len;

nlh = (struct nlmsghdr *)buffer;
nlh->nlmsg_seq = 0;
nlh->nlmsg_pid = getpid();
nlh->nlmsg_type = NLMSG_DONE;
nlh->nlmsg_len = NLMSG_LENGTH(size - sizeof(*nlh));
nlh->nlmsg_flags = 0;
nlh.nlmsg_pid = getpid();
nlh.nlmsg_len = NLMSG_LENGTH(size);

iov[0].iov_base = nlh;
iov[0].iov_len = sizeof(*nlh);
iov[0].iov_base = &nlh;
iov[0].iov_len = sizeof(nlh);

iov[1].iov_base = msg;
iov[1].iov_len = size;
Expand Down

0 comments on commit b4fb0ca

Please sign in to comment.