Skip to content

Commit

Permalink
mISDN: switch to sock_recvmsg()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Al Viro committed Dec 3, 2017
1 parent f7765c3 commit 956a27e
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions drivers/isdn/mISDN/l1oip_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

Expand Down Expand Up @@ -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);
Expand All @@ -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 {
Expand Down

0 comments on commit 956a27e

Please sign in to comment.