Skip to content

Commit

Permalink
util: Update checks for FI_AV_AUTH_KEY
Browse files Browse the repository at this point in the history
When FI_AV_AUTH_KEY is used, domain_attr::auth_key and ep_attr::auth_key
must be NULL. In addition, ep_attr::auth_key_size must be zero.

Signed-off-by: Ian Ziemba <ian.ziemba@hpe.com>
  • Loading branch information
iziemba authored and j-xiong committed Oct 31, 2023
1 parent fa61252 commit 6aa371e
Showing 1 changed file with 39 additions and 10 deletions.
49 changes: 39 additions & 10 deletions prov/util/src/util_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,11 +654,20 @@ int ofi_check_domain_attr(const struct fi_provider *prov, uint32_t api_version,
return -FI_ENODATA;
}

if (user_attr->auth_key && user_attr->auth_key_size &&
(user_attr->auth_key_size != prov_attr->auth_key_size)) {
FI_INFO(prov, FI_LOG_CORE, "Unsupported authentication size\n");
OFI_INFO_CHECK_SIZE(prov, prov_attr, user_attr, auth_key_size);
return -FI_ENODATA;
if (user_attr->auth_key_size == FI_AV_AUTH_KEY &&
FI_VERSION_GE(api_version, FI_VERSION(1, 20))) {
if (user_attr->auth_key) {
FI_INFO(prov, FI_LOG_CORE,
"Authentication key must be NULL with FI_AV_AUTH_KEY\n");;
return -FI_ENODATA;
}
} else {
if (user_attr->auth_key_size &&
(user_attr->auth_key_size != prov_attr->auth_key_size)) {
OFI_INFO_CHECK_SIZE(prov, prov_attr, user_attr,
auth_key_size);
return -FI_ENODATA;
}
}

if (FI_VERSION_GE(api_version, FI_VERSION(1, 20)) &&
Expand Down Expand Up @@ -693,11 +702,17 @@ int ofi_check_ep_attr(const struct util_prov *util_prov, uint32_t api_version,
const struct fi_ep_attr *user_attr = user_info->ep_attr;
const struct fi_provider *prov = util_prov->prov;
int ret;
bool av_auth_key = false;

ret = ofi_check_ep_type(prov, prov_attr, user_attr);
if (ret)
return ret;

if (FI_VERSION_GE(api_version, FI_VERSION(1, 20)) &&
user_info->domain_attr) {
av_auth_key = user_info->domain_attr->auth_key_size == FI_AV_AUTH_KEY;
}

if ((user_attr->protocol != FI_PROTO_UNSPEC) &&
(user_attr->protocol != prov_attr->protocol)) {
FI_INFO(prov, FI_LOG_CORE, "Unsupported protocol\n");
Expand Down Expand Up @@ -790,11 +805,25 @@ int ofi_check_ep_attr(const struct util_prov *util_prov, uint32_t api_version,
}
}

if (user_attr->auth_key && user_attr->auth_key_size &&
(user_attr->auth_key_size != prov_attr->auth_key_size)) {
FI_INFO(prov, FI_LOG_CORE, "Unsupported authentication size.");
OFI_INFO_CHECK_SIZE(prov, prov_attr, user_attr, auth_key_size);
return -FI_ENODATA;
if (av_auth_key) {
if (user_attr->auth_key) {
FI_INFO(prov, FI_LOG_CORE,
"Authentication key must be NULL with FI_AV_AUTH_KEY\n");;
return -FI_ENODATA;
}

if (user_attr->auth_key_size) {
FI_INFO(prov, FI_LOG_CORE,
"Authentication key must be 0 with FI_AV_AUTH_KEY\n");;
return -FI_ENODATA;
}
} else {
if (user_attr->auth_key_size &&
(user_attr->auth_key_size != prov_attr->auth_key_size)) {
OFI_INFO_CHECK_SIZE(prov, prov_attr, user_attr,
auth_key_size);
return -FI_ENODATA;
}
}

if ((user_info->caps & FI_TAGGED) && user_attr->mem_tag_format &&
Expand Down

0 comments on commit 6aa371e

Please sign in to comment.