Skip to content

Commit 2c9911b

Browse files
committed
Some updates for adapting NetPerfMeter to the mainline Linux kernel's MPTCP API.
1 parent 4c5dd64 commit 2c9911b

File tree

4 files changed

+38
-47
lines changed

4 files changed

+38
-47
lines changed

src/flow.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,8 @@ bool Flow::configureSocket(const int socketDescriptor)
464464
return false;
465465
}
466466

467+
#if 0
468+
// FIXME: OBSOLETE!
467469
if(TrafficSpec.Protocol == IPPROTO_MPTCP) {
468470
// FIXME! Add proper, platform-independent code here!
469471
#ifndef __linux__
@@ -511,6 +513,7 @@ bool Flow::configureSocket(const int socketDescriptor)
511513
}
512514
#endif
513515
}
516+
#endif
514517
const char* congestionControl = TrafficSpec.CongestionControl.c_str();
515518
if(strcmp(congestionControl, "default") != 0) {
516519
if (ext_setsockopt(socketDescriptor, IPPROTO_TCP, TCP_CONGESTION, congestionControl, strlen(congestionControl)) < 0) {

src/netperfmeter.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ static const char* parseTrafficSpecOption(const char* parameters,
358358
exit(1);
359359
}
360360

361-
// ------ Set correct "pseudo-protocol" for MPTCP ---------------------
361+
// ------ Use TCP or MPTCP? -------------------------------------------
362362
if( (trafficSpec.Protocol == IPPROTO_TCP) ||
363363
(trafficSpec.Protocol == IPPROTO_MPTCP) ) {
364364
if(trafficSpec.CMT == NPAF_PRIMARY_PATH) {
@@ -1043,6 +1043,8 @@ void passiveMode(int argc, char** argv, const uint16_t localPort)
10431043
LOG_END
10441044
}
10451045
else {
1046+
#if 0
1047+
// FIXME: OBSOLETE!
10461048
if (ext_setsockopt(gMPTCPSocket, IPPROTO_TCP, MPTCP_PATH_MANAGER_LEGACY, gPathMgr, strlen(gPathMgr)) < 0) {
10471049
if (ext_setsockopt(gMPTCPSocket, IPPROTO_TCP, MPTCP_PATH_MANAGER, gPathMgr, strlen(gPathMgr)) < 0) {
10481050
if(strcmp(gPathMgr, "default") != 0) {
@@ -1063,6 +1065,7 @@ void passiveMode(int argc, char** argv, const uint16_t localPort)
10631065
}
10641066
}
10651067
}
1068+
#endif
10661069
if(setBufferSizes(gMPTCPSocket, gSndBufSize, gRcvBufSize) == false) {
10671070
LOG_FATAL
10681071
stdlog << format("Failed to configure buffer sizes on MPTCP socket %d!",
@@ -1300,7 +1303,7 @@ void activeMode(int argc, char** argv)
13001303
const char* scalarNamePattern = "";
13011304
OutputFileFormat scalarFileFormat = OFF_None;
13021305
const char* configName = "";
1303-
uint8_t protocol = 0;
1306+
int protocol = 0;
13041307
Flow* lastFlow = nullptr;
13051308

13061309
// ------ Handle other parameters ----------------------------------------
@@ -1313,6 +1316,9 @@ void activeMode(int argc, char** argv)
13131316
if(strcmp(argv[i], "-tcp") == 0) {
13141317
protocol = IPPROTO_TCP;
13151318
}
1319+
else if(strcmp(argv[i], "-mptcp") == 0) {
1320+
protocol = IPPROTO_MPTCP;
1321+
}
13161322
else if(strcmp(argv[i], "-udp") == 0) {
13171323
protocol = IPPROTO_UDP;
13181324
}

src/tools.cc

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -508,20 +508,20 @@ const char* getProtocolName(const int protocol)
508508
switch(protocol) {
509509
case IPPROTO_SCTP:
510510
protocolName = "SCTP";
511-
break;
511+
break;
512512
case IPPROTO_TCP:
513513
protocolName = "TCP";
514-
break;
514+
break;
515515
case IPPROTO_MPTCP:
516516
protocolName = "MPTCP";
517-
break;
517+
break;
518518
case IPPROTO_UDP:
519519
protocolName = "UDP";
520-
break;
520+
break;
521521
#ifdef HAVE_DCCP
522522
case IPPROTO_DCCP:
523523
protocolName = "DCCP";
524-
break;
524+
break;
525525
#endif
526526
}
527527
return protocolName;
@@ -584,7 +584,6 @@ int createSocket(const int family,
584584
int socketProtocol = protocol;
585585
#ifdef HAVE_MPTCP
586586
if(socketProtocol == IPPROTO_MPTCP) {
587-
socketProtocol = IPPROTO_TCP;
588587
if(localAddresses > 1) {
589588
printf("WARNING: Currently, MPTCP does not support TCP_MULTIPATH_ADD. Binding to ANY address instead ...\n");
590589
}
@@ -640,7 +639,6 @@ int bindSocket(const int sd,
640639
int socketProtocol = protocol;
641640
#ifdef HAVE_MPTCP
642641
if(socketProtocol == IPPROTO_MPTCP) {
643-
socketProtocol = IPPROTO_TCP;
644642
if(localAddresses > 1) {
645643
printf("WARNING: Currently, MPTCP does not support TCP_MULTIPATH_ADD. Binding to ANY address instead ...\n");
646644
localAddressCount = 0;
@@ -660,21 +658,22 @@ int bindSocket(const int sd,
660658
#else
661659
#error IPV6_V6ONLY not defined?! Please create a bug report and provide some information about your OS!
662660
#endif
661+
// FIXME! OBSOLETE!
663662
// FIXME! Add proper, platform-independent code here!
664-
#ifndef __linux__
665-
#warning MPTCP is currently only available on Linux!
666-
#else
667-
if((protocol == IPPROTO_MPTCP) || (protocol == IPPROTO_TCP)) {
668-
const int cmtOnOff = (protocol == IPPROTO_MPTCP);
669-
if(ext_setsockopt(sd, IPPROTO_TCP, MPTCP_ENABLED_LEGACY, &cmtOnOff, sizeof(cmtOnOff)) < 0) {
670-
if(ext_setsockopt(sd, IPPROTO_TCP, MPTCP_ENABLED, &cmtOnOff, sizeof(cmtOnOff)) < 0) {
671-
if(protocol == IPPROTO_MPTCP) {
672-
return -2;
673-
}
674-
}
675-
}
676-
}
677-
#endif
663+
// #ifndef __linux__
664+
// #warning MPTCP is currently only available on Linux!
665+
// #else
666+
// if((protocol == IPPROTO_MPTCP) || (protocol == IPPROTO_TCP)) {
667+
// const int cmtOnOff = (protocol == IPPROTO_MPTCP);
668+
// if(ext_setsockopt(sd, IPPROTO_TCP, MPTCP_ENABLED_LEGACY, &cmtOnOff, sizeof(cmtOnOff)) < 0) {
669+
// if(ext_setsockopt(sd, IPPROTO_TCP, MPTCP_ENABLED, &cmtOnOff, sizeof(cmtOnOff)) < 0) {
670+
// if(protocol == IPPROTO_MPTCP) {
671+
// return -2;
672+
// }
673+
// }
674+
// }
675+
// }
676+
// #endif
678677

679678
// ====== Bind socket ====================================================
680679
if(localAddressCount == 0) {

src/tools.h

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#define TOOLS_H
3232

3333
#ifdef HAVE_CONFIG_H
34-
#include <config.h>
34+
#include "config.h"
3535
#endif
3636

3737
#include <stdio.h>
@@ -53,33 +53,16 @@
5353
#include "mutex.h"
5454

5555

56-
/* MPTCP as "pseudo-protocol". Just for internal representation. */
57-
#ifndef IPPROTO_MPTCP
58-
#define IPPROTO_MPTCP IPPROTO_EGP // 262
56+
// MPTCP definitions
57+
#ifdef HAVE_MPTCP
58+
#include <linux/mptcp.h>
59+
// #else
60+
// #warning MPTCP is not supported by the API of this system!
5961
#endif
6062

61-
62-
/* FIXME: This is ugly, but currently the only way to easily get the #defines for Linux MPTCP! */
63-
#define MPTCP_ENABLED 42
64-
#define MPTCP_SCHEDULER 43
65-
#define MPTCP_PATH_MANAGER 44
66-
#define MPTCP_INFO 45
67-
#define MPTCP_DEBUG 46
68-
#define MPTCP_NDIFFPORTS 47
69-
70-
#define MPTCP_ENABLED_LEGACY 10002
71-
#define MPTCP_SCHEDULER_LEGACY 10009
72-
#define MPTCP_PATH_MANAGER_LEGACY 10008
73-
#define MPTCP_DEBUG_LEGACY 10001
74-
#define MPTCP_NDIFFPORTS_LEGACY 10007
75-
76-
77-
/* DCCP definitions */
63+
// DCCP definitions
7864
#ifdef HAVE_DCCP
7965
#include <linux/dccp.h>
80-
#ifndef SOL_DCCP
81-
#define SOL_DCCP 269
82-
#endif
8366
// #else
8467
// #warning DCCP is not supported by the API of this system!
8568
#endif

0 commit comments

Comments
 (0)