Skip to content

Commit c189b54

Browse files
committed
Merge branch 'mptcp-multiple-subflows-path-management'
Mat Martineau says: ==================== Multipath TCP part 3: Multiple subflows and path management v2 -> v3: Remove 'inline' in .c files, fix uapi bit macros, and rebase. v1 -> v2: Rebase on current net-next, fix for netlink limit setting, and update .gitignore for selftest. This patch set allows more than one TCP subflow to be established and used for a multipath TCP connection. Subflows are added to an existing connection using the MP_JOIN option during the 3-way handshake. With multiple TCP subflows available, sent data is now stored in the MPTCP socket so it may be retransmitted on any TCP subflow if there is no DATA_ACK before a timeout. If an MPTCP-level timeout occurs, data is retransmitted using an available subflow. Storing this sent data requires the addition of memory accounting at the MPTCP level, which was previously delegated to the single subflow. Incoming DATA_ACKs now free data from the MPTCP-level retransmit buffer. IP addresses available for new subflow connections can now be advertised and received with the ADD_ADDR option, and the corresponding REMOVE_ADDR option likewise advertises that an address is no longer available. The MPTCP path manager netlink interface has commands to set in-kernel limits for the number of concurrent subflows and control the advertisement of IP addresses between peers. To track and debug MPTCP connections there are new MPTCP MIB counters, and subflow context can be requested using inet_diag. The MPTCP self-tests now validate multiple-subflow operation and the netlink path manager interface. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 41b1450 + b08fbf2 commit c189b54

File tree

27 files changed

+4158
-125
lines changed

27 files changed

+4158
-125
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11727,6 +11727,7 @@ W: https://github.com/multipath-tcp/mptcp_net-next/wiki
1172711727
B: https://github.com/multipath-tcp/mptcp_net-next/issues
1172811728
S: Maintained
1172911729
F: include/net/mptcp.h
11730+
F: include/uapi/linux/mptcp.h
1173011731
F: net/mptcp/
1173111732
F: tools/testing/selftests/net/mptcp/
1173211733

include/linux/tcp.h

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,36 @@ struct mptcp_options_received {
8686
u64 data_seq;
8787
u32 subflow_seq;
8888
u16 data_len;
89-
u8 mp_capable : 1,
89+
u16 mp_capable : 1,
9090
mp_join : 1,
91-
dss : 1;
91+
dss : 1,
92+
add_addr : 1,
93+
rm_addr : 1,
94+
family : 4,
95+
echo : 1,
96+
backup : 1;
97+
u32 token;
98+
u32 nonce;
99+
u64 thmac;
100+
u8 hmac[20];
101+
u8 join_id;
92102
u8 use_map:1,
93103
dsn64:1,
94104
data_fin:1,
95105
use_ack:1,
96106
ack64:1,
97107
mpc_map:1,
98108
__unused:2;
109+
u8 addr_id;
110+
u8 rm_id;
111+
union {
112+
struct in_addr addr;
113+
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
114+
struct in6_addr addr6;
115+
#endif
116+
};
117+
u64 ahmac;
118+
u16 port;
99119
};
100120
#endif
101121

@@ -131,6 +151,8 @@ static inline void tcp_clear_options(struct tcp_options_received *rx_opt)
131151
#if IS_ENABLED(CONFIG_MPTCP)
132152
rx_opt->mptcp.mp_capable = 0;
133153
rx_opt->mptcp.mp_join = 0;
154+
rx_opt->mptcp.add_addr = 0;
155+
rx_opt->mptcp.rm_addr = 0;
134156
rx_opt->mptcp.dss = 0;
135157
#endif
136158
}

include/net/mptcp.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include <linux/tcp.h>
1313
#include <linux/types.h>
1414

15+
struct seq_file;
16+
1517
/* MPTCP sk_buff extension data */
1618
struct mptcp_ext {
1719
u64 data_ack;
@@ -33,6 +35,21 @@ struct mptcp_out_options {
3335
u16 suboptions;
3436
u64 sndr_key;
3537
u64 rcvr_key;
38+
union {
39+
struct in_addr addr;
40+
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
41+
struct in6_addr addr6;
42+
#endif
43+
};
44+
u8 addr_id;
45+
u64 ahmac;
46+
u8 rm_id;
47+
u8 join_id;
48+
u8 backup;
49+
u32 nonce;
50+
u64 thmac;
51+
u32 token;
52+
u8 hmac[20];
3653
struct mptcp_ext ext_copy;
3754
#endif
3855
};
@@ -106,6 +123,9 @@ static inline bool mptcp_skb_can_collapse(const struct sk_buff *to,
106123
skb_ext_find(from, SKB_EXT_MPTCP));
107124
}
108125

126+
bool mptcp_sk_is_subflow(const struct sock *sk);
127+
128+
void mptcp_seq_show(struct seq_file *seq);
109129
#else
110130

111131
static inline void mptcp_init(void)
@@ -172,6 +192,12 @@ static inline bool mptcp_skb_can_collapse(const struct sk_buff *to,
172192
return true;
173193
}
174194

195+
static inline bool mptcp_sk_is_subflow(const struct sock *sk)
196+
{
197+
return false;
198+
}
199+
200+
static inline void mptcp_seq_show(struct seq_file *seq) { }
175201
#endif /* CONFIG_MPTCP */
176202

177203
#if IS_ENABLED(CONFIG_MPTCP_IPV6)

include/net/netns/mib.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ struct netns_mib {
2727
#if IS_ENABLED(CONFIG_TLS)
2828
DEFINE_SNMP_STAT(struct linux_tls_mib, tls_statistics);
2929
#endif
30+
#ifdef CONFIG_MPTCP
31+
DEFINE_SNMP_STAT(struct mptcp_mib, mptcp_statistics);
32+
#endif
3033
};
3134

3235
#endif

include/uapi/linux/inet_diag.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ enum {
166166
INET_ULP_INFO_UNSPEC,
167167
INET_ULP_INFO_NAME,
168168
INET_ULP_INFO_TLS,
169+
INET_ULP_INFO_MPTCP,
169170
__INET_ULP_INFO_MAX,
170171
};
171172
#define INET_ULP_INFO_MAX (__INET_ULP_INFO_MAX - 1)

include/uapi/linux/mptcp.h

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2+
#ifndef _UAPI_MPTCP_H
3+
#define _UAPI_MPTCP_H
4+
5+
#include <linux/const.h>
6+
#include <linux/types.h>
7+
8+
#define MPTCP_SUBFLOW_FLAG_MCAP_REM _BITUL(0)
9+
#define MPTCP_SUBFLOW_FLAG_MCAP_LOC _BITUL(1)
10+
#define MPTCP_SUBFLOW_FLAG_JOIN_REM _BITUL(2)
11+
#define MPTCP_SUBFLOW_FLAG_JOIN_LOC _BITUL(3)
12+
#define MPTCP_SUBFLOW_FLAG_BKUP_REM _BITUL(4)
13+
#define MPTCP_SUBFLOW_FLAG_BKUP_LOC _BITUL(5)
14+
#define MPTCP_SUBFLOW_FLAG_FULLY_ESTABLISHED _BITUL(6)
15+
#define MPTCP_SUBFLOW_FLAG_CONNECTED _BITUL(7)
16+
#define MPTCP_SUBFLOW_FLAG_MAPVALID _BITUL(8)
17+
18+
enum {
19+
MPTCP_SUBFLOW_ATTR_UNSPEC,
20+
MPTCP_SUBFLOW_ATTR_TOKEN_REM,
21+
MPTCP_SUBFLOW_ATTR_TOKEN_LOC,
22+
MPTCP_SUBFLOW_ATTR_RELWRITE_SEQ,
23+
MPTCP_SUBFLOW_ATTR_MAP_SEQ,
24+
MPTCP_SUBFLOW_ATTR_MAP_SFSEQ,
25+
MPTCP_SUBFLOW_ATTR_SSN_OFFSET,
26+
MPTCP_SUBFLOW_ATTR_MAP_DATALEN,
27+
MPTCP_SUBFLOW_ATTR_FLAGS,
28+
MPTCP_SUBFLOW_ATTR_ID_REM,
29+
MPTCP_SUBFLOW_ATTR_ID_LOC,
30+
MPTCP_SUBFLOW_ATTR_PAD,
31+
__MPTCP_SUBFLOW_ATTR_MAX
32+
};
33+
34+
#define MPTCP_SUBFLOW_ATTR_MAX (__MPTCP_SUBFLOW_ATTR_MAX - 1)
35+
36+
/* netlink interface */
37+
#define MPTCP_PM_NAME "mptcp_pm"
38+
#define MPTCP_PM_CMD_GRP_NAME "mptcp_pm_cmds"
39+
#define MPTCP_PM_VER 0x1
40+
41+
/*
42+
* ATTR types defined for MPTCP
43+
*/
44+
enum {
45+
MPTCP_PM_ATTR_UNSPEC,
46+
47+
MPTCP_PM_ATTR_ADDR, /* nested address */
48+
MPTCP_PM_ATTR_RCV_ADD_ADDRS, /* u32 */
49+
MPTCP_PM_ATTR_SUBFLOWS, /* u32 */
50+
51+
__MPTCP_PM_ATTR_MAX
52+
};
53+
54+
#define MPTCP_PM_ATTR_MAX (__MPTCP_PM_ATTR_MAX - 1)
55+
56+
enum {
57+
MPTCP_PM_ADDR_ATTR_UNSPEC,
58+
59+
MPTCP_PM_ADDR_ATTR_FAMILY, /* u16 */
60+
MPTCP_PM_ADDR_ATTR_ID, /* u8 */
61+
MPTCP_PM_ADDR_ATTR_ADDR4, /* struct in_addr */
62+
MPTCP_PM_ADDR_ATTR_ADDR6, /* struct in6_addr */
63+
MPTCP_PM_ADDR_ATTR_PORT, /* u16 */
64+
MPTCP_PM_ADDR_ATTR_FLAGS, /* u32 */
65+
MPTCP_PM_ADDR_ATTR_IF_IDX, /* s32 */
66+
67+
__MPTCP_PM_ADDR_ATTR_MAX
68+
};
69+
70+
#define MPTCP_PM_ADDR_ATTR_MAX (__MPTCP_PM_ADDR_ATTR_MAX - 1)
71+
72+
#define MPTCP_PM_ADDR_FLAG_SIGNAL (1 << 0)
73+
#define MPTCP_PM_ADDR_FLAG_SUBFLOW (1 << 1)
74+
#define MPTCP_PM_ADDR_FLAG_BACKUP (1 << 2)
75+
76+
enum {
77+
MPTCP_PM_CMD_UNSPEC,
78+
79+
MPTCP_PM_CMD_ADD_ADDR,
80+
MPTCP_PM_CMD_DEL_ADDR,
81+
MPTCP_PM_CMD_GET_ADDR,
82+
MPTCP_PM_CMD_FLUSH_ADDRS,
83+
MPTCP_PM_CMD_SET_LIMITS,
84+
MPTCP_PM_CMD_GET_LIMITS,
85+
86+
__MPTCP_PM_CMD_AFTER_LAST
87+
};
88+
89+
#endif /* _UAPI_MPTCP_H */

net/ipv4/af_inet.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,6 +1793,10 @@ static __net_exit void ipv4_mib_exit_net(struct net *net)
17931793
free_percpu(net->mib.net_statistics);
17941794
free_percpu(net->mib.ip_statistics);
17951795
free_percpu(net->mib.tcp_statistics);
1796+
#ifdef CONFIG_MPTCP
1797+
/* allocated on demand, see mptcp_init_sock() */
1798+
free_percpu(net->mib.mptcp_statistics);
1799+
#endif
17961800
}
17971801

17981802
static __net_initdata struct pernet_operations ipv4_mib_ops = {

net/ipv4/proc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <net/icmp.h>
3333
#include <net/protocol.h>
3434
#include <net/tcp.h>
35+
#include <net/mptcp.h>
3536
#include <net/udp.h>
3637
#include <net/udplite.h>
3738
#include <linux/bottom_half.h>
@@ -485,6 +486,7 @@ static int netstat_seq_show(struct seq_file *seq, void *v)
485486
offsetof(struct ipstats_mib, syncp)));
486487

487488
seq_putc(seq, '\n');
489+
mptcp_seq_show(seq);
488490
return 0;
489491
}
490492

net/ipv4/tcp_minisocks.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,12 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,
774774
if (!child)
775775
goto listen_overflow;
776776

777+
if (own_req && sk_is_mptcp(child) && mptcp_sk_is_subflow(child)) {
778+
reqsk_queue_removed(&inet_csk(sk)->icsk_accept_queue, req);
779+
inet_csk_reqsk_queue_drop_and_put(sk, req);
780+
return child;
781+
}
782+
777783
sock_rps_save_rxhash(child, skb);
778784
tcp_synack_rtt_meas(child, req);
779785
*req_stolen = !own_req;

net/mptcp/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# SPDX-License-Identifier: GPL-2.0
22
obj-$(CONFIG_MPTCP) += mptcp.o
33

4-
mptcp-y := protocol.o subflow.o options.o token.o crypto.o ctrl.o
4+
mptcp-y := protocol.o subflow.o options.o token.o crypto.o ctrl.o pm.o diag.o \
5+
mib.o pm_netlink.o

0 commit comments

Comments
 (0)