mISDN: switch to sock_recvmsg()
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 21 Sep 2017 00:11:00 +0000 (20:11 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 3 Dec 2017 01:38:07 +0000 (20:38 -0500)
here we do need to reinitialize ->msg_iter on each call - the
data in buffer is overwritten every time, not appended to.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
drivers/isdn/mISDN/l1oip_core.c

index e365478..21d50e4 100644 (file)
@@ -645,8 +645,10 @@ l1oip_socket_thread(void *data)
 {
        struct l1oip *hc = (struct l1oip *)data;
        int ret = 0;
-       struct msghdr msg;
        struct sockaddr_in sin_rx;
+       struct kvec iov;
+       struct msghdr msg = {.msg_name = &sin_rx,
+                            .msg_namelen = sizeof(sin_rx)};
        unsigned char *recvbuf;
        size_t recvbuf_size = 1500;
        int recvlen;
@@ -661,6 +663,9 @@ l1oip_socket_thread(void *data)
                goto fail;
        }
 
+       iov.iov_base = recvbuf;
+       iov.iov_len = recvbuf_size;
+
        /* make daemon */
        allow_signal(SIGTERM);
 
@@ -697,12 +702,6 @@ l1oip_socket_thread(void *data)
                goto fail;
        }
 
-       /* build receive message */
-       msg.msg_name = &sin_rx;
-       msg.msg_namelen = sizeof(sin_rx);
-       msg.msg_control = NULL;
-       msg.msg_controllen = 0;
-
        /* build send message */
        hc->sendmsg.msg_name = &hc->sin_remote;
        hc->sendmsg.msg_namelen = sizeof(hc->sin_remote);
@@ -719,12 +718,9 @@ l1oip_socket_thread(void *data)
                printk(KERN_DEBUG "%s: socket created and open\n",
                       __func__);
        while (!signal_pending(current)) {
-               struct kvec iov = {
-                       .iov_base = recvbuf,
-                       .iov_len = recvbuf_size,
-               };
-               recvlen = kernel_recvmsg(socket, &msg, &iov, 1,
-                                        recvbuf_size, 0);
+               iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, &iov, 1,
+                               recvbuf_size);
+               recvlen = sock_recvmsg(socket, &msg, 0);
                if (recvlen > 0) {
                        l1oip_socket_parse(hc, &sin_rx, recvbuf, recvlen);
                } else {