diff options
author | David Ahern <dsahern@kernel.org> | 2021-01-14 06:09:49 +0300 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2021-01-15 03:26:50 +0300 |
commit | 5265a0142f57b10f57b5795e0dba90edfd127803 (patch) | |
tree | cf8bc2e1a24b615118c9d5d9c8bd757b51659f35 /tools/testing/selftests/net/nettest.c | |
parent | f26a008c45122d85f8b753f861464b136a1d3ae5 (diff) | |
download | linux-5265a0142f57b10f57b5795e0dba90edfd127803.tar.xz |
selftests: Add separate option to nettest for address binding
Add separate option to nettest to specify local address
binding in client mode.
Signed-off-by: David Ahern <dsahern@kernel.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools/testing/selftests/net/nettest.c')
-rw-r--r-- | tools/testing/selftests/net/nettest.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/testing/selftests/net/nettest.c b/tools/testing/selftests/net/nettest.c index 55c586eb2393..6365c7fd1262 100644 --- a/tools/testing/selftests/net/nettest.c +++ b/tools/testing/selftests/net/nettest.c @@ -48,6 +48,7 @@ struct sock_args { /* local address */ const char *local_addr_str; + const char *client_local_addr_str; union { struct in_addr in; struct in6_addr in6; @@ -1630,6 +1631,7 @@ static int do_client(struct sock_args *args) log_msg("Switched client netns\n"); } + args->local_addr_str = args->client_local_addr_str; if (resolve_devices(args) || validate_addresses(args)) return 1; @@ -1770,7 +1772,7 @@ static int ipc_parent(int cpid, int fd, struct sock_args *args) return client_status; } -#define GETOPT_STR "sr:l:p:t:g:P:DRn:M:X:m:d:I:BN:O:SCi6L:0:1:2:3:Fbq" +#define GETOPT_STR "sr:l:c:p:t:g:P:DRn:M:X:m:d:I:BN:O:SCi6L:0:1:2:3:Fbq" static void print_usage(char *prog) { @@ -1791,7 +1793,8 @@ static void print_usage(char *prog) " -6 IPv6 (default is IPv4)\n" " -P proto protocol for socket: icmp, ospf (default: none)\n" " -D|R datagram (D) / raw (R) socket (default stream)\n" - " -l addr local address to bind to\n" + " -l addr local address to bind to in server mode\n" + " -c addr local address to bind to in client mode\n" "\n" " -d dev bind socket to given device name\n" " -I dev bind socket to given device name - server mode\n" @@ -1859,6 +1862,10 @@ int main(int argc, char *argv[]) args.has_remote_ip = 1; args.remote_addr_str = optarg; break; + case 'c': + args.has_local_ip = 1; + args.client_local_addr_str = optarg; + break; case 'p': if (str_to_uint(optarg, 1, 65535, &tmp) != 0) { fprintf(stderr, "Invalid port\n"); |