Skip to content

Commit 31048d7

Browse files
stefan-baranoffdavem330
authored andcommitted
tcp: Fix broken repair socket window probe patch
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. v2: * Remove erroneous comment; defines now make behavior clear Fixes: 70b7ff1 ("tcp: allow user to create repair socket without window probes") Signed-off-by: Stefan Baranoff <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Acked-by: Andrei Vagin <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 432e629 commit 31048d7

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

include/uapi/linux/tcp.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ enum {
127127

128128
#define TCP_CM_INQ TCP_INQ
129129

130+
#define TCP_REPAIR_ON 1
131+
#define TCP_REPAIR_OFF 0
132+
#define TCP_REPAIR_OFF_NO_WP -1 /* Turn off without window probes */
133+
130134
struct tcp_repair_opt {
131135
__u32 opt_code;
132136
__u32 opt_val;

net/ipv4/tcp.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2823,16 +2823,17 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
28232823
case TCP_REPAIR:
28242824
if (!tcp_can_repair_sock(sk))
28252825
err = -EPERM;
2826-
/* 1 for normal repair, 2 for no window probes */
2827-
else if (val == 1 || val == 2) {
2828-
tp->repair = val;
2826+
else if (val == TCP_REPAIR_ON) {
2827+
tp->repair = 1;
28292828
sk->sk_reuse = SK_FORCE_REUSE;
28302829
tp->repair_queue = TCP_NO_QUEUE;
2831-
} else if (val == 0) {
2830+
} else if (val == TCP_REPAIR_OFF) {
2831+
tp->repair = 0;
2832+
sk->sk_reuse = SK_NO_REUSE;
2833+
tcp_send_window_probe(sk);
2834+
} else if (val == TCP_REPAIR_OFF_NO_WP) {
28322835
tp->repair = 0;
28332836
sk->sk_reuse = SK_NO_REUSE;
2834-
if (tp->repair == 1)
2835-
tcp_send_window_probe(sk);
28362837
} else
28372838
err = -EINVAL;
28382839

0 commit comments

Comments
 (0)