Skip to content
Open
Show file tree
Hide file tree
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
65 changes: 65 additions & 0 deletions base/comps/mlnx-ofa_kernel/mlnx-ofa-kmod-autoupdate.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/bash
set -euo pipefail

if [[ $# -lt 4 ]]; then
exit 0
fi

pkg_name="$1"
kver="$2"
krel="$3"
karch="$4"

base_nevra="kmod-mlnx-ofa_kernel-@MLNX_OFA_VERSION@-${kver}-${krel}.${karch}"
devel_nevra="kmod-mlnx-ofa_kernel-@MLNX_OFA_VERSION@-devel-${kver}-${krel}.${karch}"
log_file="/var/log/mlnx-ofa-kmod-autoupdate.log"

notify() {
local msg="$1"
echo "$(date -Iseconds) [mlnx-ofa-kmod-autoupdate] ${msg}" >> "$log_file" 2>&1 || true
# Write to controlling terminal if available
echo "[mlnx-ofa-kmod-autoupdate] ${msg}" > /dev/tty 2>/dev/null || true
logger -t mlnx-ofa-kmod-autoupdate -- "${msg}" >/dev/null 2>&1 || true
}

# Always log invocation first so we can confirm the hook fired.
notify "invoked: pkg=${pkg_name} base_nevra=${base_nevra}"

# Only react to kernel package transactions.
if [[ ! "$pkg_name" =~ ^kernel($|-) ]]; then
notify "skipping non-kernel pkg=${pkg_name}"
exit 0
fi

notify "detected kernel transaction; checking for existing mlnx-ofa_kernel kmod"

# Only auto-install if mlnx-ofa_kernel kmod was previously installed.
if ! rpm -qa kmod-mlnx-ofa_kernel-* >/dev/null 2>&1; then
notify "no existing mlnx-ofa_kernel kmod found; skipping auto-install"
exit 0
fi

notify "found existing mlnx-ofa_kernel kmod; will attempt to install matching version for ${kver}-${krel}"

# post_transaction fires while dnf5 may still hold its lock; run the install
# in a fully detached child that retries with exit_on_lock=0.
{
for _ in 1 2 3; do
if dnf5 -y --setopt=exit_on_lock=0 install "$base_nevra" "$devel_nevra" \
>> "$log_file" 2>&1; then
notify "install succeeded"
exit 0
fi
if dnf5 -y --setopt=exit_on_lock=0 install "$base_nevra" \
>> "$log_file" 2>&1; then
notify "install succeeded (base only)"
exit 0
fi
sleep 5
done
notify "all retries failed"
} &
disown

# Best effort hook: do not fail the original transaction.
exit 0
1 change: 1 addition & 0 deletions base/comps/mlnx-ofa_kernel/mlnx-ofa-kmod.actions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
post_transaction:kernel*:in:enabled=1:/usr/libexec/mlnx-ofa-kmod-autoupdate ${pkg.name} ${pkg.version} ${pkg.release} ${pkg.arch}
25 changes: 25 additions & 0 deletions base/comps/mlnx-ofa_kernel/mlnx-ofa_kernel.comp.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# mlnx-ofa_kernel — userspace + headers + source companion to the
# kmod-mlnx-ofa subpackage built by the kernel component.
#
# Local spec because there's no upstream Fedora package for this — the
# mlnx-ofa_kernel sources only ship inside NVIDIA's MLNX_OFED_SRC bundle,
# which we download as the spec's Source0 and unpack in %prep (see the
# spec's %prep section for the bundle → SRPM → inner tarball extraction).
[components.mlnx-ofa_kernel]
spec = { type = "local", path = "mlnx-ofa_kernel.spec" }

# Manual release calculation — rpmautospec would try to derive Release: from
# `git log` over the spec file, which has nothing to do with the upstream
# tarball version. Hand-curate the changelog and bump Release: explicitly
# when the spec changes.
release = { calculation = "manual" }

# Download NVIDIA's MLNX_OFED source bundle (~70 MB). The kernel component
# downloads the same bundle (see base/comps/kernel/kernel.comp.toml); both
# components extract the inner mlnx-ofa_kernel SRPM out of it in their
# respective %prep sections. Keep the URL and hash in sync between the two.
[[components.mlnx-ofa_kernel.source-files]]
filename = "MLNX_OFED_SRC-26.04-0.8.5.0.tgz"
hash = "1829d190f84f6d54597b98c40e162afa64939e608f7eaf494ac626c454e4d0310e14dedb7108326e9c9a667634eb27cf751dae806249f1783a66c8fc07aacd13"
hash-type = "SHA512"
origin = { type = "download", uri = "https://linux.mellanox.com/public/repo/doca/3.4.0/SOURCES/mlnx_ofed/MLNX_OFED_SRC-26.04-0.8.5.0.tgz" }
165 changes: 165 additions & 0 deletions base/comps/mlnx-ofa_kernel/mlnx-ofa_kernel.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
%global _name mlnx-ofa_kernel
%global bundle_release 0.8.5.0
%global mlnx_ofa_release OFED.26.04.0.8.5.1
%global configure_options --with-core-mod --with-user_mad-mod --with-user_access-mod --with-addr_trans-mod --with-mlx5-mod --with-mlxfw-mod --with-ipoib-mod

Name: mlnx-ofa_kernel
Version: 26.04
Release: 1%{?dist}
Summary: NVIDIA / Mellanox OFED userspace utilities
License: GPLv2
URL: https://network.nvidia.com/products/infiniband-drivers/linux/mlnx_ofed/
Vendor: Microsoft Corporation
Distribution: Azure Linux
Source0: MLNX_OFED_SRC-%{version}-%{bundle_release}.tgz
Source1: mlnx-ofa-kmod-autoupdate.in
Source2: mlnx-ofa-kmod.actions

BuildArch: noarch
BuildRequires: systemd-rpm-macros
BuildRequires: cpio
BuildRequires: rpm-build
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd

Requires: kmod-mlnx-ofa_kernel-%{version}
Requires: kmod
Requires: coreutils
Requires: pciutils
Requires: grep
Requires: procps-ng
Requires: lsof
Requires: iproute
Requires: ethtool
Requires: libdnf5-plugin-actions

%description
Userspace utilities for the NVIDIA / Mellanox InfiniBand and Ethernet drivers
(mlnx-ofa_kernel %{version}): openibd service, interface manager scripts,
ibdev2netdev, modprobe configs, and udev rules. The kernel modules themselves
ship in the matching kmod-mlnx-ofa_kernel-%{version} package.

%package source
Summary: Source of the mlnx-ofa_kernel driver
BuildArch: noarch

%description source
Pristine source of the mlnx-ofa_kernel %{version} driver under
/usr/src/ofa_kernel-%{version}/source/.

%prep
%setup -T -c -n %{_name}-%{version}
tar -xf %{SOURCE0} --wildcards --strip-components=2 \
'MLNX_OFED_SRC-*/SRPMS/mlnx-ofa_kernel-*.src.rpm'
rpm2cpio mlnx-ofa_kernel-%{version}-%{mlnx_ofa_release}.src.rpm \
| cpio -idm '*mlnx-ofa_kernel-%{version}.tgz'
tar -xf mlnx-ofa_kernel-%{version}.tgz --strip-components=1
rm -f mlnx-ofa_kernel-%{version}-%{mlnx_ofa_release}.src.rpm \
mlnx-ofa_kernel-%{version}.tgz

%build
# Intentionally empty: userspace ships as plain scripts/configs/units.

%install
SRC=ofed_scripts

# Init script + systemd units
install -D -m 0755 $SRC/openibd %{buildroot}%{_sysconfdir}/init.d/openibd
install -D -m 0644 $SRC/openibd.service %{buildroot}%{_unitdir}/openibd.service
install -D -m 0644 $SRC/mlnx_interface_mgr@.service %{buildroot}%{_sysconfdir}/systemd/system/mlnx_interface_mgr@.service

# Configs
install -D -m 0644 $SRC/openib.conf %{buildroot}%{_sysconfdir}/infiniband/openib.conf
install -D -m 0644 $SRC/mlx5.conf %{buildroot}%{_sysconfdir}/infiniband/mlx5.conf
install -D -m 0644 $SRC/mlnx.conf %{buildroot}%{_sysconfdir}/modprobe.d/mlnx.conf
install -D -m 0644 $SRC/mlnx-bf.conf %{buildroot}%{_sysconfdir}/modprobe.d/mlnx-bf.conf
install -D -m 0644 $SRC/ib_ipoib.conf %{buildroot}%{_sysconfdir}/modprobe.d/ib_ipoib.conf

# Udev rules + helpers
install -D -m 0644 $SRC/83-mlnx-sf-name.rules %{buildroot}/lib/udev/rules.d/83-mlnx-sf-name.rules
install -D -m 0644 $SRC/90-ib.rules %{buildroot}/lib/udev/rules.d/90-ib.rules
install -D -m 0755 $SRC/sf-rep-netdev-rename %{buildroot}/lib/udev/sf-rep-netdev-rename
install -D -m 0755 $SRC/auxdev-sf-netdev-rename %{buildroot}/lib/udev/auxdev-sf-netdev-rename

# Interface manager + conf manager — openibd calls these by absolute /bin path.
install -D -m 0755 $SRC/mlnx_conf_mgr.sh %{buildroot}/bin/mlnx_conf_mgr.sh
install -D -m 0755 $SRC/mlnx_interface_mgr.sh %{buildroot}/bin/mlnx_interface_mgr.sh

# sbin tools
install -D -m 0755 $SRC/ibdev2netdev %{buildroot}%{_sbindir}/ibdev2netdev
install -D -m 0755 $SRC/setup_mr_cache.sh %{buildroot}%{_sbindir}/setup_mr_cache.sh
install -D -m 0755 $SRC/mlnx_drv_ctl %{buildroot}%{_sbindir}/mlnx_drv_ctl

# /usr/share/mlnx_ofed/ helpers
install -d %{buildroot}%{_datadir}/mlnx_ofed
install -m 0755 $SRC/mlnx_bf_assign_ct_cores.sh %{buildroot}%{_datadir}/mlnx_ofed/mlnx_bf_assign_ct_cores.sh
install -m 0755 $SRC/mod_load_funcs %{buildroot}%{_datadir}/mlnx_ofed/mod_load_funcs

# DNF5 actions hook: when kernel-core is added/upgraded, install the matching
# mlnx-ofa kmod package for that exact kernel EVR.
install -d %{buildroot}%{_libexecdir}
sed -e 's|@MLNX_OFA_VERSION@|%{version}|g' %{SOURCE1} > %{buildroot}%{_libexecdir}/mlnx-ofa-kmod-autoupdate
chmod 0755 %{buildroot}%{_libexecdir}/mlnx-ofa-kmod-autoupdate

install -D -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/dnf/libdnf5-plugins/actions.d/mlnx-ofa-kmod.actions

cat > %{buildroot}%{_sysconfdir}/infiniband/info << EOFINFO
#!/bin/bash
echo prefix=%{_prefix}
echo
echo "Configure options: %{configure_options}"
echo
EOFINFO
chmod 0755 %{buildroot}%{_sysconfdir}/infiniband/info

mkdir -p %{buildroot}%{_prefix}/src/ofa_kernel-%{version}/source
cp -a %{_builddir}/%{name}-%{version}/. \
%{buildroot}%{_prefix}/src/ofa_kernel-%{version}/source/
ln -s ofa_kernel-%{version}/source \
%{buildroot}%{_prefix}/src/mlnx-ofa_kernel-%{version}

%post
%systemd_post openibd.service

%preun
%systemd_preun openibd.service

%postun
%systemd_postun_with_restart openibd.service

%files
%license COPYING
%doc ofed_scripts/82-net-setup-link.rules
%doc ofed_scripts/vf-net-link-name.sh
%dir %{_sysconfdir}/infiniband
%config(noreplace) %{_sysconfdir}/infiniband/openib.conf
%config(noreplace) %{_sysconfdir}/infiniband/mlx5.conf
%{_sysconfdir}/infiniband/info
%{_sysconfdir}/init.d/openibd
%{_unitdir}/openibd.service
%{_sysconfdir}/systemd/system/mlnx_interface_mgr@.service
%config(noreplace) %{_sysconfdir}/modprobe.d/mlnx.conf
%config(noreplace) %{_sysconfdir}/modprobe.d/mlnx-bf.conf
%config(noreplace) %{_sysconfdir}/modprobe.d/ib_ipoib.conf
/lib/udev/sf-rep-netdev-rename
/lib/udev/auxdev-sf-netdev-rename
/lib/udev/rules.d/83-mlnx-sf-name.rules
/lib/udev/rules.d/90-ib.rules
%{_datadir}/mlnx_ofed/
%{_sbindir}/ibdev2netdev
%{_sbindir}/setup_mr_cache.sh
%{_sbindir}/mlnx_drv_ctl
/usr/libexec/mlnx-ofa-kmod-autoupdate
%config(noreplace) %{_sysconfdir}/dnf/libdnf5-plugins/actions.d/mlnx-ofa-kmod.actions
/bin/mlnx_interface_mgr.sh
/bin/mlnx_conf_mgr.sh

%files source
%license COPYING
%{_prefix}/src/ofa_kernel-%{version}/source
%{_prefix}/src/mlnx-ofa_kernel-%{version}

%changelog
* Thu Jun 11 2026 Elaheh Dehghani <edehghani@microsoft.com> - 26.04-1
- Initial AZL4 import: userspace + source companion to kmod-mlnx-ofa.
3 changes: 3 additions & 0 deletions locks/mlnx-ofa_kernel.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Managed by azldev component update. Do not edit manually.
version = 1
input-fingerprint = 'sha256:269090613d55c00f658be557dc5c30346740b3c57e4d01ba4cf71e5941a5892d'
65 changes: 65 additions & 0 deletions specs/m/mlnx-ofa_kernel/mlnx-ofa-kmod-autoupdate.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/bash
set -euo pipefail

if [[ $# -lt 4 ]]; then
exit 0
fi

pkg_name="$1"
kver="$2"
krel="$3"
karch="$4"

base_nevra="kmod-mlnx-ofa_kernel-@MLNX_OFA_VERSION@-${kver}-${krel}.${karch}"
devel_nevra="kmod-mlnx-ofa_kernel-@MLNX_OFA_VERSION@-devel-${kver}-${krel}.${karch}"
log_file="/var/log/mlnx-ofa-kmod-autoupdate.log"

notify() {
local msg="$1"
echo "$(date -Iseconds) [mlnx-ofa-kmod-autoupdate] ${msg}" >> "$log_file" 2>&1 || true
# Write to controlling terminal if available
echo "[mlnx-ofa-kmod-autoupdate] ${msg}" > /dev/tty 2>/dev/null || true
logger -t mlnx-ofa-kmod-autoupdate -- "${msg}" >/dev/null 2>&1 || true
}

# Always log invocation first so we can confirm the hook fired.
notify "invoked: pkg=${pkg_name} base_nevra=${base_nevra}"

# Only react to kernel package transactions.
if [[ ! "$pkg_name" =~ ^kernel($|-) ]]; then
notify "skipping non-kernel pkg=${pkg_name}"
exit 0
fi

notify "detected kernel transaction; checking for existing mlnx-ofa_kernel kmod"

# Only auto-install if mlnx-ofa_kernel kmod was previously installed.
if ! rpm -qa kmod-mlnx-ofa_kernel-* >/dev/null 2>&1; then
notify "no existing mlnx-ofa_kernel kmod found; skipping auto-install"
exit 0
fi

notify "found existing mlnx-ofa_kernel kmod; will attempt to install matching version for ${kver}-${krel}"

# post_transaction fires while dnf5 may still hold its lock; run the install
# in a fully detached child that retries with exit_on_lock=0.
{
for _ in 1 2 3; do
if dnf5 -y --setopt=exit_on_lock=0 install "$base_nevra" "$devel_nevra" \
>> "$log_file" 2>&1; then
notify "install succeeded"
exit 0
fi
if dnf5 -y --setopt=exit_on_lock=0 install "$base_nevra" \
>> "$log_file" 2>&1; then
notify "install succeeded (base only)"
exit 0
fi
sleep 5
done
notify "all retries failed"
} &
disown

# Best effort hook: do not fail the original transaction.
exit 0
1 change: 1 addition & 0 deletions specs/m/mlnx-ofa_kernel/mlnx-ofa-kmod.actions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
post_transaction:kernel*:in:enabled=1:/usr/libexec/mlnx-ofa-kmod-autoupdate ${pkg.name} ${pkg.version} ${pkg.release} ${pkg.arch}
Loading
Loading