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

Avoid loopback interfaces if not needed #1437

Merged
merged 1 commit into from
Aug 16, 2022
Merged
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
25 changes: 24 additions & 1 deletion src/mca/oob/tcp/oob_tcp_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
# include <sys/types.h>
#endif
#include <fcntl.h>
#ifdef HAVE_NET_IF_H
# include <net/if.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
Expand Down Expand Up @@ -408,13 +411,32 @@ static int component_available(void)
char string[50];
int kindex;
int i;
bool keeploopback = false;

prte_output_verbose(5, prte_oob_base_framework.framework_output,
"oob:tcp: component_available called");

/* if we are the master, then check the interfaces for loopbacks
* and keep loopbacks only if no non-loopback interface exists */
if (PRTE_PROC_IS_MASTER) {
keeploopback = true;
PMIX_LIST_FOREACH(selected_interface, &pmix_if_list, pmix_pif_t)
{
if (!(selected_interface->if_flags & IFF_LOOPBACK)) {
keeploopback = false;
break;
}
}
}

/* look at all available interfaces */
PMIX_LIST_FOREACH(selected_interface, &pmix_if_list, pmix_pif_t)
{
if ((selected_interface->if_flags & IFF_LOOPBACK) &&
!keeploopback) {
continue;
}

i = selected_interface->if_index;
kindex = selected_interface->if_kernel_index;
memcpy((struct sockaddr *) &my_ss, &selected_interface->if_addr,
Expand Down Expand Up @@ -565,7 +587,8 @@ static char *component_get_addr(void)
{
char *cptr = NULL, *tmp, *tp, *tm;

if (!prte_oob_tcp_component.disable_ipv4_family && NULL != prte_oob_tcp_component.ipv4conns) {
if (!prte_oob_tcp_component.disable_ipv4_family &&
NULL != prte_oob_tcp_component.ipv4conns) {
tmp = pmix_argv_join(prte_oob_tcp_component.ipv4conns, ',');
tp = pmix_argv_join(prte_oob_tcp_component.ipv4ports, ',');
tm = pmix_argv_join(prte_oob_tcp_component.if_masks, ',');
Expand Down