diff options
author | David S. Miller <davem@davemloft.net> | 2018-07-18 13:58:27 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-07-18 13:58:27 -0400 |
commit | 08239d43487b929471eda42b15fd61db1e078d88 (patch) | |
tree | db8d7de3553bb23e760f9d1ec3222d9baa1af0c4 | |
parent | 3bc53be9db21040b5d2de4d455f023c8c494aa68 (diff) | |
parent | f6bdc42f021194ec095914b92c7a8b1a09789e6d (diff) |
Merge branch 'smc-fixes'
Ursula Braun says:
====================
net/smc: fixes 2018-07-18
here are small fixes for SMC: The first patch speeds up unidirectional
traffic, the second patch increases security, and the third patch
fixes a problem for fallback cases.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/smc/af_smc.c | 3 | ||||
-rw-r--r-- | net/smc/smc_clc.c | 3 | ||||
-rw-r--r-- | net/smc/smc_tx.c | 12 |
3 files changed, 14 insertions, 4 deletions
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index c12a7fc18f56..6e5479067db0 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c | |||
@@ -1456,7 +1456,8 @@ static int smc_setsockopt(struct socket *sock, int level, int optname, | |||
1456 | 1456 | ||
1457 | if (optlen < sizeof(int)) | 1457 | if (optlen < sizeof(int)) |
1458 | return -EINVAL; | 1458 | return -EINVAL; |
1459 | get_user(val, (int __user *)optval); | 1459 | if (get_user(val, (int __user *)optval)) |
1460 | return -EFAULT; | ||
1460 | 1461 | ||
1461 | lock_sock(sk); | 1462 | lock_sock(sk); |
1462 | switch (optname) { | 1463 | switch (optname) { |
diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c index 717449b1da0b..ae5d168653ce 100644 --- a/net/smc/smc_clc.c +++ b/net/smc/smc_clc.c | |||
@@ -250,6 +250,7 @@ out: | |||
250 | int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen, | 250 | int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen, |
251 | u8 expected_type) | 251 | u8 expected_type) |
252 | { | 252 | { |
253 | long rcvtimeo = smc->clcsock->sk->sk_rcvtimeo; | ||
253 | struct sock *clc_sk = smc->clcsock->sk; | 254 | struct sock *clc_sk = smc->clcsock->sk; |
254 | struct smc_clc_msg_hdr *clcm = buf; | 255 | struct smc_clc_msg_hdr *clcm = buf; |
255 | struct msghdr msg = {NULL, 0}; | 256 | struct msghdr msg = {NULL, 0}; |
@@ -306,7 +307,6 @@ int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen, | |||
306 | memset(&msg, 0, sizeof(struct msghdr)); | 307 | memset(&msg, 0, sizeof(struct msghdr)); |
307 | iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, &vec, 1, datlen); | 308 | iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, &vec, 1, datlen); |
308 | krflags = MSG_WAITALL; | 309 | krflags = MSG_WAITALL; |
309 | smc->clcsock->sk->sk_rcvtimeo = CLC_WAIT_TIME; | ||
310 | len = sock_recvmsg(smc->clcsock, &msg, krflags); | 310 | len = sock_recvmsg(smc->clcsock, &msg, krflags); |
311 | if (len < datlen || !smc_clc_msg_hdr_valid(clcm)) { | 311 | if (len < datlen || !smc_clc_msg_hdr_valid(clcm)) { |
312 | smc->sk.sk_err = EPROTO; | 312 | smc->sk.sk_err = EPROTO; |
@@ -322,6 +322,7 @@ int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen, | |||
322 | } | 322 | } |
323 | 323 | ||
324 | out: | 324 | out: |
325 | smc->clcsock->sk->sk_rcvtimeo = rcvtimeo; | ||
325 | return reason_code; | 326 | return reason_code; |
326 | } | 327 | } |
327 | 328 | ||
diff --git a/net/smc/smc_tx.c b/net/smc/smc_tx.c index cee666400752..f82886b7d1d8 100644 --- a/net/smc/smc_tx.c +++ b/net/smc/smc_tx.c | |||
@@ -495,7 +495,8 @@ out: | |||
495 | 495 | ||
496 | void smc_tx_consumer_update(struct smc_connection *conn, bool force) | 496 | void smc_tx_consumer_update(struct smc_connection *conn, bool force) |
497 | { | 497 | { |
498 | union smc_host_cursor cfed, cons; | 498 | union smc_host_cursor cfed, cons, prod; |
499 | int sender_free = conn->rmb_desc->len; | ||
499 | int to_confirm; | 500 | int to_confirm; |
500 | 501 | ||
501 | smc_curs_write(&cons, | 502 | smc_curs_write(&cons, |
@@ -505,11 +506,18 @@ void smc_tx_consumer_update(struct smc_connection *conn, bool force) | |||
505 | smc_curs_read(&conn->rx_curs_confirmed, conn), | 506 | smc_curs_read(&conn->rx_curs_confirmed, conn), |
506 | conn); | 507 | conn); |
507 | to_confirm = smc_curs_diff(conn->rmb_desc->len, &cfed, &cons); | 508 | to_confirm = smc_curs_diff(conn->rmb_desc->len, &cfed, &cons); |
509 | if (to_confirm > conn->rmbe_update_limit) { | ||
510 | smc_curs_write(&prod, | ||
511 | smc_curs_read(&conn->local_rx_ctrl.prod, conn), | ||
512 | conn); | ||
513 | sender_free = conn->rmb_desc->len - | ||
514 | smc_curs_diff(conn->rmb_desc->len, &prod, &cfed); | ||
515 | } | ||
508 | 516 | ||
509 | if (conn->local_rx_ctrl.prod_flags.cons_curs_upd_req || | 517 | if (conn->local_rx_ctrl.prod_flags.cons_curs_upd_req || |
510 | force || | 518 | force || |
511 | ((to_confirm > conn->rmbe_update_limit) && | 519 | ((to_confirm > conn->rmbe_update_limit) && |
512 | ((to_confirm > (conn->rmb_desc->len / 2)) || | 520 | ((sender_free <= (conn->rmb_desc->len / 2)) || |
513 | conn->local_rx_ctrl.prod_flags.write_blocked))) { | 521 | conn->local_rx_ctrl.prod_flags.write_blocked))) { |
514 | if ((smc_cdc_get_slot_and_msg_send(conn) < 0) && | 522 | if ((smc_cdc_get_slot_and_msg_send(conn) < 0) && |
515 | conn->alert_token_local) { /* connection healthy */ | 523 | conn->alert_token_local) { /* connection healthy */ |