Fix issue #1157 (partial) - support bind device using
Этот коммит содержится в:
родитель
b043b4e245
Коммит
f54b6b4b13
@ -1019,6 +1019,8 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
|
|||||||
char* comma;
|
char* comma;
|
||||||
#endif /* HAVE_CPU_AFFINITY */
|
#endif /* HAVE_CPU_AFFINITY */
|
||||||
char* slash;
|
char* slash;
|
||||||
|
char *p, *p1;
|
||||||
|
struct in6_addr ipv6_addr;
|
||||||
struct xbind_entry *xbe;
|
struct xbind_entry *xbe;
|
||||||
double farg;
|
double farg;
|
||||||
int rcv_timeout_in = 0;
|
int rcv_timeout_in = 0;
|
||||||
@ -1101,6 +1103,26 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
iperf_set_test_role(test, 'c');
|
iperf_set_test_role(test, 'c');
|
||||||
iperf_set_test_server_hostname(test, optarg);
|
iperf_set_test_server_hostname(test, optarg);
|
||||||
|
// hostname should be extended with `%<dev>` for IPv6 link-local addresses
|
||||||
|
if ((p = strtok(optarg, "%")) != NULL) {
|
||||||
|
p1 = strtok(NULL, "%");
|
||||||
|
if (inet_pton(AF_INET6, p, &ipv6_addr) == 1) {
|
||||||
|
if (IN6_IS_ADDR_LINKLOCAL(&ipv6_addr)) {
|
||||||
|
if (!p1) {
|
||||||
|
i_errno = IEHOSTDEV;
|
||||||
|
}
|
||||||
|
} else if (p1) {
|
||||||
|
i_errno = IEHOSTDEV;
|
||||||
|
}
|
||||||
|
} else { //IPv4
|
||||||
|
if (p1) {
|
||||||
|
i_errno = IEHOSTDEV;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i_errno == IEHOSTDEV) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
set_protocol(test, Pudp);
|
set_protocol(test, Pudp);
|
||||||
@ -1213,7 +1235,20 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
|
|||||||
client_flag = 1;
|
client_flag = 1;
|
||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
test->bind_address = strdup(optarg);
|
// IP ddress format is <addr>[%<device>]
|
||||||
|
if ((p = strtok(optarg, "%")) == NULL)
|
||||||
|
test->bind_address = strdup(optarg);
|
||||||
|
else {
|
||||||
|
test->bind_address = strdup(p);
|
||||||
|
if ((p = strtok(NULL, "%")) != NULL) {
|
||||||
|
#if defined (HAVE_SO_BINDTODEVICE)
|
||||||
|
test->bind_dev = strdup(p);
|
||||||
|
#else /* HAVE_SO_BINDTODEVICE */
|
||||||
|
i_errno = IEBINDDEVNOSUPPORT;
|
||||||
|
return -1;
|
||||||
|
#endif /* HAVE_SO_BINDTODEVICE */
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#if defined (HAVE_SO_BINDTODEVICE)
|
#if defined (HAVE_SO_BINDTODEVICE)
|
||||||
case OPT_BIND_DEV:
|
case OPT_BIND_DEV:
|
||||||
|
@ -425,7 +425,9 @@ enum {
|
|||||||
IEAUTHTEST = 142, // Test authorization failed
|
IEAUTHTEST = 142, // Test authorization failed
|
||||||
IEBINDDEV = 143, // Unable to bind-to-device (check perror, maybe permissions?)
|
IEBINDDEV = 143, // Unable to bind-to-device (check perror, maybe permissions?)
|
||||||
IENOMSG = 144, // No message was received for NO_MSG_RCVD_TIMEOUT time period
|
IENOMSG = 144, // No message was received for NO_MSG_RCVD_TIMEOUT time period
|
||||||
IESETDONTFRAGMENT = 145, // Unable to set IP Do-Not-Fragment
|
IESETDONTFRAGMENT = 145, // Unable to set IP Do-Not-Fragment
|
||||||
|
IEBINDDEVNOSUPPORT = 146, // `ip%%dev` is not supported as system does not support bind to device
|
||||||
|
IEHOSTDEV = 147, // host device name (ip%%<dev>) is supported (and required) only for IPv6 link-local address
|
||||||
/* Stream errors */
|
/* Stream errors */
|
||||||
IECREATESTREAM = 200, // Unable to create a new stream (check herror/perror)
|
IECREATESTREAM = 200, // Unable to create a new stream (check herror/perror)
|
||||||
IEINITSTREAM = 201, // Unable to initialize stream (check herror/perror)
|
IEINITSTREAM = 201, // Unable to initialize stream (check herror/perror)
|
||||||
|
@ -438,6 +438,15 @@ iperf_strerror(int int_errno)
|
|||||||
case IEIDLETIMEOUT:
|
case IEIDLETIMEOUT:
|
||||||
snprintf(errstr, len, "idle timeout parameter is not positive or larget then allowed limit");
|
snprintf(errstr, len, "idle timeout parameter is not positive or larget then allowed limit");
|
||||||
break;
|
break;
|
||||||
|
case IEBINDDEV:
|
||||||
|
snprintf(errstr, len, "Unable to bind-to-device (check perror, maybe permissions?)");
|
||||||
|
break;
|
||||||
|
case IEBINDDEVNOSUPPORT:
|
||||||
|
snprintf(errstr, len, "`<ip>%%<dev>` is not supported as system does not support bind to device");
|
||||||
|
break;
|
||||||
|
case IEHOSTDEV:
|
||||||
|
snprintf(errstr, len, "host device name (ip%%<dev>) is supported (and required) only for IPv6 link-local address");
|
||||||
|
break;
|
||||||
case IENOMSG:
|
case IENOMSG:
|
||||||
snprintf(errstr, len, "idle timeout for receiving data");
|
snprintf(errstr, len, "idle timeout for receiving data");
|
||||||
break;
|
break;
|
||||||
|
@ -105,9 +105,12 @@ const char usage_longstr[] = "Usage: iperf3 [-s|-c host] [options]\n"
|
|||||||
#if defined(HAVE_CPU_AFFINITY)
|
#if defined(HAVE_CPU_AFFINITY)
|
||||||
" -A, --affinity n/n,m set CPU affinity\n"
|
" -A, --affinity n/n,m set CPU affinity\n"
|
||||||
#endif /* HAVE_CPU_AFFINITY */
|
#endif /* HAVE_CPU_AFFINITY */
|
||||||
" -B, --bind <host> bind to the interface associated with the address <host>\n"
|
|
||||||
#if defined(HAVE_SO_BINDTODEVICE)
|
#if defined(HAVE_SO_BINDTODEVICE)
|
||||||
" --bind-dev <dev> bind to the network interface with SO_BINDTODEVICE\n"
|
" -B, --bind <host>[%<dev>] bind to the interface associated with the address <host>\n"
|
||||||
|
" (optional <dev> equivalent to `--bind-dev <dev>`)\n"
|
||||||
|
" --bind-dev <dev> bind to the network interface with SO_BINDTODEVICE\n"
|
||||||
|
#else /* HAVE_SO_BINDTODEVICE */
|
||||||
|
" -B, --bind <host> bind to the interface associated with the address <host>\n"
|
||||||
#endif /* HAVE_SO_BINDTODEVICE */
|
#endif /* HAVE_SO_BINDTODEVICE */
|
||||||
" -V, --verbose more detailed output\n"
|
" -V, --verbose more detailed output\n"
|
||||||
" -J, --json output in JSON format\n"
|
" -J, --json output in JSON format\n"
|
||||||
@ -139,7 +142,8 @@ const char usage_longstr[] = "Usage: iperf3 [-s|-c host] [options]\n"
|
|||||||
" and client during the authentication process\n"
|
" and client during the authentication process\n"
|
||||||
#endif //HAVE_SSL
|
#endif //HAVE_SSL
|
||||||
"Client specific:\n"
|
"Client specific:\n"
|
||||||
" -c, --client <host> run in client mode, connecting to <host>\n"
|
" -c, --client <host>[%<dev>] run in client mode, connecting to <host>\n"
|
||||||
|
" %<dev> is supported and required when <host> is IPv6 Link-local\n"
|
||||||
#if defined(HAVE_SCTP_H)
|
#if defined(HAVE_SCTP_H)
|
||||||
" --sctp use SCTP rather than TCP\n"
|
" --sctp use SCTP rather than TCP\n"
|
||||||
" -X, --xbind <name> bind SCTP association to links\n"
|
" -X, --xbind <name> bind SCTP association to links\n"
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user