diff --git a/src/tcpkali.c b/src/tcpkali.c index e0e09fb..0d06d92 100644 --- a/src/tcpkali.c +++ b/src/tcpkali.c @@ -105,6 +105,7 @@ static struct option cli_long_options[] = { {"server", 1, 0, 'S'}, {"sndbuf", 1, 0, CLI_SOCKET_OPT + 'S'}, {"source-ip", 1, 0, 'I'}, + {"no-source-bind", 0, 0, 'B'}, {"ssl", 0, 0, SSL_OPT}, {"ssl-cert", 1, 0, SSL_OPT + 'c'}, {"ssl-key", 1, 0, SSL_OPT + 'k'}, @@ -219,7 +220,8 @@ main(int argc, char **argv) { .ssl_enable = 0, .ssl_cert = "cert.pem", .ssl_key = "key.pem", - .write_combine = WRCOMB_ON}; + .write_combine = WRCOMB_ON, + .source_bind_enable = 1}; struct rate_modulator rate_modulator = {.state = RM_UNMODULATED}; int unescape_message_data = 0; @@ -724,6 +726,9 @@ main(int argc, char **argv) { exit(EX_USAGE); } } break; + case 'B': /* --no-source-bind */ + engine_params.source_bind_enable = 0; + break; case 'S': { /* --server */ orch_args.enabled = 1; orch_args.server_addr_str = strdup(optarg); @@ -898,16 +903,18 @@ main(int argc, char **argv) { conf.first_path = ""; /* "GET / HTTP/1.1" */ } - /* Figure out source IPs */ - if(engine_params.source_addresses.n_addrs == 0) { - if(detect_source_ips(&engine_params.remote_addresses, - &engine_params.source_addresses) - < 0) { - exit(EX_SOFTWARE); + if(engine_params.source_bind_enable) { + /* Figure out source IPs */ + if(engine_params.source_addresses.n_addrs == 0) { + if(detect_source_ips(&engine_params.remote_addresses, + &engine_params.source_addresses) + < 0) { + exit(EX_SOFTWARE); + } + } else { + fprint_addresses(stderr, "Source IP: ", "\nSource IP: ", "\n", + engine_params.source_addresses); } - } else { - fprint_addresses(stderr, "Source IP: ", "\nSource IP: ", "\n", - engine_params.source_addresses); } } else { conf.max_connections = 0; diff --git a/src/tcpkali_engine.h b/src/tcpkali_engine.h index 659c8b1..7a0c80b 100644 --- a/src/tcpkali_engine.h +++ b/src/tcpkali_engine.h @@ -46,6 +46,7 @@ struct engine_params { struct addresses remote_addresses; struct addresses listen_addresses; struct addresses source_addresses; + int source_bind_enable; /* Whether to bind before connect */ size_t requested_workers; /* Number of threads to start */ rate_spec_t channel_send_rate; /* --channel-upstream */ rate_spec_t channel_recv_rate; /* --channel-downstream */