Skip to content

Commit

Permalink
Merge pull request #8 from heyvister1/add-ofed-balcklist-in-entrypoint
Browse files Browse the repository at this point in the history
Adding OFED blacklist management to MOFED container
  • Loading branch information
e0ne authored Nov 7, 2024
2 parents ee2a4b5 + 435b0ca commit f7f0c92
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@

: ${NVIDIA_NIC_DRIVERS_INVENTORY_PATH:=""}

: ${OFED_BLACKLIST_MODULES_FILE:=/etc/modprobe.d/blacklist-ofed-modules.conf}
: ${OFED_BLACKLIST_MODULES:=mlx5_core:mlx5_ib:ib_umad:ib_uverbs:ib_ipoib:rdma_cm:rdma_ucm:ib_core:ib_cm}

function timestamp_print () {
date_time_stamp=$(date +'%d-%b-%y_%H:%M:%S')
msg="[${date_time_stamp}] $@"
Expand Down Expand Up @@ -441,6 +444,25 @@ function unload_storage_modules() {
fi
}

function generate_ofed_modules_blacklist(){
echo "Function: ${FUNCNAME[0]}"

# Setting modules delimiter by ":"
IFS=':' read -ra components <<< "${OFED_BLACKLIST_MODULES}"

echo -e "# blacklist ofed-related modules on host to prevent inbox or host OFED driver loading\n" > ${OFED_BLACKLIST_MODULES_FILE}
# Split module names and append to file
for component in "${components[@]}"; do
echo "blacklist $component" >> ${OFED_BLACKLIST_MODULES_FILE}
done

debug_print "`cat ${OFED_BLACKLIST_MODULES_FILE}`"
}

function remove_ofed_modules_blacklist(){
rm -rf ${OFED_BLACKLIST_MODULES_FILE}; timestamp_print "Remove blacklisted mofed modules file from host"
}

function restart_driver() {
debug_print "Function: ${FUNCNAME[0]}"

Expand All @@ -467,9 +489,14 @@ function restart_driver() {

${load_pci_hyperv_intf} && exec_cmd "modprobe -d /host pci-hyperv-intf"

timestamp_print "Apply blacklisted mofed modules file to host (${OFED_BLACKLIST_MODULES_FILE})"
trap 'remove_ofed_modules_blacklist' EXIT
generate_ofed_modules_blacklist
${UNLOAD_STORAGE_MODULES} && unload_storage_modules

exec_cmd "/etc/init.d/openibd restart"
remove_ofed_modules_blacklist

}

function restructure_guid() {
Expand Down

0 comments on commit f7f0c92

Please sign in to comment.