All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] tcp: Fix broken repair socket window probe patch
@ 2018-07-15  1:54 Stefan Baranoff
  2018-07-15 14:57 ` Neal Cardwell
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Baranoff @ 2018-07-15  1:54 UTC (permalink / raw)
  Cc: Andrey Vagin, Pavel Emelyanov, Stefan Baranoff, Eric Dumazet,
	David S. Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI, netdev,
	linux-kernel

Correct previous bad attempt at allowing sockets to come out of TCP
repair without sending window probes. To avoid changing size of
the repair variable in struct tcp_sock, this lets the decision for
sending probes or not to be made when coming out of repair by
introducing two ways to turn it off.

Fixes: 70b7ff130224 ("tcp: allow user to create repair socket without window probes")
Signed-off-by: Stefan Baranoff <sbaranoff@gmail.com>
---
 include/uapi/linux/tcp.h |  4 ++++
 net/ipv4/tcp.c           | 12 +++++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h
index 29eb659..e3f6ed8 100644
--- a/include/uapi/linux/tcp.h
+++ b/include/uapi/linux/tcp.h
@@ -127,6 +127,10 @@ enum {
 
 #define TCP_CM_INQ		TCP_INQ
 
+#define TCP_REPAIR_ON		1
+#define TCP_REPAIR_OFF		0
+#define TCP_REPAIR_OFF_NO_WP	-1	/* Turn off without window probes */
+
 struct tcp_repair_opt {
 	__u32	opt_code;
 	__u32	opt_val;
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 8e5e2ca..9163fb1 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2824,15 +2824,17 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
 		if (!tcp_can_repair_sock(sk))
 			err = -EPERM;
 		/* 1 for normal repair, 2 for no window probes */
-		else if (val == 1 || val == 2) {
-			tp->repair = val;
+		else if (val == TCP_REPAIR_ON) {
+			tp->repair = 1;
 			sk->sk_reuse = SK_FORCE_REUSE;
 			tp->repair_queue = TCP_NO_QUEUE;
-		} else if (val == 0) {
+		} else if (val == TCP_REPAIR_OFF) {
+			tp->repair = 0;
+			sk->sk_reuse = SK_NO_REUSE;
+			tcp_send_window_probe(sk);
+		} else if (val == TCP_REPAIR_OFF_NO_WP) {
 			tp->repair = 0;
 			sk->sk_reuse = SK_NO_REUSE;
-			if (tp->repair == 1)
-				tcp_send_window_probe(sk);
 		} else
 			err = -EINVAL;
 
-- 
1.8.3.1


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

* Re: [PATCH net] tcp: Fix broken repair socket window probe patch
  2018-07-15  1:54 [PATCH net] tcp: Fix broken repair socket window probe patch Stefan Baranoff
@ 2018-07-15 14:57 ` Neal Cardwell
  0 siblings, 0 replies; 2+ messages in thread
From: Neal Cardwell @ 2018-07-15 14:57 UTC (permalink / raw)
  To: sbaranoff
  Cc: avagin, xemul, Eric Dumazet, David Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Netdev, LKML

On Sat, Jul 14, 2018 at 9:54 PM Stefan Baranoff <sbaranoff@gmail.com> wrote:
>
> Correct previous bad attempt at allowing sockets to come out of TCP
> repair without sending window probes. To avoid changing size of
> the repair variable in struct tcp_sock, this lets the decision for
> sending probes or not to be made when coming out of repair by
> introducing two ways to turn it off.
>
> Fixes: 70b7ff130224 ("tcp: allow user to create repair socket without window probes")
> Signed-off-by: Stefan Baranoff <sbaranoff@gmail.com>
> ---
>  include/uapi/linux/tcp.h |  4 ++++
>  net/ipv4/tcp.c           | 12 +++++++-----
>  2 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h
> index 29eb659..e3f6ed8 100644
> --- a/include/uapi/linux/tcp.h
> +++ b/include/uapi/linux/tcp.h
> @@ -127,6 +127,10 @@ enum {
>
>  #define TCP_CM_INQ             TCP_INQ
>
> +#define TCP_REPAIR_ON          1
> +#define TCP_REPAIR_OFF         0
> +#define TCP_REPAIR_OFF_NO_WP   -1      /* Turn off without window probes */
> +
>  struct tcp_repair_opt {
>         __u32   opt_code;
>         __u32   opt_val;
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index 8e5e2ca..9163fb1 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -2824,15 +2824,17 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
>                 if (!tcp_can_repair_sock(sk))
>                         err = -EPERM;
>                 /* 1 for normal repair, 2 for no window probes */

Looks like this comment is now inconsistent with the code.

cheers,
neal

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

end of thread, other threads:[~2018-07-15 14:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-15  1:54 [PATCH net] tcp: Fix broken repair socket window probe patch Stefan Baranoff
2018-07-15 14:57 ` Neal Cardwell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.