summaryrefslogtreecommitdiffstats
path: root/debian/patches/progress-linux/0005-mptcp-support.patch
blob: 0d9fb158ff7f6315e6decdfb7deaea63a1a3abad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
Author: mpostaire <maxime_postaire@hotmail.fr>
Description: Add MPTCP support.
 https://github.com/openssh/openssh-portable/pull/335

diff -Naurp openssh.orig/readconf.c openssh/readconf.c
--- openssh.orig/readconf.c
+++ openssh/readconf.c
@@ -179,7 +179,7 @@ typedef enum {
 	oSecurityKeyProvider, oKnownHostsCommand, oRequiredRSASize,
 	oEnableEscapeCommandline,
 	oProtocolKeepAlives, oSetupTimeOut,
-	oIgnore, oIgnoredUnknownOption, oDeprecated, oUnsupported
+	oIgnore, oIgnoredUnknownOption, oDeprecated, oUnsupported, oUseMPTCP
 } OpCodes;
 
 /* Textual representations of the tokens. */
@@ -341,6 +341,7 @@ static struct {
 	{ "enableescapecommandline", oEnableEscapeCommandline },
 	{ "protocolkeepalives", oProtocolKeepAlives },
 	{ "setuptimeout", oSetupTimeOut },
+	{ "usemptcp", oUseMPTCP},
 
 	{ NULL, oBadOption }
 };
@@ -2245,6 +2246,10 @@ parse_pubkey_algos:
 		intptr = &options->required_rsa_size;
 		goto parse_int;
 
+	case oUseMPTCP:
+		intptr = &options->use_mptcp;
+		goto parse_flag;
+
 	case oDeprecated:
 		debug("%s line %d: Deprecated option \"%s\"",
 		    filename, linenum, keyword);
@@ -2500,6 +2505,7 @@ initialize_options(Options * options)
 	options->known_hosts_command = NULL;
 	options->required_rsa_size = -1;
 	options->enable_escape_commandline = -1;
+	options->use_mptcp = -1;
 }
 
 /*
@@ -2704,6 +2710,8 @@ fill_default_options(Options * options)
 		options->canonicalize_hostname = SSH_CANONICALISE_NO;
 	if (options->fingerprint_hash == -1)
 		options->fingerprint_hash = SSH_FP_HASH_DEFAULT;
+	if (options->use_mptcp == -1)
+		options->use_mptcp = 0;
 #ifdef ENABLE_SK_INTERNAL
 	if (options->sk_provider == NULL)
 		options->sk_provider = xstrdup("internal");
@@ -3405,6 +3413,7 @@ dump_client_config(Options *o, const cha
 	dump_cfg_fmtint(oVisualHostKey, o->visual_host_key);
 	dump_cfg_fmtint(oUpdateHostkeys, o->update_hostkeys);
 	dump_cfg_fmtint(oEnableEscapeCommandline, o->enable_escape_commandline);
+	dump_cfg_fmtint(oUseMPTCP, o->use_mptcp);
 
 	/* Integer options */
 	dump_cfg_int(oCanonicalizeMaxDots, o->canonicalize_max_dots);
diff -Naurp openssh.orig/readconf.h openssh/readconf.h
--- openssh.orig/readconf.h
+++ openssh/readconf.h
@@ -187,6 +187,7 @@ typedef struct {
 	int	enable_escape_commandline;	/* ~C commandline */
 
 	char	*ignored_unknown; /* Pattern list of unknown tokens to ignore */
+	int	use_mptcp; /* decides whether to use multipath TCP */
 }       Options;
 
 #define SSH_PUBKEY_AUTH_NO	0x00
diff -Naurp openssh.orig/servconf.c openssh/servconf.c
--- openssh.orig/servconf.c
+++ openssh/servconf.c
@@ -203,6 +203,7 @@ initialize_server_options(ServerOptions
 	options->num_channel_timeouts = 0;
 	options->unused_connection_timeout = -1;
 	options->debian_banner = -1;
+	options->use_mptcp = -1;
 }
 
 /* Returns 1 if a string option is unset or set to "none" or 0 otherwise. */
@@ -463,6 +464,8 @@ fill_default_server_options(ServerOption
 		options->unused_connection_timeout = 0;
 	if (options->debian_banner == -1)
 		options->debian_banner = 1;
+	if (options->use_mptcp == -1)
+		options->use_mptcp = 0;
 
 	assemble_algorithms(options);
 
@@ -549,7 +552,7 @@ typedef enum {
 	sExposeAuthInfo, sRDomain, sPubkeyAuthOptions, sSecurityKeyProvider,
 	sRequiredRSASize, sChannelTimeout, sUnusedConnectionTimeout,
 	sDebianBanner,
-	sDeprecated, sIgnore, sUnsupported
+	sDeprecated, sIgnore, sUnsupported, sUseMPTCP
 } ServerOpCodes;
 
 #define SSHCFG_GLOBAL		0x01	/* allowed in main section of config */
@@ -723,6 +726,7 @@ static struct {
 	{ "channeltimeout", sChannelTimeout, SSHCFG_ALL },
 	{ "unusedconnectiontimeout", sUnusedConnectionTimeout, SSHCFG_ALL },
 	{ "debianbanner", sDebianBanner, SSHCFG_GLOBAL },
+	{ "usemptcp", sUseMPTCP, SSHCFG_GLOBAL},
 	{ NULL, sBadOption, 0 }
 };
 
@@ -2604,6 +2608,10 @@ process_server_config_line_depth(ServerO
 		intptr = &options->debian_banner;
 		goto parse_flag;
 
+	case sUseMPTCP:
+		intptr = &options->use_mptcp;
+		goto parse_flag;
+
 	case sDeprecated:
 	case sIgnore:
 	case sUnsupported:
@@ -3107,6 +3115,7 @@ dump_config(ServerOptions *o)
 	dump_cfg_fmtint(sStreamLocalBindUnlink, o->fwd_opts.streamlocal_bind_unlink);
 	dump_cfg_fmtint(sFingerprintHash, o->fingerprint_hash);
 	dump_cfg_fmtint(sExposeAuthInfo, o->expose_userauth_info);
+	dump_cfg_fmtint(sUseMPTCP, o->use_mptcp);
 
 	/* string arguments */
 	dump_cfg_string(sPidFile, o->pid_file);
diff -Naurp openssh.orig/servconf.h openssh/servconf.h
--- openssh.orig/servconf.h
+++ openssh/servconf.h
@@ -240,6 +240,7 @@ typedef struct {
 	int	unused_connection_timeout;
 
 	int	debian_banner;
+	int	use_mptcp;
 }       ServerOptions;
 
 /* Information about the incoming connection as used by Match */
diff -Naurp openssh.orig/ssh_config openssh/ssh_config
--- openssh.orig/ssh_config
+++ openssh/ssh_config
@@ -49,5 +49,6 @@ Host *
 #   ProxyJump gateway.example.com
 #   RekeyLimit 1G 1h
 #   UserKnownHostsFile ~/.ssh/known_hosts.d/%k
+#   UseMPTCP no
     SendEnv LANG LC_*
     HashKnownHosts yes
diff -Naurp openssh.orig/sshconnect.c openssh/sshconnect.c
--- openssh.orig/sshconnect.c
+++ openssh/sshconnect.c
@@ -358,7 +358,10 @@ ssh_create_socket(struct addrinfo *ai)
 #endif
 	char ntop[NI_MAXHOST];
 
-	sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+	if (options.use_mptcp)
+		sock = socket(ai->ai_family, ai->ai_socktype, IPPROTO_MPTCP);
+	else
+		sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
 	if (sock == -1) {
 		error("socket: %s", strerror(errno));
 		return -1;
diff -Naurp openssh.orig/sshd.c openssh/sshd.c
--- openssh.orig/sshd.c
+++ openssh/sshd.c
@@ -1092,8 +1092,13 @@ listen_on_addrs(struct listenaddr *la)
 			continue;
 		}
 		/* Create socket for listening. */
-		listen_sock = socket(ai->ai_family, ai->ai_socktype,
-		    ai->ai_protocol);
+		if (options.use_mptcp) {
+			listen_sock = socket(ai->ai_family, ai->ai_socktype,
+				IPPROTO_MPTCP);
+		} else {
+			listen_sock = socket(ai->ai_family, ai->ai_socktype,
+				ai->ai_protocol);
+		}
 		if (listen_sock == -1) {
 			/* kernel may not support ipv6 */
 			verbose("socket: %.100s", strerror(errno));
diff -Naurp openssh.orig/sshd_config openssh/sshd_config
--- openssh.orig/sshd_config
+++ openssh/sshd_config
@@ -105,6 +105,7 @@ PrintMotd no
 #PermitTunnel no
 #ChrootDirectory none
 #VersionAddendum none
+#UseMPTCP no
 
 # no default banner path
 #Banner none