Skip to contentSkip to conversation

Fix race condition between TCP_REPAIR dump and data receive

PATCH In review Stefano Brivio 4 participants 9 messages May 18 – May 20

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover Fix race condition between TCP_REPAIR dump and data receive

If we receive data on a socket that's in repair mode, the sequence and contents of the receive queue we dump depend on the timing. We need to freeze the input queue, otherwise the connection parameters restored later might not match the actual state of the connection.

Patch 1/2 has the full details and the fix, patch 2/2 introduces selftests to illustrate the problem and verify the solution.

v2: Don't touch the fast path in 1/2 (concern raised by Kuniyuki Iwashima
and Eric Dumazet). Further details in the message for 1/2 itself.

Stefano Brivio (2):
tcp: Don't accept data when socket is in repair mode
selftests: Add data path tests for TCP_REPAIR mode

 include/net/dropreason-core.h                 |   3 +
 include/net/tcp.h                             |   3 +-
 net/ipv4/tcp.c                                |   9 +
 net/ipv4/tcp_input.c                          |  15 +-
 tools/testing/selftests/Makefile              |   1 +
 .../selftests/net/tcp_repair/.gitignore       |   3 +
 .../testing/selftests/net/tcp_repair/Makefile |  23 ++
 .../testing/selftests/net/tcp_repair/client.c | 273 ++++++++++++++++++
 .../testing/selftests/net/tcp_repair/inner.sh |  32 ++
 .../testing/selftests/net/tcp_repair/outer.sh |  44 +++
 tools/testing/selftests/net/tcp_repair/run.sh |  12 +
 .../testing/selftests/net/tcp_repair/server.c | 155 ++++++++++
 tools/testing/selftests/net/tcp_repair/talk.h |  26 ++
 13 files changed, 596 insertions(+), 3 deletions(-)
 create mode 100644 tools/testing/selftests/net/tcp_repair/.gitignore
 create mode 100644 tools/testing/selftests/net/tcp_repair/Makefile
 create mode 100644 tools/testing/selftests/net/tcp_repair/client.c
 create mode 100755 tools/testing/selftests/net/tcp_repair/inner.sh
 create mode 100755 tools/testing/selftests/net/tcp_repair/outer.sh
 create mode 100755 tools/testing/selftests/net/tcp_repair/run.sh
 create mode 100644 tools/testing/selftests/net/tcp_repair/server.c
 create mode 100644 tools/testing/selftests/net/tcp_repair/talk.h
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/2 tcp: Don't accept data when socket is in repair mode

Once a socket enters repair mode (TCP_REPAIR socket option with TCP_REPAIR_ON value), it's possible to dump the receive sequence number (TCP_QUEUE_SEQ) and the contents of the receive queue itself (using TCP_REPAIR_QUEUE to select it).

If we receive data after the application fetched the sequence number or saved the contents of the queue, though, the application will now have outdated information, which defeats the whole functionality, because this leads to gaps in sequence and data once they're restored by the target instance of the application, resulting in a hanging or otherwise non-functional TCP connection.

This type of race condition was discovered in the KubeVirt integration of passt(1), using a remote iperf3 client connected to an iperf3 server running in the guest which is being migrated. The setup allows traffic to reach the origin node hosting the guest during the migration.

If passt dumps sequence number and contents of the queue *before* further data is received and acknowledged to the peer by the kernel, once the TCP data connection is migrated to the target node, the remote client becomes unable to continue sending, because a portion of the data it sent *and received an acknowledgement for* is now lost.

Schematically:

1. client --seq 1:100--> origin host --> passt --> guest --> server

2. client <--ACK: 100-- origin host

3. migration starts, passt enables repair mode, dumps the sequence number (101) and sends it to the target node of the guest migration

4. client --seq 101:201--> origin host (passt not receiving anymore)

5. client <--ACK: 201-- origin host

6. migration completes, and passt restores sequence number 101 on the migrated socket

7. client --seq 201:301--> target host (now seeing a sequence jump)

8. client <--ACK: 100-- target host

...and the connection can't recover anymore, because the client can't resend data that was already (erroneously) acknowledged. We need to avoid step 5. above.

This would equally affect CRIU (the other known user of TCP_REPAIR), should data be received while the original container is frozen: the sequence dumped and the contents of the saved incoming queue would then depend on the timing.

The race condition is also illustrated in the kselftests introduced by the next patch.

To prevent this issue, discard data received for a socket in repair mode, with a new reason, SKB_DROP_REASON_SOCKET_REPAIR.

In order to do this without affecting the TCP fast path, once repair mode is set, disable the fast path for the given socket using the pred_flags mechanism (as commonly done for other corner cases), so that tcp_rcv_established() can handle this in the slow path.

Once / if repair mode is disabled, take care of re-enabling the fast path if conditions are met, as implemented by tcp_fast_path_check().

v2: Instead of directly checking for tp->repair in the common case
of tcp_rcv_established(), disable the fast path by setting pred_flags to 0 on TCP_REPAIR_ON, and re-enable it as we leave repair mode, while checking for that in tcp_fast_path_check().

This way, we avoid touching the fast path itself, as requested by Kuniyuki Iwashima and Eric Dumazet.

Fixes ee9952831cfd ("tcp: Initial repair mode")
---
 include/net/dropreason-core.h |  3 +++
 include/net/tcp.h             |  3 ++-
 net/ipv4/tcp.c                |  9 +++++++++
 net/ipv4/tcp_input.c          | 15 +++++++++++++--
 4 files changed, 27 insertions(+), 3 deletions(-)
include/net/dropreason-core.h +3 -0
index 2f312d1f67d6..19ab9e6ffc33 100644
@@ -9,6 +9,7 @@
 	FN(SOCKET_CLOSE)		\
 	FN(SOCKET_FILTER)		\
 	FN(SOCKET_RCVBUFF)		\
+	FN(SOCKET_REPAIR)		\
 	FN(UNIX_DISCONNECT)		\
 	FN(UNIX_SKIP_OOB)		\
 	FN(PKT_TOO_SMALL)		\
@@ -158,6 +159,8 @@ enum skb_drop_reason {
 	SKB_DROP_REASON_SOCKET_FILTER,
 	/** @SKB_DROP_REASON_SOCKET_RCVBUFF: socket receive buff is full */
 	SKB_DROP_REASON_SOCKET_RCVBUFF,
+	/** @SKB_DROP_REASON_SOCKET_REPAIR: socket is in repair mode */
+	SKB_DROP_REASON_SOCKET_REPAIR,
 	/**
 	 * @SKB_DROP_REASON_UNIX_DISCONNECT: recv queue is purged when SOCK_DGRAM
 	 * or SOCK_SEQPACKET socket re-connect()s to another socket or notices
include/net/tcp.h +2 -1
index ecbadcb3a744..bc26ab16e39d 100644
@@ -1958,7 +1958,8 @@ static inline void tcp_fast_path_check(struct sock *sk)
 	if (RB_EMPTY_ROOT(&tp->out_of_order_queue) &&
 	    tp->rcv_wnd &&
 	    atomic_read(&sk->sk_rmem_alloc) < sk->sk_rcvbuf &&
-	    !tp->urg_data)
+	    !tp->urg_data &&
+	    !tp->repair)
 		tcp_fast_path_on(tp);
 }
 
net/ipv4/tcp.c +9 -0
index 432fa28e47d4..74ef96bda8c7 100644
@@ -3993,13 +3993,22 @@ int do_tcp_setsockopt(struct sock *sk, int level, int optname,
 			tp->repair = 1;
 			sk->sk_reuse = SK_FORCE_REUSE;
 			tp->repair_queue = TCP_NO_QUEUE;
+
+			/* Disable fast path so that we can freeze the receive
+			 * queue as needed, see tcp_rcv_established().
+			 */
+			tp->pred_flags = 0;
 		} else if (val == TCP_REPAIR_OFF) {
 			tp->repair = 0;
 			sk->sk_reuse = SK_NO_REUSE;
 			tcp_send_window_probe(sk);
+
+			tcp_fast_path_check(sk);
 		} else if (val == TCP_REPAIR_OFF_NO_WP) {
 			tp->repair = 0;
 			sk->sk_reuse = SK_NO_REUSE;
+
+			tcp_fast_path_check(sk);
 		} else
 			err = -EINVAL;
 
net/ipv4/tcp_input.c +13 -2
index d5c9e65d9760..3081ccfa90b4 100644
@@ -6451,8 +6451,9 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb,
  *	- Out of order segments arrived.
  *	- Urgent data is expected.
  *	- There is no buffer space left
- *	- Unexpected TCP flags/window values/header lengths are received
- *	  (detected by checking the TCP header against pred_flags)
+ *	- Unexpected TCP flags/window values/header lengths are received, or
+ *	  socket is in repair mode (detected by checking the TCP header against
+ *	  pred_flags)
  *	- Data is sent in both directions. Fast path only supports pure senders
  *	  or pure receivers (this means either the sequence number or the ack
  *	  value must stay constant)
@@ -6632,6 +6633,11 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb)
 		goto discard;
 	}
 
+	if (tp->repair) {
+		reason = SKB_DROP_REASON_SOCKET_REPAIR;
+		goto discard;
+	}
+
 	/*
 	 *	Standard slow path.
 	 */
@@ -7125,6 +7131,11 @@ tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)
 	int queued = 0;
 	SKB_DR(reason);
 
+	if (tp->repair) {
+		SKB_DR_SET(reason, SOCKET_REPAIR);
+		goto discard;
+	}
+
 	switch (sk->sk_state) {
 	case TCP_CLOSE:
 		SKB_DR_SET(reason, TCP_CLOSE);
Signature · 1 line
2.43.0
#2 lore raw

PATCH v2 2/2 selftests: Add data path tests for TCP_REPAIR mode

In reply to Stefano Brivio

The new tests check that, once TCP_REPAIR is enabled on a socket:

- additional incoming data queued to it don't increase the sequence number dumped via TCP_QUEUE_SEQ socket option

- a connected endpoint will not receive ACK segments after sending more data

These tests are implemented by a client, sending data and commands (accept connection, enter repair mode, dump sequences, receive data, and exit) describing the test sequence, and a server receiving data and implementing those commands.

This way, the client can accurately synchronise repair modes with data exchanges.

In order to avoid using loopback connections, where data would be immediately acknowledged by the server side without packets being actually sent or received, the client resides in a separate network namespace ("inner") compared to the server, and a veth interface pair connects them.

The tests can be run unprivileged as the outer network and user namespaces are also detached as a first step, so that the veth interfaces can be created in outer and inner namespaces without capabilities.

---
v2: No changes

 tools/testing/selftests/Makefile              |   1 +
 .../selftests/net/tcp_repair/.gitignore       |   3 +
 .../testing/selftests/net/tcp_repair/Makefile |  23 ++
 .../testing/selftests/net/tcp_repair/client.c | 273 ++++++++++++++++++
 .../testing/selftests/net/tcp_repair/inner.sh |  32 ++
 .../testing/selftests/net/tcp_repair/outer.sh |  44 +++
 tools/testing/selftests/net/tcp_repair/run.sh |  12 +
 .../testing/selftests/net/tcp_repair/server.c | 155 ++++++++++
 tools/testing/selftests/net/tcp_repair/talk.h |  26 ++
 9 files changed, 569 insertions(+)
 create mode 100644 tools/testing/selftests/net/tcp_repair/.gitignore
 create mode 100644 tools/testing/selftests/net/tcp_repair/Makefile
 create mode 100644 tools/testing/selftests/net/tcp_repair/client.c
 create mode 100755 tools/testing/selftests/net/tcp_repair/inner.sh
 create mode 100755 tools/testing/selftests/net/tcp_repair/outer.sh
 create mode 100755 tools/testing/selftests/net/tcp_repair/run.sh
 create mode 100644 tools/testing/selftests/net/tcp_repair/server.c
 create mode 100644 tools/testing/selftests/net/tcp_repair/talk.h
tools/testing/selftests/Makefile +1 -0
index 6e59b8f63e41..e119abe5c78e 100644
@@ -84,6 +84,7 @@ TARGETS += net/packetdrill
 TARGETS += net/ppp
 TARGETS += net/rds
 TARGETS += net/tcp_ao
+TARGETS += net/tcp_repair
 TARGETS += nolibc
 TARGETS += nsfs
 TARGETS += pci_endpoint
tools/testing/selftests/net/tcp_repair/.gitignore new file +3 -0
new file mode 100644
index 000000000000..9756c86770b9
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+client
+server
tools/testing/selftests/net/tcp_repair/Makefile new file +23 -0
new file mode 100644
index 000000000000..d01d0a20b6df
@@ -0,0 +1,23 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# selftests/net/tcp_repair: TCP_REPAIR connection tests
+#
+# Makefile - Build test client and server, declare run.sh entrypoint
+#
+# Copyright (c) 2026 Red Hat GmbH
+#
+# Author: Stefano Brivio <[email protected]>
+
+top_srcdir = ../../../../..
+
+CFLAGS += -Wall -Wextra -pedantic
+
+TEST_PROGS := \
+	run.sh
+
+TEST_GEN_FILES := \
+	client \
+	server \
+# end of TEST_GEN_FILES
+
+include ../../lib.mk
tools/testing/selftests/net/tcp_repair/client.c new file +273 -0

273 lines not on this page · raw message

tools/testing/selftests/net/tcp_repair/inner.sh new file +32 -0
new file mode 100755
index 000000000000..3987dc0514a8
@@ -0,0 +1,32 @@
+#!/bin/sh -euf
+# SPDX-License-Identifier: GPL-2.0
+#
+# selftests/net/tcp_repair: TCP_REPAIR connection tests
+#
+# inner.sh - Set up link to outer namespace, run test client in inner namespace
+#
+# Copyright (c) 2026 Red Hat GmbH
+#
+# Author: Stefano Brivio <[email protected]>
+
+ns_inner_dir="${1}"
+
+# Tell the parent shell about our PID
+echo "${$}" > "${ns_inner_dir}/pid"
+mkdir "${ns_inner_dir}/pid_ready"
+
+# Wait for veth to appear
+while [ -z "$(sed -n '4p' /proc/net/dev)" ]; do
+	sleep 0.1 || sleep 1
+done
+
+# Set up link to outer namespace
+ip link set dev veth0 up
+ip addr add 169.254.2.2 dev veth0
+ip ro add default dev veth0
+
+# Finally run tests
+set +e
+./client 169.254.2.1 1024
+echo "${?}" > "${ns_inner_dir}/result"
+mkdir "${ns_inner_dir}/result_ready"
tools/testing/selftests/net/tcp_repair/outer.sh new file +44 -0

44 lines not on this page · raw message

tools/testing/selftests/net/tcp_repair/run.sh new file +12 -0
new file mode 100755
index 000000000000..f87ff0a8a6f6
@@ -0,0 +1,12 @@
+#!/bin/sh -euf
+# SPDX-License-Identifier: GPL-2.0
+#
+# selftests/net/tcp_repair: TCP_REPAIR connection tests
+#
+# run.sh - Test entry point: detach outer namespace and run outer.sh in it
+#
+# Copyright (c) 2026 Red Hat GmbH
+#
+# Author: Stefano Brivio <[email protected]>
+
+unshare -rUn -- ./outer.sh
tools/testing/selftests/net/tcp_repair/server.c new file +155 -0

155 lines not on this page · raw message

tools/testing/selftests/net/tcp_repair/talk.h new file +26 -0
new file mode 100644
index 000000000000..e2fbad7fae07
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+/* selftests/net/tcp_repair: TCP_REPAIR connection tests
+ *
+ * talk.h - Communication protocol for client and server
+ *
+ * Copyright (c) 2026 Red Hat GmbH
+ *
+ * Author: Stefano Brivio <[email protected]>
+ */
+
+/**
+ * enum op - Server command type (taking optional int argument, returning int)
+ * @ACCEPT		Accept connection on data socket (doesn't return int)
+ * @DUMP_RECV_SEQ	Dump receive sequence, return it to the client
+ * @EXIT		Exit, return 0 to the client
+ * @RECV		Try receiving given amount of bytes, return received
+ * @REPAIR		Set repair mode to argument, return setsockopt() value
+ */
+enum op {
+	ACCEPT,
+	DUMP_RECV_SEQ,
+	EXIT,
+	RECV,
+	REPAIR,
+};
Signature · 1 line
2.43.0
maintainer
#3 lore raw
In reply to Stefano Brivio
Quoted 2 lines · On Mon, 18 May 2026 20:34:22 +0200 Stefano Brivio wrote:

Stefano Brivio (2):
tcp: Don't accept data when socket is in repair mode

Not sure Eric is on board with this patch in the first place. Sound like it's not the intended use case for REPAIR so IMO it's up to TCP maintainers whether we want to support this. And it's definitely not a Fix.

Quoted 1 line

selftests: Add data path tests for TCP_REPAIR mode

Please don't add a new target, fold it under net. Targets are a PITA to deal with in kselftests.

#4 lore raw
Quoted 9 lines · Jakub Kicinski
Quoted 2 lines · On Mon, 18 May 2026 20:34:22 +0200 Stefano Brivio wrote:

Stefano Brivio (2):
tcp: Don't accept data when socket is in repair mode

Not sure Eric is on board with this patch in the first place. Sound like it's not the intended use case for REPAIR so IMO it's up to TCP maintainers whether we want to support this. And it's definitely not a Fix.

I am not on board. Only net-next material for sure.

While v2 is slightly better, we have the fundamental problem of adding stuff to TCP receive path for features that almost nobody use. (It took more than 13 years to finally complain about the race)

This consumes Gigawats of power on our planet (and tons of CO2), given the trillions of packets processed every second.

Please at least add a static key as we did in:

commit 020e71a3cf7f50c0f2c54cf2444067b76fe6d785

Author: Eric Dumazet <[email protected]>
Date:   Mon Oct 25 09:48:24 2021 -0700

ipv4: guard IP_MINTTL with a static key

RFC 5082 IP_MINTTL option is rarely used on hosts.

But in my original feedback I pointed that we TCP_REPAIR should probably only insert a TCP socket into TPC established hash table only when it is ready to process incoming packets.

Quoted 5 lines
Quoted 2 lines

selftests: Add data path tests for TCP_REPAIR mode

Please don't add a new target, fold it under net. Targets are a PITA to deal with in kselftests.

#5 lore raw
Quoted 26 lines · Eric Dumazet
Quoted 9 lines · Jakub Kicinski
Quoted 2 lines · On Mon, 18 May 2026 20:34:22 +0200 Stefano Brivio wrote:

Stefano Brivio (2):
tcp: Don't accept data when socket is in repair mode

Not sure Eric is on board with this patch in the first place. Sound like it's not the intended use case for REPAIR so IMO it's up to TCP maintainers whether we want to support this. And it's definitely not a Fix.

I am not on board. Only net-next material for sure.

While v2 is slightly better, we have the fundamental problem of adding stuff to TCP receive path for features that almost nobody use. (It took more than 13 years to finally complain about the race)

This consumes Gigawats of power on our planet (and tons of CO2), given the trillions of packets processed every second.

Please at least add a static key as we did in:

commit 020e71a3cf7f50c0f2c54cf2444067b76fe6d785

Author: Eric Dumazet <[email protected]>
Date:   Mon Oct 25 09:48:24 2021 -0700
Quoted 8 lines

ipv4: guard IP_MINTTL with a static key

RFC 5082 IP_MINTTL option is rarely used on hosts.

But in my original feedback I pointed that we TCP_REPAIR should probably only insert a TCP socket into TPC established hash table only when it is ready to process incoming packets.

The problem is on the source side of the migration and I think removing the socket from the ehash table would trigger RSTs, closing the connection on the remote side.

Thanks,
Laurent

#6 lore raw
Quoted 33 lines · Laurent Vivier
Quoted 31 lines · Eric Dumazet
Quoted 9 lines · Jakub Kicinski
Quoted 2 lines · On Mon, 18 May 2026 20:34:22 +0200 Stefano Brivio wrote:

Stefano Brivio (2):
tcp: Don't accept data when socket is in repair mode

Not sure Eric is on board with this patch in the first place. Sound like it's not the intended use case for REPAIR so IMO it's up to TCP maintainers whether we want to support this. And it's definitely not a Fix.

I am not on board. Only net-next material for sure.

While v2 is slightly better, we have the fundamental problem of adding stuff to TCP receive path for features that almost nobody use. (It took more than 13 years to finally complain about the race)

This consumes Gigawats of power on our planet (and tons of CO2), given the trillions of packets processed every second.

Please at least add a static key as we did in:

commit 020e71a3cf7f50c0f2c54cf2444067b76fe6d785

Author: Eric Dumazet <[email protected]>
Date:   Mon Oct 25 09:48:24 2021 -0700

ipv4: guard IP_MINTTL with a static key

RFC 5082 IP_MINTTL option is rarely used on hosts.

Quoted 6 lines
Quoted 3 lines

But in my original feedback I pointed that we TCP_REPAIR should probably only insert a TCP socket into TPC established hash table only when it is ready to process incoming packets.

The problem is on the source side of the migration and I think removing the socket from the ehash table would trigger RSTs, closing the connection on the remote side.

RST is triggered anyway if TCP_REPAIR did not occur yet.

This is why a netfilter solution is generally used to make sure no incoming packet is received until the whole state has been repaired.

#7 lore raw
Quoted 9 lines · On Wed, 20 May 2026 00:27:38 -0700 Eric Dumazet <[email protected]> wrote:
Quoted 8 lines · Laurent Vivier
Quoted 6 lines · Eric Dumazet
Quoted 5 lines · Jakub Kicinski
Quoted 2 lines · On Mon, 18 May 2026 20:34:22 +0200 Stefano Brivio wrote:

Stefano Brivio (2):
tcp: Don't accept data when socket is in repair mode

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

Not sure Eric is on board with this patch in the first place. Sound like it's not the intended use case for REPAIR so IMO it's up to TCP maintainers whether we want to support this. And it's definitely not a Fix.

I am not on board. Only net-next material for sure.

I wasn't quite sure, I'll re-target it for net-next.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

While v2 is slightly better, we have the fundamental problem of adding stuff to TCP receive path for features that almost nobody use. (It took more than 13 years to finally complain about the race)

This consumes Gigawats of power on our planet (and tons of CO2), given the trillions of packets processed every second.

Absolutely not what I want, I didn't consider that.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Please at least add a static key as we did in:

commit 020e71a3cf7f50c0f2c54cf2444067b76fe6d785

Author: Eric Dumazet <[email protected]>
Date:   Mon Oct 25 09:48:24 2021 -0700

ipv4: guard IP_MINTTL with a static key

RFC 5082 IP_MINTTL option is rarely used on hosts.

I will, indeed, thanks for providing the reference.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

But in my original feedback I pointed that we TCP_REPAIR should probably only insert a TCP socket into TPC established hash table only when it is ready to process incoming packets.

I looked into your original feedback, and replied, because I couldn't understand how adding sockets to the hash table (they are already there) would help fixing this.

Now I understand the confusion:

Quoted 4 lines
Quoted 2 lines

The problem is on the source side of the migration and I think removing the socket from the ehash table would trigger RSTs, closing the connection on the remote side.

RST is triggered anyway if TCP_REPAIR did not occur yet.

It's different than the problem Kuniyuki pointed to (with the link to that proposed hack from January): there, you have a situation where the socket doesn't exist yet because it hasn't been restored yet.

That's livepatching, on the same host / node, a different (new) usage.

But here (regardless of whether it's CRIU or passt) we're talking about *migration* (CRIU: container, passt: VM) to a different host.

In this case, migration will be considered done / ready only after the sockets on the *target node* are up and running. No traffic will be routed to the target node before that point.

As long as we don't prematurely close the sockets on the source node, there's no issue with RSTs anywhere (and we can also roll things back on a failed migration). That's something we fixed in userspace without bothering the kernel at all.

Quoted 2 lines

This is why a netfilter solution is generally used to make sure no incoming packet is received until the whole state has been repaired.

See comment from Andrei here: the _main_ reason why CRIU (only by default, though) sets up netfilter rules seems to be that it makes things simpler *while dumping connections* in that specific case. A separate namespace makes it straightforward.

That's not the case for passt: it doesn't need to touch netfilter at all, and I think it's a very useful thing in terms of complexity, security, and keeping the downtime to a minimum (other than, as Andrei mentioned, making things generally safer).

Signature · 1 line
Stefano
#8 lore raw
In reply to Jakub Kicinski
Quoted 8 lines · On Tue, 19 May 2026 19:03:52 -0700 Jakub Kicinski <[email protected]> wrote:
Quoted 2 lines · On Mon, 18 May 2026 20:34:22 +0200 Stefano Brivio wrote:

Stefano Brivio (2):
tcp: Don't accept data when socket is in repair mode

Not sure Eric is on board with this patch in the first place. Sound like it's not the intended use case for REPAIR so IMO it's up to TCP maintainers whether we want to support this. And it's definitely not a Fix.

Jakub, thanks for looking into this.

As I was pointing out on the v1 thread, I think it's a race condition regardless of the usage, because after you switch a socket to repair mode you can do separate operations on the socket and the outcome will be inconsistent between them. It depends on external conditions and looks quite fragile.

For example, you could dump a given length of the receive queue, just to read it a moment later, but now the length is wrong.

Note that now, on the v1 thread, also Andrei, one of the authors of TCP_REPAIR and the matching feature in CRIU, agreed that my "fix" makes things safer:

https://lore.kernel.org/all/CAEWA0a4d-PpWpVexYGP5SLRuzj8hs1W1_Ww6qA4BBrkzSs4umQ@mail.gmail.com/

But I won't certainly insist on handling it as a fix and I'm now taking care of the new feedback coming from Eric of course.

Quoted 4 lines
Quoted 1 line

selftests: Add data path tests for TCP_REPAIR mode

Please don't add a new target, fold it under net. Targets are a PITA to deal with in kselftests.

Sorry, I had no idea, I'll change that.

Signature · 1 line
Stefano