Hello community,

here is the log from the commit of package hyper-v for openSUSE:Factory checked 
in at 2017-06-07 09:50:24
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/hyper-v (Old)
 and      /work/SRC/openSUSE:Factory/.hyper-v.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "hyper-v"

Wed Jun  7 09:50:24 2017 rev:33 rq:498992 version:7

Changes:
--------
--- /work/SRC/openSUSE:Factory/hyper-v/hyper-v.changes  2015-10-03 
20:29:47.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.hyper-v.new/hyper-v.changes     2017-06-07 
09:50:25.725033439 +0200
@@ -1,0 +2,12 @@
+Wed May  4 13:29:54 UTC 2016 - [email protected]
+
+- add Conflicts with kernel < 4.2 (fate#320485)
+- vss: fix the write()'s argument: error -> vss_msg
+- remove repeated HV_FCOPY string
+- report ENOSPC errors in hv_fcopy_daemon
+- fcopy: full handshake support
+- vss: full handshake support
+- vss: use misc char device to communicate with kernel
+- kvp: use misc char device to communicate with kernel
+
+-------------------------------------------------------------------

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ hyper-v.spec ++++++
--- /var/tmp/diff_new_pack.OMl4qu/_old  2017-06-07 09:50:28.780601617 +0200
+++ /var/tmp/diff_new_pack.OMl4qu/_new  2017-06-07 09:50:28.784601051 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package hyper-v
 #
-# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -36,6 +36,8 @@
 PreReq:         %insserv_prereq
 Requires(pre):  coreutils
 %endif
+# Due to usage of char device instead of netlink
+Conflicts:      kernel < 4.2
 Summary:        Microsoft Hyper-V tools
 License:        GPL-2.0
 Group:          System/Kernel
@@ -43,7 +45,7 @@
 Supplements:    modalias(pci:v00001414d00005353sv*sd*bc*sc*i*)
 Url:            http://www.kernel.org
 # Arbitrary version number
-Version:        6
+Version:        7
 Release:        0
 Source0:        hyper-v.lsvmbus.py
 Source5:        hyper-v.kvptest.ps1.txt
@@ -187,10 +189,10 @@
 d=$RPM_BUILD_ROOT%{_udevrulesdir}
 mkdir -vp ${d}
 cat > ${d}/%{hv_kvp_daemon}.rules <<EOF
-SUBSYSTEM=="vmbus", ACTION=="add", 
ATTR{class_id}=="{a9a0f4e7-5a45-4d96-b827-8a841e8c03e6}", TAG+="systemd", 
ENV{SYSTEMD_WANTS}+="%{hv_kvp_daemon}.service"
+ACTION=="add", KERNEL=="vmbus/hv_kvp", TAG+="systemd", 
ENV{SYSTEMD_WANTS}+="%{hv_kvp_daemon}.service"
 EOF
 cat > ${d}/%{hv_vss_daemon}.rules <<EOF
-SUBSYSTEM=="vmbus", ACTION=="add", 
ATTR{class_id}=="{35fa2e29-ea23-4236-96ae-3a6ebacba440}", TAG+="systemd", 
ENV{SYSTEMD_WANTS}+="%{hv_vss_daemon}.service"
+ACTION=="add", KERNEL=="vmbus/hv_vss", TAG+="systemd", 
ENV{SYSTEMD_WANTS}+="%{hv_vss_daemon}.service"
 EOF
 cat > ${d}/%{hv_fcopy_daemon}.rules <<EOF
 ACTION=="add", KERNEL=="vmbus/hv_fcopy", TAG+="systemd", 
ENV{SYSTEMD_WANTS}+="%{hv_fcopy_daemon}.service"

++++++ hyper-v.include.linux.hyperv.h ++++++
--- /var/tmp/diff_new_pack.OMl4qu/_old  2017-06-07 09:50:28.828594834 +0200
+++ /var/tmp/diff_new_pack.OMl4qu/_new  2017-06-07 09:50:28.828594834 +0200
@@ -38,6 +38,11 @@
 
 #define VSS_OP_REGISTER 128
 
+/*
+  Daemon code with full handshake support.
+ */
+#define VSS_OP_REGISTER1 129
+
 enum hv_vss_op {
        VSS_OP_CREATE = 0,
        VSS_OP_DELETE,
@@ -94,7 +99,8 @@
  */
 
 #define FCOPY_VERSION_0 0
-#define FCOPY_CURRENT_VERSION FCOPY_VERSION_0
+#define FCOPY_VERSION_1 1
+#define FCOPY_CURRENT_VERSION FCOPY_VERSION_1
 #define W_MAX_PATH 260
 
 enum hv_fcopy_op {
@@ -302,6 +308,7 @@
 #define HV_INVALIDARG                  0x80070057
 #define HV_GUID_NOTFOUND               0x80041002
 #define HV_ERROR_ALREADY_EXISTS                0x80070050
+#define HV_ERROR_DISK_FULL             0x80070070
 
 #define ADDR_FAMILY_NONE       0x00
 #define ADDR_FAMILY_IPV4       0x01

++++++ hyper-v.tools.hv.hv_fcopy_daemon.c ++++++
--- /var/tmp/diff_new_pack.OMl4qu/_old  2017-06-07 09:50:28.904584095 +0200
+++ /var/tmp/diff_new_pack.OMl4qu/_new  2017-06-07 09:50:28.904584095 +0200
@@ -37,12 +37,14 @@
 
 static int target_fd;
 static char target_fname[W_MAX_PATH];
+static unsigned long long filesize;
 
 static int hv_start_fcopy(struct hv_start_fcopy *smsg)
 {
        int error = HV_E_FAIL;
        char *q, *p;
 
+       filesize = 0;
        p = (char *)smsg->path_name;
        snprintf(target_fname, sizeof(target_fname), "%s/%s",
                 (char *)smsg->path_name, (char *)smsg->file_name);
@@ -98,14 +100,26 @@
 static int hv_copy_data(struct hv_do_fcopy *cpmsg)
 {
        ssize_t bytes_written;
+       int ret = 0;
 
        bytes_written = pwrite(target_fd, cpmsg->data, cpmsg->size,
                                cpmsg->offset);
 
-       if (bytes_written != cpmsg->size)
-               return HV_E_FAIL;
+       filesize += cpmsg->size;
+       if (bytes_written != cpmsg->size) {
+               switch (errno) {
+               case ENOSPC:
+                       ret = HV_ERROR_DISK_FULL;
+                       break;
+               default:
+                       ret = HV_E_FAIL;
+                       break;
+               }
+               syslog(LOG_ERR, "pwrite failed to write %llu bytes: %ld (%s)",
+                      filesize, (long)bytes_written, strerror(errno));
+       }
 
-       return 0;
+       return ret;
 }
 
 static int hv_copy_finished(void)
@@ -137,6 +151,8 @@
        int version = FCOPY_CURRENT_VERSION;
        char *buffer[4096 * 2];
        struct hv_fcopy_hdr *in_msg;
+       int in_handshake = 1;
+       __u32 kernel_modver;
 
        static struct option long_options[] = {
                {"help",        no_argument,       0,  'h' },
@@ -163,7 +179,7 @@
        }
 
        openlog("HV_FCOPY", 0, LOG_USER);
-       syslog(LOG_INFO, "HV_FCOPY starting; pid is:%d", getpid());
+       syslog(LOG_INFO, "starting; pid is:%d", getpid());
 
        fcopy_fd = open("/dev/vmbus/hv_fcopy", O_RDWR);
 
@@ -191,6 +207,19 @@
                        syslog(LOG_ERR, "pread failed: %s", strerror(errno));
                        exit(EXIT_FAILURE);
                }
+
+               if (in_handshake) {
+                       if (len != sizeof(kernel_modver)) {
+                               syslog(LOG_ERR, "invalid version negotiation");
+                               exit(EXIT_FAILURE);
+                       }
+                       kernel_modver = *(__u32 *)buffer;
+                       in_handshake = 0;
+                       syslog(LOG_INFO, "kernel module version: %d",
+                              kernel_modver);
+                       continue;
+               }
+
                in_msg = (struct hv_fcopy_hdr *)buffer;
 
                switch (in_msg->operation) {

++++++ hyper-v.tools.hv.hv_kvp_daemon.c ++++++
--- /var/tmp/diff_new_pack.OMl4qu/_old  2017-06-07 09:50:28.940579008 +0200
+++ /var/tmp/diff_new_pack.OMl4qu/_new  2017-06-07 09:50:28.944578443 +0200
@@ -26,7 +26,6 @@
 #include <sys/socket.h>
 #include <sys/poll.h>
 #include <sys/utsname.h>
-#include <linux/types.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -34,7 +33,6 @@
 #include <ctype.h>
 #include <errno.h>
 #include <arpa/inet.h>
-#include <linux/connector.h>
 #include <linux/hyperv.h>
 #include <linux/netlink.h>
 #include <ifaddrs.h>
@@ -80,7 +78,6 @@
        DNS
 };
 
-static struct sockaddr_nl addr;
 static int in_hand_shake = 1;
 
 static char *os_name = "";
@@ -1389,34 +1386,6 @@
        freeaddrinfo(info);
 }
 
-static int
-netlink_send(int fd, struct cn_msg *msg)
-{
-       struct nlmsghdr nlh = { .nlmsg_type = NLMSG_DONE };
-       unsigned int size;
-       struct msghdr message;
-       struct iovec iov[2];
-
-       size = sizeof(struct cn_msg) + msg->len;
-
-       nlh.nlmsg_pid = getpid();
-       nlh.nlmsg_len = NLMSG_LENGTH(size);
-
-       iov[0].iov_base = &nlh;
-       iov[0].iov_len = sizeof(nlh);
-
-       iov[1].iov_base = msg;
-       iov[1].iov_len = size;
-
-       memset(&message, 0, sizeof(message));
-       message.msg_name = &addr;
-       message.msg_namelen = sizeof(addr);
-       message.msg_iov = iov;
-       message.msg_iovlen = 2;
-
-       return sendmsg(fd, &message, 0);
-}
-
 void print_usage(char *argv[])
 {
        fprintf(stderr, "Usage: %s [options]\n"
@@ -1427,22 +1396,17 @@
 
 int main(int argc, char *argv[])
 {
-       int fd, len, nl_group;
+       int kvp_fd, len;
        int error;
-       struct cn_msg *message;
        struct pollfd pfd;
-       struct nlmsghdr *incoming_msg;
-       struct cn_msg   *incoming_cn_msg;
-       struct hv_kvp_msg *hv_msg;
-       char    *p;
+       char    *p;
+       struct hv_kvp_msg hv_msg[1];
        char    *key_value;
        char    *key_name;
        int     op;
        int     pool;
        char    *if_name;
        struct hv_kvp_ipaddr_value *kvp_ip_val;
-       char *kvp_recv_buffer;
-       size_t kvp_recv_buffer_len;
        int daemonize = 1, long_index = 0, opt;
 
        static struct option long_options[] = {
@@ -1470,12 +1434,14 @@
        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 = calloc(1, kvp_recv_buffer_len);
-       if (!kvp_recv_buffer) {
-               syslog(LOG_ERR, "Failed to allocate netlink buffer");
+       kvp_fd = open("/dev/vmbus/hv_kvp", O_RDWR);
+
+       if (kvp_fd < 0) {
+               syslog(LOG_ERR, "open /dev/vmbus/hv_kvp failed; error: %d %s",
+                       errno, strerror(errno));
                exit(EXIT_FAILURE);
        }
+
        /*
         * Retrieve OS release information.
         */
@@ -1491,100 +1457,44 @@
                exit(EXIT_FAILURE);
        }
 
-       fd = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR);
-       if (fd < 0) {
-               syslog(LOG_ERR, "netlink socket creation failed; error: %d %s", 
errno,
-                               strerror(errno));
-               exit(EXIT_FAILURE);
-       }
-       addr.nl_family = AF_NETLINK;
-       addr.nl_pad = 0;
-       addr.nl_pid = 0;
-       addr.nl_groups = 0;
-
-
-       error = bind(fd, (struct sockaddr *)&addr, sizeof(addr));
-       if (error < 0) {
-               syslog(LOG_ERR, "bind failed; error: %d %s", errno, 
strerror(errno));
-               close(fd);
-               exit(EXIT_FAILURE);
-       }
-       nl_group = CN_KVP_IDX;
-
-       if (setsockopt(fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, &nl_group, 
sizeof(nl_group)) < 0) {
-               syslog(LOG_ERR, "setsockopt failed; error: %d %s", errno, 
strerror(errno));
-               close(fd);
-               exit(EXIT_FAILURE);
-       }
-
        /*
         * Register ourselves with the kernel.
         */
-       message = (struct cn_msg *)kvp_recv_buffer;
-       message->id.idx = CN_KVP_IDX;
-       message->id.val = CN_KVP_VAL;
-
-       hv_msg = (struct hv_kvp_msg *)message->data;
        hv_msg->kvp_hdr.operation = KVP_OP_REGISTER1;
-       message->ack = 0;
-       message->len = sizeof(struct hv_kvp_msg);
-
-       len = netlink_send(fd, message);
-       if (len < 0) {
-               syslog(LOG_ERR, "netlink_send failed; error: %d %s", errno, 
strerror(errno));
-               close(fd);
+       len = write(kvp_fd, hv_msg, sizeof(struct hv_kvp_msg));
+       if (len != sizeof(struct hv_kvp_msg)) {
+               syslog(LOG_ERR, "registration to kernel failed; error: %d %s",
+                      errno, strerror(errno));
+               close(kvp_fd);
                exit(EXIT_FAILURE);
        }
 
-       pfd.fd = fd;
+       pfd.fd = kvp_fd;
 
        while (1) {
-               struct sockaddr *addr_p = (struct sockaddr *) &addr;
-               socklen_t addr_l = sizeof(addr);
                pfd.events = POLLIN;
                pfd.revents = 0;
 
                if (poll(&pfd, 1, -1) < 0) {
                        syslog(LOG_ERR, "poll failed; error: %d %s", errno, 
strerror(errno));
                        if (errno == EINVAL) {
-                               close(fd);
+                               close(kvp_fd);
                                exit(EXIT_FAILURE);
                        }
                        else
                                continue;
                }
 
-               len = recvfrom(fd, kvp_recv_buffer, kvp_recv_buffer_len, 0,
-                               addr_p, &addr_l);
-
-               if (len < 0) {
-                       int saved_errno = errno;
-                       syslog(LOG_ERR, "recvfrom failed; pid:%u error:%d %s",
-                                       addr.nl_pid, errno, strerror(errno));
+               len = read(kvp_fd, hv_msg, sizeof(struct hv_kvp_msg));
 
-                       if (saved_errno == ENOBUFS) {
-                               syslog(LOG_ERR, "receive error: ignored");
-                               continue;
-                       }
+               if (len != sizeof(struct hv_kvp_msg)) {
+                       syslog(LOG_ERR, "read failed; error:%d %s",
+                              errno, strerror(errno));
 
-                       close(fd);
-                       return -1;
+                       close(kvp_fd);
+                       return EXIT_FAILURE;
                }
 
-               if (addr.nl_pid) {
-                       syslog(LOG_WARNING, "Received packet from untrusted 
pid:%u",
-                                       addr.nl_pid);
-                       continue;
-               }
-
-               incoming_msg = (struct nlmsghdr *)kvp_recv_buffer;
-
-               if (incoming_msg->nlmsg_type != NLMSG_DONE)
-                       continue;
-
-               incoming_cn_msg = (struct cn_msg *)NLMSG_DATA(incoming_msg);
-               hv_msg = (struct hv_kvp_msg *)incoming_cn_msg->data;
-
                /*
                 * We will use the KVP header information to pass back
                 * the error from this daemon. So, first copy the state
@@ -1605,7 +1515,7 @@
                        if (lic_version) {
                                strcpy(lic_version, p);
                                syslog(LOG_INFO, "KVP LIC Version: %s",
-                                       lic_version);
+                                      lic_version);
                        } else {
                                syslog(LOG_ERR, "malloc failed");
                        }
@@ -1704,7 +1614,6 @@
                        goto kvp_done;
                }
 
-               hv_msg = (struct hv_kvp_msg *)incoming_cn_msg->data;
                key_name = (char *)hv_msg->body.kvp_enum_data.data.key;
                key_value = (char *)hv_msg->body.kvp_enum_data.data.value;
 
@@ -1755,31 +1664,17 @@
                        hv_msg->error = HV_S_CONT;
                        break;
                }
-               /*
-                * Send the value back to the kernel. The response is
-                * already in the receive buffer. Update the cn_msg header to
-                * reflect the key value that has been added to the message
-                */
-kvp_done:
-
-               incoming_cn_msg->id.idx = CN_KVP_IDX;
-               incoming_cn_msg->id.val = CN_KVP_VAL;
-               incoming_cn_msg->ack = 0;
-               incoming_cn_msg->len = sizeof(struct hv_kvp_msg);
-
-               len = netlink_send(fd, incoming_cn_msg);
-               if (len < 0) {
-                       int saved_errno = errno;
-                       syslog(LOG_ERR, "net_link send failed; error: %d %s", 
errno,
-                                       strerror(errno));
-
-                       if (saved_errno == ENOMEM || saved_errno == ENOBUFS) {
-                               syslog(LOG_ERR, "send error: ignored");
-                               continue;
-                       }
 
+               /* Send the value back to the kernel. */
+kvp_done:
+               len = write(kvp_fd, hv_msg, sizeof(struct hv_kvp_msg));
+               if (len != sizeof(struct hv_kvp_msg)) {
+                       syslog(LOG_ERR, "write failed; error: %d %s", errno,
+                              strerror(errno));
                        exit(EXIT_FAILURE);
                }
        }
 
+       close(kvp_fd);
+       exit(0);
 }

++++++ hyper-v.tools.hv.hv_vss_daemon.c ++++++
--- /var/tmp/diff_new_pack.OMl4qu/_old  2017-06-07 09:50:28.972574487 +0200
+++ /var/tmp/diff_new_pack.OMl4qu/_new  2017-06-07 09:50:28.972574487 +0200
@@ -19,10 +19,8 @@
 
 
 #include <sys/types.h>
-#include <sys/socket.h>
 #include <sys/poll.h>
 #include <sys/ioctl.h>
-#include <linux/types.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <mntent.h>
@@ -31,21 +29,11 @@
 #include <string.h>
 #include <ctype.h>
 #include <errno.h>
-#include <arpa/inet.h>
 #include <linux/fs.h>
-#include <linux/connector.h>
 #include <linux/hyperv.h>
-#include <linux/netlink.h>
 #include <syslog.h>
 #include <getopt.h>
 
-static struct sockaddr_nl addr;
-
-#ifndef SOL_NETLINK
-#define SOL_NETLINK 270
-#endif
-
-
 /* Don't use syslog() in the function since that can cause write to disk */
 static int vss_do_freeze(char *dir, unsigned int cmd)
 {
@@ -144,33 +132,6 @@
        return error;
 }
 
-static int netlink_send(int fd, struct cn_msg *msg)
-{
-       struct nlmsghdr nlh = { .nlmsg_type = NLMSG_DONE };
-       unsigned int size;
-       struct msghdr message;
-       struct iovec iov[2];
-
-       size = sizeof(struct cn_msg) + msg->len;
-
-       nlh.nlmsg_pid = getpid();
-       nlh.nlmsg_len = NLMSG_LENGTH(size);
-
-       iov[0].iov_base = &nlh;
-       iov[0].iov_len = sizeof(nlh);
-
-       iov[1].iov_base = msg;
-       iov[1].iov_len = size;
-
-       memset(&message, 0, sizeof(message));
-       message.msg_name = &addr;
-       message.msg_namelen = sizeof(addr);
-       message.msg_iov = iov;
-       message.msg_iovlen = 2;
-
-       return sendmsg(fd, &message, 0);
-}
-
 void print_usage(char *argv[])
 {
        fprintf(stderr, "Usage: %s [options]\n"
@@ -181,17 +142,14 @@
 
 int main(int argc, char *argv[])
 {
-       int fd, len, nl_group;
+       int vss_fd, len;
        int error;
-       struct cn_msg *message;
        struct pollfd pfd;
-       struct nlmsghdr *incoming_msg;
-       struct cn_msg   *incoming_cn_msg;
        int     op;
-       struct hv_vss_msg *vss_msg;
-       char *vss_recv_buffer;
-       size_t vss_recv_buffer_len;
+       struct hv_vss_msg vss_msg[1];
        int daemonize = 1, long_index = 0, opt;
+       int in_handshake = 1;
+       __u32 kernel_modver;
 
        static struct option long_options[] = {
                {"help",        no_argument,       0,  'h' },
@@ -218,98 +176,62 @@
        openlog("Hyper-V VSS", 0, LOG_USER);
        syslog(LOG_INFO, "VSS starting; pid is:%d", getpid());
 
-       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_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",
-                               errno, strerror(errno));
-               exit(EXIT_FAILURE);
-       }
-       addr.nl_family = AF_NETLINK;
-       addr.nl_pad = 0;
-       addr.nl_pid = 0;
-       addr.nl_groups = 0;
-
-
-       error = bind(fd, (struct sockaddr *)&addr, sizeof(addr));
-       if (error < 0) {
-               syslog(LOG_ERR, "bind failed; error:%d %s", errno, 
strerror(errno));
-               close(fd);
-               exit(EXIT_FAILURE);
-       }
-       nl_group = CN_VSS_IDX;
-       if (setsockopt(fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, &nl_group, 
sizeof(nl_group)) < 0) {
-               syslog(LOG_ERR, "setsockopt failed; error:%d %s", errno, 
strerror(errno));
-               close(fd);
+       vss_fd = open("/dev/vmbus/hv_vss", O_RDWR);
+       if (vss_fd < 0) {
+               syslog(LOG_ERR, "open /dev/vmbus/hv_vss failed; error: %d %s",
+                      errno, strerror(errno));
                exit(EXIT_FAILURE);
        }
        /*
         * Register ourselves with the kernel.
         */
-       message = (struct cn_msg *)vss_recv_buffer;
-       message->id.idx = CN_VSS_IDX;
-       message->id.val = CN_VSS_VAL;
-       message->ack = 0;
-       vss_msg = (struct hv_vss_msg *)message->data;
-       vss_msg->vss_hdr.operation = VSS_OP_REGISTER;
+       vss_msg->vss_hdr.operation = VSS_OP_REGISTER1;
 
-       message->len = sizeof(struct hv_vss_msg);
-
-       len = netlink_send(fd, message);
+       len = write(vss_fd, vss_msg, sizeof(struct hv_vss_msg));
        if (len < 0) {
-               syslog(LOG_ERR, "netlink_send failed; error:%d %s", errno, 
strerror(errno));
-               close(fd);
+               syslog(LOG_ERR, "registration to kernel failed; error: %d %s",
+                      errno, strerror(errno));
+               close(vss_fd);
                exit(EXIT_FAILURE);
        }
 
-       pfd.fd = fd;
+       pfd.fd = vss_fd;
 
        while (1) {
-               struct sockaddr *addr_p = (struct sockaddr *) &addr;
-               socklen_t addr_l = sizeof(addr);
                pfd.events = POLLIN;
                pfd.revents = 0;
 
                if (poll(&pfd, 1, -1) < 0) {
                        syslog(LOG_ERR, "poll failed; error:%d %s", errno, 
strerror(errno));
                        if (errno == EINVAL) {
-                               close(fd);
+                               close(vss_fd);
                                exit(EXIT_FAILURE);
                        }
                        else
                                continue;
                }
 
-               len = recvfrom(fd, vss_recv_buffer, vss_recv_buffer_len, 0,
-                               addr_p, &addr_l);
+               len = read(vss_fd, vss_msg, sizeof(struct hv_vss_msg));
 
-               if (len < 0) {
-                       syslog(LOG_ERR, "recvfrom failed; pid:%u error:%d %s",
-                                       addr.nl_pid, errno, strerror(errno));
-                       close(fd);
-                       return -1;
-               }
-
-               if (addr.nl_pid) {
-                       syslog(LOG_WARNING,
-                               "Received packet from untrusted pid:%u",
-                               addr.nl_pid);
+               if (in_handshake) {
+                       if (len != sizeof(kernel_modver)) {
+                               syslog(LOG_ERR, "invalid version negotiation");
+                               exit(EXIT_FAILURE);
+                       }
+                       kernel_modver = *(__u32 *)vss_msg;
+                       in_handshake = 0;
+                       syslog(LOG_INFO, "VSS: kernel module version: %d",
+                              kernel_modver);
                        continue;
                }
 
-               incoming_msg = (struct nlmsghdr *)vss_recv_buffer;
-
-               if (incoming_msg->nlmsg_type != NLMSG_DONE)
-                       continue;
+               if (len != sizeof(struct hv_vss_msg)) {
+                       syslog(LOG_ERR, "read failed; error:%d %s",
+                              errno, strerror(errno));
+                       close(vss_fd);
+                       return EXIT_FAILURE;
+               }
 
-               incoming_cn_msg = (struct cn_msg *)NLMSG_DATA(incoming_msg);
-               vss_msg = (struct hv_vss_msg *)incoming_cn_msg->data;
                op = vss_msg->vss_hdr.operation;
                error =  HV_S_OK;
 
@@ -332,12 +254,14 @@
                        syslog(LOG_ERR, "Illegal op:%d\n", op);
                }
                vss_msg->error = error;
-               len = netlink_send(fd, incoming_cn_msg);
-               if (len < 0) {
-                       syslog(LOG_ERR, "net_link send failed; error:%d %s",
-                                       errno, strerror(errno));
+               len = write(vss_fd, vss_msg, sizeof(struct hv_vss_msg));
+               if (len != sizeof(struct hv_vss_msg)) {
+                       syslog(LOG_ERR, "write failed; error: %d %s", errno,
+                              strerror(errno));
                        exit(EXIT_FAILURE);
                }
        }
 
+       close(vss_fd);
+       exit(0);
 }


Reply via email to