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

Fix the loop condition in ncclFindInterfaceMatchSubnet as it may not behave as expected when maxIfs > 1 #1574

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Fix the loop condition in ncclFindInterfaceMatchSubnet as it may not …
…behave as expected when maxIfs > 1

Signed-off-by: fengquyoumo <[email protected]>
  • Loading branch information
wjl269368 authored and fengquyoumo committed Jan 15, 2025
commit 8b0a5d05338aeb7c4016ceed2f1744c6ebae3027
3 changes: 1 addition & 2 deletions src/misc/socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ int ncclFindInterfaceMatchSubnet(char* ifNames, union ncclSocketAddress* localAd
int found = 0;
struct ifaddrs *interfaces, *interface;
getifaddrs(&interfaces);
for (interface = interfaces; interface && !found; interface = interface->ifa_next) {
for (interface = interfaces; interface && found < maxIfs; interface = interface->ifa_next) {
if (interface->ifa_addr == NULL) continue;

/* We only support IPv4 & IPv6 */
Expand All @@ -253,7 +253,6 @@ int ncclFindInterfaceMatchSubnet(char* ifNames, union ncclSocketAddress* localAd

TRACE(NCCL_INIT|NCCL_NET,"NET : Found interface %s:%s in the same subnet as remote address %s", interface->ifa_name, ncclSocketToString(localAddrs+found, line), ncclSocketToString(remoteAddr, line_a));
found++;
if (found == maxIfs) break;
}

if (found == 0) {
Expand Down