Skip to content

Commit

Permalink
util: Add source address to fi_pingpong
Browse files Browse the repository at this point in the history
In multi-adapter environment, fi_pingpong is failing with -61,
No data available error when not using the first interface.

Add source address parameter and use it with hints src_addr to
get at the correct interface for data transfer.

Signed-off-by: Chien Tin Tung <[email protected]>
  • Loading branch information
Chien Tin Tung authored and shijin-aws committed Apr 4, 2024
1 parent ce244a7 commit f9faa20
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
3 changes: 3 additions & 0 deletions man/fi_pingpong.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ given domains cannot communicate, then the application will fail.
*-d \<domain\>*
: The name of the specific domain to be used.

*-s \<source address\>*
: Address to corresponding domain. Required in multi-adapter environment.

## Test Options

*-I \<iter\>*
Expand Down
33 changes: 32 additions & 1 deletion util/pingpong.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ enum {
struct pp_opts {
uint16_t src_port;
uint16_t dst_port;
char *src_addr;
char *dst_addr;
int iterations;
int transfer_size;
Expand Down Expand Up @@ -280,6 +281,8 @@ static void pp_banner_options(struct ct_pingpong *ct)
}

PP_DEBUG(" * PingPong options:\n");
PP_DEBUG(" - %-20s: [%s]\n", "src_addr",
(opts.src_addr)? opts.src_addr: "None");
PP_DEBUG(" - %-20s: [%" PRIu16 "]\n", "src_port", opts.src_port);
PP_DEBUG(" - %-20s: [%s]\n", "dst_addr", opts.dst_addr);
PP_DEBUG(" - %-20s: [%" PRIu16 "]\n", "dst_port", opts.dst_port);
Expand Down Expand Up @@ -1999,6 +2002,8 @@ static void pp_pingpong_usage(struct ct_pingpong *ct, char *name, char *desc)
"destination control port number (client: 47592)");

fprintf(stderr, " %-20s %s\n", "-d <domain>", "domain name");
fprintf(stderr, " %-20s %s\n", "-s <source address>",
"source address associated with domain name");
fprintf(stderr, " %-20s %s\n", "-p <provider>",
"specific provider name eg sockets, verbs");
fprintf(stderr, " %-20s %s\n", "-e <ep_type>",
Expand Down Expand Up @@ -2071,6 +2076,11 @@ static void pp_parse_opts(struct ct_pingpong *ct, int op, char *optarg)
}
break;

/* Source address */
case 's':
ct->opts.src_addr = optarg;
break;

/* Check data */
case 'c':
ct->opts.options |= PP_OPT_VERIFY_DATA;
Expand Down Expand Up @@ -2274,6 +2284,24 @@ static int run_pingpong_msg(struct ct_pingpong *ct)
return ret;
}

static void pp_set_src_hint(struct ct_pingpong *ct)
{
struct addrinfo *results = NULL;

if (getaddrinfo(ct->opts.src_addr, NULL, NULL, &results))
return;

ct->hints->src_addr = calloc(1, results->ai_addrlen);
if (!ct->hints->src_addr)
return;

ct->hints->src_addrlen = results->ai_addrlen;
memcpy(ct->hints->src_addr, results->ai_addr, results->ai_addrlen);
ct->hints->addr_format = results->ai_family;

freeaddrinfo(results);
}

int main(int argc, char **argv)
{
int op, ret = EXIT_SUCCESS;
Expand All @@ -2298,7 +2326,7 @@ int main(int argc, char **argv)

ofi_osd_init();

while ((op = getopt(argc, argv, "hvd:p:e:I:S:B:P:cm:6")) != -1) {
while ((op = getopt(argc, argv, "hvd:p:e:I:S:s:B:P:cm:6")) != -1) {
switch (op) {
default:
pp_parse_opts(&ct, op, optarg);
Expand All @@ -2314,6 +2342,9 @@ int main(int argc, char **argv)
if (optind < argc)
ct.opts.dst_addr = argv[optind];

if (ct.opts.src_addr)
pp_set_src_hint(&ct);

pp_banner_options(&ct);

switch (ct.hints->ep_attr->type) {
Expand Down

0 comments on commit f9faa20

Please sign in to comment.