Skip to content

Commit

Permalink
Issue esnet#1107 support of IP Do-Not-Fragment flag (with debug)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidBar-On committed Jan 31, 2021
1 parent 524a005 commit f9b1039
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 4 deletions.
4 changes: 1 addition & 3 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -13813,9 +13813,7 @@ fi
$as_echo "$iperf3_cv_header_tcp_congestion" >&6; }
if test "x$iperf3_cv_header_tcp_congestion" = "xyes"; then

# DBO >>> $as_echo "#define HAVE_TCP_CONGESTION 1" >>confdefs.h
$as_echo "#undef HAVE_TCP_CONGESTION 1" >>confdefs.h
# <<< DBO */
$as_echo "#define HAVE_TCP_CONGESTION 1" >>confdefs.h

fi

Expand Down
1 change: 1 addition & 0 deletions src/iperf.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ struct iperf_settings
iperf_size_t blocks; /* number of blocks (packets) to send */
char unit_format; /* -f */
int num_ostreams; /* SCTP initmsg settings */
int dont_fragment; /* Whether to set IP flag Do-Not_Fragment */
#if defined(HAVE_SSL)
char *authtoken; /* Authentication token */
char *client_username;
Expand Down
26 changes: 26 additions & 0 deletions src/iperf_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,12 @@ iperf_get_test_connect_timeout(struct iperf_test *ipt)
return ipt->settings->connect_timeout;
}

int
iperf_get_dont_fragment(struct iperf_test *ipt)
{
return ipt->settings->dont_fragment;
}

/************** Setter routines for some fields inside iperf_test *************/

void
Expand Down Expand Up @@ -719,6 +725,11 @@ iperf_set_test_connect_timeout(struct iperf_test* ipt, int ct)
ipt->settings->connect_timeout = ct;
}

void
iperf_set_dont_fragment(struct iperf_test* ipt, int dnf)
{
ipt->settings->dont_fragment = dnf;
}

/********************** Get/set test protocol structure ***********************/

Expand Down Expand Up @@ -950,6 +961,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
{"rsa-private-key-path", required_argument, NULL, OPT_SERVER_RSA_PRIVATE_KEY},
{"authorized-users-path", required_argument, NULL, OPT_SERVER_AUTHORIZED_USERS},
{"time-skew-threshold", required_argument, NULL, OPT_SERVER_SKEW_THRESHOLD},
{"dont-fragment", no_argument, NULL, OPT_DONT_FRAGMENT},
#endif /* HAVE_SSL */
{"fq-rate", required_argument, NULL, OPT_FQ_RATE},
{"pacing-timer", required_argument, NULL, OPT_PACING_TIMER},
Expand Down Expand Up @@ -1369,6 +1381,10 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
return -1;
}
break;
case OPT_DONT_FRAGMENT:
test->settings->dont_fragment = 1;
client_flag = 1;
break;
#endif /* HAVE_SSL */
case OPT_PACING_TIMER:
test->settings->pacing_timer = unit_atoi(optarg);
Expand Down Expand Up @@ -4030,6 +4046,16 @@ iperf_init_stream(struct iperf_stream *sp, struct iperf_test *test)
}
}

/* Set Do-Not-Fragment */
if ((opt = test->settings->dont_fragment)) {
printf("SETTING DONT FRAGMENT\n");
opt = IP_PMTUDISC_DO;
if (setsockopt(sp->socket, IPPROTO_IP, IP_MTU_DISCOVER, &opt, sizeof(opt)) < 0) {
i_errno = IESETDONTFRAGMENT;
return -1;
}
}

return 0;
}

Expand Down
4 changes: 4 additions & 0 deletions src/iperf_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ typedef uint64_t iperf_size_t;
#define OPT_TIMESTAMPS 22
#define OPT_SERVER_SKEW_THRESHOLD 23
#define OPT_BIND_DEV 24
#define OPT_DONT_FRAGMENT 25

/* states */
#define TEST_START 1
Expand Down Expand Up @@ -139,6 +140,7 @@ char* iperf_get_extra_data( struct iperf_test* ipt );
char* iperf_get_iperf_version(void);
int iperf_get_test_no_delay( struct iperf_test* ipt );
int iperf_get_test_connect_timeout( struct iperf_test* ipt );
int iperf_get_dont_fragment( struct iperf_test* ipt );

/* Setter routines for some fields inside iperf_test. */
void iperf_set_verbose( struct iperf_test* ipt, int verbose );
Expand Down Expand Up @@ -176,6 +178,7 @@ void iperf_set_test_tos( struct iperf_test* ipt, int tos );
void iperf_set_test_extra_data( struct iperf_test* ipt, const char *dat );
void iperf_set_test_bidirectional( struct iperf_test* ipt, int bidirectional);
void iperf_set_test_no_delay( struct iperf_test* ipt, int no_delay);
void iperf_set_dont_fragment( struct iperf_test* ipt, int dont_fragment );

#if defined(HAVE_SSL)
void iperf_set_test_client_username(struct iperf_test *ipt, const char *client_username);
Expand Down Expand Up @@ -410,6 +413,7 @@ enum {
IESETBUF2= 141, // Socket buffer size incorrect (written value != read value)
IEAUTHTEST = 142, // Test authorization failed
IEBINDDEV = 143, // Unable to bind-to-device (check perror, maybe permissions?)
IESETDONTFRAGMENT = 144, // Unable to set IP Do-Not-Fragment
/* Stream errors */
IECREATESTREAM = 200, // Unable to create a new stream (check herror/perror)
IEINITSTREAM = 201, // Unable to initialize stream (check herror/perror)
Expand Down
3 changes: 3 additions & 0 deletions src/iperf_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,9 @@ iperf_strerror(int int_errno)
case IESKEWTHRESHOLD:
snprintf(errstr, len, "skew threshold must be a positive number");
break;
case IESETDONTFRAGMENT:
snprintf(errstr, len, "unable to set IP Do-Not-Fragment flag");
break;
default:
snprintf(errstr, len, "int_errno=%d", int_errno);
perr = 1;
Expand Down
1 change: 1 addition & 0 deletions src/iperf_locale.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ const char usage_longstr[] = "Usage: iperf3 [-s|-c host] [options]\n"
" --udp-counters-64bit use 64-bit counters in UDP test packets\n"
" --repeating-payload use repeating pattern in payload, instead of\n"
" randomized payload (like in iperf2)\n"
" --dont-fragment set IP Do-Not-fragment flag\n"
#if defined(HAVE_SSL)
" --username username for authentication\n"
" --rsa-public-key-path path to the RSA public key used to encrypt\n"
Expand Down
2 changes: 1 addition & 1 deletion src/tcp_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void
save_tcpinfo(struct iperf_stream *sp, struct iperf_interval_results *irp)
{
#if (defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__)) && \
defined(TCP_INFO)/*DBO >>> */ && 0 /*<<<DBO*/
defined(TCP_INFO)
socklen_t tcp_info_length = sizeof(struct tcp_info);

if (getsockopt(sp->socket, IPPROTO_TCP, TCP_INFO, (void *)&irp->tcpInfo, &tcp_info_length) < 0)
Expand Down

0 comments on commit f9b1039

Please sign in to comment.