#!/usr/sbin/sh # # Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. # PATH=/usr/bin:/usr/sbin . /lib/svc/share/smf_include.sh ENX_DRIVER_SIG=eibnx@ EOIB_DRIVER_SIG=/ib/eibnx@0/eoib@hermon VERSION_PROP=config/version EOIB_UPGRADE_CURRENT_VERSION=1 DEV_FS_FMRI=svc:/system/devfsadm:default old_enx_signature_is_present() { # # Check if there are any eoib physical datalinks registered in the # system before the upgrade. # grep "$ENX_DRIVER_SIG" /etc/path_to_inst > /dev/null return $? } gwmap() { grep "$EOIB_DRIVER_SIG" /etc/path_to_inst | sed -e "s#$EOIB_DRIVER_SIG##g" | sed -e 's/\"//g' | sed -e 's/\,/:/g' | awk '{print $1":"$2}' } upgrade_service() { svccfg -s $1 setprop $VERSION_PROP = $EOIB_UPGRADE_CURRENT_VERSION svcadm refresh $1 } disable_old_eoib() { # # Disable the old eoib and eibnx driver # rem_drv eoib 2>&1 > /dev/null rem_drv eibnx 2>&1 > /dev/null # # Remove stale /dev/eoib symlinks. # rm -f /dev/eoib* return 0 } wait_for_gw() { MAX_ITER=30 count=0 GWIDS=`gwmap | cut -d: -f3 | sort | uniq | xargs | sed 's, ,|,g'` if [ -z "$GWIDS" ]; then return 0 fi while [ $count -lt $MAX_ITER ]; do dladm show-ib -p -o gwid | egrep -i "$GWIDS" > /dev/null if [ $? -eq 0 ]; then return 0 fi sleep 1 count=`expr $count + 1` done return 1 } migrate_eoib() { # # Wait for gateway discovery to begin and GWID translations # to become available # wait_for_gw # # Try to migrate each existing link to the new model # for i in $(gwmap) do HCA=`echo $i | cut -f1 -d:` PORT=`echo $i | cut -f2 -d:` GWID=`echo $i | cut -f3 -d:` INST=`echo $i | cut -f4 -d:` echo "migrating eoib$INST(hca$HCA,port$PORT,gwid$GWID)..." eoib_link_migrate $HCA $PORT $GWID $INST 2>&1 if [ $? -ne 0 ] then echo " migrate eoib$INST manually using dladm(1M)" fi done sync return 0 } clean_pti() { MAX_ITER=600 count=0 while [ $count -lt $MAX_ITER ]; do devfsadm_state=`svcprop -p restarter/state $DEV_FS_FMRI` if [ "$devfsadm_state" == "online" ]; then break; fi sleep 1 count=`expr $count + 1` done grep -v "$ENX_DRIVER_SIG" /etc/path_to_inst > /etc/path_to_inst.old \ 2> /dev/null cp /etc/path_to_inst.old /etc/path_to_inst > /dev/null 2>&1 sync return 0 } # # Main script # # # do just path_to_inst cleanup if no arguments are given # trigger_pti_cleanup=$0 if [ -z "$1" ]; then clean_pti exit $SMF_EXIT_OK fi # # if passed in version is the same as current version, nothing to do # if [ "$1" == "$EOIB_UPGRADE_CURRENT_VERSION" ]; then exit $SMF_EXIT_OK fi if old_enx_signature_is_present then disable_old_eoib migrate_eoib $trigger_pti_cleanup & fi upgrade_service $SMF_FMRI exit $SMF_EXIT_OK