libnvme: Add nvme_getifaddrs()#3090
Merged
igaw merged 1 commit intolinux-nvme:masterfrom Feb 12, 2026
Merged
Conversation
igaw
reviewed
Feb 11, 2026
libnvme/src/nvme/util.h
Outdated
| * | ||
| * Return: 0 on success, -1 on error (with errno set). | ||
| */ | ||
| int nvme_getifaddrs(struct ifaddrs **ifap); |
Collaborator
There was a problem hiding this comment.
Let's keep this function private and don't expose it to user.
Collaborator
|
it would be indeed good to tie it to the global context. If I read it correctly, the users of this function are getting either a bool nvme_ctrl_config_match(struct nvme_ctrl *c, const char *transport,
const char *traddr, const char *trsvcid,
const char *subsysnqn, const char *host_traddr,
const char *host_iface)
{
_cleanup_candidate_ struct candidate_args candidate = {};
ctrl_match_t ctrl_match;
/* Init candidate and get the matching function to use */
ctrl_match = _candidate_init(&candidate, transport, traddr, trsvcid,
subsysnqn, host_traddr, host_iface);
return ctrl_match(c, &candidate);
}That means it is possible to access the global context via those two pointers, |
Author
|
Ah! You're right. It's been so long since I've worked on libnvme that I forgot how to access the ctx from a ctrl or subsys object. Let me rework this. |
The POSIX `getifaddrs()` API returns the list of network interfaces on the system, but invoking it can be costly. On large-scale systems with hundreds of NVMe-over-TCP connections, this API may be called hundreds of times, resulting in increased latency. This patch introduces `nvme_getifaddrs()`, a wrapper around `getifaddrs()` that caches the results on the first invocation and reuses the cached data on subsequent calls. Signed-off-by: Martin Belanger <martin.belanger@dell.com>
975498d to
4f33af1
Compare
Author
|
@igaw - Thanks for your suggestion. I am now saving the cache in the global context. |
Collaborator
|
Yes, this looks way better! Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The POSIX
getifaddrs()API returns the list of network interfaces on the system, but invoking it can be costly. On large-scale systems with hundreds of NVMe-over-TCP connections, this API may be called hundreds of times, resulting in increased latency.This patch introduces
nvme_getifaddrs(), a wrapper aroundgetifaddrs()that caches the results on the first invocation and reuses the cached data on subsequent calls.Fixes: linux-nvme/libnvme#1098