@@ -219,6 +219,7 @@ static struct config {
219
219
cliConnInfo conn_info ; /* conn_info.hostip is used as unix socket path on ct == VALKEY_CONN_UNIX */
220
220
struct timeval connect_timeout ;
221
221
int tls ;
222
+ int mptcp ;
222
223
cliSSLconfig sslconfig ;
223
224
long repeat ;
224
225
long interval ;
@@ -1639,7 +1640,7 @@ static int cliConnect(int flags) {
1639
1640
cliRefreshPrompt ();
1640
1641
}
1641
1642
1642
- context = valkeyConnectWrapper (config .ct , config .conn_info .hostip , config .conn_info .hostport , config .connect_timeout , 0 );
1643
+ context = valkeyConnectWrapper (config .ct , config .conn_info .hostip , config .conn_info .hostport , config .connect_timeout , 0 , config . mptcp );
1643
1644
1644
1645
if (!context -> err && config .tls ) {
1645
1646
const char * err = NULL ;
@@ -2526,7 +2527,7 @@ static valkeyReply *reconnectingValkeyCommand(valkeyContext *c, const char *fmt,
2526
2527
fflush (stdout );
2527
2528
2528
2529
valkeyFree (c );
2529
- c = valkeyConnectWrapper (config .ct , config .conn_info .hostip , config .conn_info .hostport , config .connect_timeout , 0 );
2530
+ c = valkeyConnectWrapper (config .ct , config .conn_info .hostip , config .conn_info .hostport , config .connect_timeout , 0 , config . mptcp );
2530
2531
if (!c -> err && config .tls ) {
2531
2532
const char * err = NULL ;
2532
2533
if (cliSecureConnection (c , config .sslconfig , & err ) == VALKEY_ERR && err ) {
@@ -2831,6 +2832,8 @@ static int parseOptions(int argc, char **argv) {
2831
2832
}
2832
2833
config .ct = VALKEY_CONN_RDMA ;
2833
2834
#endif
2835
+ } else if (!strcmp (argv [i ], "--mptcp" )) {
2836
+ config .mptcp = 1 ;
2834
2837
} else if (!strcmp (argv [i ], "-v" ) || !strcmp (argv [i ], "--version" )) {
2835
2838
sds version = cliVersion ();
2836
2839
printf ("valkey-cli %s\n" , version );
@@ -2910,6 +2913,11 @@ static int parseOptions(int argc, char **argv) {
2910
2913
exit (1 );
2911
2914
}
2912
2915
2916
+ if (config .mptcp && (config .ct != VALKEY_CONN_TCP )) {
2917
+ fprintf (stderr , "Options --mptcp is only supported by TCP.\n" );
2918
+ exit (1 );
2919
+ }
2920
+
2913
2921
return i ;
2914
2922
}
2915
2923
@@ -3001,6 +3009,7 @@ static void usage(int err) {
3001
3009
" -6 Prefer IPv6 over IPv4 on DNS lookup.\n"
3002
3010
"%s"
3003
3011
"%s"
3012
+ " --mptcp Enable an MPTCP connection.\n"
3004
3013
" --raw Use raw formatting for replies (default when STDOUT is\n"
3005
3014
" not a tty).\n"
3006
3015
" --no-raw Force formatted output even when STDOUT is not a tty.\n"
@@ -3985,7 +3994,7 @@ static int clusterManagerExecTransaction(clusterManagerNode *node, clusterManage
3985
3994
3986
3995
static int clusterManagerNodeConnect (clusterManagerNode * node ) {
3987
3996
if (node -> context ) valkeyFree (node -> context );
3988
- node -> context = valkeyConnectWrapper (config .ct , node -> ip , node -> port , config .connect_timeout , 0 );
3997
+ node -> context = valkeyConnectWrapper (config .ct , node -> ip , node -> port , config .connect_timeout , 0 , config . mptcp );
3989
3998
if (!node -> context -> err && config .tls ) {
3990
3999
const char * err = NULL ;
3991
4000
if (cliSecureConnection (node -> context , config .sslconfig , & err ) == VALKEY_ERR && err ) {
@@ -7727,7 +7736,7 @@ static int clusterManagerCommandImport(int argc, char **argv) {
7727
7736
char * reply_err = NULL ;
7728
7737
valkeyReply * src_reply = NULL ;
7729
7738
// Connect to the source node.
7730
- valkeyContext * src_ctx = valkeyConnectWrapper (config .ct , src_ip , src_port , config .connect_timeout , 0 );
7739
+ valkeyContext * src_ctx = valkeyConnectWrapper (config .ct , src_ip , src_port , config .connect_timeout , 0 , config . mptcp );
7731
7740
if (src_ctx -> err ) {
7732
7741
success = 0 ;
7733
7742
fprintf (stderr , "Could not connect to Valkey at %s:%d: %s.\n" , src_ip , src_port , src_ctx -> errstr );
0 commit comments