Skip to content

Commit

Permalink
Avoid loopback interfaces if not needed
Browse files Browse the repository at this point in the history
Only the DVM master can use a loopback interface, and then
only if no other daemon is in the DVM. So block those
interfaces unless we are the DVM master and no other
interfaces are available.

Signed-off-by: Ralph Castain <rhc@pmix.org>
(cherry picked from commit 50ee741)
  • Loading branch information
rhc54 committed Aug 16, 2022
1 parent 9a635b2 commit 14c8b56
Showing 1 changed file with 24 additions and 1 deletion.
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

0 comments on commit 14c8b56

Please sign in to comment.