-
Notifications
You must be signed in to change notification settings - Fork 398
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
prov/tcp: implement FI_FIREWALL_ADDR for AV inserts #10724
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,23 +98,29 @@ static void rxm_free_peer(struct util_peer_addr *peer) | |
ofi_ibuf_free(peer); | ||
} | ||
|
||
struct util_peer_addr * | ||
util_get_peer(struct rxm_av *av, const void *addr) | ||
|
||
int util_get_peer(struct rxm_av *av, const void *addr, struct util_peer_addr **peer, | ||
uint64_t flags) | ||
{ | ||
struct util_peer_addr *peer; | ||
struct ofi_rbnode *node; | ||
int ret; | ||
|
||
ofi_mutex_lock(&av->util_av.lock); | ||
node = ofi_rbmap_find(&av->addr_map, (void *) addr); | ||
if (node) { | ||
peer = node->data; | ||
peer->refcnt++; | ||
*peer = node->data; | ||
(*peer)->refcnt++; | ||
shefty marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Set ret = FI_SUCCESS here to avoid an extra branch on return. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something is off in the flag settings. A peer might be inserted in response to a connection request (xnet_process_connreq). In that case, peer->av_flags = 0. When an address is inserted with FI_FIREWALL_ADDR, the peer will be found, but peer->av_flags won't be adjusted. I think you need |
||
} else if (flags & FI_FIREWALL_ADDR) { | ||
*peer = NULL; | ||
ret = -FI_EHOSTUNREACH; | ||
} else { | ||
peer = rxm_alloc_peer(av, addr); | ||
*peer = rxm_alloc_peer(av, addr); | ||
if (!*peer) | ||
ret = -FI_ENOMEM; | ||
(*peer)->av_flags = flags; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs to be part of an else, or this results in a crash. |
||
} | ||
|
||
ofi_mutex_unlock(&av->util_av.lock); | ||
return peer; | ||
return peer ? FI_SUCCESS : ret; | ||
} | ||
|
||
static void util_deref_peer(struct util_peer_addr *peer) | ||
|
@@ -165,17 +171,17 @@ rxm_put_peer_addr(struct rxm_av *av, fi_addr_t fi_addr) | |
|
||
static int | ||
rxm_av_add_peers(struct rxm_av *av, const void *addr, size_t count, | ||
fi_addr_t *fi_addr, fi_addr_t *user_ids) | ||
fi_addr_t *fi_addr, fi_addr_t *user_ids, uint64_t flags) | ||
{ | ||
struct util_peer_addr *peer; | ||
const void *cur_addr; | ||
fi_addr_t cur_fi_addr; | ||
size_t i; | ||
size_t i, ret; | ||
|
||
for (i = 0; i < count; i++) { | ||
cur_addr = ((char *) addr + i * av->util_av.addrlen); | ||
peer = util_get_peer(av, cur_addr); | ||
if (!peer) | ||
ret = util_get_peer(av, cur_addr, &peer, flags); | ||
if (ret) | ||
goto err; | ||
|
||
if (user_ids) { | ||
|
@@ -206,7 +212,7 @@ rxm_av_add_peers(struct rxm_av *av, const void *addr, size_t count, | |
ofi_mutex_unlock(&av->util_av.lock); | ||
} | ||
} | ||
return -FI_ENOMEM; | ||
return ret; | ||
} | ||
|
||
static int rxm_av_remove(struct fid_av *av_fid, fi_addr_t *fi_addr, | ||
|
@@ -299,7 +305,7 @@ static int rxm_av_insert(struct fid_av *av_fid, const void *addr, size_t count, | |
|
||
count = ret; | ||
|
||
ret = rxm_av_add_peers(av, addr, count, fi_addr, user_ids); | ||
ret = rxm_av_add_peers(av, addr, count, fi_addr, user_ids, flags); | ||
if (ret) { | ||
rxm_av_remove(av_fid, fi_addr, count, flags); | ||
goto out; | ||
|
@@ -345,7 +351,7 @@ static int rxm_av_insertsym(struct fid_av *av_fid, const char *node, | |
if (ret > 0 && ret < count) | ||
count = ret; | ||
|
||
ret = rxm_av_add_peers(av, addr, count, fi_addr, NULL); | ||
ret = rxm_av_add_peers(av, addr, count, fi_addr, NULL, flags); | ||
if (ret) { | ||
rxm_av_remove(av_fid, fi_addr, count, flags); | ||
return ret; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: check line length