Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fabtests/shared.c: Check if fi_info is returned correctly in case of FI_CONNREQ #9355

Merged
merged 2 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions fabtests/common/shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,20 @@ int ft_complete_connect(struct fid_ep *ep, struct fid_eq *eq)
return 0;
}

int ft_verify_info(struct fi_info *fi_pep, struct fi_info *info)
{
if (!info || !info->fabric_attr || !info->domain_attr ||
!info->ep_attr || !info->tx_attr || !info->rx_attr)
return -FI_EINVAL;

if (!info->fabric_attr->prov_name ||
!info->fabric_attr->name || !info->domain_attr->name ||
info->fabric_attr->api_version != fi_pep->fabric_attr->api_version)
return -FI_EINVAL;

return 0;
}

int ft_retrieve_conn_req(struct fid_eq *eq, struct fi_info **fi)
{
struct fi_eq_cm_entry entry;
Expand All @@ -1103,6 +1117,11 @@ int ft_retrieve_conn_req(struct fid_eq *eq, struct fi_info **fi)
return ret;
}

if ((ret = ft_verify_info(fi_pep, entry.info))) {
printf("ret: %d\n", ret);
return ret;
}

return 0;
}

Expand Down
1 change: 1 addition & 0 deletions fabtests/include/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ int ft_server_connect();
int ft_client_connect();
int ft_init_fabric_cm(void);
int ft_complete_connect(struct fid_ep *ep, struct fid_eq *eq);
int ft_verify_info(struct fi_info *fi_pep, struct fi_info *info);
int ft_retrieve_conn_req(struct fid_eq *eq, struct fi_info **fi);
int ft_accept_connection(struct fid_ep *ep, struct fid_eq *eq);
int ft_connect_ep(struct fid_ep *ep,
Expand Down
32 changes: 12 additions & 20 deletions prov/sockets/src/sock_ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -1417,7 +1417,8 @@ static void sock_set_fabric_attr(void *src_addr, const struct fi_fabric_attr *hi
if (!attr->name)
attr->name = strdup(sock_fab_name);

attr->prov_name = NULL;
attr->prov_name = strdup(hint_attr->prov_name);
attr->api_version = hint_attr->api_version;
}

static void sock_set_domain_attr(uint32_t api_version, void *src_addr,
Expand Down Expand Up @@ -1498,11 +1499,17 @@ struct fi_info *sock_fi_info(uint32_t version, enum fi_ep_type ep_type,
{
struct fi_info *info;

info = fi_allocinfo();
info = fi_dupinfo(hints);
if (!info)
return NULL;

info->src_addr = calloc(1, sizeof(union ofi_sock_ip));
free(info->src_addr);
free(info->dest_addr);
Juee14Desai marked this conversation as resolved.
Show resolved Hide resolved
info->src_addr = NULL;
info->dest_addr = NULL;
info->src_addrlen = 0;
info->dest_addrlen = 0;

info->src_addr = calloc(1, ofi_sizeofip(src_addr));
if (!info->src_addr)
goto err;

Expand All @@ -1523,29 +1530,14 @@ struct fi_info *sock_fi_info(uint32_t version, enum fi_ep_type ep_type,
info->addr_format = FI_SOCKADDR_IN;

if (dest_addr) {
info->dest_addr = calloc(1, sizeof(union ofi_sock_ip));
info->dest_addr = calloc(1, ofi_sizeofip(dest_addr));
if (!info->dest_addr)
goto err;
info->dest_addrlen = ofi_sizeofaddr(dest_addr);
memcpy(info->dest_addr, dest_addr, info->dest_addrlen);
}

if (hints) {
if (hints->caps)
info->caps = hints->caps;

if (hints->ep_attr)
*(info->ep_attr) = *(hints->ep_attr);

if (hints->tx_attr)
*(info->tx_attr) = *(hints->tx_attr);

if (hints->rx_attr)
*(info->rx_attr) = *(hints->rx_attr);

if (hints->handle)
info->handle = hints->handle;

sock_set_domain_attr(version, info->src_addr, hints->domain_attr,
info->domain_attr);
sock_set_fabric_attr(info->src_addr, hints->fabric_attr, info->fabric_attr);
Expand Down