netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/3] net/smc: fixes 2018-07-18
@ 2018-07-18 13:22 Ursula Braun
  2018-07-18 13:22 ` [PATCH net 1/3] net/smc: optimize consumer cursor updates Ursula Braun
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Ursula Braun @ 2018-07-18 13:22 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl, linux-kernel

From: Ursula Braun <ursula.braun@linux.ibm.com>

Dave,

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.

Thanks, Ursula

Karsten Graul (1):
  net/smc: reset recv timeout after clc handshake

Ursula Braun (2):
  net/smc: optimize consumer cursor updates
  net/smc: add error handling for get_user()

 net/smc/af_smc.c  |  3 ++-
 net/smc/smc_clc.c |  3 ++-
 net/smc/smc_tx.c  | 12 ++++++++++--
 3 files changed, 14 insertions(+), 4 deletions(-)

-- 
2.16.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net 1/3] net/smc: optimize consumer cursor updates
  2018-07-18 13:22 [PATCH net 0/3] net/smc: fixes 2018-07-18 Ursula Braun
@ 2018-07-18 13:22 ` Ursula Braun
  2018-07-18 13:22 ` [PATCH net 2/3] net/smc: add error handling for get_user() Ursula Braun
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Ursula Braun @ 2018-07-18 13:22 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl, linux-kernel

From: Ursula Braun <ursula.braun@linux.ibm.com>

The SMC protocol requires to send a separate consumer cursor update,
if it cannot be piggybacked to updates of the producer cursor.
Currently the decision to send a separate consumer cursor update
just considers the amount of data already received by the socket
program. It does not consider the amount of data already arrived, but
not yet consumed by the receiver. Basing the decision on the
difference between already confirmed and already arrived data
(instead of difference between already confirmed and already consumed
data), may lead to a somewhat earlier consumer cursor update send in
fast unidirectional traffic scenarios, and thus to better throughput.

Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
Suggested-by: Thomas Richter <tmricht@linux.ibm.com>
---
 net/smc/smc_tx.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

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 @@ void smc_tx_work(struct work_struct *work)
 
 void smc_tx_consumer_update(struct smc_connection *conn, bool force)
 {
-	union smc_host_cursor cfed, cons;
+	union smc_host_cursor cfed, cons, prod;
+	int sender_free = conn->rmb_desc->len;
 	int to_confirm;
 
 	smc_curs_write(&cons,
@@ -505,11 +506,18 @@ void smc_tx_consumer_update(struct smc_connection *conn, bool force)
 		       smc_curs_read(&conn->rx_curs_confirmed, conn),
 		       conn);
 	to_confirm = smc_curs_diff(conn->rmb_desc->len, &cfed, &cons);
+	if (to_confirm > conn->rmbe_update_limit) {
+		smc_curs_write(&prod,
+			       smc_curs_read(&conn->local_rx_ctrl.prod, conn),
+			       conn);
+		sender_free = conn->rmb_desc->len -
+			      smc_curs_diff(conn->rmb_desc->len, &prod, &cfed);
+	}
 
 	if (conn->local_rx_ctrl.prod_flags.cons_curs_upd_req ||
 	    force ||
 	    ((to_confirm > conn->rmbe_update_limit) &&
-	     ((to_confirm > (conn->rmb_desc->len / 2)) ||
+	     ((sender_free <= (conn->rmb_desc->len / 2)) ||
 	      conn->local_rx_ctrl.prod_flags.write_blocked))) {
 		if ((smc_cdc_get_slot_and_msg_send(conn) < 0) &&
 		    conn->alert_token_local) { /* connection healthy */
-- 
2.16.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net 2/3] net/smc: add error handling for get_user()
  2018-07-18 13:22 [PATCH net 0/3] net/smc: fixes 2018-07-18 Ursula Braun
  2018-07-18 13:22 ` [PATCH net 1/3] net/smc: optimize consumer cursor updates Ursula Braun
@ 2018-07-18 13:22 ` Ursula Braun
  2018-07-18 13:22 ` [PATCH net 3/3] net/smc: reset recv timeout after clc handshake Ursula Braun
  2018-07-18 17:59 ` [PATCH net 0/3] net/smc: fixes 2018-07-18 David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Ursula Braun @ 2018-07-18 13:22 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl, linux-kernel

From: Ursula Braun <ursula.braun@linux.ibm.com>

For security reasons the return code of get_user() should always be
checked.

Fixes: 01d2f7e2cdd31 ("net/smc: sockopts TCP_NODELAY and TCP_CORK")
Reported-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
---
 net/smc/af_smc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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,
 
 	if (optlen < sizeof(int))
 		return -EINVAL;
-	get_user(val, (int __user *)optval);
+	if (get_user(val, (int __user *)optval))
+		return -EFAULT;
 
 	lock_sock(sk);
 	switch (optname) {
-- 
2.16.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net 3/3] net/smc: reset recv timeout after clc handshake
  2018-07-18 13:22 [PATCH net 0/3] net/smc: fixes 2018-07-18 Ursula Braun
  2018-07-18 13:22 ` [PATCH net 1/3] net/smc: optimize consumer cursor updates Ursula Braun
  2018-07-18 13:22 ` [PATCH net 2/3] net/smc: add error handling for get_user() Ursula Braun
@ 2018-07-18 13:22 ` Ursula Braun
  2018-07-18 17:59 ` [PATCH net 0/3] net/smc: fixes 2018-07-18 David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Ursula Braun @ 2018-07-18 13:22 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl, linux-kernel

From: Karsten Graul <kgraul@linux.ibm.com>

During clc handshake the receive timeout is set to CLC_WAIT_TIME.
Remember and reset the original timeout value after the receive calls,
and remove a duplicate assignment of CLC_WAIT_TIME.

Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
---
 net/smc/smc_clc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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 @@ int smc_clc_prfx_match(struct socket *clcsock,
 int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen,
 		     u8 expected_type)
 {
+	long rcvtimeo = smc->clcsock->sk->sk_rcvtimeo;
 	struct sock *clc_sk = smc->clcsock->sk;
 	struct smc_clc_msg_hdr *clcm = buf;
 	struct msghdr msg = {NULL, 0};
@@ -306,7 +307,6 @@ int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen,
 	memset(&msg, 0, sizeof(struct msghdr));
 	iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, &vec, 1, datlen);
 	krflags = MSG_WAITALL;
-	smc->clcsock->sk->sk_rcvtimeo = CLC_WAIT_TIME;
 	len = sock_recvmsg(smc->clcsock, &msg, krflags);
 	if (len < datlen || !smc_clc_msg_hdr_valid(clcm)) {
 		smc->sk.sk_err = EPROTO;
@@ -322,6 +322,7 @@ int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen,
 	}
 
 out:
+	smc->clcsock->sk->sk_rcvtimeo = rcvtimeo;
 	return reason_code;
 }
 
-- 
2.16.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net 0/3] net/smc: fixes 2018-07-18
  2018-07-18 13:22 [PATCH net 0/3] net/smc: fixes 2018-07-18 Ursula Braun
                   ` (2 preceding siblings ...)
  2018-07-18 13:22 ` [PATCH net 3/3] net/smc: reset recv timeout after clc handshake Ursula Braun
@ 2018-07-18 17:59 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2018-07-18 17:59 UTC (permalink / raw)
  To: ubraun
  Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl, linux-kernel

From: Ursula Braun <ubraun@linux.ibm.com>
Date: Wed, 18 Jul 2018 15:22:48 +0200

> 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.

Series applied, thank you.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-07-18 17:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-18 13:22 [PATCH net 0/3] net/smc: fixes 2018-07-18 Ursula Braun
2018-07-18 13:22 ` [PATCH net 1/3] net/smc: optimize consumer cursor updates Ursula Braun
2018-07-18 13:22 ` [PATCH net 2/3] net/smc: add error handling for get_user() Ursula Braun
2018-07-18 13:22 ` [PATCH net 3/3] net/smc: reset recv timeout after clc handshake Ursula Braun
2018-07-18 17:59 ` [PATCH net 0/3] net/smc: fixes 2018-07-18 David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).