2020-01-22 00:56:15 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
/* Multipath TCP
|
|
|
|
*
|
|
|
|
* Copyright (c) 2017 - 2019, Intel Corporation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __MPTCP_PROTOCOL_H
|
|
|
|
#define __MPTCP_PROTOCOL_H
|
|
|
|
|
2020-01-22 00:56:20 +00:00
|
|
|
#include <linux/random.h>
|
|
|
|
#include <net/tcp.h>
|
|
|
|
#include <net/inet_connection_sock.h>
|
2021-02-13 00:00:01 +00:00
|
|
|
#include <uapi/linux/mptcp.h>
|
2022-05-04 02:38:52 +00:00
|
|
|
#include <net/genetlink.h>
|
2024-04-25 03:13:39 +00:00
|
|
|
#include <net/rstreason.h>
|
2020-01-22 00:56:20 +00:00
|
|
|
|
2020-01-22 00:56:31 +00:00
|
|
|
#define MPTCP_SUPPORTED_VERSION 1
|
2020-01-22 00:56:16 +00:00
|
|
|
|
|
|
|
/* MPTCP option bits */
|
|
|
|
#define OPTION_MPTCP_MPC_SYN BIT(0)
|
|
|
|
#define OPTION_MPTCP_MPC_SYNACK BIT(1)
|
|
|
|
#define OPTION_MPTCP_MPC_ACK BIT(2)
|
2020-03-27 21:48:39 +00:00
|
|
|
#define OPTION_MPTCP_MPJ_SYN BIT(3)
|
|
|
|
#define OPTION_MPTCP_MPJ_SYNACK BIT(4)
|
|
|
|
#define OPTION_MPTCP_MPJ_ACK BIT(5)
|
2020-03-27 21:48:37 +00:00
|
|
|
#define OPTION_MPTCP_ADD_ADDR BIT(6)
|
2021-04-07 00:15:59 +00:00
|
|
|
#define OPTION_MPTCP_RM_ADDR BIT(7)
|
|
|
|
#define OPTION_MPTCP_FASTCLOSE BIT(8)
|
|
|
|
#define OPTION_MPTCP_PRIO BIT(9)
|
|
|
|
#define OPTION_MPTCP_RST BIT(10)
|
2021-08-24 23:26:13 +00:00
|
|
|
#define OPTION_MPTCP_DSS BIT(11)
|
2021-08-24 23:26:15 +00:00
|
|
|
#define OPTION_MPTCP_FAIL BIT(12)
|
2020-01-22 00:56:16 +00:00
|
|
|
|
2021-08-27 00:44:52 +00:00
|
|
|
#define OPTION_MPTCP_CSUMREQD BIT(13)
|
|
|
|
|
|
|
|
#define OPTIONS_MPTCP_MPC (OPTION_MPTCP_MPC_SYN | OPTION_MPTCP_MPC_SYNACK | \
|
|
|
|
OPTION_MPTCP_MPC_ACK)
|
|
|
|
#define OPTIONS_MPTCP_MPJ (OPTION_MPTCP_MPJ_SYN | OPTION_MPTCP_MPJ_SYNACK | \
|
2021-09-01 03:19:32 +00:00
|
|
|
OPTION_MPTCP_MPJ_ACK)
|
2021-08-27 00:44:52 +00:00
|
|
|
|
2020-01-22 00:56:16 +00:00
|
|
|
/* MPTCP option subtypes */
|
|
|
|
#define MPTCPOPT_MP_CAPABLE 0
|
|
|
|
#define MPTCPOPT_MP_JOIN 1
|
|
|
|
#define MPTCPOPT_DSS 2
|
|
|
|
#define MPTCPOPT_ADD_ADDR 3
|
|
|
|
#define MPTCPOPT_RM_ADDR 4
|
|
|
|
#define MPTCPOPT_MP_PRIO 5
|
|
|
|
#define MPTCPOPT_MP_FAIL 6
|
|
|
|
#define MPTCPOPT_MP_FASTCLOSE 7
|
2021-04-01 23:19:44 +00:00
|
|
|
#define MPTCPOPT_RST 8
|
2020-01-22 00:56:16 +00:00
|
|
|
|
|
|
|
/* MPTCP suboption lengths */
|
2020-01-22 00:56:31 +00:00
|
|
|
#define TCPOLEN_MPTCP_MPC_SYN 4
|
2020-01-22 00:56:16 +00:00
|
|
|
#define TCPOLEN_MPTCP_MPC_SYNACK 12
|
|
|
|
#define TCPOLEN_MPTCP_MPC_ACK 20
|
2020-01-22 00:56:31 +00:00
|
|
|
#define TCPOLEN_MPTCP_MPC_ACK_DATA 22
|
2020-03-27 21:48:39 +00:00
|
|
|
#define TCPOLEN_MPTCP_MPJ_SYN 12
|
|
|
|
#define TCPOLEN_MPTCP_MPJ_SYNACK 16
|
|
|
|
#define TCPOLEN_MPTCP_MPJ_ACK 24
|
2020-01-22 00:56:23 +00:00
|
|
|
#define TCPOLEN_MPTCP_DSS_BASE 4
|
2020-01-22 00:56:24 +00:00
|
|
|
#define TCPOLEN_MPTCP_DSS_ACK32 4
|
2020-01-22 00:56:23 +00:00
|
|
|
#define TCPOLEN_MPTCP_DSS_ACK64 8
|
2020-01-22 00:56:24 +00:00
|
|
|
#define TCPOLEN_MPTCP_DSS_MAP32 10
|
2020-01-22 00:56:23 +00:00
|
|
|
#define TCPOLEN_MPTCP_DSS_MAP64 14
|
|
|
|
#define TCPOLEN_MPTCP_DSS_CHECKSUM 2
|
2020-03-27 21:48:37 +00:00
|
|
|
#define TCPOLEN_MPTCP_ADD_ADDR 16
|
mptcp: fix length of ADD_ADDR with port sub-option
in current Linux, MPTCP peers advertising endpoints with port numbers use
a sub-option length that wrongly accounts for the trailing TCP NOP. Also,
receivers will only process incoming ADD_ADDR with port having such wrong
sub-option length. Fix this, making ADD_ADDR compliant to RFC8684 §3.4.1.
this can be verified running tcpdump on the kselftests artifacts:
unpatched kernel:
[root@bottarga mptcp]# tcpdump -tnnr unpatched.pcap | grep add-addr
reading from file unpatched.pcap, link-type LINUX_SLL (Linux cooked v1), snapshot length 65535
IP 10.0.1.1.10000 > 10.0.1.2.53078: Flags [.], ack 101, win 509, options [nop,nop,TS val 214459678 ecr 521312851,mptcp add-addr v1 id 1 a00:201:2774:2d88:7436:85c3:17fd:101], length 0
IP 10.0.1.2.53078 > 10.0.1.1.10000: Flags [.], ack 101, win 502, options [nop,nop,TS val 521312852 ecr 214459678,mptcp add-addr[bad opt]]
patched kernel:
[root@bottarga mptcp]# tcpdump -tnnr patched.pcap | grep add-addr
reading from file patched.pcap, link-type LINUX_SLL (Linux cooked v1), snapshot length 65535
IP 10.0.1.1.10000 > 10.0.1.2.38178: Flags [.], ack 101, win 509, options [nop,nop,TS val 3728873902 ecr 2732713192,mptcp add-addr v1 id 1 10.0.2.1:10100 hmac 0xbccdfcbe59292a1f,nop,nop], length 0
IP 10.0.1.2.38178 > 10.0.1.1.10000: Flags [.], ack 101, win 502, options [nop,nop,TS val 2732713195 ecr 3728873902,mptcp add-addr v1-echo id 1 10.0.2.1:10100,nop,nop], length 0
Fixes: 22fb85ffaefb ("mptcp: add port support for ADD_ADDR suboption writing")
CC: stable@vger.kernel.org # 5.11+
Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Acked-and-tested-by: Geliang Tang <geliangtang@gmail.com>
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-08 09:00:04 +00:00
|
|
|
#define TCPOLEN_MPTCP_ADD_ADDR_PORT 18
|
2020-03-27 21:48:37 +00:00
|
|
|
#define TCPOLEN_MPTCP_ADD_ADDR_BASE 8
|
mptcp: fix length of ADD_ADDR with port sub-option
in current Linux, MPTCP peers advertising endpoints with port numbers use
a sub-option length that wrongly accounts for the trailing TCP NOP. Also,
receivers will only process incoming ADD_ADDR with port having such wrong
sub-option length. Fix this, making ADD_ADDR compliant to RFC8684 §3.4.1.
this can be verified running tcpdump on the kselftests artifacts:
unpatched kernel:
[root@bottarga mptcp]# tcpdump -tnnr unpatched.pcap | grep add-addr
reading from file unpatched.pcap, link-type LINUX_SLL (Linux cooked v1), snapshot length 65535
IP 10.0.1.1.10000 > 10.0.1.2.53078: Flags [.], ack 101, win 509, options [nop,nop,TS val 214459678 ecr 521312851,mptcp add-addr v1 id 1 a00:201:2774:2d88:7436:85c3:17fd:101], length 0
IP 10.0.1.2.53078 > 10.0.1.1.10000: Flags [.], ack 101, win 502, options [nop,nop,TS val 521312852 ecr 214459678,mptcp add-addr[bad opt]]
patched kernel:
[root@bottarga mptcp]# tcpdump -tnnr patched.pcap | grep add-addr
reading from file patched.pcap, link-type LINUX_SLL (Linux cooked v1), snapshot length 65535
IP 10.0.1.1.10000 > 10.0.1.2.38178: Flags [.], ack 101, win 509, options [nop,nop,TS val 3728873902 ecr 2732713192,mptcp add-addr v1 id 1 10.0.2.1:10100 hmac 0xbccdfcbe59292a1f,nop,nop], length 0
IP 10.0.1.2.38178 > 10.0.1.1.10000: Flags [.], ack 101, win 502, options [nop,nop,TS val 2732713195 ecr 3728873902,mptcp add-addr v1-echo id 1 10.0.2.1:10100,nop,nop], length 0
Fixes: 22fb85ffaefb ("mptcp: add port support for ADD_ADDR suboption writing")
CC: stable@vger.kernel.org # 5.11+
Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Acked-and-tested-by: Geliang Tang <geliangtang@gmail.com>
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-08 09:00:04 +00:00
|
|
|
#define TCPOLEN_MPTCP_ADD_ADDR_BASE_PORT 10
|
2020-03-27 21:48:37 +00:00
|
|
|
#define TCPOLEN_MPTCP_ADD_ADDR6 28
|
mptcp: fix length of ADD_ADDR with port sub-option
in current Linux, MPTCP peers advertising endpoints with port numbers use
a sub-option length that wrongly accounts for the trailing TCP NOP. Also,
receivers will only process incoming ADD_ADDR with port having such wrong
sub-option length. Fix this, making ADD_ADDR compliant to RFC8684 §3.4.1.
this can be verified running tcpdump on the kselftests artifacts:
unpatched kernel:
[root@bottarga mptcp]# tcpdump -tnnr unpatched.pcap | grep add-addr
reading from file unpatched.pcap, link-type LINUX_SLL (Linux cooked v1), snapshot length 65535
IP 10.0.1.1.10000 > 10.0.1.2.53078: Flags [.], ack 101, win 509, options [nop,nop,TS val 214459678 ecr 521312851,mptcp add-addr v1 id 1 a00:201:2774:2d88:7436:85c3:17fd:101], length 0
IP 10.0.1.2.53078 > 10.0.1.1.10000: Flags [.], ack 101, win 502, options [nop,nop,TS val 521312852 ecr 214459678,mptcp add-addr[bad opt]]
patched kernel:
[root@bottarga mptcp]# tcpdump -tnnr patched.pcap | grep add-addr
reading from file patched.pcap, link-type LINUX_SLL (Linux cooked v1), snapshot length 65535
IP 10.0.1.1.10000 > 10.0.1.2.38178: Flags [.], ack 101, win 509, options [nop,nop,TS val 3728873902 ecr 2732713192,mptcp add-addr v1 id 1 10.0.2.1:10100 hmac 0xbccdfcbe59292a1f,nop,nop], length 0
IP 10.0.1.2.38178 > 10.0.1.1.10000: Flags [.], ack 101, win 502, options [nop,nop,TS val 2732713195 ecr 3728873902,mptcp add-addr v1-echo id 1 10.0.2.1:10100,nop,nop], length 0
Fixes: 22fb85ffaefb ("mptcp: add port support for ADD_ADDR suboption writing")
CC: stable@vger.kernel.org # 5.11+
Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Acked-and-tested-by: Geliang Tang <geliangtang@gmail.com>
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-08 09:00:04 +00:00
|
|
|
#define TCPOLEN_MPTCP_ADD_ADDR6_PORT 30
|
2020-03-27 21:48:37 +00:00
|
|
|
#define TCPOLEN_MPTCP_ADD_ADDR6_BASE 20
|
mptcp: fix length of ADD_ADDR with port sub-option
in current Linux, MPTCP peers advertising endpoints with port numbers use
a sub-option length that wrongly accounts for the trailing TCP NOP. Also,
receivers will only process incoming ADD_ADDR with port having such wrong
sub-option length. Fix this, making ADD_ADDR compliant to RFC8684 §3.4.1.
this can be verified running tcpdump on the kselftests artifacts:
unpatched kernel:
[root@bottarga mptcp]# tcpdump -tnnr unpatched.pcap | grep add-addr
reading from file unpatched.pcap, link-type LINUX_SLL (Linux cooked v1), snapshot length 65535
IP 10.0.1.1.10000 > 10.0.1.2.53078: Flags [.], ack 101, win 509, options [nop,nop,TS val 214459678 ecr 521312851,mptcp add-addr v1 id 1 a00:201:2774:2d88:7436:85c3:17fd:101], length 0
IP 10.0.1.2.53078 > 10.0.1.1.10000: Flags [.], ack 101, win 502, options [nop,nop,TS val 521312852 ecr 214459678,mptcp add-addr[bad opt]]
patched kernel:
[root@bottarga mptcp]# tcpdump -tnnr patched.pcap | grep add-addr
reading from file patched.pcap, link-type LINUX_SLL (Linux cooked v1), snapshot length 65535
IP 10.0.1.1.10000 > 10.0.1.2.38178: Flags [.], ack 101, win 509, options [nop,nop,TS val 3728873902 ecr 2732713192,mptcp add-addr v1 id 1 10.0.2.1:10100 hmac 0xbccdfcbe59292a1f,nop,nop], length 0
IP 10.0.1.2.38178 > 10.0.1.1.10000: Flags [.], ack 101, win 502, options [nop,nop,TS val 2732713195 ecr 3728873902,mptcp add-addr v1-echo id 1 10.0.2.1:10100,nop,nop], length 0
Fixes: 22fb85ffaefb ("mptcp: add port support for ADD_ADDR suboption writing")
CC: stable@vger.kernel.org # 5.11+
Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Acked-and-tested-by: Geliang Tang <geliangtang@gmail.com>
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-08 09:00:04 +00:00
|
|
|
#define TCPOLEN_MPTCP_ADD_ADDR6_BASE_PORT 22
|
|
|
|
#define TCPOLEN_MPTCP_PORT_LEN 2
|
|
|
|
#define TCPOLEN_MPTCP_PORT_ALIGN 2
|
2021-03-13 01:16:11 +00:00
|
|
|
#define TCPOLEN_MPTCP_RM_ADDR_BASE 3
|
mptcp: fix length of MP_PRIO suboption
With version 0 of the protocol it was legal to encode the 'Subflow Id' in
the MP_PRIO suboption, to specify which subflow would change its 'Backup'
flag. This has been removed from v1 specification: thus, according to RFC
8684 §3.3.8, the resulting 'Length' for MP_PRIO changed from 4 to 3 byte.
Current Linux generates / parses MP_PRIO according to the old spec, using
'Length' equal to 4, and hardcoding 1 as 'Subflow Id'; RFC compliance can
improve if we change 'Length' in other to become 3, leaving a 'Nop' after
the MP_PRIO suboption. In this way the kernel will emit and accept *only*
MP_PRIO suboptions that are compliant to version 1 of the MPTCP protocol.
unpatched 5.11-rc kernel:
[root@bottarga ~]# tcpdump -tnnr unpatched.pcap | grep prio
reading from file unpatched.pcap, link-type LINUX_SLL (Linux cooked v1)
dropped privs to tcpdump
IP 10.0.3.2.48433 > 10.0.1.1.10006: Flags [.], ack 1, win 502, options [nop,nop,TS val 4032325513 ecr 1876514270,mptcp prio non-backup id 1,mptcp dss ack 14084896651682217737], length 0
patched 5.11-rc kernel:
[root@bottarga ~]# tcpdump -tnnr patched.pcap | grep prio
reading from file patched.pcap, link-type LINUX_SLL (Linux cooked v1)
dropped privs to tcpdump
IP 10.0.3.2.49735 > 10.0.1.1.10006: Flags [.], ack 1, win 502, options [nop,nop,TS val 1276737699 ecr 2686399734,mptcp prio non-backup,nop,mptcp dss ack 18433038869082491686], length 0
Changes since v2:
- when accounting for option space, don't increment 'TCPOLEN_MPTCP_PRIO'
and use 'TCPOLEN_MPTCP_PRIO_ALIGN' instead, thanks to Matthieu Baerts.
Changes since v1:
- refactor patch to avoid using 'TCPOLEN_MPTCP_PRIO' with its old value,
thanks to Geliang Tang.
Fixes: 067065422fcd ("mptcp: add the outgoing MP_PRIO support")
Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Reviewed-by: Matteo Croce <mcroce@linux.microsoft.com>
Link: https://lore.kernel.org/r/846cdd41e6ad6ec88ef23fee1552ab39c2f5a3d1.1612184361.git.dcaratti@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2021-02-01 13:05:26 +00:00
|
|
|
#define TCPOLEN_MPTCP_PRIO 3
|
|
|
|
#define TCPOLEN_MPTCP_PRIO_ALIGN 4
|
2020-12-10 22:25:04 +00:00
|
|
|
#define TCPOLEN_MPTCP_FASTCLOSE 12
|
2021-04-01 23:19:44 +00:00
|
|
|
#define TCPOLEN_MPTCP_RST 4
|
2021-08-24 23:26:15 +00:00
|
|
|
#define TCPOLEN_MPTCP_FAIL 12
|
2020-01-22 00:56:16 +00:00
|
|
|
|
2021-06-17 23:46:14 +00:00
|
|
|
#define TCPOLEN_MPTCP_MPC_ACK_DATA_CSUM (TCPOLEN_MPTCP_DSS_CHECKSUM + TCPOLEN_MPTCP_MPC_ACK_DATA)
|
|
|
|
|
2020-03-27 21:48:40 +00:00
|
|
|
/* MPTCP MP_JOIN flags */
|
2020-03-27 21:48:39 +00:00
|
|
|
#define MPTCPOPT_BACKUP BIT(0)
|
2020-03-27 21:48:40 +00:00
|
|
|
#define MPTCPOPT_THMAC_LEN 8
|
2020-03-27 21:48:39 +00:00
|
|
|
|
2020-01-22 00:56:16 +00:00
|
|
|
/* MPTCP MP_CAPABLE flags */
|
|
|
|
#define MPTCP_VERSION_MASK (0x0F)
|
|
|
|
#define MPTCP_CAP_CHECKSUM_REQD BIT(7)
|
|
|
|
#define MPTCP_CAP_EXTENSIBILITY BIT(6)
|
2021-06-22 19:25:19 +00:00
|
|
|
#define MPTCP_CAP_DENY_JOIN_ID0 BIT(5)
|
2020-01-22 00:56:30 +00:00
|
|
|
#define MPTCP_CAP_HMAC_SHA256 BIT(0)
|
2021-06-22 19:25:19 +00:00
|
|
|
#define MPTCP_CAP_FLAG_MASK (0x1F)
|
2020-01-22 00:56:16 +00:00
|
|
|
|
2020-01-22 00:56:23 +00:00
|
|
|
/* MPTCP DSS flags */
|
|
|
|
#define MPTCP_DSS_DATA_FIN BIT(4)
|
|
|
|
#define MPTCP_DSS_DSN64 BIT(3)
|
|
|
|
#define MPTCP_DSS_HAS_MAP BIT(2)
|
|
|
|
#define MPTCP_DSS_ACK64 BIT(1)
|
|
|
|
#define MPTCP_DSS_HAS_ACK BIT(0)
|
2020-01-22 00:56:24 +00:00
|
|
|
#define MPTCP_DSS_FLAG_MASK (0x1F)
|
|
|
|
|
2020-03-27 21:48:37 +00:00
|
|
|
/* MPTCP ADD_ADDR flags */
|
|
|
|
#define MPTCP_ADDR_ECHO BIT(0)
|
|
|
|
|
2021-01-09 00:47:58 +00:00
|
|
|
/* MPTCP MP_PRIO flags */
|
|
|
|
#define MPTCP_PRIO_BKUP BIT(0)
|
|
|
|
|
2021-04-01 23:19:44 +00:00
|
|
|
/* MPTCP TCPRST flags */
|
|
|
|
#define MPTCP_RST_TRANSIENT BIT(0)
|
|
|
|
|
2022-01-07 00:20:26 +00:00
|
|
|
/* MPTCP socket atomic flags */
|
2024-03-01 17:43:44 +00:00
|
|
|
#define MPTCP_WORK_RTX 1
|
|
|
|
#define MPTCP_FALLBACK_DONE 2
|
|
|
|
#define MPTCP_WORK_CLOSE_SUBFLOW 3
|
2022-01-07 00:20:26 +00:00
|
|
|
|
|
|
|
/* MPTCP socket release cb flags */
|
|
|
|
#define MPTCP_PUSH_PENDING 1
|
|
|
|
#define MPTCP_CLEAN_UNA 2
|
|
|
|
#define MPTCP_ERROR_REPORT 3
|
|
|
|
#define MPTCP_RETRANSMIT 4
|
|
|
|
#define MPTCP_FLUSH_JOIN_LIST 5
|
2023-12-15 16:04:25 +00:00
|
|
|
#define MPTCP_SYNC_STATE 6
|
2023-10-23 20:44:42 +00:00
|
|
|
#define MPTCP_SYNC_SNDBUF 7
|
2020-01-22 00:56:23 +00:00
|
|
|
|
2022-11-25 22:29:50 +00:00
|
|
|
struct mptcp_skb_cb {
|
|
|
|
u64 map_seq;
|
|
|
|
u64 end_seq;
|
|
|
|
u32 offset;
|
|
|
|
u8 has_rxtstamp:1;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MPTCP_SKB_CB(__skb) ((struct mptcp_skb_cb *)&((__skb)->cb[0]))
|
|
|
|
|
2020-11-16 09:48:08 +00:00
|
|
|
static inline bool before64(__u64 seq1, __u64 seq2)
|
|
|
|
{
|
|
|
|
return (__s64)(seq1 - seq2) < 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define after64(seq2, seq1) before64(seq1, seq2)
|
|
|
|
|
mptcp: move option parsing into mptcp_incoming_options()
The mptcp_options_received structure carries several per
packet flags (mp_capable, mp_join, etc.). Such fields must
be cleared on each packet, even on dropped ones or packet
not carrying any MPTCP options, but the current mptcp
code clears them only on TCP option reset.
On several races/corner cases we end-up with stray bits in
incoming options, leading to WARN_ON splats. e.g.:
[ 171.164906] Bad mapping: ssn=32714 map_seq=1 map_data_len=32713
[ 171.165006] WARNING: CPU: 1 PID: 5026 at net/mptcp/subflow.c:533 warn_bad_map (linux-mptcp/net/mptcp/subflow.c:533 linux-mptcp/net/mptcp/subflow.c:531)
[ 171.167632] Modules linked in: ip6_vti ip_vti ip_gre ipip sit tunnel4 ip_tunnel geneve ip6_udp_tunnel udp_tunnel macsec macvtap tap ipvlan macvlan 8021q garp mrp xfrm_interface veth netdevsim nlmon dummy team bonding vcan bridge stp llc ip6_gre gre ip6_tunnel tunnel6 tun binfmt_misc intel_rapl_msr intel_rapl_common rfkill kvm_intel kvm irqbypass crct10dif_pclmul crc32_pclmul ghash_clmulni_intel joydev virtio_balloon pcspkr i2c_piix4 sunrpc ip_tables xfs libcrc32c crc32c_intel serio_raw virtio_console ata_generic virtio_blk virtio_net net_failover failover ata_piix libata
[ 171.199464] CPU: 1 PID: 5026 Comm: repro Not tainted 5.7.0-rc1.mptcp_f227fdf5d388+ #95
[ 171.200886] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-2.fc30 04/01/2014
[ 171.202546] RIP: 0010:warn_bad_map (linux-mptcp/net/mptcp/subflow.c:533 linux-mptcp/net/mptcp/subflow.c:531)
[ 171.206537] Code: c1 ea 03 0f b6 14 02 48 89 f8 83 e0 07 83 c0 03 38 d0 7c 04 84 d2 75 1d 8b 55 3c 44 89 e6 48 c7 c7 20 51 13 95 e8 37 8b 22 fe <0f> 0b 48 83 c4 08 5b 5d 41 5c c3 89 4c 24 04 e8 db d6 94 fe 8b 4c
[ 171.220473] RSP: 0018:ffffc90000150560 EFLAGS: 00010282
[ 171.221639] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
[ 171.223108] RDX: 0000000000000000 RSI: 0000000000000008 RDI: fffff5200002a09e
[ 171.224388] RBP: ffff8880aa6e3c00 R08: 0000000000000001 R09: fffffbfff2ec9955
[ 171.225706] R10: ffffffff9764caa7 R11: fffffbfff2ec9954 R12: 0000000000007fca
[ 171.227211] R13: ffff8881066f4a7f R14: ffff8880aa6e3c00 R15: 0000000000000020
[ 171.228460] FS: 00007f8623719740(0000) GS:ffff88810be00000(0000) knlGS:0000000000000000
[ 171.230065] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 171.231303] CR2: 00007ffdab190a50 CR3: 00000001038ea006 CR4: 0000000000160ee0
[ 171.232586] Call Trace:
[ 171.233109] <IRQ>
[ 171.233531] get_mapping_status (linux-mptcp/net/mptcp/subflow.c:691)
[ 171.234371] mptcp_subflow_data_available (linux-mptcp/net/mptcp/subflow.c:736 linux-mptcp/net/mptcp/subflow.c:832)
[ 171.238181] subflow_state_change (linux-mptcp/net/mptcp/subflow.c:1085 (discriminator 1))
[ 171.239066] tcp_fin (linux-mptcp/net/ipv4/tcp_input.c:4217)
[ 171.240123] tcp_data_queue (linux-mptcp/./include/linux/compiler.h:199 linux-mptcp/net/ipv4/tcp_input.c:4822)
[ 171.245083] tcp_rcv_established (linux-mptcp/./include/linux/skbuff.h:1785 linux-mptcp/./include/net/tcp.h:1774 linux-mptcp/./include/net/tcp.h:1847 linux-mptcp/net/ipv4/tcp_input.c:5238 linux-mptcp/net/ipv4/tcp_input.c:5730)
[ 171.254089] tcp_v4_rcv (linux-mptcp/./include/linux/spinlock.h:393 linux-mptcp/net/ipv4/tcp_ipv4.c:2009)
[ 171.258969] ip_protocol_deliver_rcu (linux-mptcp/net/ipv4/ip_input.c:204 (discriminator 1))
[ 171.260214] ip_local_deliver_finish (linux-mptcp/./include/linux/rcupdate.h:651 linux-mptcp/net/ipv4/ip_input.c:232)
[ 171.261389] ip_local_deliver (linux-mptcp/./include/linux/netfilter.h:307 linux-mptcp/./include/linux/netfilter.h:301 linux-mptcp/net/ipv4/ip_input.c:252)
[ 171.265884] ip_rcv (linux-mptcp/./include/linux/netfilter.h:307 linux-mptcp/./include/linux/netfilter.h:301 linux-mptcp/net/ipv4/ip_input.c:539)
[ 171.273666] process_backlog (linux-mptcp/./include/linux/rcupdate.h:651 linux-mptcp/net/core/dev.c:6135)
[ 171.275328] net_rx_action (linux-mptcp/net/core/dev.c:6572 linux-mptcp/net/core/dev.c:6640)
[ 171.280472] __do_softirq (linux-mptcp/./arch/x86/include/asm/jump_label.h:25 linux-mptcp/./include/linux/jump_label.h:200 linux-mptcp/./include/trace/events/irq.h:142 linux-mptcp/kernel/softirq.c:293)
[ 171.281379] do_softirq_own_stack (linux-mptcp/arch/x86/entry/entry_64.S:1083)
[ 171.282358] </IRQ>
We could address the issue clearing explicitly the relevant fields
in several places - tcp_parse_option, tcp_fast_parse_options,
possibly others.
Instead we move the MPTCP option parsing into the already existing
mptcp ingress hook, so that we need to clear the fields in a single
place.
This allows us dropping an MPTCP hook from the TCP code and
removing the quite large mptcp_options_received from the tcp_sock
struct. On the flip side, the MPTCP sockets will traverse the
option space twice (in tcp_parse_option() and in
mptcp_incoming_options(). That looks acceptable: we already
do that for syn and 3rd ack packets, plain TCP socket will
benefit from it, and even MPTCP sockets will experience better
code locality, reducing the jumps between TCP and MPTCP code.
v1 -> v2:
- rebased on current '-net' tree
Fixes: 648ef4b88673 ("mptcp: Implement MPTCP receive path")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-30 13:01:52 +00:00
|
|
|
struct mptcp_options_received {
|
|
|
|
u64 sndr_key;
|
|
|
|
u64 rcvr_key;
|
|
|
|
u64 data_ack;
|
|
|
|
u64 data_seq;
|
|
|
|
u32 subflow_seq;
|
|
|
|
u16 data_len;
|
2021-06-17 23:46:14 +00:00
|
|
|
__sum16 csum;
|
2021-08-27 00:44:52 +00:00
|
|
|
u16 suboptions;
|
mptcp: move option parsing into mptcp_incoming_options()
The mptcp_options_received structure carries several per
packet flags (mp_capable, mp_join, etc.). Such fields must
be cleared on each packet, even on dropped ones or packet
not carrying any MPTCP options, but the current mptcp
code clears them only on TCP option reset.
On several races/corner cases we end-up with stray bits in
incoming options, leading to WARN_ON splats. e.g.:
[ 171.164906] Bad mapping: ssn=32714 map_seq=1 map_data_len=32713
[ 171.165006] WARNING: CPU: 1 PID: 5026 at net/mptcp/subflow.c:533 warn_bad_map (linux-mptcp/net/mptcp/subflow.c:533 linux-mptcp/net/mptcp/subflow.c:531)
[ 171.167632] Modules linked in: ip6_vti ip_vti ip_gre ipip sit tunnel4 ip_tunnel geneve ip6_udp_tunnel udp_tunnel macsec macvtap tap ipvlan macvlan 8021q garp mrp xfrm_interface veth netdevsim nlmon dummy team bonding vcan bridge stp llc ip6_gre gre ip6_tunnel tunnel6 tun binfmt_misc intel_rapl_msr intel_rapl_common rfkill kvm_intel kvm irqbypass crct10dif_pclmul crc32_pclmul ghash_clmulni_intel joydev virtio_balloon pcspkr i2c_piix4 sunrpc ip_tables xfs libcrc32c crc32c_intel serio_raw virtio_console ata_generic virtio_blk virtio_net net_failover failover ata_piix libata
[ 171.199464] CPU: 1 PID: 5026 Comm: repro Not tainted 5.7.0-rc1.mptcp_f227fdf5d388+ #95
[ 171.200886] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-2.fc30 04/01/2014
[ 171.202546] RIP: 0010:warn_bad_map (linux-mptcp/net/mptcp/subflow.c:533 linux-mptcp/net/mptcp/subflow.c:531)
[ 171.206537] Code: c1 ea 03 0f b6 14 02 48 89 f8 83 e0 07 83 c0 03 38 d0 7c 04 84 d2 75 1d 8b 55 3c 44 89 e6 48 c7 c7 20 51 13 95 e8 37 8b 22 fe <0f> 0b 48 83 c4 08 5b 5d 41 5c c3 89 4c 24 04 e8 db d6 94 fe 8b 4c
[ 171.220473] RSP: 0018:ffffc90000150560 EFLAGS: 00010282
[ 171.221639] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
[ 171.223108] RDX: 0000000000000000 RSI: 0000000000000008 RDI: fffff5200002a09e
[ 171.224388] RBP: ffff8880aa6e3c00 R08: 0000000000000001 R09: fffffbfff2ec9955
[ 171.225706] R10: ffffffff9764caa7 R11: fffffbfff2ec9954 R12: 0000000000007fca
[ 171.227211] R13: ffff8881066f4a7f R14: ffff8880aa6e3c00 R15: 0000000000000020
[ 171.228460] FS: 00007f8623719740(0000) GS:ffff88810be00000(0000) knlGS:0000000000000000
[ 171.230065] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 171.231303] CR2: 00007ffdab190a50 CR3: 00000001038ea006 CR4: 0000000000160ee0
[ 171.232586] Call Trace:
[ 171.233109] <IRQ>
[ 171.233531] get_mapping_status (linux-mptcp/net/mptcp/subflow.c:691)
[ 171.234371] mptcp_subflow_data_available (linux-mptcp/net/mptcp/subflow.c:736 linux-mptcp/net/mptcp/subflow.c:832)
[ 171.238181] subflow_state_change (linux-mptcp/net/mptcp/subflow.c:1085 (discriminator 1))
[ 171.239066] tcp_fin (linux-mptcp/net/ipv4/tcp_input.c:4217)
[ 171.240123] tcp_data_queue (linux-mptcp/./include/linux/compiler.h:199 linux-mptcp/net/ipv4/tcp_input.c:4822)
[ 171.245083] tcp_rcv_established (linux-mptcp/./include/linux/skbuff.h:1785 linux-mptcp/./include/net/tcp.h:1774 linux-mptcp/./include/net/tcp.h:1847 linux-mptcp/net/ipv4/tcp_input.c:5238 linux-mptcp/net/ipv4/tcp_input.c:5730)
[ 171.254089] tcp_v4_rcv (linux-mptcp/./include/linux/spinlock.h:393 linux-mptcp/net/ipv4/tcp_ipv4.c:2009)
[ 171.258969] ip_protocol_deliver_rcu (linux-mptcp/net/ipv4/ip_input.c:204 (discriminator 1))
[ 171.260214] ip_local_deliver_finish (linux-mptcp/./include/linux/rcupdate.h:651 linux-mptcp/net/ipv4/ip_input.c:232)
[ 171.261389] ip_local_deliver (linux-mptcp/./include/linux/netfilter.h:307 linux-mptcp/./include/linux/netfilter.h:301 linux-mptcp/net/ipv4/ip_input.c:252)
[ 171.265884] ip_rcv (linux-mptcp/./include/linux/netfilter.h:307 linux-mptcp/./include/linux/netfilter.h:301 linux-mptcp/net/ipv4/ip_input.c:539)
[ 171.273666] process_backlog (linux-mptcp/./include/linux/rcupdate.h:651 linux-mptcp/net/core/dev.c:6135)
[ 171.275328] net_rx_action (linux-mptcp/net/core/dev.c:6572 linux-mptcp/net/core/dev.c:6640)
[ 171.280472] __do_softirq (linux-mptcp/./arch/x86/include/asm/jump_label.h:25 linux-mptcp/./include/linux/jump_label.h:200 linux-mptcp/./include/trace/events/irq.h:142 linux-mptcp/kernel/softirq.c:293)
[ 171.281379] do_softirq_own_stack (linux-mptcp/arch/x86/entry/entry_64.S:1083)
[ 171.282358] </IRQ>
We could address the issue clearing explicitly the relevant fields
in several places - tcp_parse_option, tcp_fast_parse_options,
possibly others.
Instead we move the MPTCP option parsing into the already existing
mptcp ingress hook, so that we need to clear the fields in a single
place.
This allows us dropping an MPTCP hook from the TCP code and
removing the quite large mptcp_options_received from the tcp_sock
struct. On the flip side, the MPTCP sockets will traverse the
option space twice (in tcp_parse_option() and in
mptcp_incoming_options(). That looks acceptable: we already
do that for syn and 3rd ack packets, plain TCP socket will
benefit from it, and even MPTCP sockets will experience better
code locality, reducing the jumps between TCP and MPTCP code.
v1 -> v2:
- rebased on current '-net' tree
Fixes: 648ef4b88673 ("mptcp: Implement MPTCP receive path")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-30 13:01:52 +00:00
|
|
|
u32 token;
|
|
|
|
u32 nonce;
|
2021-08-27 00:44:51 +00:00
|
|
|
u16 use_map:1,
|
mptcp: move option parsing into mptcp_incoming_options()
The mptcp_options_received structure carries several per
packet flags (mp_capable, mp_join, etc.). Such fields must
be cleared on each packet, even on dropped ones or packet
not carrying any MPTCP options, but the current mptcp
code clears them only on TCP option reset.
On several races/corner cases we end-up with stray bits in
incoming options, leading to WARN_ON splats. e.g.:
[ 171.164906] Bad mapping: ssn=32714 map_seq=1 map_data_len=32713
[ 171.165006] WARNING: CPU: 1 PID: 5026 at net/mptcp/subflow.c:533 warn_bad_map (linux-mptcp/net/mptcp/subflow.c:533 linux-mptcp/net/mptcp/subflow.c:531)
[ 171.167632] Modules linked in: ip6_vti ip_vti ip_gre ipip sit tunnel4 ip_tunnel geneve ip6_udp_tunnel udp_tunnel macsec macvtap tap ipvlan macvlan 8021q garp mrp xfrm_interface veth netdevsim nlmon dummy team bonding vcan bridge stp llc ip6_gre gre ip6_tunnel tunnel6 tun binfmt_misc intel_rapl_msr intel_rapl_common rfkill kvm_intel kvm irqbypass crct10dif_pclmul crc32_pclmul ghash_clmulni_intel joydev virtio_balloon pcspkr i2c_piix4 sunrpc ip_tables xfs libcrc32c crc32c_intel serio_raw virtio_console ata_generic virtio_blk virtio_net net_failover failover ata_piix libata
[ 171.199464] CPU: 1 PID: 5026 Comm: repro Not tainted 5.7.0-rc1.mptcp_f227fdf5d388+ #95
[ 171.200886] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-2.fc30 04/01/2014
[ 171.202546] RIP: 0010:warn_bad_map (linux-mptcp/net/mptcp/subflow.c:533 linux-mptcp/net/mptcp/subflow.c:531)
[ 171.206537] Code: c1 ea 03 0f b6 14 02 48 89 f8 83 e0 07 83 c0 03 38 d0 7c 04 84 d2 75 1d 8b 55 3c 44 89 e6 48 c7 c7 20 51 13 95 e8 37 8b 22 fe <0f> 0b 48 83 c4 08 5b 5d 41 5c c3 89 4c 24 04 e8 db d6 94 fe 8b 4c
[ 171.220473] RSP: 0018:ffffc90000150560 EFLAGS: 00010282
[ 171.221639] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
[ 171.223108] RDX: 0000000000000000 RSI: 0000000000000008 RDI: fffff5200002a09e
[ 171.224388] RBP: ffff8880aa6e3c00 R08: 0000000000000001 R09: fffffbfff2ec9955
[ 171.225706] R10: ffffffff9764caa7 R11: fffffbfff2ec9954 R12: 0000000000007fca
[ 171.227211] R13: ffff8881066f4a7f R14: ffff8880aa6e3c00 R15: 0000000000000020
[ 171.228460] FS: 00007f8623719740(0000) GS:ffff88810be00000(0000) knlGS:0000000000000000
[ 171.230065] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 171.231303] CR2: 00007ffdab190a50 CR3: 00000001038ea006 CR4: 0000000000160ee0
[ 171.232586] Call Trace:
[ 171.233109] <IRQ>
[ 171.233531] get_mapping_status (linux-mptcp/net/mptcp/subflow.c:691)
[ 171.234371] mptcp_subflow_data_available (linux-mptcp/net/mptcp/subflow.c:736 linux-mptcp/net/mptcp/subflow.c:832)
[ 171.238181] subflow_state_change (linux-mptcp/net/mptcp/subflow.c:1085 (discriminator 1))
[ 171.239066] tcp_fin (linux-mptcp/net/ipv4/tcp_input.c:4217)
[ 171.240123] tcp_data_queue (linux-mptcp/./include/linux/compiler.h:199 linux-mptcp/net/ipv4/tcp_input.c:4822)
[ 171.245083] tcp_rcv_established (linux-mptcp/./include/linux/skbuff.h:1785 linux-mptcp/./include/net/tcp.h:1774 linux-mptcp/./include/net/tcp.h:1847 linux-mptcp/net/ipv4/tcp_input.c:5238 linux-mptcp/net/ipv4/tcp_input.c:5730)
[ 171.254089] tcp_v4_rcv (linux-mptcp/./include/linux/spinlock.h:393 linux-mptcp/net/ipv4/tcp_ipv4.c:2009)
[ 171.258969] ip_protocol_deliver_rcu (linux-mptcp/net/ipv4/ip_input.c:204 (discriminator 1))
[ 171.260214] ip_local_deliver_finish (linux-mptcp/./include/linux/rcupdate.h:651 linux-mptcp/net/ipv4/ip_input.c:232)
[ 171.261389] ip_local_deliver (linux-mptcp/./include/linux/netfilter.h:307 linux-mptcp/./include/linux/netfilter.h:301 linux-mptcp/net/ipv4/ip_input.c:252)
[ 171.265884] ip_rcv (linux-mptcp/./include/linux/netfilter.h:307 linux-mptcp/./include/linux/netfilter.h:301 linux-mptcp/net/ipv4/ip_input.c:539)
[ 171.273666] process_backlog (linux-mptcp/./include/linux/rcupdate.h:651 linux-mptcp/net/core/dev.c:6135)
[ 171.275328] net_rx_action (linux-mptcp/net/core/dev.c:6572 linux-mptcp/net/core/dev.c:6640)
[ 171.280472] __do_softirq (linux-mptcp/./arch/x86/include/asm/jump_label.h:25 linux-mptcp/./include/linux/jump_label.h:200 linux-mptcp/./include/trace/events/irq.h:142 linux-mptcp/kernel/softirq.c:293)
[ 171.281379] do_softirq_own_stack (linux-mptcp/arch/x86/entry/entry_64.S:1083)
[ 171.282358] </IRQ>
We could address the issue clearing explicitly the relevant fields
in several places - tcp_parse_option, tcp_fast_parse_options,
possibly others.
Instead we move the MPTCP option parsing into the already existing
mptcp ingress hook, so that we need to clear the fields in a single
place.
This allows us dropping an MPTCP hook from the TCP code and
removing the quite large mptcp_options_received from the tcp_sock
struct. On the flip side, the MPTCP sockets will traverse the
option space twice (in tcp_parse_option() and in
mptcp_incoming_options(). That looks acceptable: we already
do that for syn and 3rd ack packets, plain TCP socket will
benefit from it, and even MPTCP sockets will experience better
code locality, reducing the jumps between TCP and MPTCP code.
v1 -> v2:
- rebased on current '-net' tree
Fixes: 648ef4b88673 ("mptcp: Implement MPTCP receive path")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-30 13:01:52 +00:00
|
|
|
dsn64:1,
|
|
|
|
data_fin:1,
|
|
|
|
use_ack:1,
|
|
|
|
ack64:1,
|
|
|
|
mpc_map:1,
|
2021-08-27 00:44:51 +00:00
|
|
|
reset_reason:4,
|
|
|
|
reset_transient:1,
|
|
|
|
echo:1,
|
|
|
|
backup:1,
|
|
|
|
deny_join_id0:1,
|
mptcp: move option parsing into mptcp_incoming_options()
The mptcp_options_received structure carries several per
packet flags (mp_capable, mp_join, etc.). Such fields must
be cleared on each packet, even on dropped ones or packet
not carrying any MPTCP options, but the current mptcp
code clears them only on TCP option reset.
On several races/corner cases we end-up with stray bits in
incoming options, leading to WARN_ON splats. e.g.:
[ 171.164906] Bad mapping: ssn=32714 map_seq=1 map_data_len=32713
[ 171.165006] WARNING: CPU: 1 PID: 5026 at net/mptcp/subflow.c:533 warn_bad_map (linux-mptcp/net/mptcp/subflow.c:533 linux-mptcp/net/mptcp/subflow.c:531)
[ 171.167632] Modules linked in: ip6_vti ip_vti ip_gre ipip sit tunnel4 ip_tunnel geneve ip6_udp_tunnel udp_tunnel macsec macvtap tap ipvlan macvlan 8021q garp mrp xfrm_interface veth netdevsim nlmon dummy team bonding vcan bridge stp llc ip6_gre gre ip6_tunnel tunnel6 tun binfmt_misc intel_rapl_msr intel_rapl_common rfkill kvm_intel kvm irqbypass crct10dif_pclmul crc32_pclmul ghash_clmulni_intel joydev virtio_balloon pcspkr i2c_piix4 sunrpc ip_tables xfs libcrc32c crc32c_intel serio_raw virtio_console ata_generic virtio_blk virtio_net net_failover failover ata_piix libata
[ 171.199464] CPU: 1 PID: 5026 Comm: repro Not tainted 5.7.0-rc1.mptcp_f227fdf5d388+ #95
[ 171.200886] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-2.fc30 04/01/2014
[ 171.202546] RIP: 0010:warn_bad_map (linux-mptcp/net/mptcp/subflow.c:533 linux-mptcp/net/mptcp/subflow.c:531)
[ 171.206537] Code: c1 ea 03 0f b6 14 02 48 89 f8 83 e0 07 83 c0 03 38 d0 7c 04 84 d2 75 1d 8b 55 3c 44 89 e6 48 c7 c7 20 51 13 95 e8 37 8b 22 fe <0f> 0b 48 83 c4 08 5b 5d 41 5c c3 89 4c 24 04 e8 db d6 94 fe 8b 4c
[ 171.220473] RSP: 0018:ffffc90000150560 EFLAGS: 00010282
[ 171.221639] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
[ 171.223108] RDX: 0000000000000000 RSI: 0000000000000008 RDI: fffff5200002a09e
[ 171.224388] RBP: ffff8880aa6e3c00 R08: 0000000000000001 R09: fffffbfff2ec9955
[ 171.225706] R10: ffffffff9764caa7 R11: fffffbfff2ec9954 R12: 0000000000007fca
[ 171.227211] R13: ffff8881066f4a7f R14: ffff8880aa6e3c00 R15: 0000000000000020
[ 171.228460] FS: 00007f8623719740(0000) GS:ffff88810be00000(0000) knlGS:0000000000000000
[ 171.230065] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 171.231303] CR2: 00007ffdab190a50 CR3: 00000001038ea006 CR4: 0000000000160ee0
[ 171.232586] Call Trace:
[ 171.233109] <IRQ>
[ 171.233531] get_mapping_status (linux-mptcp/net/mptcp/subflow.c:691)
[ 171.234371] mptcp_subflow_data_available (linux-mptcp/net/mptcp/subflow.c:736 linux-mptcp/net/mptcp/subflow.c:832)
[ 171.238181] subflow_state_change (linux-mptcp/net/mptcp/subflow.c:1085 (discriminator 1))
[ 171.239066] tcp_fin (linux-mptcp/net/ipv4/tcp_input.c:4217)
[ 171.240123] tcp_data_queue (linux-mptcp/./include/linux/compiler.h:199 linux-mptcp/net/ipv4/tcp_input.c:4822)
[ 171.245083] tcp_rcv_established (linux-mptcp/./include/linux/skbuff.h:1785 linux-mptcp/./include/net/tcp.h:1774 linux-mptcp/./include/net/tcp.h:1847 linux-mptcp/net/ipv4/tcp_input.c:5238 linux-mptcp/net/ipv4/tcp_input.c:5730)
[ 171.254089] tcp_v4_rcv (linux-mptcp/./include/linux/spinlock.h:393 linux-mptcp/net/ipv4/tcp_ipv4.c:2009)
[ 171.258969] ip_protocol_deliver_rcu (linux-mptcp/net/ipv4/ip_input.c:204 (discriminator 1))
[ 171.260214] ip_local_deliver_finish (linux-mptcp/./include/linux/rcupdate.h:651 linux-mptcp/net/ipv4/ip_input.c:232)
[ 171.261389] ip_local_deliver (linux-mptcp/./include/linux/netfilter.h:307 linux-mptcp/./include/linux/netfilter.h:301 linux-mptcp/net/ipv4/ip_input.c:252)
[ 171.265884] ip_rcv (linux-mptcp/./include/linux/netfilter.h:307 linux-mptcp/./include/linux/netfilter.h:301 linux-mptcp/net/ipv4/ip_input.c:539)
[ 171.273666] process_backlog (linux-mptcp/./include/linux/rcupdate.h:651 linux-mptcp/net/core/dev.c:6135)
[ 171.275328] net_rx_action (linux-mptcp/net/core/dev.c:6572 linux-mptcp/net/core/dev.c:6640)
[ 171.280472] __do_softirq (linux-mptcp/./arch/x86/include/asm/jump_label.h:25 linux-mptcp/./include/linux/jump_label.h:200 linux-mptcp/./include/trace/events/irq.h:142 linux-mptcp/kernel/softirq.c:293)
[ 171.281379] do_softirq_own_stack (linux-mptcp/arch/x86/entry/entry_64.S:1083)
[ 171.282358] </IRQ>
We could address the issue clearing explicitly the relevant fields
in several places - tcp_parse_option, tcp_fast_parse_options,
possibly others.
Instead we move the MPTCP option parsing into the already existing
mptcp ingress hook, so that we need to clear the fields in a single
place.
This allows us dropping an MPTCP hook from the TCP code and
removing the quite large mptcp_options_received from the tcp_sock
struct. On the flip side, the MPTCP sockets will traverse the
option space twice (in tcp_parse_option() and in
mptcp_incoming_options(). That looks acceptable: we already
do that for syn and 3rd ack packets, plain TCP socket will
benefit from it, and even MPTCP sockets will experience better
code locality, reducing the jumps between TCP and MPTCP code.
v1 -> v2:
- rebased on current '-net' tree
Fixes: 648ef4b88673 ("mptcp: Implement MPTCP receive path")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-30 13:01:52 +00:00
|
|
|
__unused:2;
|
2021-08-27 00:44:51 +00:00
|
|
|
u8 join_id;
|
|
|
|
u64 thmac;
|
|
|
|
u8 hmac[MPTCPOPT_HMAC_LEN];
|
2021-04-07 00:16:00 +00:00
|
|
|
struct mptcp_addr_info addr;
|
2021-03-13 01:16:13 +00:00
|
|
|
struct mptcp_rm_list rm_list;
|
mptcp: move option parsing into mptcp_incoming_options()
The mptcp_options_received structure carries several per
packet flags (mp_capable, mp_join, etc.). Such fields must
be cleared on each packet, even on dropped ones or packet
not carrying any MPTCP options, but the current mptcp
code clears them only on TCP option reset.
On several races/corner cases we end-up with stray bits in
incoming options, leading to WARN_ON splats. e.g.:
[ 171.164906] Bad mapping: ssn=32714 map_seq=1 map_data_len=32713
[ 171.165006] WARNING: CPU: 1 PID: 5026 at net/mptcp/subflow.c:533 warn_bad_map (linux-mptcp/net/mptcp/subflow.c:533 linux-mptcp/net/mptcp/subflow.c:531)
[ 171.167632] Modules linked in: ip6_vti ip_vti ip_gre ipip sit tunnel4 ip_tunnel geneve ip6_udp_tunnel udp_tunnel macsec macvtap tap ipvlan macvlan 8021q garp mrp xfrm_interface veth netdevsim nlmon dummy team bonding vcan bridge stp llc ip6_gre gre ip6_tunnel tunnel6 tun binfmt_misc intel_rapl_msr intel_rapl_common rfkill kvm_intel kvm irqbypass crct10dif_pclmul crc32_pclmul ghash_clmulni_intel joydev virtio_balloon pcspkr i2c_piix4 sunrpc ip_tables xfs libcrc32c crc32c_intel serio_raw virtio_console ata_generic virtio_blk virtio_net net_failover failover ata_piix libata
[ 171.199464] CPU: 1 PID: 5026 Comm: repro Not tainted 5.7.0-rc1.mptcp_f227fdf5d388+ #95
[ 171.200886] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-2.fc30 04/01/2014
[ 171.202546] RIP: 0010:warn_bad_map (linux-mptcp/net/mptcp/subflow.c:533 linux-mptcp/net/mptcp/subflow.c:531)
[ 171.206537] Code: c1 ea 03 0f b6 14 02 48 89 f8 83 e0 07 83 c0 03 38 d0 7c 04 84 d2 75 1d 8b 55 3c 44 89 e6 48 c7 c7 20 51 13 95 e8 37 8b 22 fe <0f> 0b 48 83 c4 08 5b 5d 41 5c c3 89 4c 24 04 e8 db d6 94 fe 8b 4c
[ 171.220473] RSP: 0018:ffffc90000150560 EFLAGS: 00010282
[ 171.221639] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
[ 171.223108] RDX: 0000000000000000 RSI: 0000000000000008 RDI: fffff5200002a09e
[ 171.224388] RBP: ffff8880aa6e3c00 R08: 0000000000000001 R09: fffffbfff2ec9955
[ 171.225706] R10: ffffffff9764caa7 R11: fffffbfff2ec9954 R12: 0000000000007fca
[ 171.227211] R13: ffff8881066f4a7f R14: ffff8880aa6e3c00 R15: 0000000000000020
[ 171.228460] FS: 00007f8623719740(0000) GS:ffff88810be00000(0000) knlGS:0000000000000000
[ 171.230065] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 171.231303] CR2: 00007ffdab190a50 CR3: 00000001038ea006 CR4: 0000000000160ee0
[ 171.232586] Call Trace:
[ 171.233109] <IRQ>
[ 171.233531] get_mapping_status (linux-mptcp/net/mptcp/subflow.c:691)
[ 171.234371] mptcp_subflow_data_available (linux-mptcp/net/mptcp/subflow.c:736 linux-mptcp/net/mptcp/subflow.c:832)
[ 171.238181] subflow_state_change (linux-mptcp/net/mptcp/subflow.c:1085 (discriminator 1))
[ 171.239066] tcp_fin (linux-mptcp/net/ipv4/tcp_input.c:4217)
[ 171.240123] tcp_data_queue (linux-mptcp/./include/linux/compiler.h:199 linux-mptcp/net/ipv4/tcp_input.c:4822)
[ 171.245083] tcp_rcv_established (linux-mptcp/./include/linux/skbuff.h:1785 linux-mptcp/./include/net/tcp.h:1774 linux-mptcp/./include/net/tcp.h:1847 linux-mptcp/net/ipv4/tcp_input.c:5238 linux-mptcp/net/ipv4/tcp_input.c:5730)
[ 171.254089] tcp_v4_rcv (linux-mptcp/./include/linux/spinlock.h:393 linux-mptcp/net/ipv4/tcp_ipv4.c:2009)
[ 171.258969] ip_protocol_deliver_rcu (linux-mptcp/net/ipv4/ip_input.c:204 (discriminator 1))
[ 171.260214] ip_local_deliver_finish (linux-mptcp/./include/linux/rcupdate.h:651 linux-mptcp/net/ipv4/ip_input.c:232)
[ 171.261389] ip_local_deliver (linux-mptcp/./include/linux/netfilter.h:307 linux-mptcp/./include/linux/netfilter.h:301 linux-mptcp/net/ipv4/ip_input.c:252)
[ 171.265884] ip_rcv (linux-mptcp/./include/linux/netfilter.h:307 linux-mptcp/./include/linux/netfilter.h:301 linux-mptcp/net/ipv4/ip_input.c:539)
[ 171.273666] process_backlog (linux-mptcp/./include/linux/rcupdate.h:651 linux-mptcp/net/core/dev.c:6135)
[ 171.275328] net_rx_action (linux-mptcp/net/core/dev.c:6572 linux-mptcp/net/core/dev.c:6640)
[ 171.280472] __do_softirq (linux-mptcp/./arch/x86/include/asm/jump_label.h:25 linux-mptcp/./include/linux/jump_label.h:200 linux-mptcp/./include/trace/events/irq.h:142 linux-mptcp/kernel/softirq.c:293)
[ 171.281379] do_softirq_own_stack (linux-mptcp/arch/x86/entry/entry_64.S:1083)
[ 171.282358] </IRQ>
We could address the issue clearing explicitly the relevant fields
in several places - tcp_parse_option, tcp_fast_parse_options,
possibly others.
Instead we move the MPTCP option parsing into the already existing
mptcp ingress hook, so that we need to clear the fields in a single
place.
This allows us dropping an MPTCP hook from the TCP code and
removing the quite large mptcp_options_received from the tcp_sock
struct. On the flip side, the MPTCP sockets will traverse the
option space twice (in tcp_parse_option() and in
mptcp_incoming_options(). That looks acceptable: we already
do that for syn and 3rd ack packets, plain TCP socket will
benefit from it, and even MPTCP sockets will experience better
code locality, reducing the jumps between TCP and MPTCP code.
v1 -> v2:
- rebased on current '-net' tree
Fixes: 648ef4b88673 ("mptcp: Implement MPTCP receive path")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-30 13:01:52 +00:00
|
|
|
u64 ahmac;
|
2021-08-24 23:26:16 +00:00
|
|
|
u64 fail_seq;
|
mptcp: move option parsing into mptcp_incoming_options()
The mptcp_options_received structure carries several per
packet flags (mp_capable, mp_join, etc.). Such fields must
be cleared on each packet, even on dropped ones or packet
not carrying any MPTCP options, but the current mptcp
code clears them only on TCP option reset.
On several races/corner cases we end-up with stray bits in
incoming options, leading to WARN_ON splats. e.g.:
[ 171.164906] Bad mapping: ssn=32714 map_seq=1 map_data_len=32713
[ 171.165006] WARNING: CPU: 1 PID: 5026 at net/mptcp/subflow.c:533 warn_bad_map (linux-mptcp/net/mptcp/subflow.c:533 linux-mptcp/net/mptcp/subflow.c:531)
[ 171.167632] Modules linked in: ip6_vti ip_vti ip_gre ipip sit tunnel4 ip_tunnel geneve ip6_udp_tunnel udp_tunnel macsec macvtap tap ipvlan macvlan 8021q garp mrp xfrm_interface veth netdevsim nlmon dummy team bonding vcan bridge stp llc ip6_gre gre ip6_tunnel tunnel6 tun binfmt_misc intel_rapl_msr intel_rapl_common rfkill kvm_intel kvm irqbypass crct10dif_pclmul crc32_pclmul ghash_clmulni_intel joydev virtio_balloon pcspkr i2c_piix4 sunrpc ip_tables xfs libcrc32c crc32c_intel serio_raw virtio_console ata_generic virtio_blk virtio_net net_failover failover ata_piix libata
[ 171.199464] CPU: 1 PID: 5026 Comm: repro Not tainted 5.7.0-rc1.mptcp_f227fdf5d388+ #95
[ 171.200886] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-2.fc30 04/01/2014
[ 171.202546] RIP: 0010:warn_bad_map (linux-mptcp/net/mptcp/subflow.c:533 linux-mptcp/net/mptcp/subflow.c:531)
[ 171.206537] Code: c1 ea 03 0f b6 14 02 48 89 f8 83 e0 07 83 c0 03 38 d0 7c 04 84 d2 75 1d 8b 55 3c 44 89 e6 48 c7 c7 20 51 13 95 e8 37 8b 22 fe <0f> 0b 48 83 c4 08 5b 5d 41 5c c3 89 4c 24 04 e8 db d6 94 fe 8b 4c
[ 171.220473] RSP: 0018:ffffc90000150560 EFLAGS: 00010282
[ 171.221639] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
[ 171.223108] RDX: 0000000000000000 RSI: 0000000000000008 RDI: fffff5200002a09e
[ 171.224388] RBP: ffff8880aa6e3c00 R08: 0000000000000001 R09: fffffbfff2ec9955
[ 171.225706] R10: ffffffff9764caa7 R11: fffffbfff2ec9954 R12: 0000000000007fca
[ 171.227211] R13: ffff8881066f4a7f R14: ffff8880aa6e3c00 R15: 0000000000000020
[ 171.228460] FS: 00007f8623719740(0000) GS:ffff88810be00000(0000) knlGS:0000000000000000
[ 171.230065] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 171.231303] CR2: 00007ffdab190a50 CR3: 00000001038ea006 CR4: 0000000000160ee0
[ 171.232586] Call Trace:
[ 171.233109] <IRQ>
[ 171.233531] get_mapping_status (linux-mptcp/net/mptcp/subflow.c:691)
[ 171.234371] mptcp_subflow_data_available (linux-mptcp/net/mptcp/subflow.c:736 linux-mptcp/net/mptcp/subflow.c:832)
[ 171.238181] subflow_state_change (linux-mptcp/net/mptcp/subflow.c:1085 (discriminator 1))
[ 171.239066] tcp_fin (linux-mptcp/net/ipv4/tcp_input.c:4217)
[ 171.240123] tcp_data_queue (linux-mptcp/./include/linux/compiler.h:199 linux-mptcp/net/ipv4/tcp_input.c:4822)
[ 171.245083] tcp_rcv_established (linux-mptcp/./include/linux/skbuff.h:1785 linux-mptcp/./include/net/tcp.h:1774 linux-mptcp/./include/net/tcp.h:1847 linux-mptcp/net/ipv4/tcp_input.c:5238 linux-mptcp/net/ipv4/tcp_input.c:5730)
[ 171.254089] tcp_v4_rcv (linux-mptcp/./include/linux/spinlock.h:393 linux-mptcp/net/ipv4/tcp_ipv4.c:2009)
[ 171.258969] ip_protocol_deliver_rcu (linux-mptcp/net/ipv4/ip_input.c:204 (discriminator 1))
[ 171.260214] ip_local_deliver_finish (linux-mptcp/./include/linux/rcupdate.h:651 linux-mptcp/net/ipv4/ip_input.c:232)
[ 171.261389] ip_local_deliver (linux-mptcp/./include/linux/netfilter.h:307 linux-mptcp/./include/linux/netfilter.h:301 linux-mptcp/net/ipv4/ip_input.c:252)
[ 171.265884] ip_rcv (linux-mptcp/./include/linux/netfilter.h:307 linux-mptcp/./include/linux/netfilter.h:301 linux-mptcp/net/ipv4/ip_input.c:539)
[ 171.273666] process_backlog (linux-mptcp/./include/linux/rcupdate.h:651 linux-mptcp/net/core/dev.c:6135)
[ 171.275328] net_rx_action (linux-mptcp/net/core/dev.c:6572 linux-mptcp/net/core/dev.c:6640)
[ 171.280472] __do_softirq (linux-mptcp/./arch/x86/include/asm/jump_label.h:25 linux-mptcp/./include/linux/jump_label.h:200 linux-mptcp/./include/trace/events/irq.h:142 linux-mptcp/kernel/softirq.c:293)
[ 171.281379] do_softirq_own_stack (linux-mptcp/arch/x86/entry/entry_64.S:1083)
[ 171.282358] </IRQ>
We could address the issue clearing explicitly the relevant fields
in several places - tcp_parse_option, tcp_fast_parse_options,
possibly others.
Instead we move the MPTCP option parsing into the already existing
mptcp ingress hook, so that we need to clear the fields in a single
place.
This allows us dropping an MPTCP hook from the TCP code and
removing the quite large mptcp_options_received from the tcp_sock
struct. On the flip side, the MPTCP sockets will traverse the
option space twice (in tcp_parse_option() and in
mptcp_incoming_options(). That looks acceptable: we already
do that for syn and 3rd ack packets, plain TCP socket will
benefit from it, and even MPTCP sockets will experience better
code locality, reducing the jumps between TCP and MPTCP code.
v1 -> v2:
- rebased on current '-net' tree
Fixes: 648ef4b88673 ("mptcp: Implement MPTCP receive path")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-30 13:01:52 +00:00
|
|
|
};
|
|
|
|
|
2020-03-27 21:48:37 +00:00
|
|
|
static inline __be32 mptcp_option(u8 subopt, u8 len, u8 nib, u8 field)
|
|
|
|
{
|
|
|
|
return htonl((TCPOPT_MPTCP << 24) | (len << 16) | (subopt << 12) |
|
|
|
|
((nib & 0xF) << 8) | field);
|
|
|
|
}
|
|
|
|
|
2020-03-27 21:48:38 +00:00
|
|
|
enum mptcp_pm_status {
|
|
|
|
MPTCP_PM_ADD_ADDR_RECEIVED,
|
2020-11-19 19:46:00 +00:00
|
|
|
MPTCP_PM_ADD_ADDR_SEND_ACK,
|
2020-09-24 00:29:49 +00:00
|
|
|
MPTCP_PM_RM_ADDR_RECEIVED,
|
2020-03-27 21:48:38 +00:00
|
|
|
MPTCP_PM_ESTABLISHED,
|
|
|
|
MPTCP_PM_SUBFLOW_ESTABLISHED,
|
2022-01-07 00:20:22 +00:00
|
|
|
MPTCP_PM_ALREADY_ESTABLISHED, /* persistent status, set after ESTABLISHED event */
|
|
|
|
MPTCP_PM_MPC_ENDPOINT_ACCOUNTED /* persistent status, set after MPC local address is
|
|
|
|
* accounted int id_avail_bitmap
|
|
|
|
*/
|
2020-03-27 21:48:38 +00:00
|
|
|
};
|
|
|
|
|
2022-04-27 22:49:58 +00:00
|
|
|
enum mptcp_pm_type {
|
|
|
|
MPTCP_PM_TYPE_KERNEL = 0,
|
|
|
|
MPTCP_PM_TYPE_USERSPACE,
|
|
|
|
|
|
|
|
__MPTCP_PM_TYPE_NR,
|
|
|
|
__MPTCP_PM_TYPE_MAX = __MPTCP_PM_TYPE_NR - 1,
|
|
|
|
};
|
|
|
|
|
2022-01-07 00:20:22 +00:00
|
|
|
/* Status bits below MPTCP_PM_ALREADY_ESTABLISHED need pm worker actions */
|
|
|
|
#define MPTCP_PM_WORK_MASK ((1 << MPTCP_PM_ALREADY_ESTABLISHED) - 1)
|
|
|
|
|
2020-12-09 23:51:27 +00:00
|
|
|
enum mptcp_addr_signal_status {
|
2020-11-19 19:45:59 +00:00
|
|
|
MPTCP_ADD_ADDR_SIGNAL,
|
|
|
|
MPTCP_ADD_ADDR_ECHO,
|
2020-12-09 23:51:26 +00:00
|
|
|
MPTCP_RM_ADDR_SIGNAL,
|
2020-11-19 19:45:59 +00:00
|
|
|
};
|
|
|
|
|
2022-01-07 00:20:22 +00:00
|
|
|
/* max value of mptcp_addr_info.id */
|
|
|
|
#define MPTCP_PM_MAX_ADDR_ID U8_MAX
|
|
|
|
|
2020-03-27 21:48:38 +00:00
|
|
|
struct mptcp_pm_data {
|
|
|
|
struct mptcp_addr_info local;
|
|
|
|
struct mptcp_addr_info remote;
|
2020-09-24 00:29:54 +00:00
|
|
|
struct list_head anno_list;
|
2022-05-04 02:38:49 +00:00
|
|
|
struct list_head userspace_pm_local_addr_list;
|
2020-03-27 21:48:38 +00:00
|
|
|
|
|
|
|
spinlock_t lock; /*protects the whole PM data */
|
|
|
|
|
2020-12-09 23:51:27 +00:00
|
|
|
u8 addr_signal;
|
2020-03-27 21:48:38 +00:00
|
|
|
bool server_side;
|
|
|
|
bool work_pending;
|
|
|
|
bool accept_addr;
|
|
|
|
bool accept_subflow;
|
2021-06-22 19:25:20 +00:00
|
|
|
bool remote_deny_join_id0;
|
2020-03-27 21:48:38 +00:00
|
|
|
u8 add_addr_signaled;
|
|
|
|
u8 add_addr_accepted;
|
|
|
|
u8 local_addr_used;
|
2022-04-27 22:49:58 +00:00
|
|
|
u8 pm_type;
|
2020-03-27 21:48:38 +00:00
|
|
|
u8 subflows;
|
|
|
|
u8 status;
|
2022-01-07 00:20:22 +00:00
|
|
|
DECLARE_BITMAP(id_avail_bitmap, MPTCP_PM_MAX_ADDR_ID + 1);
|
2021-03-13 01:16:12 +00:00
|
|
|
struct mptcp_rm_list rm_list_tx;
|
2021-03-13 01:16:14 +00:00
|
|
|
struct mptcp_rm_list rm_list_rx;
|
2020-03-27 21:48:38 +00:00
|
|
|
};
|
|
|
|
|
2024-09-02 10:45:53 +00:00
|
|
|
struct mptcp_pm_local {
|
|
|
|
struct mptcp_addr_info addr;
|
|
|
|
u8 flags;
|
|
|
|
int ifindex;
|
|
|
|
};
|
|
|
|
|
2022-05-04 02:38:49 +00:00
|
|
|
struct mptcp_pm_addr_entry {
|
|
|
|
struct list_head list;
|
|
|
|
struct mptcp_addr_info addr;
|
|
|
|
u8 flags;
|
|
|
|
int ifindex;
|
|
|
|
struct socket *lsk;
|
|
|
|
};
|
|
|
|
|
2020-03-27 21:48:43 +00:00
|
|
|
struct mptcp_data_frag {
|
|
|
|
struct list_head list;
|
|
|
|
u64 data_seq;
|
2020-11-16 09:48:07 +00:00
|
|
|
u16 data_len;
|
|
|
|
u16 offset;
|
|
|
|
u16 overhead;
|
|
|
|
u16 already_sent;
|
2020-03-27 21:48:43 +00:00
|
|
|
struct page *page;
|
|
|
|
};
|
|
|
|
|
2020-01-22 00:56:15 +00:00
|
|
|
/* MPTCP connection sock */
|
|
|
|
struct mptcp_sock {
|
|
|
|
/* inet_connection_sock must be the first member */
|
|
|
|
struct inet_connection_sock sk;
|
2024-02-02 11:40:07 +00:00
|
|
|
u64 local_key; /* protected by the first subflow socket lock
|
|
|
|
* lockless access read
|
|
|
|
*/
|
|
|
|
u64 remote_key; /* same as above */
|
2020-01-22 00:56:23 +00:00
|
|
|
u64 write_seq;
|
2023-06-20 16:30:15 +00:00
|
|
|
u64 bytes_sent;
|
2020-11-16 09:48:08 +00:00
|
|
|
u64 snd_nxt;
|
2023-06-20 16:30:15 +00:00
|
|
|
u64 bytes_received;
|
2020-01-22 00:56:23 +00:00
|
|
|
u64 ack_seq;
|
2022-05-04 21:54:07 +00:00
|
|
|
atomic64_t rcv_wnd_sent;
|
2020-07-28 22:12:03 +00:00
|
|
|
u64 rcv_data_fin_seq;
|
2023-06-20 16:30:15 +00:00
|
|
|
u64 bytes_retrans;
|
2023-10-23 20:44:38 +00:00
|
|
|
u64 bytes_consumed;
|
2021-10-26 23:29:15 +00:00
|
|
|
int rmem_fwd_alloc;
|
2020-09-14 08:01:17 +00:00
|
|
|
int snd_burst;
|
2020-11-19 19:46:03 +00:00
|
|
|
int old_wspace;
|
2021-08-13 22:15:43 +00:00
|
|
|
u64 recovery_snd_nxt; /* in recovery mode accept up to this seq;
|
|
|
|
* recovery related fields are under data_lock
|
|
|
|
* protection
|
|
|
|
*/
|
2023-06-20 16:30:15 +00:00
|
|
|
u64 bytes_acked;
|
2020-11-27 10:10:26 +00:00
|
|
|
u64 snd_una;
|
|
|
|
u64 wnd_end;
|
mptcp: add last time fields in mptcp_info
This patch adds "last time" fields last_data_sent, last_data_recv and
last_ack_recv in struct mptcp_sock to record the last time data_sent,
data_recv and ack_recv happened. They all are initialized as
tcp_jiffies32 in __mptcp_init_sock(), and updated as tcp_jiffies32 too
when data is sent in __subflow_push_pending(), data is received in
__mptcp_move_skbs_from_subflow(), and ack is received in ack_update_msk().
Similar to tcpi_last_data_sent, tcpi_last_data_recv and tcpi_last_ack_recv
exposed with TCP, this patch exposes the last time "an action happened" for
MPTCP in mptcp_info, named mptcpi_last_data_sent, mptcpi_last_data_recv and
mptcpi_last_ack_recv, calculated in mptcp_diag_fill_info() as the time
deltas between now and the newly added last time fields in mptcp_sock.
Since msk->last_ack_recv needs to be protected by mptcp_data_lock/unlock,
and lock_sock_fast can sleep and be quite slow, move the entire
mptcp_data_lock/unlock block after the lock/unlock_sock_fast block.
Then mptcpi_last_data_sent and mptcpi_last_data_recv are set in
lock/unlock_sock_fast block, while mptcpi_last_ack_recv is set in
mptcp_data_lock/unlock block, which is protected by a spinlock and
should not block for too long.
Also add three reserved bytes in struct mptcp_info not to have holes in
this structure exposed to userspace.
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/446
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Reviewed-by: Mat Martineau <martineau@kernel.org>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://lore.kernel.org/r/20240410-upstream-net-next-20240405-mptcp-last-time-info-v2-1-f95bd6b33e51@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2024-04-10 09:48:24 +00:00
|
|
|
u32 last_data_sent;
|
|
|
|
u32 last_data_recv;
|
|
|
|
u32 last_ack_recv;
|
2020-03-27 21:48:44 +00:00
|
|
|
unsigned long timer_ival;
|
2020-01-22 00:56:20 +00:00
|
|
|
u32 token;
|
2020-11-27 10:10:24 +00:00
|
|
|
int rmem_released;
|
2020-01-22 00:56:24 +00:00
|
|
|
unsigned long flags;
|
2022-01-07 00:20:26 +00:00
|
|
|
unsigned long cb_flags;
|
2021-08-13 22:15:43 +00:00
|
|
|
bool recovery; /* closing subflow write queue reinjected */
|
2020-01-22 00:56:32 +00:00
|
|
|
bool can_ack;
|
2020-07-23 11:02:32 +00:00
|
|
|
bool fully_established;
|
2020-07-28 22:12:03 +00:00
|
|
|
bool rcv_data_fin;
|
2020-07-28 22:12:02 +00:00
|
|
|
bool snd_data_fin_enable;
|
2020-12-10 22:25:04 +00:00
|
|
|
bool rcv_fastclose;
|
2020-10-06 16:26:17 +00:00
|
|
|
bool use_64bit_ack; /* Set when we received a 64-bit DSN */
|
2021-06-17 23:46:07 +00:00
|
|
|
bool csum_enabled;
|
2022-04-22 21:55:38 +00:00
|
|
|
bool allow_infinite_fallback;
|
2023-12-15 16:04:25 +00:00
|
|
|
u8 pending_state; /* A subflow asked to set this sk_state,
|
|
|
|
* protected by the msk data lock
|
|
|
|
*/
|
2022-07-11 19:16:32 +00:00
|
|
|
u8 mpc_endpoint_id;
|
2021-12-03 22:35:41 +00:00
|
|
|
u8 recvmsg_inq:1,
|
|
|
|
cork:1,
|
2022-10-21 22:58:55 +00:00
|
|
|
nodelay:1,
|
2023-03-09 14:49:59 +00:00
|
|
|
fastopening:1,
|
2023-08-11 15:57:26 +00:00
|
|
|
in_accept_queue:1,
|
2024-02-08 18:03:50 +00:00
|
|
|
free_first:1,
|
|
|
|
rcvspace_init:1;
|
2024-03-01 17:43:46 +00:00
|
|
|
u32 notsent_lowat;
|
mptcp: fix full TCP keep-alive support
SO_KEEPALIVE support has been added a while ago, as part of a series
"adding SOL_SOCKET" support. To have a full control of this keep-alive
feature, it is important to also support TCP_KEEP* socket options at the
SOL_TCP level.
Supporting them on the setsockopt() part is easy, it is just a matter of
remembering each value in the MPTCP sock structure, and calling
tcp_sock_set_keep*() helpers on each subflow. If the value is not
modified (0), calling these helpers will not do anything. For the
getsockopt() part, the corresponding value from the MPTCP sock structure
or the default one is simply returned. All of this is very similar to
other TCP_* socket options supported by MPTCP.
It looks important for kernels supporting SO_KEEPALIVE, to also support
TCP_KEEP* options as well: some apps seem to (wrongly) consider that if
the former is supported, the latter ones will be supported as well. But
also, not having this simple and isolated change is preventing MPTCP
support in some apps, and libraries like GoLang [1]. This is why this
patch is seen as a fix.
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/383
Fixes: 1b3e7ede1365 ("mptcp: setsockopt: handle SO_KEEPALIVE and SO_PRIORITY")
Link: https://github.com/golang/go/issues/56539 [1]
Acked-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Mat Martineau <martineau@kernel.org>
Link: https://lore.kernel.org/r/20240514011335.176158-3-martineau@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2024-05-14 01:13:26 +00:00
|
|
|
int keepalive_cnt;
|
|
|
|
int keepalive_idle;
|
|
|
|
int keepalive_intvl;
|
2020-02-26 09:14:47 +00:00
|
|
|
struct work_struct work;
|
2020-09-14 08:01:12 +00:00
|
|
|
struct sk_buff *ooo_last_skb;
|
|
|
|
struct rb_root out_of_order_queue;
|
2020-11-27 10:10:24 +00:00
|
|
|
struct sk_buff_head receive_queue;
|
2020-01-22 00:56:18 +00:00
|
|
|
struct list_head conn_list;
|
2020-03-27 21:48:43 +00:00
|
|
|
struct list_head rtx_queue;
|
2020-11-16 09:48:07 +00:00
|
|
|
struct mptcp_data_frag *first_pending;
|
2020-03-27 21:48:40 +00:00
|
|
|
struct list_head join_list;
|
2023-08-11 15:57:26 +00:00
|
|
|
struct sock *first; /* The mptcp ops can safely dereference, using suitable
|
|
|
|
* ONCE annotation, the subflow outside the socket
|
|
|
|
* lock as such sock is freed after close().
|
|
|
|
*/
|
2020-03-27 21:48:38 +00:00
|
|
|
struct mptcp_pm_data pm;
|
2023-08-21 22:25:16 +00:00
|
|
|
struct mptcp_sched_ops *sched;
|
2020-06-30 19:24:45 +00:00
|
|
|
struct {
|
|
|
|
u32 space; /* bytes copied in last measurement window */
|
|
|
|
u32 copied; /* bytes copied in this measurement window */
|
|
|
|
u64 time; /* start time of measurement window */
|
|
|
|
u64 rtt_us; /* last maximum rtt of subflows */
|
|
|
|
} rcvq_space;
|
2023-07-20 18:47:50 +00:00
|
|
|
u8 scaling_ratio;
|
2021-04-15 23:44:54 +00:00
|
|
|
|
2023-06-20 16:30:17 +00:00
|
|
|
u32 subflow_id;
|
|
|
|
u32 setsockopt_seq;
|
2021-05-25 21:23:10 +00:00
|
|
|
char ca_name[TCP_CA_NAME_MAX];
|
2020-01-22 00:56:15 +00:00
|
|
|
};
|
|
|
|
|
2020-11-27 10:10:24 +00:00
|
|
|
#define mptcp_data_lock(sk) spin_lock_bh(&(sk)->sk_lock.slock)
|
|
|
|
#define mptcp_data_unlock(sk) spin_unlock_bh(&(sk)->sk_lock.slock)
|
|
|
|
|
2020-01-22 00:56:18 +00:00
|
|
|
#define mptcp_for_each_subflow(__msk, __subflow) \
|
|
|
|
list_for_each_entry(__subflow, &((__msk)->conn_list), node)
|
2022-09-06 20:55:39 +00:00
|
|
|
#define mptcp_for_each_subflow_safe(__msk, __subflow, __tmp) \
|
|
|
|
list_for_each_entry_safe(__subflow, __tmp, &((__msk)->conn_list), node)
|
2020-01-22 00:56:18 +00:00
|
|
|
|
2024-03-01 18:18:26 +00:00
|
|
|
extern struct genl_family mptcp_genl_family;
|
|
|
|
|
2021-02-04 23:23:30 +00:00
|
|
|
static inline void msk_owned_by_me(const struct mptcp_sock *msk)
|
|
|
|
{
|
|
|
|
sock_owned_by_me((const struct sock *)msk);
|
|
|
|
}
|
|
|
|
|
2024-02-23 20:17:55 +00:00
|
|
|
#ifdef CONFIG_DEBUG_NET
|
|
|
|
/* MPTCP-specific: we might (indirectly) call this helper with the wrong sk */
|
|
|
|
#undef tcp_sk
|
|
|
|
#define tcp_sk(ptr) ({ \
|
|
|
|
typeof(ptr) _ptr = (ptr); \
|
|
|
|
WARN_ON(_ptr->sk_protocol != IPPROTO_TCP); \
|
|
|
|
container_of_const(_ptr, struct tcp_sock, inet_conn.icsk_inet.sk); \
|
|
|
|
})
|
2024-02-23 20:17:56 +00:00
|
|
|
#define mptcp_sk(ptr) ({ \
|
|
|
|
typeof(ptr) _ptr = (ptr); \
|
|
|
|
WARN_ON(_ptr->sk_protocol != IPPROTO_MPTCP); \
|
|
|
|
container_of_const(_ptr, struct mptcp_sock, sk.icsk_inet.sk); \
|
|
|
|
})
|
2024-02-23 20:17:55 +00:00
|
|
|
|
2024-02-23 20:17:56 +00:00
|
|
|
#else /* !CONFIG_DEBUG_NET */
|
2023-03-17 15:55:38 +00:00
|
|
|
#define mptcp_sk(ptr) container_of_const(ptr, struct mptcp_sock, sk.icsk_inet.sk)
|
2024-02-23 20:17:56 +00:00
|
|
|
#endif
|
2020-01-22 00:56:15 +00:00
|
|
|
|
2021-07-10 00:20:51 +00:00
|
|
|
/* the msk socket don't use the backlog, also account for the bulk
|
|
|
|
* free memory
|
|
|
|
*/
|
|
|
|
static inline int __mptcp_rmem(const struct sock *sk)
|
|
|
|
{
|
|
|
|
return atomic_read(&sk->sk_rmem_alloc) - READ_ONCE(mptcp_sk(sk)->rmem_released);
|
|
|
|
}
|
|
|
|
|
2023-07-20 18:47:50 +00:00
|
|
|
static inline int mptcp_win_from_space(const struct sock *sk, int space)
|
|
|
|
{
|
|
|
|
return __tcp_win_from_space(mptcp_sk(sk)->scaling_ratio, space);
|
|
|
|
}
|
|
|
|
|
2024-06-05 07:15:41 +00:00
|
|
|
static inline int mptcp_space_from_win(const struct sock *sk, int win)
|
|
|
|
{
|
|
|
|
return __tcp_space_from_win(mptcp_sk(sk)->scaling_ratio, win);
|
|
|
|
}
|
|
|
|
|
2020-11-19 19:46:03 +00:00
|
|
|
static inline int __mptcp_space(const struct sock *sk)
|
|
|
|
{
|
2023-07-20 18:47:50 +00:00
|
|
|
return mptcp_win_from_space(sk, READ_ONCE(sk->sk_rcvbuf) - __mptcp_rmem(sk));
|
2020-11-19 19:46:03 +00:00
|
|
|
}
|
|
|
|
|
2020-11-16 09:48:07 +00:00
|
|
|
static inline struct mptcp_data_frag *mptcp_send_head(const struct sock *sk)
|
|
|
|
{
|
|
|
|
const struct mptcp_sock *msk = mptcp_sk(sk);
|
|
|
|
|
|
|
|
return READ_ONCE(msk->first_pending);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct mptcp_data_frag *mptcp_send_next(struct sock *sk)
|
|
|
|
{
|
|
|
|
struct mptcp_sock *msk = mptcp_sk(sk);
|
|
|
|
struct mptcp_data_frag *cur;
|
|
|
|
|
|
|
|
cur = msk->first_pending;
|
|
|
|
return list_is_last(&cur->list, &msk->rtx_queue) ? NULL :
|
|
|
|
list_next_entry(cur, list);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct mptcp_data_frag *mptcp_pending_tail(const struct sock *sk)
|
|
|
|
{
|
2023-03-17 15:55:38 +00:00
|
|
|
const struct mptcp_sock *msk = mptcp_sk(sk);
|
2020-11-16 09:48:07 +00:00
|
|
|
|
|
|
|
if (!msk->first_pending)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (WARN_ON_ONCE(list_empty(&msk->rtx_queue)))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return list_last_entry(&msk->rtx_queue, struct mptcp_data_frag, list);
|
|
|
|
}
|
|
|
|
|
2023-03-17 15:55:38 +00:00
|
|
|
static inline struct mptcp_data_frag *mptcp_rtx_head(struct sock *sk)
|
2020-03-27 21:48:43 +00:00
|
|
|
{
|
|
|
|
struct mptcp_sock *msk = mptcp_sk(sk);
|
|
|
|
|
2024-02-02 11:40:08 +00:00
|
|
|
if (msk->snd_una == msk->snd_nxt)
|
2020-03-27 21:48:43 +00:00
|
|
|
return NULL;
|
|
|
|
|
2020-06-15 08:34:28 +00:00
|
|
|
return list_first_entry_or_null(&msk->rtx_queue, struct mptcp_data_frag, list);
|
2020-03-27 21:48:46 +00:00
|
|
|
}
|
|
|
|
|
2021-06-17 23:46:08 +00:00
|
|
|
struct csum_pseudo_header {
|
|
|
|
__be64 data_seq;
|
|
|
|
__be32 subflow_seq;
|
|
|
|
__be16 data_len;
|
|
|
|
__sum16 csum;
|
|
|
|
};
|
|
|
|
|
2020-01-22 00:56:18 +00:00
|
|
|
struct mptcp_subflow_request_sock {
|
|
|
|
struct tcp_request_sock sk;
|
2020-01-22 00:56:32 +00:00
|
|
|
u16 mp_capable : 1,
|
2020-01-22 00:56:18 +00:00
|
|
|
mp_join : 1,
|
2021-06-17 23:46:09 +00:00
|
|
|
backup : 1,
|
2024-07-27 10:01:24 +00:00
|
|
|
request_bkup : 1,
|
2021-06-22 19:25:19 +00:00
|
|
|
csum_reqd : 1,
|
|
|
|
allow_join_id0 : 1;
|
2020-03-27 21:48:38 +00:00
|
|
|
u8 local_id;
|
2020-03-27 21:48:39 +00:00
|
|
|
u8 remote_id;
|
2020-01-22 00:56:18 +00:00
|
|
|
u64 local_key;
|
2020-01-22 00:56:20 +00:00
|
|
|
u64 idsn;
|
|
|
|
u32 token;
|
2020-01-22 00:56:24 +00:00
|
|
|
u32 ssn_offset;
|
2020-03-27 21:48:39 +00:00
|
|
|
u64 thmac;
|
|
|
|
u32 local_nonce;
|
|
|
|
u32 remote_nonce;
|
2020-06-17 10:08:56 +00:00
|
|
|
struct mptcp_sock *msk;
|
2020-06-26 17:30:00 +00:00
|
|
|
struct hlist_nulls_node token_node;
|
2020-01-22 00:56:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct mptcp_subflow_request_sock *
|
|
|
|
mptcp_subflow_rsk(const struct request_sock *rsk)
|
|
|
|
{
|
|
|
|
return (struct mptcp_subflow_request_sock *)rsk;
|
|
|
|
}
|
|
|
|
|
2021-01-20 14:39:14 +00:00
|
|
|
struct mptcp_delegated_action {
|
|
|
|
struct napi_struct napi;
|
|
|
|
struct list_head head;
|
|
|
|
};
|
|
|
|
|
|
|
|
DECLARE_PER_CPU(struct mptcp_delegated_action, mptcp_delegated_actions);
|
|
|
|
|
2023-10-04 20:38:11 +00:00
|
|
|
#define MPTCP_DELEGATE_SCHEDULED 0
|
|
|
|
#define MPTCP_DELEGATE_SEND 1
|
|
|
|
#define MPTCP_DELEGATE_ACK 2
|
2023-10-23 20:44:42 +00:00
|
|
|
#define MPTCP_DELEGATE_SNDBUF 3
|
2021-01-20 14:39:14 +00:00
|
|
|
|
2023-10-04 20:38:11 +00:00
|
|
|
#define MPTCP_DELEGATE_ACTIONS_MASK (~BIT(MPTCP_DELEGATE_SCHEDULED))
|
2020-01-22 00:56:17 +00:00
|
|
|
/* MPTCP subflow context */
|
|
|
|
struct mptcp_subflow_context {
|
2020-01-22 00:56:18 +00:00
|
|
|
struct list_head node;/* conn_list of subflows */
|
2022-01-07 00:20:16 +00:00
|
|
|
|
2022-01-21 07:39:35 +00:00
|
|
|
struct_group(reset,
|
2022-01-07 00:20:16 +00:00
|
|
|
|
2021-12-17 23:37:00 +00:00
|
|
|
unsigned long avg_pacing_rate; /* protected by msk socket lock */
|
2020-01-22 00:56:18 +00:00
|
|
|
u64 local_key;
|
|
|
|
u64 remote_key;
|
2020-01-22 00:56:20 +00:00
|
|
|
u64 idsn;
|
2020-01-22 00:56:24 +00:00
|
|
|
u64 map_seq;
|
2020-01-22 00:56:31 +00:00
|
|
|
u32 snd_isn;
|
2020-01-22 00:56:20 +00:00
|
|
|
u32 token;
|
2020-01-22 00:56:23 +00:00
|
|
|
u32 rel_write_seq;
|
2020-01-22 00:56:24 +00:00
|
|
|
u32 map_subflow_seq;
|
|
|
|
u32 ssn_offset;
|
|
|
|
u32 map_data_len;
|
mptcp: validate the data checksum
This patch added three new members named data_csum, csum_len and
map_csum in struct mptcp_subflow_context, implemented a new function
named mptcp_validate_data_checksum().
If the current mapping is valid and csum is enabled traverse the later
pending skbs and compute csum incrementally till the whole mapping has
been covered. If not enough data is available in the rx queue, return
MAPPING_EMPTY - that is, no data.
Next subflow_data_ready invocation will trigger again csum computation.
When the full DSS is available, validate the csum and return to the
caller an appropriate error code, to trigger subflow reset of fallback
as required by the RFC.
Additionally:
- if the csum prevence in the DSS don't match the negotiated value e.g.
csum present, but not requested, return invalid mapping to trigger
subflow reset.
- keep some csum state, to avoid re-compute the csum on the same data
when multiple rx queue traversal are required.
- clean-up the uncompleted mapping from the receive queue on close, to
allow proper subflow disposal
Co-developed-by: Geliang Tang <geliangtang@gmail.com>
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-06-17 23:46:16 +00:00
|
|
|
__wsum map_data_csum;
|
|
|
|
u32 map_csum_len;
|
2020-01-22 00:56:18 +00:00
|
|
|
u32 request_mptcp : 1, /* send MP_CAPABLE */
|
2020-03-27 21:48:40 +00:00
|
|
|
request_join : 1, /* send MP_JOIN */
|
|
|
|
request_bkup : 1,
|
2020-01-22 00:56:18 +00:00
|
|
|
mp_capable : 1, /* remote is MPTCP capable */
|
2020-03-27 21:48:39 +00:00
|
|
|
mp_join : 1, /* remote is JOINing */
|
|
|
|
pm_notified : 1, /* PM hook called for established status */
|
2020-01-22 00:56:24 +00:00
|
|
|
conn_finished : 1,
|
|
|
|
map_valid : 1,
|
mptcp: validate the data checksum
This patch added three new members named data_csum, csum_len and
map_csum in struct mptcp_subflow_context, implemented a new function
named mptcp_validate_data_checksum().
If the current mapping is valid and csum is enabled traverse the later
pending skbs and compute csum incrementally till the whole mapping has
been covered. If not enough data is available in the rx queue, return
MAPPING_EMPTY - that is, no data.
Next subflow_data_ready invocation will trigger again csum computation.
When the full DSS is available, validate the csum and return to the
caller an appropriate error code, to trigger subflow reset of fallback
as required by the RFC.
Additionally:
- if the csum prevence in the DSS don't match the negotiated value e.g.
csum present, but not requested, return invalid mapping to trigger
subflow reset.
- keep some csum state, to avoid re-compute the csum on the same data
when multiple rx queue traversal are required.
- clean-up the uncompleted mapping from the receive queue on close, to
allow proper subflow disposal
Co-developed-by: Geliang Tang <geliangtang@gmail.com>
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-06-17 23:46:16 +00:00
|
|
|
map_csum_reqd : 1,
|
|
|
|
map_data_fin : 1,
|
2020-01-22 00:56:32 +00:00
|
|
|
mpc_map : 1,
|
2020-03-27 21:48:39 +00:00
|
|
|
backup : 1,
|
2021-01-09 00:47:57 +00:00
|
|
|
send_mp_prio : 1,
|
2021-08-24 23:26:15 +00:00
|
|
|
send_mp_fail : 1,
|
2022-01-07 00:20:15 +00:00
|
|
|
send_fastclose : 1,
|
2022-04-22 21:55:39 +00:00
|
|
|
send_infinite_map : 1,
|
2022-11-25 22:29:49 +00:00
|
|
|
remote_key_valid : 1, /* received the peer key from */
|
2021-08-13 22:15:45 +00:00
|
|
|
disposable : 1, /* ctx can be free at ulp release time */
|
2022-03-07 20:44:37 +00:00
|
|
|
stale : 1, /* unable to snd/rcv data, do not use for xmit */
|
2022-11-25 22:29:50 +00:00
|
|
|
valid_csum_seen : 1, /* at least one csum validated */
|
|
|
|
is_mptfo : 1, /* subflow is doing TFO */
|
2024-08-28 06:14:35 +00:00
|
|
|
close_event_done : 1, /* has done the post-closed part */
|
2024-09-09 20:09:23 +00:00
|
|
|
mpc_drop : 1, /* the MPC option has been dropped in a rtx */
|
2024-10-21 15:14:04 +00:00
|
|
|
__unused : 9;
|
2023-10-23 20:44:36 +00:00
|
|
|
bool data_avail;
|
2023-08-21 22:25:17 +00:00
|
|
|
bool scheduled;
|
mptcp: prevent MPC handshake on port-based signal endpoints
Syzkaller reported a lockdep splat:
============================================
WARNING: possible recursive locking detected
6.11.0-rc6-syzkaller-00019-g67784a74e258 #0 Not tainted
--------------------------------------------
syz-executor364/5113 is trying to acquire lock:
ffff8880449f1958 (k-slock-AF_INET){+.-.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline]
ffff8880449f1958 (k-slock-AF_INET){+.-.}-{2:2}, at: sk_clone_lock+0x2cd/0xf40 net/core/sock.c:2328
but task is already holding lock:
ffff88803fe3cb58 (k-slock-AF_INET){+.-.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline]
ffff88803fe3cb58 (k-slock-AF_INET){+.-.}-{2:2}, at: sk_clone_lock+0x2cd/0xf40 net/core/sock.c:2328
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
----
lock(k-slock-AF_INET);
lock(k-slock-AF_INET);
*** DEADLOCK ***
May be due to missing lock nesting notation
7 locks held by syz-executor364/5113:
#0: ffff8880449f0e18 (sk_lock-AF_INET){+.+.}-{0:0}, at: lock_sock include/net/sock.h:1607 [inline]
#0: ffff8880449f0e18 (sk_lock-AF_INET){+.+.}-{0:0}, at: mptcp_sendmsg+0x153/0x1b10 net/mptcp/protocol.c:1806
#1: ffff88803fe39ad8 (k-sk_lock-AF_INET){+.+.}-{0:0}, at: lock_sock include/net/sock.h:1607 [inline]
#1: ffff88803fe39ad8 (k-sk_lock-AF_INET){+.+.}-{0:0}, at: mptcp_sendmsg_fastopen+0x11f/0x530 net/mptcp/protocol.c:1727
#2: ffffffff8e938320 (rcu_read_lock){....}-{1:2}, at: rcu_lock_acquire include/linux/rcupdate.h:326 [inline]
#2: ffffffff8e938320 (rcu_read_lock){....}-{1:2}, at: rcu_read_lock include/linux/rcupdate.h:838 [inline]
#2: ffffffff8e938320 (rcu_read_lock){....}-{1:2}, at: __ip_queue_xmit+0x5f/0x1b80 net/ipv4/ip_output.c:470
#3: ffffffff8e938320 (rcu_read_lock){....}-{1:2}, at: rcu_lock_acquire include/linux/rcupdate.h:326 [inline]
#3: ffffffff8e938320 (rcu_read_lock){....}-{1:2}, at: rcu_read_lock include/linux/rcupdate.h:838 [inline]
#3: ffffffff8e938320 (rcu_read_lock){....}-{1:2}, at: ip_finish_output2+0x45f/0x1390 net/ipv4/ip_output.c:228
#4: ffffffff8e938320 (rcu_read_lock){....}-{1:2}, at: local_lock_acquire include/linux/local_lock_internal.h:29 [inline]
#4: ffffffff8e938320 (rcu_read_lock){....}-{1:2}, at: process_backlog+0x33b/0x15b0 net/core/dev.c:6104
#5: ffffffff8e938320 (rcu_read_lock){....}-{1:2}, at: rcu_lock_acquire include/linux/rcupdate.h:326 [inline]
#5: ffffffff8e938320 (rcu_read_lock){....}-{1:2}, at: rcu_read_lock include/linux/rcupdate.h:838 [inline]
#5: ffffffff8e938320 (rcu_read_lock){....}-{1:2}, at: ip_local_deliver_finish+0x230/0x5f0 net/ipv4/ip_input.c:232
#6: ffff88803fe3cb58 (k-slock-AF_INET){+.-.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline]
#6: ffff88803fe3cb58 (k-slock-AF_INET){+.-.}-{2:2}, at: sk_clone_lock+0x2cd/0xf40 net/core/sock.c:2328
stack backtrace:
CPU: 0 UID: 0 PID: 5113 Comm: syz-executor364 Not tainted 6.11.0-rc6-syzkaller-00019-g67784a74e258 #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Call Trace:
<IRQ>
__dump_stack lib/dump_stack.c:93 [inline]
dump_stack_lvl+0x241/0x360 lib/dump_stack.c:119
check_deadlock kernel/locking/lockdep.c:3061 [inline]
validate_chain+0x15d3/0x5900 kernel/locking/lockdep.c:3855
__lock_acquire+0x137a/0x2040 kernel/locking/lockdep.c:5142
lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5759
__raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
_raw_spin_lock+0x2e/0x40 kernel/locking/spinlock.c:154
spin_lock include/linux/spinlock.h:351 [inline]
sk_clone_lock+0x2cd/0xf40 net/core/sock.c:2328
mptcp_sk_clone_init+0x32/0x13c0 net/mptcp/protocol.c:3279
subflow_syn_recv_sock+0x931/0x1920 net/mptcp/subflow.c:874
tcp_check_req+0xfe4/0x1a20 net/ipv4/tcp_minisocks.c:853
tcp_v4_rcv+0x1c3e/0x37f0 net/ipv4/tcp_ipv4.c:2267
ip_protocol_deliver_rcu+0x22e/0x440 net/ipv4/ip_input.c:205
ip_local_deliver_finish+0x341/0x5f0 net/ipv4/ip_input.c:233
NF_HOOK+0x3a4/0x450 include/linux/netfilter.h:314
NF_HOOK+0x3a4/0x450 include/linux/netfilter.h:314
__netif_receive_skb_one_core net/core/dev.c:5661 [inline]
__netif_receive_skb+0x2bf/0x650 net/core/dev.c:5775
process_backlog+0x662/0x15b0 net/core/dev.c:6108
__napi_poll+0xcb/0x490 net/core/dev.c:6772
napi_poll net/core/dev.c:6841 [inline]
net_rx_action+0x89b/0x1240 net/core/dev.c:6963
handle_softirqs+0x2c4/0x970 kernel/softirq.c:554
do_softirq+0x11b/0x1e0 kernel/softirq.c:455
</IRQ>
<TASK>
__local_bh_enable_ip+0x1bb/0x200 kernel/softirq.c:382
local_bh_enable include/linux/bottom_half.h:33 [inline]
rcu_read_unlock_bh include/linux/rcupdate.h:908 [inline]
__dev_queue_xmit+0x1763/0x3e90 net/core/dev.c:4450
dev_queue_xmit include/linux/netdevice.h:3105 [inline]
neigh_hh_output include/net/neighbour.h:526 [inline]
neigh_output include/net/neighbour.h:540 [inline]
ip_finish_output2+0xd41/0x1390 net/ipv4/ip_output.c:235
ip_local_out net/ipv4/ip_output.c:129 [inline]
__ip_queue_xmit+0x118c/0x1b80 net/ipv4/ip_output.c:535
__tcp_transmit_skb+0x2544/0x3b30 net/ipv4/tcp_output.c:1466
tcp_rcv_synsent_state_process net/ipv4/tcp_input.c:6542 [inline]
tcp_rcv_state_process+0x2c32/0x4570 net/ipv4/tcp_input.c:6729
tcp_v4_do_rcv+0x77d/0xc70 net/ipv4/tcp_ipv4.c:1934
sk_backlog_rcv include/net/sock.h:1111 [inline]
__release_sock+0x214/0x350 net/core/sock.c:3004
release_sock+0x61/0x1f0 net/core/sock.c:3558
mptcp_sendmsg_fastopen+0x1ad/0x530 net/mptcp/protocol.c:1733
mptcp_sendmsg+0x1884/0x1b10 net/mptcp/protocol.c:1812
sock_sendmsg_nosec net/socket.c:730 [inline]
__sock_sendmsg+0x1a6/0x270 net/socket.c:745
____sys_sendmsg+0x525/0x7d0 net/socket.c:2597
___sys_sendmsg net/socket.c:2651 [inline]
__sys_sendmmsg+0x3b2/0x740 net/socket.c:2737
__do_sys_sendmmsg net/socket.c:2766 [inline]
__se_sys_sendmmsg net/socket.c:2763 [inline]
__x64_sys_sendmmsg+0xa0/0xb0 net/socket.c:2763
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f04fb13a6b9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 01 1a 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffd651f42d8 EFLAGS: 00000246 ORIG_RAX: 0000000000000133
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f04fb13a6b9
RDX: 0000000000000001 RSI: 0000000020000d00 RDI: 0000000000000004
RBP: 00007ffd651f4310 R08: 0000000000000001 R09: 0000000000000001
R10: 0000000020000080 R11: 0000000000000246 R12: 00000000000f4240
R13: 00007f04fb187449 R14: 00007ffd651f42f4 R15: 00007ffd651f4300
</TASK>
As noted by Cong Wang, the splat is false positive, but the code
path leading to the report is an unexpected one: a client is
attempting an MPC handshake towards the in-kernel listener created
by the in-kernel PM for a port based signal endpoint.
Such connection will be never accepted; many of them can make the
listener queue full and preventing the creation of MPJ subflow via
such listener - its intended role.
Explicitly detect this scenario at initial-syn time and drop the
incoming MPC request.
Fixes: 1729cf186d8a ("mptcp: create the listening socket for new port")
Cc: stable@vger.kernel.org
Reported-by: syzbot+f4aacdfef2c6a6529c3e@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=f4aacdfef2c6a6529c3e
Cc: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20241014-net-mptcp-mpc-port-endp-v2-1-7faea8e6b6ae@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2024-10-14 14:06:00 +00:00
|
|
|
bool pm_listener; /* a listener managed by the kernel PM? */
|
2024-10-21 15:14:04 +00:00
|
|
|
bool fully_established; /* path validated */
|
2020-03-27 21:48:39 +00:00
|
|
|
u32 remote_nonce;
|
|
|
|
u64 thmac;
|
|
|
|
u32 local_nonce;
|
2020-03-27 21:48:40 +00:00
|
|
|
u32 remote_token;
|
2022-11-25 22:29:49 +00:00
|
|
|
union {
|
|
|
|
u8 hmac[MPTCPOPT_HMAC_LEN]; /* MPJ subflow only */
|
|
|
|
u64 iasn; /* initial ack sequence number, MPC subflows only */
|
|
|
|
};
|
2024-02-15 18:25:31 +00:00
|
|
|
s16 local_id; /* if negative not initialized yet */
|
2020-03-27 21:48:39 +00:00
|
|
|
u8 remote_id;
|
2021-04-01 23:19:44 +00:00
|
|
|
u8 reset_seen:1;
|
|
|
|
u8 reset_transient:1;
|
|
|
|
u8 reset_reason:4;
|
2021-08-13 22:15:42 +00:00
|
|
|
u8 stale_count;
|
2020-01-22 00:56:24 +00:00
|
|
|
|
2023-06-20 16:30:17 +00:00
|
|
|
u32 subflow_id;
|
|
|
|
|
2021-01-20 14:39:14 +00:00
|
|
|
long delegated_status;
|
2022-06-28 01:02:37 +00:00
|
|
|
unsigned long fail_tout;
|
2022-01-07 00:20:16 +00:00
|
|
|
|
2022-01-21 07:39:35 +00:00
|
|
|
);
|
2022-01-07 00:20:16 +00:00
|
|
|
|
2021-01-20 14:39:14 +00:00
|
|
|
struct list_head delegated_node; /* link into delegated_action, protected by local BH */
|
|
|
|
|
2021-08-13 22:15:42 +00:00
|
|
|
u32 setsockopt_seq;
|
|
|
|
u32 stale_rcv_tstamp;
|
2023-10-23 20:44:42 +00:00
|
|
|
int cached_sndbuf; /* sndbuf size when last synced with the msk sndbuf,
|
|
|
|
* protected by the msk socket lock
|
|
|
|
*/
|
2021-04-15 23:44:54 +00:00
|
|
|
|
2020-01-22 00:56:17 +00:00
|
|
|
struct sock *tcp_sock; /* tcp sk backpointer */
|
|
|
|
struct sock *conn; /* parent mptcp_sock */
|
2020-01-22 00:56:18 +00:00
|
|
|
const struct inet_connection_sock_af_ops *icsk_af_ops;
|
2020-01-22 00:56:24 +00:00
|
|
|
void (*tcp_state_change)(struct sock *sk);
|
2021-02-11 23:30:37 +00:00
|
|
|
void (*tcp_error_report)(struct sock *sk);
|
2020-01-22 00:56:24 +00:00
|
|
|
|
2020-01-22 00:56:17 +00:00
|
|
|
struct rcu_head rcu;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct mptcp_subflow_context *
|
|
|
|
mptcp_subflow_ctx(const struct sock *sk)
|
|
|
|
{
|
2024-03-29 14:49:31 +00:00
|
|
|
const struct inet_connection_sock *icsk = inet_csk(sk);
|
2020-01-22 00:56:17 +00:00
|
|
|
|
|
|
|
/* Use RCU on icsk_ulp_data only for sock diag code */
|
|
|
|
return (__force struct mptcp_subflow_context *)icsk->icsk_ulp_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct sock *
|
|
|
|
mptcp_subflow_tcp_sock(const struct mptcp_subflow_context *subflow)
|
|
|
|
{
|
|
|
|
return subflow->tcp_sock;
|
|
|
|
}
|
|
|
|
|
2022-01-07 00:20:16 +00:00
|
|
|
static inline void
|
|
|
|
mptcp_subflow_ctx_reset(struct mptcp_subflow_context *subflow)
|
|
|
|
{
|
2022-01-21 07:39:35 +00:00
|
|
|
memset(&subflow->reset, 0, sizeof(subflow->reset));
|
2022-01-07 00:20:16 +00:00
|
|
|
subflow->request_mptcp = 1;
|
2024-02-15 18:25:31 +00:00
|
|
|
WRITE_ONCE(subflow->local_id, -1);
|
2022-01-07 00:20:16 +00:00
|
|
|
}
|
|
|
|
|
2024-04-25 03:13:38 +00:00
|
|
|
/* Convert reset reasons in MPTCP to enum sk_rst_reason type */
|
|
|
|
static inline enum sk_rst_reason
|
|
|
|
sk_rst_convert_mptcp_reason(u32 reason)
|
|
|
|
{
|
|
|
|
switch (reason) {
|
|
|
|
case MPTCP_RST_EUNSPEC:
|
|
|
|
return SK_RST_REASON_MPTCP_RST_EUNSPEC;
|
|
|
|
case MPTCP_RST_EMPTCP:
|
|
|
|
return SK_RST_REASON_MPTCP_RST_EMPTCP;
|
|
|
|
case MPTCP_RST_ERESOURCE:
|
|
|
|
return SK_RST_REASON_MPTCP_RST_ERESOURCE;
|
|
|
|
case MPTCP_RST_EPROHIBIT:
|
|
|
|
return SK_RST_REASON_MPTCP_RST_EPROHIBIT;
|
|
|
|
case MPTCP_RST_EWQ2BIG:
|
|
|
|
return SK_RST_REASON_MPTCP_RST_EWQ2BIG;
|
|
|
|
case MPTCP_RST_EBADPERF:
|
|
|
|
return SK_RST_REASON_MPTCP_RST_EBADPERF;
|
|
|
|
case MPTCP_RST_EMIDDLEBOX:
|
|
|
|
return SK_RST_REASON_MPTCP_RST_EMIDDLEBOX;
|
|
|
|
default:
|
|
|
|
/* It should not happen, or else errors may occur
|
|
|
|
* in MPTCP layer
|
|
|
|
*/
|
|
|
|
return SK_RST_REASON_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-25 03:13:39 +00:00
|
|
|
static inline void
|
|
|
|
mptcp_send_active_reset_reason(struct sock *sk)
|
|
|
|
{
|
|
|
|
struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
|
|
|
|
enum sk_rst_reason reason;
|
|
|
|
|
|
|
|
reason = sk_rst_convert_mptcp_reason(subflow->reset_reason);
|
|
|
|
tcp_send_active_reset(sk, GFP_ATOMIC, reason);
|
|
|
|
}
|
|
|
|
|
2020-01-22 00:56:24 +00:00
|
|
|
static inline u64
|
|
|
|
mptcp_subflow_get_map_offset(const struct mptcp_subflow_context *subflow)
|
|
|
|
{
|
|
|
|
return tcp_sk(mptcp_subflow_tcp_sock(subflow))->copied_seq -
|
|
|
|
subflow->ssn_offset -
|
|
|
|
subflow->map_subflow_seq;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u64
|
|
|
|
mptcp_subflow_get_mapped_dsn(const struct mptcp_subflow_context *subflow)
|
|
|
|
{
|
|
|
|
return subflow->map_seq + mptcp_subflow_get_map_offset(subflow);
|
|
|
|
}
|
|
|
|
|
2023-10-04 20:38:11 +00:00
|
|
|
void mptcp_subflow_process_delegated(struct sock *ssk, long actions);
|
2021-01-20 14:39:14 +00:00
|
|
|
|
2021-11-19 14:27:55 +00:00
|
|
|
static inline void mptcp_subflow_delegate(struct mptcp_subflow_context *subflow, int action)
|
2021-01-20 14:39:14 +00:00
|
|
|
{
|
2023-10-04 20:38:11 +00:00
|
|
|
long old, set_bits = BIT(MPTCP_DELEGATE_SCHEDULED) | BIT(action);
|
2021-01-20 14:39:14 +00:00
|
|
|
struct mptcp_delegated_action *delegated;
|
|
|
|
bool schedule;
|
|
|
|
|
2021-11-19 14:27:55 +00:00
|
|
|
/* the caller held the subflow bh socket lock */
|
|
|
|
lockdep_assert_in_softirq();
|
|
|
|
|
2023-10-04 20:38:11 +00:00
|
|
|
/* The implied barrier pairs with tcp_release_cb_override()
|
|
|
|
* mptcp_napi_poll(), and ensures the below list check sees list
|
|
|
|
* updates done prior to delegated status bits changes
|
2021-01-20 14:39:14 +00:00
|
|
|
*/
|
2023-10-04 20:38:11 +00:00
|
|
|
old = set_mask_bits(&subflow->delegated_status, 0, set_bits);
|
|
|
|
if (!(old & BIT(MPTCP_DELEGATE_SCHEDULED))) {
|
|
|
|
if (WARN_ON_ONCE(!list_empty(&subflow->delegated_node)))
|
2021-01-20 14:39:14 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
delegated = this_cpu_ptr(&mptcp_delegated_actions);
|
|
|
|
schedule = list_empty(&delegated->head);
|
|
|
|
list_add_tail(&subflow->delegated_node, &delegated->head);
|
|
|
|
sock_hold(mptcp_subflow_tcp_sock(subflow));
|
|
|
|
if (schedule)
|
|
|
|
napi_schedule(&delegated->napi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct mptcp_subflow_context *
|
|
|
|
mptcp_subflow_delegated_next(struct mptcp_delegated_action *delegated)
|
|
|
|
{
|
|
|
|
struct mptcp_subflow_context *ret;
|
|
|
|
|
|
|
|
if (list_empty(&delegated->head))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
ret = list_first_entry(&delegated->head, struct mptcp_subflow_context, delegated_node);
|
|
|
|
list_del_init(&ret->delegated_node);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-08-13 22:15:44 +00:00
|
|
|
int mptcp_is_enabled(const struct net *net);
|
|
|
|
unsigned int mptcp_get_add_addr_timeout(const struct net *net);
|
|
|
|
int mptcp_is_checksum_enabled(const struct net *net);
|
|
|
|
int mptcp_allow_join_id0(const struct net *net);
|
2021-08-13 22:15:45 +00:00
|
|
|
unsigned int mptcp_stale_loss_cnt(const struct net *net);
|
2023-10-23 20:44:34 +00:00
|
|
|
unsigned int mptcp_close_timeout(const struct sock *sk);
|
2022-04-27 22:50:01 +00:00
|
|
|
int mptcp_get_pm_type(const struct net *net);
|
2023-08-21 22:25:15 +00:00
|
|
|
const char *mptcp_get_scheduler(const struct net *net);
|
2024-09-09 20:09:23 +00:00
|
|
|
|
|
|
|
void mptcp_active_disable(struct sock *sk);
|
|
|
|
bool mptcp_active_should_disable(struct sock *ssk);
|
|
|
|
void mptcp_active_enable(struct sock *sk);
|
|
|
|
|
2024-05-14 01:13:28 +00:00
|
|
|
void mptcp_get_available_schedulers(char *buf, size_t maxlen);
|
2024-02-08 18:03:52 +00:00
|
|
|
void __mptcp_subflow_fully_established(struct mptcp_sock *msk,
|
|
|
|
struct mptcp_subflow_context *subflow,
|
|
|
|
const struct mptcp_options_received *mp_opt);
|
2021-08-13 22:15:43 +00:00
|
|
|
bool __mptcp_retransmit_pending_data(struct sock *sk);
|
2021-12-03 22:35:40 +00:00
|
|
|
void mptcp_check_and_set_pending(struct sock *sk);
|
2021-08-13 22:15:45 +00:00
|
|
|
void __mptcp_push_pending(struct sock *sk, unsigned int flags);
|
2020-01-22 00:56:24 +00:00
|
|
|
bool mptcp_subflow_data_available(struct sock *sk);
|
2020-06-26 17:29:59 +00:00
|
|
|
void __init mptcp_subflow_init(void);
|
2020-09-24 00:29:49 +00:00
|
|
|
void mptcp_subflow_shutdown(struct sock *sk, struct sock *ssk, int how);
|
2021-02-12 23:59:55 +00:00
|
|
|
void mptcp_close_ssk(struct sock *sk, struct sock *ssk,
|
|
|
|
struct mptcp_subflow_context *subflow);
|
2022-07-05 21:32:13 +00:00
|
|
|
void __mptcp_subflow_send_ack(struct sock *ssk);
|
2020-10-09 17:00:00 +00:00
|
|
|
void mptcp_subflow_reset(struct sock *ssk);
|
2023-04-17 14:00:40 +00:00
|
|
|
void mptcp_subflow_queue_clean(struct sock *sk, struct sock *ssk);
|
2021-01-20 14:39:10 +00:00
|
|
|
void mptcp_sock_graft(struct sock *sk, struct socket *parent);
|
2023-08-11 15:57:25 +00:00
|
|
|
struct sock *__mptcp_nmpc_sk(struct mptcp_sock *msk);
|
2022-09-27 19:31:57 +00:00
|
|
|
bool __mptcp_close(struct sock *sk, long timeout);
|
mptcp: fix unreleased socket in accept queue
The mptcp socket and its subflow sockets in accept queue can't be
released after the process exit.
While the release of a mptcp socket in listening state, the
corresponding tcp socket will be released too. Meanwhile, the tcp
socket in the unaccept queue will be released too. However, only init
subflow is in the unaccept queue, and the joined subflow is not in the
unaccept queue, which makes the joined subflow won't be released, and
therefore the corresponding unaccepted mptcp socket will not be released
to.
This can be reproduced easily with following steps:
1. create 2 namespace and veth:
$ ip netns add mptcp-client
$ ip netns add mptcp-server
$ sysctl -w net.ipv4.conf.all.rp_filter=0
$ ip netns exec mptcp-client sysctl -w net.mptcp.enabled=1
$ ip netns exec mptcp-server sysctl -w net.mptcp.enabled=1
$ ip link add red-client netns mptcp-client type veth peer red-server \
netns mptcp-server
$ ip -n mptcp-server address add 10.0.0.1/24 dev red-server
$ ip -n mptcp-server address add 192.168.0.1/24 dev red-server
$ ip -n mptcp-client address add 10.0.0.2/24 dev red-client
$ ip -n mptcp-client address add 192.168.0.2/24 dev red-client
$ ip -n mptcp-server link set red-server up
$ ip -n mptcp-client link set red-client up
2. configure the endpoint and limit for client and server:
$ ip -n mptcp-server mptcp endpoint flush
$ ip -n mptcp-server mptcp limits set subflow 2 add_addr_accepted 2
$ ip -n mptcp-client mptcp endpoint flush
$ ip -n mptcp-client mptcp limits set subflow 2 add_addr_accepted 2
$ ip -n mptcp-client mptcp endpoint add 192.168.0.2 dev red-client id \
1 subflow
3. listen and accept on a port, such as 9999. The nc command we used
here is modified, which makes it use mptcp protocol by default.
$ ip netns exec mptcp-server nc -l -k -p 9999
4. open another *two* terminal and use each of them to connect to the
server with the following command:
$ ip netns exec mptcp-client nc 10.0.0.1 9999
Input something after connect to trigger the connection of the second
subflow. So that there are two established mptcp connections, with the
second one still unaccepted.
5. exit all the nc command, and check the tcp socket in server namespace.
And you will find that there is one tcp socket in CLOSE_WAIT state
and can't release forever.
Fix this by closing all of the unaccepted mptcp socket in
mptcp_subflow_queue_clean() with __mptcp_close().
Now, we can ensure that all unaccepted mptcp sockets will be cleaned by
__mptcp_close() before they are released, so mptcp_sock_destruct(), which
is used to clean the unaccepted mptcp socket, is not needed anymore.
The selftests for mptcp is ran for this commit, and no new failures.
Fixes: f296234c98a8 ("mptcp: Add handling of incoming MP_JOIN requests")
Fixes: 6aeed9045071 ("mptcp: fix race on unaccepted mptcp sockets")
Cc: stable@vger.kernel.org
Reviewed-by: Jiang Biao <benbjiang@tencent.com>
Reviewed-by: Mengen Sun <mengensun@tencent.com>
Acked-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Menglong Dong <imagedong@tencent.com>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2022-09-27 19:31:58 +00:00
|
|
|
void mptcp_cancel_work(struct sock *sk);
|
2023-04-17 14:00:41 +00:00
|
|
|
void __mptcp_unaccepted_force_close(struct sock *sk);
|
2022-11-25 22:29:51 +00:00
|
|
|
void mptcp_set_owner_r(struct sk_buff *skb, struct sock *sk);
|
2023-12-22 12:47:22 +00:00
|
|
|
void mptcp_set_state(struct sock *sk, int state);
|
2020-03-27 21:48:40 +00:00
|
|
|
|
2022-05-04 02:38:49 +00:00
|
|
|
bool mptcp_addresses_equal(const struct mptcp_addr_info *a,
|
|
|
|
const struct mptcp_addr_info *b, bool use_port);
|
2023-06-08 13:20:49 +00:00
|
|
|
void mptcp_local_address(const struct sock_common *skc, struct mptcp_addr_info *addr);
|
2022-05-04 02:38:49 +00:00
|
|
|
|
2020-03-27 21:48:40 +00:00
|
|
|
/* called with sk socket lock held */
|
2024-09-02 10:45:53 +00:00
|
|
|
int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_pm_local *local,
|
2021-08-17 22:07:22 +00:00
|
|
|
const struct mptcp_addr_info *remote);
|
2023-01-12 17:42:51 +00:00
|
|
|
int mptcp_subflow_create_socket(struct sock *sk, unsigned short family,
|
|
|
|
struct socket **new_sock);
|
2021-02-01 23:09:12 +00:00
|
|
|
void mptcp_info2sockaddr(const struct mptcp_addr_info *info,
|
|
|
|
struct sockaddr_storage *addr,
|
|
|
|
unsigned short family);
|
2023-08-21 22:25:14 +00:00
|
|
|
struct mptcp_sched_ops *mptcp_sched_find(const char *name);
|
|
|
|
int mptcp_register_scheduler(struct mptcp_sched_ops *sched);
|
|
|
|
void mptcp_unregister_scheduler(struct mptcp_sched_ops *sched);
|
2023-08-21 22:25:21 +00:00
|
|
|
void mptcp_sched_init(void);
|
2023-08-21 22:25:16 +00:00
|
|
|
int mptcp_init_sched(struct mptcp_sock *msk,
|
|
|
|
struct mptcp_sched_ops *sched);
|
|
|
|
void mptcp_release_sched(struct mptcp_sock *msk);
|
2023-08-21 22:25:17 +00:00
|
|
|
void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow,
|
|
|
|
bool scheduled);
|
2023-08-21 22:25:18 +00:00
|
|
|
struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk);
|
|
|
|
struct sock *mptcp_subflow_get_retrans(struct mptcp_sock *msk);
|
|
|
|
int mptcp_sched_get_send(struct mptcp_sock *msk);
|
|
|
|
int mptcp_sched_get_retrans(struct mptcp_sock *msk);
|
2020-01-22 00:56:17 +00:00
|
|
|
|
2023-10-23 20:44:38 +00:00
|
|
|
static inline u64 mptcp_data_avail(const struct mptcp_sock *msk)
|
|
|
|
{
|
|
|
|
return READ_ONCE(msk->bytes_received) - READ_ONCE(msk->bytes_consumed);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool mptcp_epollin_ready(const struct sock *sk)
|
|
|
|
{
|
|
|
|
/* mptcp doesn't have to deal with small skbs in the receive queue,
|
|
|
|
* at it can always coalesce them
|
|
|
|
*/
|
|
|
|
return (mptcp_data_avail(mptcp_sk(sk)) >= sk->sk_rcvlowat) ||
|
|
|
|
(mem_cgroup_sockets_enabled && sk->sk_memcg &&
|
|
|
|
mem_cgroup_under_socket_pressure(sk->sk_memcg)) ||
|
|
|
|
READ_ONCE(tcp_memory_pressure);
|
|
|
|
}
|
|
|
|
|
|
|
|
int mptcp_set_rcvlowat(struct sock *sk, int val);
|
|
|
|
|
2022-08-05 00:21:26 +00:00
|
|
|
static inline bool __tcp_can_send(const struct sock *ssk)
|
2021-04-16 22:38:03 +00:00
|
|
|
{
|
2022-08-05 00:21:26 +00:00
|
|
|
/* only send if our side has not closed yet */
|
|
|
|
return ((1 << inet_sk_state_load(ssk)) & (TCPF_ESTABLISHED | TCPF_CLOSE_WAIT));
|
|
|
|
}
|
2021-04-16 22:38:03 +00:00
|
|
|
|
2022-08-05 00:21:26 +00:00
|
|
|
static inline bool __mptcp_subflow_active(struct mptcp_subflow_context *subflow)
|
|
|
|
{
|
2021-04-16 22:38:03 +00:00
|
|
|
/* can't send if JOIN hasn't completed yet (i.e. is usable for mptcp) */
|
2024-10-21 15:14:04 +00:00
|
|
|
if (subflow->request_join && !READ_ONCE(subflow->fully_established))
|
2021-04-16 22:38:03 +00:00
|
|
|
return false;
|
|
|
|
|
2022-08-05 00:21:26 +00:00
|
|
|
return __tcp_can_send(mptcp_subflow_tcp_sock(subflow));
|
2021-04-16 22:38:03 +00:00
|
|
|
}
|
|
|
|
|
2021-08-13 22:15:45 +00:00
|
|
|
void mptcp_subflow_set_active(struct mptcp_subflow_context *subflow);
|
|
|
|
|
|
|
|
bool mptcp_subflow_active(struct mptcp_subflow_context *subflow);
|
|
|
|
|
2023-03-09 14:49:59 +00:00
|
|
|
void mptcp_subflow_drop_ctx(struct sock *ssk);
|
|
|
|
|
2020-01-22 00:56:24 +00:00
|
|
|
static inline void mptcp_subflow_tcp_fallback(struct sock *sk,
|
|
|
|
struct mptcp_subflow_context *ctx)
|
|
|
|
{
|
2022-02-16 02:11:30 +00:00
|
|
|
sk->sk_data_ready = sock_def_readable;
|
2020-01-22 00:56:24 +00:00
|
|
|
sk->sk_state_change = ctx->tcp_state_change;
|
2022-02-16 02:11:30 +00:00
|
|
|
sk->sk_write_space = sk_stream_write_space;
|
2021-02-11 23:30:37 +00:00
|
|
|
sk->sk_error_report = ctx->tcp_error_report;
|
2020-01-22 00:56:24 +00:00
|
|
|
|
|
|
|
inet_csk(sk)->icsk_af_ops = ctx->icsk_af_ops;
|
|
|
|
}
|
|
|
|
|
2020-06-26 17:29:59 +00:00
|
|
|
void __init mptcp_proto_init(void);
|
2020-01-22 00:56:28 +00:00
|
|
|
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
|
2020-06-26 17:29:59 +00:00
|
|
|
int __init mptcp_proto_v6_init(void);
|
2020-01-22 00:56:28 +00:00
|
|
|
#endif
|
2020-01-22 00:56:24 +00:00
|
|
|
|
2023-05-31 19:37:05 +00:00
|
|
|
struct sock *mptcp_sk_clone_init(const struct sock *sk,
|
|
|
|
const struct mptcp_options_received *mp_opt,
|
|
|
|
struct sock *ssk,
|
|
|
|
struct request_sock *req);
|
2022-02-16 02:11:25 +00:00
|
|
|
void mptcp_get_options(const struct sk_buff *skb,
|
mptcp: move option parsing into mptcp_incoming_options()
The mptcp_options_received structure carries several per
packet flags (mp_capable, mp_join, etc.). Such fields must
be cleared on each packet, even on dropped ones or packet
not carrying any MPTCP options, but the current mptcp
code clears them only on TCP option reset.
On several races/corner cases we end-up with stray bits in
incoming options, leading to WARN_ON splats. e.g.:
[ 171.164906] Bad mapping: ssn=32714 map_seq=1 map_data_len=32713
[ 171.165006] WARNING: CPU: 1 PID: 5026 at net/mptcp/subflow.c:533 warn_bad_map (linux-mptcp/net/mptcp/subflow.c:533 linux-mptcp/net/mptcp/subflow.c:531)
[ 171.167632] Modules linked in: ip6_vti ip_vti ip_gre ipip sit tunnel4 ip_tunnel geneve ip6_udp_tunnel udp_tunnel macsec macvtap tap ipvlan macvlan 8021q garp mrp xfrm_interface veth netdevsim nlmon dummy team bonding vcan bridge stp llc ip6_gre gre ip6_tunnel tunnel6 tun binfmt_misc intel_rapl_msr intel_rapl_common rfkill kvm_intel kvm irqbypass crct10dif_pclmul crc32_pclmul ghash_clmulni_intel joydev virtio_balloon pcspkr i2c_piix4 sunrpc ip_tables xfs libcrc32c crc32c_intel serio_raw virtio_console ata_generic virtio_blk virtio_net net_failover failover ata_piix libata
[ 171.199464] CPU: 1 PID: 5026 Comm: repro Not tainted 5.7.0-rc1.mptcp_f227fdf5d388+ #95
[ 171.200886] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-2.fc30 04/01/2014
[ 171.202546] RIP: 0010:warn_bad_map (linux-mptcp/net/mptcp/subflow.c:533 linux-mptcp/net/mptcp/subflow.c:531)
[ 171.206537] Code: c1 ea 03 0f b6 14 02 48 89 f8 83 e0 07 83 c0 03 38 d0 7c 04 84 d2 75 1d 8b 55 3c 44 89 e6 48 c7 c7 20 51 13 95 e8 37 8b 22 fe <0f> 0b 48 83 c4 08 5b 5d 41 5c c3 89 4c 24 04 e8 db d6 94 fe 8b 4c
[ 171.220473] RSP: 0018:ffffc90000150560 EFLAGS: 00010282
[ 171.221639] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
[ 171.223108] RDX: 0000000000000000 RSI: 0000000000000008 RDI: fffff5200002a09e
[ 171.224388] RBP: ffff8880aa6e3c00 R08: 0000000000000001 R09: fffffbfff2ec9955
[ 171.225706] R10: ffffffff9764caa7 R11: fffffbfff2ec9954 R12: 0000000000007fca
[ 171.227211] R13: ffff8881066f4a7f R14: ffff8880aa6e3c00 R15: 0000000000000020
[ 171.228460] FS: 00007f8623719740(0000) GS:ffff88810be00000(0000) knlGS:0000000000000000
[ 171.230065] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 171.231303] CR2: 00007ffdab190a50 CR3: 00000001038ea006 CR4: 0000000000160ee0
[ 171.232586] Call Trace:
[ 171.233109] <IRQ>
[ 171.233531] get_mapping_status (linux-mptcp/net/mptcp/subflow.c:691)
[ 171.234371] mptcp_subflow_data_available (linux-mptcp/net/mptcp/subflow.c:736 linux-mptcp/net/mptcp/subflow.c:832)
[ 171.238181] subflow_state_change (linux-mptcp/net/mptcp/subflow.c:1085 (discriminator 1))
[ 171.239066] tcp_fin (linux-mptcp/net/ipv4/tcp_input.c:4217)
[ 171.240123] tcp_data_queue (linux-mptcp/./include/linux/compiler.h:199 linux-mptcp/net/ipv4/tcp_input.c:4822)
[ 171.245083] tcp_rcv_established (linux-mptcp/./include/linux/skbuff.h:1785 linux-mptcp/./include/net/tcp.h:1774 linux-mptcp/./include/net/tcp.h:1847 linux-mptcp/net/ipv4/tcp_input.c:5238 linux-mptcp/net/ipv4/tcp_input.c:5730)
[ 171.254089] tcp_v4_rcv (linux-mptcp/./include/linux/spinlock.h:393 linux-mptcp/net/ipv4/tcp_ipv4.c:2009)
[ 171.258969] ip_protocol_deliver_rcu (linux-mptcp/net/ipv4/ip_input.c:204 (discriminator 1))
[ 171.260214] ip_local_deliver_finish (linux-mptcp/./include/linux/rcupdate.h:651 linux-mptcp/net/ipv4/ip_input.c:232)
[ 171.261389] ip_local_deliver (linux-mptcp/./include/linux/netfilter.h:307 linux-mptcp/./include/linux/netfilter.h:301 linux-mptcp/net/ipv4/ip_input.c:252)
[ 171.265884] ip_rcv (linux-mptcp/./include/linux/netfilter.h:307 linux-mptcp/./include/linux/netfilter.h:301 linux-mptcp/net/ipv4/ip_input.c:539)
[ 171.273666] process_backlog (linux-mptcp/./include/linux/rcupdate.h:651 linux-mptcp/net/core/dev.c:6135)
[ 171.275328] net_rx_action (linux-mptcp/net/core/dev.c:6572 linux-mptcp/net/core/dev.c:6640)
[ 171.280472] __do_softirq (linux-mptcp/./arch/x86/include/asm/jump_label.h:25 linux-mptcp/./include/linux/jump_label.h:200 linux-mptcp/./include/trace/events/irq.h:142 linux-mptcp/kernel/softirq.c:293)
[ 171.281379] do_softirq_own_stack (linux-mptcp/arch/x86/entry/entry_64.S:1083)
[ 171.282358] </IRQ>
We could address the issue clearing explicitly the relevant fields
in several places - tcp_parse_option, tcp_fast_parse_options,
possibly others.
Instead we move the MPTCP option parsing into the already existing
mptcp ingress hook, so that we need to clear the fields in a single
place.
This allows us dropping an MPTCP hook from the TCP code and
removing the quite large mptcp_options_received from the tcp_sock
struct. On the flip side, the MPTCP sockets will traverse the
option space twice (in tcp_parse_option() and in
mptcp_incoming_options(). That looks acceptable: we already
do that for syn and 3rd ack packets, plain TCP socket will
benefit from it, and even MPTCP sockets will experience better
code locality, reducing the jumps between TCP and MPTCP code.
v1 -> v2:
- rebased on current '-net' tree
Fixes: 648ef4b88673 ("mptcp: Implement MPTCP receive path")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-30 13:01:52 +00:00
|
|
|
struct mptcp_options_received *mp_opt);
|
2020-01-22 00:56:18 +00:00
|
|
|
|
|
|
|
void mptcp_finish_connect(struct sock *sk);
|
2023-12-15 16:04:25 +00:00
|
|
|
void __mptcp_sync_state(struct sock *sk, int state);
|
2023-09-16 10:52:48 +00:00
|
|
|
void mptcp_reset_tout_timer(struct mptcp_sock *msk, unsigned long fail_tout);
|
2023-09-16 10:52:49 +00:00
|
|
|
|
|
|
|
static inline void mptcp_stop_tout_timer(struct sock *sk)
|
|
|
|
{
|
|
|
|
if (!inet_csk(sk)->icsk_mtup.probe_timestamp)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sk_stop_timer(sk, &sk->sk_timer);
|
|
|
|
inet_csk(sk)->icsk_mtup.probe_timestamp = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void mptcp_set_close_tout(struct sock *sk, unsigned long tout)
|
|
|
|
{
|
|
|
|
/* avoid 0 timestamp, as that means no close timeout */
|
|
|
|
inet_csk(sk)->icsk_mtup.probe_timestamp = tout ? : 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void mptcp_start_tout_timer(struct sock *sk)
|
|
|
|
{
|
|
|
|
mptcp_set_close_tout(sk, tcp_jiffies32);
|
|
|
|
mptcp_reset_tout_timer(mptcp_sk(sk), 0);
|
|
|
|
}
|
|
|
|
|
2020-07-23 11:02:32 +00:00
|
|
|
static inline bool mptcp_is_fully_established(struct sock *sk)
|
|
|
|
{
|
|
|
|
return inet_sk_state_load(sk) == TCP_ESTABLISHED &&
|
|
|
|
READ_ONCE(mptcp_sk(sk)->fully_established);
|
|
|
|
}
|
2023-10-23 20:44:38 +00:00
|
|
|
|
2020-06-30 19:24:45 +00:00
|
|
|
void mptcp_rcv_space_init(struct mptcp_sock *msk, const struct sock *ssk);
|
2020-02-26 09:14:51 +00:00
|
|
|
void mptcp_data_ready(struct sock *sk, struct sock *ssk);
|
2020-03-27 21:48:39 +00:00
|
|
|
bool mptcp_finish_join(struct sock *sk);
|
2020-11-16 09:48:05 +00:00
|
|
|
bool mptcp_schedule_work(struct sock *sk);
|
2021-04-15 23:44:51 +00:00
|
|
|
int mptcp_setsockopt(struct sock *sk, int level, int optname,
|
|
|
|
sockptr_t optval, unsigned int optlen);
|
|
|
|
int mptcp_getsockopt(struct sock *sk, int level, int optname,
|
|
|
|
char __user *optval, int __user *option);
|
|
|
|
|
2021-06-18 22:02:20 +00:00
|
|
|
u64 __mptcp_expand_seq(u64 old_seq, u64 cur_seq);
|
|
|
|
static inline u64 mptcp_expand_seq(u64 old_seq, u64 cur_seq, bool use_64bit)
|
|
|
|
{
|
|
|
|
if (use_64bit)
|
|
|
|
return cur_seq;
|
|
|
|
|
|
|
|
return __mptcp_expand_seq(old_seq, cur_seq);
|
|
|
|
}
|
2020-12-16 11:48:34 +00:00
|
|
|
void __mptcp_check_push(struct sock *sk, struct sock *ssk);
|
2020-11-27 10:10:26 +00:00
|
|
|
void __mptcp_data_acked(struct sock *sk);
|
2021-02-11 23:30:37 +00:00
|
|
|
void __mptcp_error_report(struct sock *sk);
|
2020-09-29 22:08:20 +00:00
|
|
|
bool mptcp_update_rcv_data_fin(struct mptcp_sock *msk, u64 data_fin_seq, bool use_64bit);
|
2020-11-16 09:48:09 +00:00
|
|
|
static inline bool mptcp_data_fin_enabled(const struct mptcp_sock *msk)
|
|
|
|
{
|
|
|
|
return READ_ONCE(msk->snd_data_fin_enable) &&
|
|
|
|
READ_ONCE(msk->write_seq) == READ_ONCE(msk->snd_nxt);
|
|
|
|
}
|
|
|
|
|
2024-03-01 17:43:46 +00:00
|
|
|
static inline u32 mptcp_notsent_lowat(const struct sock *sk)
|
|
|
|
{
|
|
|
|
struct net *net = sock_net(sk);
|
|
|
|
u32 val;
|
|
|
|
|
|
|
|
val = READ_ONCE(mptcp_sk(sk)->notsent_lowat);
|
|
|
|
return val ?: READ_ONCE(net->ipv4.sysctl_tcp_notsent_lowat);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool mptcp_stream_memory_free(const struct sock *sk, int wake)
|
|
|
|
{
|
|
|
|
const struct mptcp_sock *msk = mptcp_sk(sk);
|
|
|
|
u32 notsent_bytes;
|
|
|
|
|
|
|
|
notsent_bytes = READ_ONCE(msk->write_seq) - READ_ONCE(msk->snd_nxt);
|
|
|
|
return (notsent_bytes << wake) < mptcp_notsent_lowat(sk);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool __mptcp_stream_is_writeable(const struct sock *sk, int wake)
|
|
|
|
{
|
|
|
|
return mptcp_stream_memory_free(sk, wake) &&
|
|
|
|
__sk_stream_is_writeable(sk, wake);
|
|
|
|
}
|
|
|
|
|
2024-02-23 16:14:16 +00:00
|
|
|
static inline void mptcp_write_space(struct sock *sk)
|
|
|
|
{
|
2024-03-01 17:43:44 +00:00
|
|
|
/* pairs with memory barrier in mptcp_poll */
|
|
|
|
smp_mb();
|
2024-03-01 17:43:46 +00:00
|
|
|
if (mptcp_stream_memory_free(sk, 1))
|
|
|
|
sk_stream_write_space(sk);
|
2024-02-23 16:14:16 +00:00
|
|
|
}
|
|
|
|
|
2023-10-23 20:44:42 +00:00
|
|
|
static inline void __mptcp_sync_sndbuf(struct sock *sk)
|
2021-01-20 14:39:11 +00:00
|
|
|
{
|
2023-10-23 20:44:42 +00:00
|
|
|
struct mptcp_subflow_context *subflow;
|
|
|
|
int ssk_sndbuf, new_sndbuf;
|
|
|
|
|
|
|
|
if (sk->sk_userlocks & SOCK_SNDBUF_LOCK)
|
|
|
|
return;
|
|
|
|
|
2024-03-08 11:25:03 +00:00
|
|
|
new_sndbuf = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_wmem[0]);
|
2023-10-23 20:44:42 +00:00
|
|
|
mptcp_for_each_subflow(mptcp_sk(sk), subflow) {
|
|
|
|
ssk_sndbuf = READ_ONCE(mptcp_subflow_tcp_sock(subflow)->sk_sndbuf);
|
|
|
|
|
|
|
|
subflow->cached_sndbuf = ssk_sndbuf;
|
|
|
|
new_sndbuf += ssk_sndbuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the msk max wmem limit is <nr_subflows> * tcp wmem[2] */
|
|
|
|
WRITE_ONCE(sk->sk_sndbuf, new_sndbuf);
|
2024-02-23 16:14:16 +00:00
|
|
|
mptcp_write_space(sk);
|
2023-10-23 20:44:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The called held both the msk socket and the subflow socket locks,
|
|
|
|
* possibly under BH
|
|
|
|
*/
|
|
|
|
static inline void __mptcp_propagate_sndbuf(struct sock *sk, struct sock *ssk)
|
|
|
|
{
|
|
|
|
struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
|
|
|
|
|
|
|
|
if (READ_ONCE(ssk->sk_sndbuf) != subflow->cached_sndbuf)
|
|
|
|
__mptcp_sync_sndbuf(sk);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the caller held only the subflow socket lock, either in process or
|
|
|
|
* BH context. Additionally this can be called under the msk data lock,
|
|
|
|
* so we can't acquire such lock here: let the delegate action acquires
|
|
|
|
* the needed locks in suitable order.
|
|
|
|
*/
|
|
|
|
static inline void mptcp_propagate_sndbuf(struct sock *sk, struct sock *ssk)
|
|
|
|
{
|
|
|
|
struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
|
|
|
|
|
|
|
|
if (likely(READ_ONCE(ssk->sk_sndbuf) == subflow->cached_sndbuf))
|
|
|
|
return;
|
2021-01-20 14:39:11 +00:00
|
|
|
|
2023-10-23 20:44:42 +00:00
|
|
|
local_bh_disable();
|
|
|
|
mptcp_subflow_delegate(subflow, MPTCP_DELEGATE_SNDBUF);
|
|
|
|
local_bh_enable();
|
2021-01-20 14:39:11 +00:00
|
|
|
}
|
|
|
|
|
2022-08-05 00:21:25 +00:00
|
|
|
void mptcp_destroy_common(struct mptcp_sock *msk, unsigned int flags);
|
2020-01-22 00:56:18 +00:00
|
|
|
|
2021-05-27 23:54:25 +00:00
|
|
|
#define MPTCP_TOKEN_MAX_RETRIES 4
|
|
|
|
|
2020-06-26 17:30:00 +00:00
|
|
|
void __init mptcp_token_init(void);
|
|
|
|
static inline void mptcp_token_init_request(struct request_sock *req)
|
|
|
|
{
|
|
|
|
mptcp_subflow_rsk(req)->token_node.pprev = NULL;
|
|
|
|
}
|
|
|
|
|
2020-01-22 00:56:20 +00:00
|
|
|
int mptcp_token_new_request(struct request_sock *req);
|
2020-06-26 17:30:00 +00:00
|
|
|
void mptcp_token_destroy_request(struct request_sock *req);
|
2023-01-06 18:57:22 +00:00
|
|
|
int mptcp_token_new_connect(struct sock *ssk);
|
2020-06-26 17:30:00 +00:00
|
|
|
void mptcp_token_accept(struct mptcp_subflow_request_sock *r,
|
|
|
|
struct mptcp_sock *msk);
|
2020-07-30 19:25:54 +00:00
|
|
|
bool mptcp_token_exists(u32 token);
|
2021-09-24 00:04:11 +00:00
|
|
|
struct mptcp_sock *mptcp_token_get_sock(struct net *net, u32 token);
|
2020-07-09 13:12:40 +00:00
|
|
|
struct mptcp_sock *mptcp_token_iter_next(const struct net *net, long *s_slot,
|
|
|
|
long *s_num);
|
2020-06-26 17:30:00 +00:00
|
|
|
void mptcp_token_destroy(struct mptcp_sock *msk);
|
2020-01-22 00:56:20 +00:00
|
|
|
|
|
|
|
void mptcp_crypto_key_sha(u64 key, u32 *token, u64 *idsn);
|
|
|
|
|
2020-03-27 21:48:37 +00:00
|
|
|
void mptcp_crypto_hmac_sha(u64 key1, u64 key2, u8 *msg, int len, void *hmac);
|
2022-05-17 18:02:11 +00:00
|
|
|
__sum16 __mptcp_make_csum(u64 data_seq, u32 subflow_seq, u16 data_len, __wsum sum);
|
2020-01-22 00:56:20 +00:00
|
|
|
|
2020-06-26 17:29:59 +00:00
|
|
|
void __init mptcp_pm_init(void);
|
2020-03-27 21:48:38 +00:00
|
|
|
void mptcp_pm_data_init(struct mptcp_sock *msk);
|
2022-01-07 00:20:16 +00:00
|
|
|
void mptcp_pm_data_reset(struct mptcp_sock *msk);
|
mptcp: netlink: allow userspace-driven subflow establishment
This allows userspace to tell kernel to add a new subflow to an existing
mptcp connection.
Userspace provides the token to identify the mptcp-level connection
that needs a change in active subflows and the local and remote
addresses of the new or the to-be-removed subflow.
MPTCP_PM_CMD_SUBFLOW_CREATE requires the following parameters:
{ token, { loc_id, family, loc_addr4 | loc_addr6 }, { family, rem_addr4 |
rem_addr6, rem_port }
MPTCP_PM_CMD_SUBFLOW_DESTROY requires the following parameters:
{ token, { family, loc_addr4 | loc_addr6, loc_port }, { family, rem_addr4 |
rem_addr6, rem_port }
Acked-by: Paolo Abeni <pabeni@redhat.com>
Co-developed-by: Kishen Maloor <kishen.maloor@intel.com>
Signed-off-by: Kishen Maloor <kishen.maloor@intel.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-05-04 02:38:56 +00:00
|
|
|
int mptcp_pm_parse_addr(struct nlattr *attr, struct genl_info *info,
|
|
|
|
struct mptcp_addr_info *addr);
|
2022-05-04 02:38:52 +00:00
|
|
|
int mptcp_pm_parse_entry(struct nlattr *attr, struct genl_info *info,
|
|
|
|
bool require_family,
|
|
|
|
struct mptcp_pm_addr_entry *entry);
|
2023-01-12 17:42:52 +00:00
|
|
|
bool mptcp_pm_addr_families_match(const struct sock *sk,
|
|
|
|
const struct mptcp_addr_info *loc,
|
|
|
|
const struct mptcp_addr_info *rem);
|
2021-08-13 22:15:42 +00:00
|
|
|
void mptcp_pm_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk);
|
2021-08-13 22:15:45 +00:00
|
|
|
void mptcp_pm_nl_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk);
|
2021-02-12 23:59:58 +00:00
|
|
|
void mptcp_pm_new_connection(struct mptcp_sock *msk, const struct sock *ssk, int server_side);
|
2023-04-14 14:08:00 +00:00
|
|
|
void mptcp_pm_fully_established(struct mptcp_sock *msk, const struct sock *ssk);
|
2020-03-27 21:48:38 +00:00
|
|
|
bool mptcp_pm_allow_new_subflow(struct mptcp_sock *msk);
|
|
|
|
void mptcp_pm_connection_closed(struct mptcp_sock *msk);
|
2021-03-26 18:26:33 +00:00
|
|
|
void mptcp_pm_subflow_established(struct mptcp_sock *msk);
|
2022-01-07 00:20:23 +00:00
|
|
|
bool mptcp_pm_nl_check_work_pending(struct mptcp_sock *msk);
|
2023-10-25 23:37:05 +00:00
|
|
|
void mptcp_pm_subflow_check_next(struct mptcp_sock *msk,
|
2022-01-07 00:20:23 +00:00
|
|
|
const struct mptcp_subflow_context *subflow);
|
2022-05-02 20:52:34 +00:00
|
|
|
void mptcp_pm_add_addr_received(const struct sock *ssk,
|
2020-03-27 21:48:38 +00:00
|
|
|
const struct mptcp_addr_info *addr);
|
2021-03-26 18:26:38 +00:00
|
|
|
void mptcp_pm_add_addr_echoed(struct mptcp_sock *msk,
|
2022-02-16 02:11:28 +00:00
|
|
|
const struct mptcp_addr_info *addr);
|
2020-11-19 19:46:00 +00:00
|
|
|
void mptcp_pm_add_addr_send_ack(struct mptcp_sock *msk);
|
2024-08-28 06:14:37 +00:00
|
|
|
bool mptcp_pm_nl_is_init_remote_addr(struct mptcp_sock *msk,
|
|
|
|
const struct mptcp_addr_info *remote);
|
2021-03-26 18:26:41 +00:00
|
|
|
void mptcp_pm_nl_addr_send_ack(struct mptcp_sock *msk);
|
2021-03-13 01:16:13 +00:00
|
|
|
void mptcp_pm_rm_addr_received(struct mptcp_sock *msk,
|
|
|
|
const struct mptcp_rm_list *rm_list);
|
2021-01-09 00:47:58 +00:00
|
|
|
void mptcp_pm_mp_prio_received(struct sock *sk, u8 bkup);
|
2021-08-24 23:26:16 +00:00
|
|
|
void mptcp_pm_mp_fail_received(struct sock *sk, u64 fail_seq);
|
2022-07-05 21:32:14 +00:00
|
|
|
int mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk,
|
|
|
|
struct mptcp_addr_info *addr,
|
|
|
|
struct mptcp_addr_info *rem,
|
|
|
|
u8 bkup);
|
2022-05-04 02:38:52 +00:00
|
|
|
bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk,
|
2023-06-20 16:30:22 +00:00
|
|
|
const struct mptcp_addr_info *addr);
|
2020-09-24 00:29:54 +00:00
|
|
|
void mptcp_pm_free_anno_list(struct mptcp_sock *msk);
|
2021-02-01 23:09:15 +00:00
|
|
|
bool mptcp_pm_sport_in_anno_list(struct mptcp_sock *msk, const struct sock *sk);
|
2020-09-24 00:30:02 +00:00
|
|
|
struct mptcp_pm_add_entry *
|
|
|
|
mptcp_pm_del_add_timer(struct mptcp_sock *msk,
|
2022-02-16 02:11:28 +00:00
|
|
|
const struct mptcp_addr_info *addr, bool check_id);
|
2021-03-26 18:26:37 +00:00
|
|
|
struct mptcp_pm_add_entry *
|
2022-02-16 02:11:28 +00:00
|
|
|
mptcp_lookup_anno_list_by_saddr(const struct mptcp_sock *msk,
|
|
|
|
const struct mptcp_addr_info *addr);
|
2024-12-13 19:52:55 +00:00
|
|
|
bool mptcp_lookup_subflow_by_saddr(const struct list_head *list,
|
|
|
|
const struct mptcp_addr_info *saddr);
|
|
|
|
bool mptcp_remove_anno_list_by_saddr(struct mptcp_sock *msk,
|
|
|
|
const struct mptcp_addr_info *addr);
|
2024-03-05 11:04:31 +00:00
|
|
|
int mptcp_pm_set_flags(struct sk_buff *skb, struct genl_info *info);
|
|
|
|
int mptcp_pm_nl_set_flags(struct sk_buff *skb, struct genl_info *info);
|
|
|
|
int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info);
|
2020-03-27 21:48:38 +00:00
|
|
|
int mptcp_pm_announce_addr(struct mptcp_sock *msk,
|
2020-09-24 00:29:50 +00:00
|
|
|
const struct mptcp_addr_info *addr,
|
2021-03-26 18:26:31 +00:00
|
|
|
bool echo);
|
2021-03-13 01:16:12 +00:00
|
|
|
int mptcp_pm_remove_addr(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list);
|
2024-12-13 19:52:56 +00:00
|
|
|
void mptcp_pm_remove_addr_entry(struct mptcp_sock *msk,
|
|
|
|
struct mptcp_pm_addr_entry *entry);
|
2022-05-04 02:38:54 +00:00
|
|
|
|
2022-05-04 02:38:49 +00:00
|
|
|
void mptcp_free_local_addr_list(struct mptcp_sock *msk);
|
2020-03-27 21:48:38 +00:00
|
|
|
|
2021-02-13 00:00:01 +00:00
|
|
|
void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk,
|
|
|
|
const struct sock *ssk, gfp_t gfp);
|
2022-05-02 20:52:34 +00:00
|
|
|
void mptcp_event_addr_announced(const struct sock *ssk, const struct mptcp_addr_info *info);
|
2021-02-13 00:00:01 +00:00
|
|
|
void mptcp_event_addr_removed(const struct mptcp_sock *msk, u8 id);
|
2022-11-30 14:06:28 +00:00
|
|
|
void mptcp_event_pm_listener(const struct sock *ssk,
|
|
|
|
enum mptcp_event_type event);
|
2022-05-02 20:52:31 +00:00
|
|
|
bool mptcp_userspace_pm_active(const struct mptcp_sock *msk);
|
2021-02-13 00:00:01 +00:00
|
|
|
|
2024-02-08 18:03:52 +00:00
|
|
|
void __mptcp_fastopen_gen_msk_ackseq(struct mptcp_sock *msk, struct mptcp_subflow_context *subflow,
|
|
|
|
const struct mptcp_options_received *mp_opt);
|
2022-11-25 22:29:51 +00:00
|
|
|
void mptcp_fastopen_subflow_synack_set_params(struct mptcp_subflow_context *subflow,
|
|
|
|
struct request_sock *req);
|
2024-03-01 18:18:26 +00:00
|
|
|
int mptcp_nl_fill_addr(struct sk_buff *skb,
|
|
|
|
struct mptcp_pm_addr_entry *entry);
|
2022-11-25 22:29:50 +00:00
|
|
|
|
2020-09-24 00:29:47 +00:00
|
|
|
static inline bool mptcp_pm_should_add_signal(struct mptcp_sock *msk)
|
2021-08-24 01:05:40 +00:00
|
|
|
{
|
|
|
|
return READ_ONCE(msk->pm.addr_signal) &
|
|
|
|
(BIT(MPTCP_ADD_ADDR_SIGNAL) | BIT(MPTCP_ADD_ADDR_ECHO));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool mptcp_pm_should_add_signal_addr(struct mptcp_sock *msk)
|
2020-03-27 21:48:38 +00:00
|
|
|
{
|
2020-12-09 23:51:27 +00:00
|
|
|
return READ_ONCE(msk->pm.addr_signal) & BIT(MPTCP_ADD_ADDR_SIGNAL);
|
2020-11-19 19:45:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool mptcp_pm_should_add_signal_echo(struct mptcp_sock *msk)
|
|
|
|
{
|
2020-12-09 23:51:27 +00:00
|
|
|
return READ_ONCE(msk->pm.addr_signal) & BIT(MPTCP_ADD_ADDR_ECHO);
|
2020-03-27 21:48:38 +00:00
|
|
|
}
|
|
|
|
|
2020-09-24 00:29:48 +00:00
|
|
|
static inline bool mptcp_pm_should_rm_signal(struct mptcp_sock *msk)
|
|
|
|
{
|
2020-12-09 23:51:27 +00:00
|
|
|
return READ_ONCE(msk->pm.addr_signal) & BIT(MPTCP_RM_ADDR_SIGNAL);
|
2020-09-24 00:29:48 +00:00
|
|
|
}
|
|
|
|
|
2022-04-27 22:49:59 +00:00
|
|
|
static inline bool mptcp_pm_is_userspace(const struct mptcp_sock *msk)
|
|
|
|
{
|
|
|
|
return READ_ONCE(msk->pm.pm_type) == MPTCP_PM_TYPE_USERSPACE;
|
|
|
|
}
|
|
|
|
|
2022-05-02 20:52:31 +00:00
|
|
|
static inline bool mptcp_pm_is_kernel(const struct mptcp_sock *msk)
|
|
|
|
{
|
|
|
|
return READ_ONCE(msk->pm.pm_type) == MPTCP_PM_TYPE_KERNEL;
|
|
|
|
}
|
|
|
|
|
2020-12-09 23:51:22 +00:00
|
|
|
static inline unsigned int mptcp_add_addr_len(int family, bool echo, bool port)
|
2020-03-27 21:48:38 +00:00
|
|
|
{
|
2020-12-09 23:51:21 +00:00
|
|
|
u8 len = TCPOLEN_MPTCP_ADD_ADDR_BASE;
|
|
|
|
|
|
|
|
if (family == AF_INET6)
|
|
|
|
len = TCPOLEN_MPTCP_ADD_ADDR6_BASE;
|
|
|
|
if (!echo)
|
|
|
|
len += MPTCPOPT_THMAC_LEN;
|
mptcp: fix length of ADD_ADDR with port sub-option
in current Linux, MPTCP peers advertising endpoints with port numbers use
a sub-option length that wrongly accounts for the trailing TCP NOP. Also,
receivers will only process incoming ADD_ADDR with port having such wrong
sub-option length. Fix this, making ADD_ADDR compliant to RFC8684 §3.4.1.
this can be verified running tcpdump on the kselftests artifacts:
unpatched kernel:
[root@bottarga mptcp]# tcpdump -tnnr unpatched.pcap | grep add-addr
reading from file unpatched.pcap, link-type LINUX_SLL (Linux cooked v1), snapshot length 65535
IP 10.0.1.1.10000 > 10.0.1.2.53078: Flags [.], ack 101, win 509, options [nop,nop,TS val 214459678 ecr 521312851,mptcp add-addr v1 id 1 a00:201:2774:2d88:7436:85c3:17fd:101], length 0
IP 10.0.1.2.53078 > 10.0.1.1.10000: Flags [.], ack 101, win 502, options [nop,nop,TS val 521312852 ecr 214459678,mptcp add-addr[bad opt]]
patched kernel:
[root@bottarga mptcp]# tcpdump -tnnr patched.pcap | grep add-addr
reading from file patched.pcap, link-type LINUX_SLL (Linux cooked v1), snapshot length 65535
IP 10.0.1.1.10000 > 10.0.1.2.38178: Flags [.], ack 101, win 509, options [nop,nop,TS val 3728873902 ecr 2732713192,mptcp add-addr v1 id 1 10.0.2.1:10100 hmac 0xbccdfcbe59292a1f,nop,nop], length 0
IP 10.0.1.2.38178 > 10.0.1.1.10000: Flags [.], ack 101, win 502, options [nop,nop,TS val 2732713195 ecr 3728873902,mptcp add-addr v1-echo id 1 10.0.2.1:10100,nop,nop], length 0
Fixes: 22fb85ffaefb ("mptcp: add port support for ADD_ADDR suboption writing")
CC: stable@vger.kernel.org # 5.11+
Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Acked-and-tested-by: Geliang Tang <geliangtang@gmail.com>
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-08 09:00:04 +00:00
|
|
|
/* account for 2 trailing 'nop' options */
|
2020-12-09 23:51:22 +00:00
|
|
|
if (port)
|
mptcp: fix length of ADD_ADDR with port sub-option
in current Linux, MPTCP peers advertising endpoints with port numbers use
a sub-option length that wrongly accounts for the trailing TCP NOP. Also,
receivers will only process incoming ADD_ADDR with port having such wrong
sub-option length. Fix this, making ADD_ADDR compliant to RFC8684 §3.4.1.
this can be verified running tcpdump on the kselftests artifacts:
unpatched kernel:
[root@bottarga mptcp]# tcpdump -tnnr unpatched.pcap | grep add-addr
reading from file unpatched.pcap, link-type LINUX_SLL (Linux cooked v1), snapshot length 65535
IP 10.0.1.1.10000 > 10.0.1.2.53078: Flags [.], ack 101, win 509, options [nop,nop,TS val 214459678 ecr 521312851,mptcp add-addr v1 id 1 a00:201:2774:2d88:7436:85c3:17fd:101], length 0
IP 10.0.1.2.53078 > 10.0.1.1.10000: Flags [.], ack 101, win 502, options [nop,nop,TS val 521312852 ecr 214459678,mptcp add-addr[bad opt]]
patched kernel:
[root@bottarga mptcp]# tcpdump -tnnr patched.pcap | grep add-addr
reading from file patched.pcap, link-type LINUX_SLL (Linux cooked v1), snapshot length 65535
IP 10.0.1.1.10000 > 10.0.1.2.38178: Flags [.], ack 101, win 509, options [nop,nop,TS val 3728873902 ecr 2732713192,mptcp add-addr v1 id 1 10.0.2.1:10100 hmac 0xbccdfcbe59292a1f,nop,nop], length 0
IP 10.0.1.2.38178 > 10.0.1.1.10000: Flags [.], ack 101, win 502, options [nop,nop,TS val 2732713195 ecr 3728873902,mptcp add-addr v1-echo id 1 10.0.2.1:10100,nop,nop], length 0
Fixes: 22fb85ffaefb ("mptcp: add port support for ADD_ADDR suboption writing")
CC: stable@vger.kernel.org # 5.11+
Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Acked-and-tested-by: Geliang Tang <geliangtang@gmail.com>
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-08 09:00:04 +00:00
|
|
|
len += TCPOLEN_MPTCP_PORT_LEN + TCPOLEN_MPTCP_PORT_ALIGN;
|
2020-12-09 23:51:21 +00:00
|
|
|
|
|
|
|
return len;
|
2020-03-27 21:48:38 +00:00
|
|
|
}
|
|
|
|
|
2021-03-13 01:16:11 +00:00
|
|
|
static inline int mptcp_rm_addr_len(const struct mptcp_rm_list *rm_list)
|
|
|
|
{
|
|
|
|
if (rm_list->nr == 0 || rm_list->nr > MPTCP_RM_IDS_MAX)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return TCPOLEN_MPTCP_RM_ADDR_BASE + roundup(rm_list->nr - 1, 4) + 1;
|
|
|
|
}
|
|
|
|
|
2022-02-16 02:11:28 +00:00
|
|
|
bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, const struct sk_buff *skb,
|
2021-08-24 01:05:39 +00:00
|
|
|
unsigned int opt_size, unsigned int remaining,
|
2021-08-24 01:05:42 +00:00
|
|
|
struct mptcp_addr_info *addr, bool *echo,
|
2022-02-16 02:11:27 +00:00
|
|
|
bool *drop_other_suboptions);
|
2020-09-24 00:29:48 +00:00
|
|
|
bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
|
2021-03-13 01:16:11 +00:00
|
|
|
struct mptcp_rm_list *rm_list);
|
2020-03-27 21:48:38 +00:00
|
|
|
int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc);
|
2023-06-08 13:20:50 +00:00
|
|
|
int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skc);
|
2022-05-04 02:38:50 +00:00
|
|
|
int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skc);
|
2024-07-27 10:01:28 +00:00
|
|
|
bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc);
|
|
|
|
bool mptcp_pm_nl_is_backup(struct mptcp_sock *msk, struct mptcp_addr_info *skc);
|
|
|
|
bool mptcp_userspace_pm_is_backup(struct mptcp_sock *msk, struct mptcp_addr_info *skc);
|
2024-03-01 18:18:29 +00:00
|
|
|
int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb);
|
|
|
|
int mptcp_pm_nl_dump_addr(struct sk_buff *msg,
|
|
|
|
struct netlink_callback *cb);
|
2024-03-01 18:18:27 +00:00
|
|
|
int mptcp_userspace_pm_dump_addr(struct sk_buff *msg,
|
|
|
|
struct netlink_callback *cb);
|
2024-03-01 18:18:37 +00:00
|
|
|
int mptcp_pm_get_addr(struct sk_buff *skb, struct genl_info *info);
|
|
|
|
int mptcp_pm_nl_get_addr(struct sk_buff *skb, struct genl_info *info);
|
2024-03-01 18:18:36 +00:00
|
|
|
int mptcp_userspace_pm_get_addr(struct sk_buff *skb,
|
|
|
|
struct genl_info *info);
|
2020-03-27 21:48:38 +00:00
|
|
|
|
2024-02-15 18:25:31 +00:00
|
|
|
static inline u8 subflow_get_local_id(const struct mptcp_subflow_context *subflow)
|
|
|
|
{
|
|
|
|
int local_id = READ_ONCE(subflow->local_id);
|
|
|
|
|
|
|
|
if (local_id < 0)
|
|
|
|
return 0;
|
|
|
|
return local_id;
|
|
|
|
}
|
|
|
|
|
2020-06-26 17:29:59 +00:00
|
|
|
void __init mptcp_pm_nl_init(void);
|
2021-02-12 23:59:54 +00:00
|
|
|
void mptcp_pm_nl_work(struct mptcp_sock *msk);
|
2022-02-16 02:11:28 +00:00
|
|
|
unsigned int mptcp_pm_get_add_addr_signal_max(const struct mptcp_sock *msk);
|
|
|
|
unsigned int mptcp_pm_get_add_addr_accept_max(const struct mptcp_sock *msk);
|
|
|
|
unsigned int mptcp_pm_get_subflows_max(const struct mptcp_sock *msk);
|
|
|
|
unsigned int mptcp_pm_get_local_addr_max(const struct mptcp_sock *msk);
|
2021-04-15 23:44:53 +00:00
|
|
|
|
2022-05-12 23:26:41 +00:00
|
|
|
/* called under PM lock */
|
|
|
|
static inline void __mptcp_pm_close_subflow(struct mptcp_sock *msk)
|
|
|
|
{
|
|
|
|
if (--msk->pm.subflows < mptcp_pm_get_subflows_max(msk))
|
|
|
|
WRITE_ONCE(msk->pm.accept_subflow, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void mptcp_pm_close_subflow(struct mptcp_sock *msk)
|
|
|
|
{
|
|
|
|
spin_lock_bh(&msk->pm.lock);
|
|
|
|
__mptcp_pm_close_subflow(msk);
|
|
|
|
spin_unlock_bh(&msk->pm.lock);
|
|
|
|
}
|
|
|
|
|
2022-01-07 00:20:25 +00:00
|
|
|
void mptcp_sockopt_sync_locked(struct mptcp_sock *msk, struct sock *ssk);
|
2020-03-27 21:48:51 +00:00
|
|
|
|
2021-04-01 23:19:44 +00:00
|
|
|
static inline struct mptcp_ext *mptcp_get_ext(const struct sk_buff *skb)
|
2020-01-22 00:56:23 +00:00
|
|
|
{
|
|
|
|
return (struct mptcp_ext *)skb_ext_find(skb, SKB_EXT_MPTCP);
|
|
|
|
}
|
|
|
|
|
2020-03-27 21:48:49 +00:00
|
|
|
void mptcp_diag_subflow_init(struct tcp_ulp_ops *ops);
|
|
|
|
|
2020-09-14 08:01:17 +00:00
|
|
|
static inline bool __mptcp_check_fallback(const struct mptcp_sock *msk)
|
2020-06-29 20:26:20 +00:00
|
|
|
{
|
|
|
|
return test_bit(MPTCP_FALLBACK_DONE, &msk->flags);
|
|
|
|
}
|
|
|
|
|
2020-09-14 08:01:17 +00:00
|
|
|
static inline bool mptcp_check_fallback(const struct sock *sk)
|
2020-06-29 20:26:20 +00:00
|
|
|
{
|
|
|
|
struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
|
|
|
|
struct mptcp_sock *msk = mptcp_sk(subflow->conn);
|
|
|
|
|
|
|
|
return __mptcp_check_fallback(msk);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void __mptcp_do_fallback(struct mptcp_sock *msk)
|
|
|
|
{
|
2023-10-25 23:37:06 +00:00
|
|
|
if (__mptcp_check_fallback(msk)) {
|
mptcp: pr_debug: add missing \n at the end
pr_debug() have been added in various places in MPTCP code to help
developers to debug some situations. With the dynamic debug feature, it
is easy to enable all or some of them, and asks users to reproduce
issues with extra debug.
Many of these pr_debug() don't end with a new line, while no 'pr_cont()'
are used in MPTCP code. So the goal was not to display multiple debug
messages on one line: they were then not missing the '\n' on purpose.
Not having the new line at the end causes these messages to be printed
with a delay, when something else needs to be printed. This issue is not
visible when many messages need to be printed, but it is annoying and
confusing when only specific messages are expected, e.g.
# echo "func mptcp_pm_add_addr_echoed +fmp" \
> /sys/kernel/debug/dynamic_debug/control
# ./mptcp_join.sh "signal address"; \
echo "$(awk '{print $1}' /proc/uptime) - end"; \
sleep 5s; \
echo "$(awk '{print $1}' /proc/uptime) - restart"; \
./mptcp_join.sh "signal address"
013 signal address
(...)
10.75 - end
15.76 - restart
013 signal address
[ 10.367935] mptcp:mptcp_pm_add_addr_echoed: MPTCP: msk=(...)
(...)
=> a delay of 5 seconds: printed with a 10.36 ts, but after 'restart'
which was printed at the 15.76 ts.
The 'Fixes' tag here below points to the first pr_debug() used without
'\n' in net/mptcp. This patch could be split in many small ones, with
different Fixes tag, but it doesn't seem worth it, because it is easy to
re-generate this patch with this simple 'sed' command:
git grep -l pr_debug -- net/mptcp |
xargs sed -i "s/\(pr_debug(\".*[^n]\)\(\"[,)]\)/\1\\\n\2/g"
So in case of conflicts, simply drop the modifications, and launch this
command.
Fixes: f870fa0b5768 ("mptcp: Add MPTCP socket stubs")
Cc: stable@vger.kernel.org
Reviewed-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20240826-net-mptcp-close-extra-sf-fin-v1-4-905199fe1172@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2024-08-26 17:11:21 +00:00
|
|
|
pr_debug("TCP fallback already done (msk=%p)\n", msk);
|
2020-06-29 20:26:20 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
set_bit(MPTCP_FALLBACK_DONE, &msk->flags);
|
|
|
|
}
|
|
|
|
|
2023-11-28 23:18:45 +00:00
|
|
|
static inline bool __mptcp_has_initial_subflow(const struct mptcp_sock *msk)
|
|
|
|
{
|
|
|
|
struct sock *ssk = READ_ONCE(msk->first);
|
|
|
|
|
|
|
|
return ssk && ((1 << inet_sk_state_load(ssk)) &
|
|
|
|
(TCPF_ESTABLISHED | TCPF_SYN_SENT |
|
|
|
|
TCPF_SYN_RECV | TCPF_LISTEN));
|
|
|
|
}
|
|
|
|
|
2022-06-28 01:02:38 +00:00
|
|
|
static inline void mptcp_do_fallback(struct sock *ssk)
|
2020-06-29 20:26:20 +00:00
|
|
|
{
|
2022-06-28 01:02:38 +00:00
|
|
|
struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
|
|
|
|
struct sock *sk = subflow->conn;
|
|
|
|
struct mptcp_sock *msk;
|
2020-06-29 20:26:20 +00:00
|
|
|
|
2022-06-28 01:02:38 +00:00
|
|
|
msk = mptcp_sk(sk);
|
2020-06-29 20:26:20 +00:00
|
|
|
__mptcp_do_fallback(msk);
|
2022-06-28 01:02:38 +00:00
|
|
|
if (READ_ONCE(msk->snd_data_fin_enable) && !(ssk->sk_shutdown & SEND_SHUTDOWN)) {
|
|
|
|
gfp_t saved_allocation = ssk->sk_allocation;
|
|
|
|
|
|
|
|
/* we are in a atomic (BH) scope, override ssk default for data
|
|
|
|
* fin allocation
|
|
|
|
*/
|
|
|
|
ssk->sk_allocation = GFP_ATOMIC;
|
|
|
|
ssk->sk_shutdown |= SEND_SHUTDOWN;
|
|
|
|
tcp_shutdown(ssk, SEND_SHUTDOWN);
|
|
|
|
ssk->sk_allocation = saved_allocation;
|
|
|
|
}
|
2020-06-29 20:26:20 +00:00
|
|
|
}
|
|
|
|
|
mptcp: pr_debug: add missing \n at the end
pr_debug() have been added in various places in MPTCP code to help
developers to debug some situations. With the dynamic debug feature, it
is easy to enable all or some of them, and asks users to reproduce
issues with extra debug.
Many of these pr_debug() don't end with a new line, while no 'pr_cont()'
are used in MPTCP code. So the goal was not to display multiple debug
messages on one line: they were then not missing the '\n' on purpose.
Not having the new line at the end causes these messages to be printed
with a delay, when something else needs to be printed. This issue is not
visible when many messages need to be printed, but it is annoying and
confusing when only specific messages are expected, e.g.
# echo "func mptcp_pm_add_addr_echoed +fmp" \
> /sys/kernel/debug/dynamic_debug/control
# ./mptcp_join.sh "signal address"; \
echo "$(awk '{print $1}' /proc/uptime) - end"; \
sleep 5s; \
echo "$(awk '{print $1}' /proc/uptime) - restart"; \
./mptcp_join.sh "signal address"
013 signal address
(...)
10.75 - end
15.76 - restart
013 signal address
[ 10.367935] mptcp:mptcp_pm_add_addr_echoed: MPTCP: msk=(...)
(...)
=> a delay of 5 seconds: printed with a 10.36 ts, but after 'restart'
which was printed at the 15.76 ts.
The 'Fixes' tag here below points to the first pr_debug() used without
'\n' in net/mptcp. This patch could be split in many small ones, with
different Fixes tag, but it doesn't seem worth it, because it is easy to
re-generate this patch with this simple 'sed' command:
git grep -l pr_debug -- net/mptcp |
xargs sed -i "s/\(pr_debug(\".*[^n]\)\(\"[,)]\)/\1\\\n\2/g"
So in case of conflicts, simply drop the modifications, and launch this
command.
Fixes: f870fa0b5768 ("mptcp: Add MPTCP socket stubs")
Cc: stable@vger.kernel.org
Reviewed-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20240826-net-mptcp-close-extra-sf-fin-v1-4-905199fe1172@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2024-08-26 17:11:21 +00:00
|
|
|
#define pr_fallback(a) pr_debug("%s:fallback to TCP (msk=%p)\n", __func__, a)
|
2020-06-29 20:26:20 +00:00
|
|
|
|
2024-09-09 20:09:21 +00:00
|
|
|
static inline void mptcp_subflow_early_fallback(struct mptcp_sock *msk,
|
|
|
|
struct mptcp_subflow_context *subflow)
|
|
|
|
{
|
|
|
|
pr_fallback(msk);
|
|
|
|
subflow->request_mptcp = 0;
|
|
|
|
__mptcp_do_fallback(msk);
|
|
|
|
}
|
|
|
|
|
2022-04-22 21:55:39 +00:00
|
|
|
static inline bool mptcp_check_infinite_map(struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct mptcp_ext *mpext;
|
|
|
|
|
|
|
|
mpext = skb ? mptcp_get_ext(skb) : NULL;
|
|
|
|
if (mpext && mpext->infinite_map)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-05-02 20:52:35 +00:00
|
|
|
static inline bool is_active_ssk(struct mptcp_subflow_context *subflow)
|
|
|
|
{
|
|
|
|
return (subflow->request_mptcp || subflow->request_join);
|
|
|
|
}
|
|
|
|
|
mptcp: fallback in case of simultaneous connect
when a MPTCP client tries to connect to itself, tcp_finish_connect() is
never reached. Because of this, depending on the socket current state,
multiple faulty behaviours can be observed:
1) a WARN_ON() in subflow_data_ready() is hit
WARNING: CPU: 2 PID: 882 at net/mptcp/subflow.c:911 subflow_data_ready+0x18b/0x230
[...]
CPU: 2 PID: 882 Comm: gh35 Not tainted 5.7.0+ #187
[...]
RIP: 0010:subflow_data_ready+0x18b/0x230
[...]
Call Trace:
tcp_data_queue+0xd2f/0x4250
tcp_rcv_state_process+0xb1c/0x49d3
tcp_v4_do_rcv+0x2bc/0x790
__release_sock+0x153/0x2d0
release_sock+0x4f/0x170
mptcp_shutdown+0x167/0x4e0
__sys_shutdown+0xe6/0x180
__x64_sys_shutdown+0x50/0x70
do_syscall_64+0x9a/0x370
entry_SYSCALL_64_after_hwframe+0x44/0xa9
2) client is stuck forever in mptcp_sendmsg() because the socket is not
TCP_ESTABLISHED
crash> bt 4847
PID: 4847 TASK: ffff88814b2fb100 CPU: 1 COMMAND: "gh35"
#0 [ffff8881376ff680] __schedule at ffffffff97248da4
#1 [ffff8881376ff778] schedule at ffffffff9724a34f
#2 [ffff8881376ff7a0] schedule_timeout at ffffffff97252ba0
#3 [ffff8881376ff8a8] wait_woken at ffffffff958ab4ba
#4 [ffff8881376ff940] sk_stream_wait_connect at ffffffff96c2d859
#5 [ffff8881376ffa28] mptcp_sendmsg at ffffffff97207fca
#6 [ffff8881376ffbc0] sock_sendmsg at ffffffff96be1b5b
#7 [ffff8881376ffbe8] sock_write_iter at ffffffff96be1daa
#8 [ffff8881376ffce8] new_sync_write at ffffffff95e5cb52
#9 [ffff8881376ffe50] vfs_write at ffffffff95e6547f
#10 [ffff8881376ffe90] ksys_write at ffffffff95e65d26
#11 [ffff8881376fff28] do_syscall_64 at ffffffff956088ba
#12 [ffff8881376fff50] entry_SYSCALL_64_after_hwframe at ffffffff9740008c
RIP: 00007f126f6956ed RSP: 00007ffc2a320278 RFLAGS: 00000217
RAX: ffffffffffffffda RBX: 0000000020000044 RCX: 00007f126f6956ed
RDX: 0000000000000004 RSI: 00000000004007b8 RDI: 0000000000000003
RBP: 00007ffc2a3202a0 R8: 0000000000400720 R9: 0000000000400720
R10: 0000000000400720 R11: 0000000000000217 R12: 00000000004004b0
R13: 00007ffc2a320380 R14: 0000000000000000 R15: 0000000000000000
ORIG_RAX: 0000000000000001 CS: 0033 SS: 002b
3) tcpdump captures show that DSS is exchanged even when MP_CAPABLE handshake
didn't complete.
$ tcpdump -tnnr bad.pcap
IP 127.0.0.1.20000 > 127.0.0.1.20000: Flags [S], seq 3208913911, win 65483, options [mss 65495,sackOK,TS val 3291706876 ecr 3291694721,nop,wscale 7,mptcp capable v1], length 0
IP 127.0.0.1.20000 > 127.0.0.1.20000: Flags [S.], seq 3208913911, ack 3208913912, win 65483, options [mss 65495,sackOK,TS val 3291706876 ecr 3291706876,nop,wscale 7,mptcp capable v1], length 0
IP 127.0.0.1.20000 > 127.0.0.1.20000: Flags [.], ack 1, win 512, options [nop,nop,TS val 3291706876 ecr 3291706876], length 0
IP 127.0.0.1.20000 > 127.0.0.1.20000: Flags [F.], seq 1, ack 1, win 512, options [nop,nop,TS val 3291707876 ecr 3291706876,mptcp dss fin seq 0 subseq 0 len 1,nop,nop], length 0
IP 127.0.0.1.20000 > 127.0.0.1.20000: Flags [.], ack 2, win 512, options [nop,nop,TS val 3291707876 ecr 3291707876], length 0
force a fallback to TCP in these cases, and adjust the main socket
state to avoid hanging in mptcp_sendmsg().
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/35
Reported-by: Christoph Paasch <cpaasch@apple.com>
Suggested-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-06-29 20:26:21 +00:00
|
|
|
static inline bool subflow_simultaneous_connect(struct sock *sk)
|
|
|
|
{
|
|
|
|
struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
|
|
|
|
|
2024-02-08 18:03:54 +00:00
|
|
|
return (1 << sk->sk_state) &
|
|
|
|
(TCPF_ESTABLISHED | TCPF_FIN_WAIT1 | TCPF_FIN_WAIT2 | TCPF_CLOSING) &&
|
2022-05-02 20:52:35 +00:00
|
|
|
is_active_ssk(subflow) &&
|
mptcp: fallback in case of simultaneous connect
when a MPTCP client tries to connect to itself, tcp_finish_connect() is
never reached. Because of this, depending on the socket current state,
multiple faulty behaviours can be observed:
1) a WARN_ON() in subflow_data_ready() is hit
WARNING: CPU: 2 PID: 882 at net/mptcp/subflow.c:911 subflow_data_ready+0x18b/0x230
[...]
CPU: 2 PID: 882 Comm: gh35 Not tainted 5.7.0+ #187
[...]
RIP: 0010:subflow_data_ready+0x18b/0x230
[...]
Call Trace:
tcp_data_queue+0xd2f/0x4250
tcp_rcv_state_process+0xb1c/0x49d3
tcp_v4_do_rcv+0x2bc/0x790
__release_sock+0x153/0x2d0
release_sock+0x4f/0x170
mptcp_shutdown+0x167/0x4e0
__sys_shutdown+0xe6/0x180
__x64_sys_shutdown+0x50/0x70
do_syscall_64+0x9a/0x370
entry_SYSCALL_64_after_hwframe+0x44/0xa9
2) client is stuck forever in mptcp_sendmsg() because the socket is not
TCP_ESTABLISHED
crash> bt 4847
PID: 4847 TASK: ffff88814b2fb100 CPU: 1 COMMAND: "gh35"
#0 [ffff8881376ff680] __schedule at ffffffff97248da4
#1 [ffff8881376ff778] schedule at ffffffff9724a34f
#2 [ffff8881376ff7a0] schedule_timeout at ffffffff97252ba0
#3 [ffff8881376ff8a8] wait_woken at ffffffff958ab4ba
#4 [ffff8881376ff940] sk_stream_wait_connect at ffffffff96c2d859
#5 [ffff8881376ffa28] mptcp_sendmsg at ffffffff97207fca
#6 [ffff8881376ffbc0] sock_sendmsg at ffffffff96be1b5b
#7 [ffff8881376ffbe8] sock_write_iter at ffffffff96be1daa
#8 [ffff8881376ffce8] new_sync_write at ffffffff95e5cb52
#9 [ffff8881376ffe50] vfs_write at ffffffff95e6547f
#10 [ffff8881376ffe90] ksys_write at ffffffff95e65d26
#11 [ffff8881376fff28] do_syscall_64 at ffffffff956088ba
#12 [ffff8881376fff50] entry_SYSCALL_64_after_hwframe at ffffffff9740008c
RIP: 00007f126f6956ed RSP: 00007ffc2a320278 RFLAGS: 00000217
RAX: ffffffffffffffda RBX: 0000000020000044 RCX: 00007f126f6956ed
RDX: 0000000000000004 RSI: 00000000004007b8 RDI: 0000000000000003
RBP: 00007ffc2a3202a0 R8: 0000000000400720 R9: 0000000000400720
R10: 0000000000400720 R11: 0000000000000217 R12: 00000000004004b0
R13: 00007ffc2a320380 R14: 0000000000000000 R15: 0000000000000000
ORIG_RAX: 0000000000000001 CS: 0033 SS: 002b
3) tcpdump captures show that DSS is exchanged even when MP_CAPABLE handshake
didn't complete.
$ tcpdump -tnnr bad.pcap
IP 127.0.0.1.20000 > 127.0.0.1.20000: Flags [S], seq 3208913911, win 65483, options [mss 65495,sackOK,TS val 3291706876 ecr 3291694721,nop,wscale 7,mptcp capable v1], length 0
IP 127.0.0.1.20000 > 127.0.0.1.20000: Flags [S.], seq 3208913911, ack 3208913912, win 65483, options [mss 65495,sackOK,TS val 3291706876 ecr 3291706876,nop,wscale 7,mptcp capable v1], length 0
IP 127.0.0.1.20000 > 127.0.0.1.20000: Flags [.], ack 1, win 512, options [nop,nop,TS val 3291706876 ecr 3291706876], length 0
IP 127.0.0.1.20000 > 127.0.0.1.20000: Flags [F.], seq 1, ack 1, win 512, options [nop,nop,TS val 3291707876 ecr 3291706876,mptcp dss fin seq 0 subseq 0 len 1,nop,nop], length 0
IP 127.0.0.1.20000 > 127.0.0.1.20000: Flags [.], ack 2, win 512, options [nop,nop,TS val 3291707876 ecr 3291707876], length 0
force a fallback to TCP in these cases, and adjust the main socket
state to avoid hanging in mptcp_sendmsg().
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/35
Reported-by: Christoph Paasch <cpaasch@apple.com>
Suggested-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-06-29 20:26:21 +00:00
|
|
|
!subflow->conn_finished;
|
|
|
|
}
|
|
|
|
|
2020-07-30 19:25:56 +00:00
|
|
|
#ifdef CONFIG_SYN_COOKIES
|
|
|
|
void subflow_init_req_cookie_join_save(const struct mptcp_subflow_request_sock *subflow_req,
|
|
|
|
struct sk_buff *skb);
|
|
|
|
bool mptcp_token_join_cookie_init_state(struct mptcp_subflow_request_sock *subflow_req,
|
|
|
|
struct sk_buff *skb);
|
|
|
|
void __init mptcp_join_cookie_init(void);
|
|
|
|
#else
|
|
|
|
static inline void
|
|
|
|
subflow_init_req_cookie_join_save(const struct mptcp_subflow_request_sock *subflow_req,
|
|
|
|
struct sk_buff *skb) {}
|
|
|
|
static inline bool
|
|
|
|
mptcp_token_join_cookie_init_state(struct mptcp_subflow_request_sock *subflow_req,
|
|
|
|
struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void mptcp_join_cookie_init(void) {}
|
|
|
|
#endif
|
|
|
|
|
2020-01-22 00:56:15 +00:00
|
|
|
#endif /* __MPTCP_PROTOCOL_H */
|