Skip to content

Commit d63d271

Browse files
author
Al Viro
committed
smc: switch to sock_recvmsg()
Signed-off-by: Al Viro <[email protected]>
1 parent 7edffd2 commit d63d271

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

net/smc/smc_clc.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,23 @@ int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen,
3535
struct smc_clc_msg_hdr *clcm = buf;
3636
struct msghdr msg = {NULL, 0};
3737
int reason_code = 0;
38-
struct kvec vec;
38+
struct kvec vec = {buf, buflen};
3939
int len, datlen;
4040
int krflags;
4141

4242
/* peek the first few bytes to determine length of data to receive
4343
* so we don't consume any subsequent CLC message or payload data
4444
* in the TCP byte stream
4545
*/
46-
vec.iov_base = buf;
47-
vec.iov_len = buflen;
46+
/*
47+
* Caller must make sure that buflen is no less than
48+
* sizeof(struct smc_clc_msg_hdr)
49+
*/
4850
krflags = MSG_PEEK | MSG_WAITALL;
4951
smc->clcsock->sk->sk_rcvtimeo = CLC_WAIT_TIME;
50-
len = kernel_recvmsg(smc->clcsock, &msg, &vec, 1,
51-
sizeof(struct smc_clc_msg_hdr), krflags);
52+
iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, &vec, 1,
53+
sizeof(struct smc_clc_msg_hdr));
54+
len = sock_recvmsg(smc->clcsock, &msg, krflags);
5255
if (signal_pending(current)) {
5356
reason_code = -EINTR;
5457
clc_sk->sk_err = EINTR;
@@ -83,12 +86,11 @@ int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen,
8386
}
8487

8588
/* receive the complete CLC message */
86-
vec.iov_base = buf;
87-
vec.iov_len = buflen;
8889
memset(&msg, 0, sizeof(struct msghdr));
90+
iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, &vec, 1, buflen);
8991
krflags = MSG_WAITALL;
9092
smc->clcsock->sk->sk_rcvtimeo = CLC_WAIT_TIME;
91-
len = kernel_recvmsg(smc->clcsock, &msg, &vec, 1, datlen, krflags);
93+
len = sock_recvmsg(smc->clcsock, &msg, krflags);
9294
if (len < datlen) {
9395
smc->sk.sk_err = EPROTO;
9496
reason_code = -EPROTO;

0 commit comments

Comments
 (0)