1321762Ssephe#!/bin/sh 2321762Ssephe 3321762Ssephe# 4321762Ssephe# If transparent VF is enabled, don't do anything. 5321762Ssephe# 6321762Ssephe 7321762Ssephesysctl -n hw.hn.vf_transparent > /dev/null 2>&1 8321762Ssepheif [ $? -ne 0 ] 9321762Ssephethen 10321762Ssephe # Old kernel; no transparent VF. 11321762Ssephe vf_transparent=0 12321762Ssepheelse 13321762Ssephe vf_transparent=`sysctl -n hw.hn.vf_transparent` 14321762Ssephefi 15321762Ssephe 16321762Ssepheif [ $vf_transparent -ne 0 ] 17321762Ssephethen 18321762Ssephe # Transparent VF; done! 19321762Ssephe exit 0 20321762Ssephefi 21321762Ssephe 22321762Ssepheiface=$1 23321762Ssephedelay=$2 24321762Ssephe 25321762Ssepheif [ $delay -gt 0 ] 26321762Ssephethen 27321762Ssephe # 28321762Ssephe # Delayed VF up. 29321762Ssephe # 30321762Ssephe sleep $delay 31321762Ssephe ifconfig $iface up 32321762Ssephe # Done! 33321762Ssephe exit $? 34321762Ssephefi 35321762Ssephe 36321762Ssephe# 37321762Ssephe# Check to see whether $iface is a VF or not. 38321762Ssephe# If $iface is a VF, bring it up now. 39321762Ssephe# 40321762Ssephe 41321762Ssephe# for hyperv_vf_delay 42321762Ssephe. /etc/rc.conf 43321762Ssephe 44321762Ssephesysctl -n hw.hn.vflist > /dev/null 2>&1 45321762Ssepheif [ $? -ne 0 ] 46321762Ssephethen 47321762Ssephe # Old kernel; nothing could be done properly. 48321762Ssephe exit 0 49321762Ssephefi 50321762Ssephevf_list=`sysctl -n hw.hn.vflist` 51321762Ssephe 52321762Ssephefor vf in $vf_list 53321762Ssephedo 54321762Ssephe if [ $vf = $iface ] 55321762Ssephe then 56321762Ssephe # 57321762Ssephe # Linger a little bit (at least 2 seconds) mainly to 58321762Ssephe # make sure that $iface is fully attached. 59321762Ssephe # 60321762Ssephe # NOTE: 61321762Ssephe # In Azure hyperv_vf_delay should be configured to a 62321762Ssephe # large value, e.g. 120 seconds, to avoid racing cloud 63321762Ssephe # agent goofs. 64321762Ssephe # 65321762Ssephe test $hyperv_vf_delay -ge 2 > /dev/null 2>&1 66321762Ssephe if [ $? -ne 0 ] 67321762Ssephe then 68321762Ssephe hyperv_vf_delay=2 69321762Ssephe fi 70321762Ssephe # 71321762Ssephe # NOTE: 72321762Ssephe # "(sleep ..; ifconfig .. up) > /dev/null 2>&1 &" 73321762Ssephe # does _not_ work. 74321762Ssephe # 75321762Ssephe daemon -f /usr/libexec/hyperv/hyperv_vfattach \ 76321762Ssephe $iface $hyperv_vf_delay 77321762Ssephe break 78321762Ssephe fi 79321762Ssephedone 80