Skip to content

Commit

Permalink
UCT/TCP: Filtered out bridge devices.
Browse files Browse the repository at this point in the history
  • Loading branch information
rakhmets committed Nov 7, 2023
1 parent a459ad9 commit b6e1145
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/uct/tcp/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ typedef struct uct_tcp_md {
struct {
int af_prio_count;
sa_family_t af_prio_list[2];
int bridge_devices;
} config;
} uct_tcp_md_t;

Expand All @@ -475,6 +476,7 @@ typedef struct uct_tcp_md {
typedef struct uct_tcp_md_config {
uct_md_config_t super;
UCS_CONFIG_STRING_ARRAY_FIELD(af) af_prio;
int bridge_devices;
} uct_tcp_md_config_t;


Expand Down
21 changes: 20 additions & 1 deletion src/uct/tcp/tcp_iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,23 @@ static UCS_CLASS_DEFINE_NEW_FUNC(uct_tcp_iface_t, uct_iface_t, uct_md_h,
uct_worker_h, const uct_iface_params_t*,
const uct_iface_config_t*);

static int uct_tcp_filter_bridges(const struct dirent *entry)
{
char path[PATH_MAX];
struct stat st;
int is_bridge;

ucs_snprintf_safe(path, PATH_MAX, UCT_TCP_IFACE_NETDEV_DIR "/%s/bridge",
entry->d_name);

is_bridge = (stat(path, &st) == 0) && S_ISDIR(st.st_mode);
if (is_bridge) {
ucs_debug("filtered out bridge device %s", entry->d_name);
}

return !is_bridge;
}

ucs_status_t uct_tcp_query_devices(uct_md_h md,
uct_tl_device_resource_t **devices_p,
unsigned *num_devices_p)
Expand All @@ -877,7 +894,9 @@ ucs_status_t uct_tcp_query_devices(uct_md_h md,
char path_buffer[PATH_MAX];
ucs_sys_device_t sys_dev;

n = scandir(UCT_TCP_IFACE_NETDEV_DIR, &entries, NULL, alphasort);
n = scandir(UCT_TCP_IFACE_NETDEV_DIR, &entries,
tcp_md->config.bridge_devices ? NULL : uct_tcp_filter_bridges,
alphasort);
if (n == -1) {
ucs_error("scandir(%s) failed: %m", UCT_TCP_IFACE_NETDEV_DIR);
status = UCS_ERR_IO_ERROR;
Expand Down
14 changes: 9 additions & 5 deletions src/uct/tcp/tcp_md.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@


static ucs_config_field_t uct_tcp_md_config_table[] = {
{"", "", NULL,
ucs_offsetof(uct_tcp_md_config_t, super), UCS_CONFIG_TYPE_TABLE(uct_md_config_table)},
{"", "", NULL, ucs_offsetof(uct_tcp_md_config_t, super),
UCS_CONFIG_TYPE_TABLE(uct_md_config_table)},

{"AF_PRIO", "inet,inet6",
"Priority of address families used for socket connections",
ucs_offsetof(uct_tcp_md_config_t, af_prio), UCS_CONFIG_TYPE_STRING_ARRAY},

{"BRIDGE_DEVICES", "n", "Use bridge devices",
ucs_offsetof(uct_tcp_md_config_t, bridge_devices), UCS_CONFIG_TYPE_BOOL},

{NULL}
};

Expand Down Expand Up @@ -76,9 +79,10 @@ uct_tcp_md_open(uct_component_t *component, const char *md_name,
goto err;
}

tcp_md->super.ops = &uct_tcp_md_ops;
tcp_md->super.component = &uct_tcp_component;
tcp_md->config.af_prio_count = ucs_min(md_config->af_prio.count, 2);
tcp_md->super.ops = &uct_tcp_md_ops;
tcp_md->super.component = &uct_tcp_component;
tcp_md->config.af_prio_count = ucs_min(md_config->af_prio.count, 2);
tcp_md->config.bridge_devices = md_config->bridge_devices;

for (i = 0; i < tcp_md->config.af_prio_count; i++) {
if (!strcasecmp(md_config->af_prio.af[i], "inet")) {
Expand Down

0 comments on commit b6e1145

Please sign in to comment.