linux/net/mptcp
Krister Johansen 9be08390ed mptcp: sockopt: make sync_socket_options propagate SOCK_KEEPOPEN
commit 648de37416 upstream.

Users reported a scenario where MPTCP connections that were configured
with SO_KEEPALIVE prior to connect would fail to enable their keepalives
if MTPCP fell back to TCP mode.

After investigating, this affects keepalives for any connection where
sync_socket_options is called on a socket that is in the closed or
listening state.  Joins are handled properly. For connects,
sync_socket_options is called when the socket is still in the closed
state.  The tcp_set_keepalive() function does not act on sockets that
are closed or listening, hence keepalive is not immediately enabled.
Since the SO_KEEPOPEN flag is absent, it is not enabled later in the
connect sequence via tcp_finish_connect.  Setting the keepalive via
sockopt after connect does work, but would not address any subsequently
created flows.

Fortunately, the fix here is straight-forward: set SOCK_KEEPOPEN on the
subflow when calling sync_socket_options.

The fix was valdidated both by using tcpdump to observe keepalive
packets not being sent before the fix, and being sent after the fix.  It
was also possible to observe via ss that the keepalive timer was not
enabled on these sockets before the fix, but was enabled afterwards.

Fixes: 1b3e7ede13 ("mptcp: setsockopt: handle SO_KEEPALIVE and SO_PRIORITY")
Cc: stable@vger.kernel.org
Signed-off-by: Krister Johansen <kjlx@templeofstupid.com>
Reviewed-by: Geliang Tang <geliang@kernel.org>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/aL8dYfPZrwedCIh9@templeofstupid.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2025-09-19 16:35:45 +02:00
..
bpf.c bpf: Add update_socket_protocol hook 2023-08-16 10:22:16 -07:00
crypto.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
crypto_test.c mptcp: fill in missing MODULE_DESCRIPTION() 2023-12-17 20:54:22 +00:00
ctrl.c mptcp: blackhole only if 1st SYN retrans w/o MPC is accepted 2025-02-08 09:58:16 +01:00
diag.c mptcp: annotate data-races around subflow->fully_established 2024-12-14 20:03:52 +01:00
fastopen.c mptcp: pr_debug: add missing \n at the end 2024-08-27 14:45:16 -07:00
Kconfig kunit: mptcp: adhere to KUNIT formatting standard 2021-04-16 17:10:40 -07:00
Makefile net: mptcp: use policy generated by YAML spec 2023-10-24 13:00:32 -07:00
mib.c mptcp: prevent MPC handshake on port-based signal endpoints 2024-10-15 10:57:02 -07:00
mib.h mptcp: prevent MPC handshake on port-based signal endpoints 2024-10-15 10:57:02 -07:00
mptcp_diag.c mptcp: drop duplicate header inclusions 2024-03-06 20:24:10 -08:00
mptcp_pm_gen.c mptcp: no admin perm to list endpoints 2024-11-05 17:51:08 -08:00
mptcp_pm_gen.h mptcp: add token for get-addr in yaml 2024-03-04 13:07:45 +00:00
options.c mptcp: drop skb if MPTCP skb extension allocation fails 2025-08-28 16:31:03 +02:00
pm.c mptcp: plug races between subflow fail and subflow creation 2025-07-24 08:56:24 +02:00
pm_netlink.c mptcp: disable add_addr retransmission when timeout is 0 2025-08-28 16:31:07 +02:00
pm_userspace.c mptcp: pm: userspace: flags: clearer msg if no remote addr 2025-05-29 11:02:56 +02:00
protocol.c mptcp: reset fallback status gracefully at disconnect() time 2025-07-24 08:56:24 +02:00
protocol.h mptcp: plug races between subflow fail and subflow creation 2025-07-24 08:56:24 +02:00
sched.c mptcp: pr_debug: add missing \n at the end 2024-08-27 14:45:16 -07:00
sockopt.c mptcp: sockopt: make sync_socket_options propagate SOCK_KEEPOPEN 2025-09-19 16:35:45 +02:00
subflow.c net: better track kernel sockets lifetime 2025-08-20 18:30:56 +02:00
syncookies.c mptcp: don't return sockets in foreign netns 2021-09-24 10:51:36 +01:00
token.c mptcp: add statistics for mptcp socket in use 2023-01-09 07:30:50 +00:00
token_test.c mptcp: token kunit: set protocol 2024-02-26 18:42:12 -08:00