+if $unload_all; then
+ unload_dep_modules_inclusive 'ptlrpc' || exit 1
+ # LNet may have an internal ref which can prevent LND modules from
+ # unloading. Try to drop it before unloading modules.
+ # NB: we squelch stderr because lnetctl/lctl may complain about
+ # LNet being "busy", but this is normal. We're making a best effort
+ # here.
+ # Prefer lnetctl if it is present
+ if [ -n "$(which lnetctl 2>/dev/null)" ]; then
+ lnetctl lnet unconfigure 2>/dev/null
+ elif [ -n "$(which lctl 2>/dev/null)" ]; then
+ lctl net down 2>/dev/null | grep -v "LNET ready to unload"
+ fi
+fi
+