diff options
author | Marius Bakke <marius@gnu.org> | 2021-05-22 15:47:49 +0200 |
---|---|---|
committer | Marius Bakke <marius@gnu.org> | 2021-05-22 16:04:59 +0200 |
commit | 404feffa303e38a6a48443faa229864157c3bc1c (patch) | |
tree | f64898ac7f032d8e723a57f3909b1403852134a8 | |
parent | 19ea43c907a86a408e1c7248f2fff272cbd198e7 (diff) | |
download | guix-404feffa303e38a6a48443faa229864157c3bc1c.tar.gz guix-404feffa303e38a6a48443faa229864157c3bc1c.zip |
gnu: ucx: Restore (and adapt) ioctl fallback patch.
This is a followup to 4ebd4a58ce307874b18c30ffcd4852440e475ad5 which
removed the patch, but it was still necessary for some dependents.
* gnu/packages/patches/ucx-tcp-iface-ioctl.patch: New file.
* gnu/local.mk (dist_patch_DATA): Adjust accordingly.
* gnu/packages/fabric-management.scm (ucx)[source](patches): New field.
-rw-r--r-- | gnu/local.mk | 1 | ||||
-rw-r--r-- | gnu/packages/fabric-management.scm | 1 | ||||
-rw-r--r-- | gnu/packages/patches/ucx-tcp-iface-ioctl.patch | 108 |
3 files changed, 110 insertions, 0 deletions
diff --git a/gnu/local.mk b/gnu/local.mk index 20d37f3b11..1c8bc22ebf 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1744,6 +1744,7 @@ dist_patch_DATA = \ %D%/packages/patches/twinkle-bcg729.patch \ %D%/packages/patches/u-boot-rockchip-inno-usb.patch \ %D%/packages/patches/u-boot-riscv64-fix-extlinux.patch \ + %D%/packages/patches/ucx-tcp-iface-ioctl.patch \ %D%/packages/patches/udiskie-no-appindicator.patch \ %D%/packages/patches/ungoogled-chromium-extension-search-path.patch \ %D%/packages/patches/unison-fix-ocaml-4.08.patch \ diff --git a/gnu/packages/fabric-management.scm b/gnu/packages/fabric-management.scm index e0ea3c2bf1..08cf85cd00 100644 --- a/gnu/packages/fabric-management.scm +++ b/gnu/packages/fabric-management.scm @@ -188,6 +188,7 @@ testing InfiniBand networks.") (url "https://github.com/openucx/ucx") (commit (string-append "v" version)))) (file-name (git-file-name name version)) + (patches (search-patches "ucx-tcp-iface-ioctl.patch")) (sha256 (base32 "0i0ji5ivzxjqh3ys1m517ghw3am7cw1hvf40ma7hsq3wznsyx5s1")))) diff --git a/gnu/packages/patches/ucx-tcp-iface-ioctl.patch b/gnu/packages/patches/ucx-tcp-iface-ioctl.patch new file mode 100644 index 0000000000..56f06fc920 --- /dev/null +++ b/gnu/packages/patches/ucx-tcp-iface-ioctl.patch @@ -0,0 +1,108 @@ +Since /sys is unavailable in build environments, the list of available +TCP network interfaces cannot be obtained via /sys/class/net. This patch +provides alternative code that uses the SIOCGIFCONF ioctl to get the +names of the available TCP network interfaces. + +diff --git a/src/uct/tcp/tcp_iface.c b/src/uct/tcp/tcp_iface.c +index cad4a2709..7c1d2c9de 100644 +--- a/src/uct/tcp/tcp_iface.c ++++ b/src/uct/tcp/tcp_iface.c +@@ -17,6 +17,8 @@ + #include <sys/poll.h> + #include <netinet/tcp.h> + #include <dirent.h> ++#include <net/if.h> ++#include <sys/ioctl.h> + + + extern ucs_class_t UCS_CLASS_DECL_NAME(uct_tcp_iface_t); +@@ -586,6 +588,68 @@ 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*); + ++/* Fetch information about available network devices through an ioctl. */ ++static ucs_status_t query_devices_ioctl(uct_md_h md, ++ uct_tl_device_resource_t **tl_devices_p, ++ unsigned *num_tl_devices_p) ++{ ++ int sock, err, i; ++ uct_tl_device_resource_t *resources, *tmp; ++ unsigned num_resources; ++ ucs_status_t status; ++ struct ifconf conf; ++ struct ifreq reqs[10]; ++ ++ conf.ifc_len = sizeof reqs; ++ conf.ifc_req = reqs; ++ ++ sock = socket(SOCK_STREAM, AF_INET, 0); ++ if (sock < 0) { ++ ucs_error("socket(2) failed: %m"); ++ status = UCS_ERR_IO_ERROR; ++ goto out; ++ } ++ ++ err = ioctl(sock, SIOCGIFCONF, &conf); ++ if (err < 0) { ++ ucs_error("SIOCGIFCONF ioctl failed: %m"); ++ status = UCS_ERR_IO_ERROR; ++ goto out; ++ } ++ ++ resources = NULL; ++ num_resources = 0; ++ for (i = 0; i < conf.ifc_len / sizeof(struct ifreq); i++) { ++ const char *name = reqs[i].ifr_name; ++ ++ if (!ucs_netif_is_active(name)) { ++ continue; ++ } ++ ++ tmp = ucs_realloc(resources, sizeof(*resources) * (num_resources + 1), ++ "tcp resources"); ++ if (tmp == NULL) { ++ ucs_free(resources); ++ status = UCS_ERR_NO_MEMORY; ++ goto out; ++ } ++ resources = tmp; ++ ++ ucs_snprintf_zero(resources[i].name, sizeof(resources[i].name), ++ "%s", name); ++ resources[i].type = UCT_DEVICE_TYPE_NET; ++ ++num_resources; ++ } ++ ++ *num_tl_devices_p = num_resources; ++ *tl_devices_p = resources; ++ status = UCS_OK; ++ ++out: ++ if (sock >= 0) close(sock); ++ return status; ++} ++ + ucs_status_t uct_tcp_query_devices(uct_md_h md, + uct_tl_device_resource_t **devices_p, + unsigned *num_devices_p) +@@ -599,9 +663,9 @@ ucs_status_t uct_tcp_query_devices(uct_md_h md, + + dir = opendir(netdev_dir); + if (dir == NULL) { +- ucs_error("opendir(%s) failed: %m", netdev_dir); +- status = UCS_ERR_IO_ERROR; +- goto out; ++ /* When /sys is unavailable, as can be the case in a container, ++ * resort to a good old 'ioctl'. */ ++ return query_devices_ioctl(md, devices_p, num_devices_p); + } + + devices = NULL; +@@ -655,7 +719,6 @@ ucs_status_t uct_tcp_query_devices(uct_md_h md, + + out_closedir: + closedir(dir); +-out: + return status; + } + |