commit d9bcb21179ccfea122f326aca4690afe0f7de0c6 Author: Mingming Cao Date: Mon Mar 1 21:34:34 2021 -0800 hcnmgr: Wait for sysfs device ready when looking up device name At the time of calling ofpathname to look up for devicename, wait for sysfs device ready. Otherwise, the OS may be in the middle of device renaming. Signed-off-by: Mingming Cao [tyreld: fixed up commit log] Signed-off-by: Tyrel Datwyler diff --git a/scripts/hcnmgr b/scripts/hcnmgr index c95edba..0d20e7d 100644 --- a/scripts/hcnmgr +++ b/scripts/hcnmgr @@ -241,7 +241,10 @@ get_dev_hcn() { # Let's retry a few times. while [ $wait != 0 ]; do if DEVNAME=$(ofpathname -l "$(echo "$1" | sed -e "s/\/proc\/device-tree//")" 2>/dev/null); then - break + if [ -e /sys/class/net/"$DEVNAME" ]; then + hcnlog DEBUG "ofpathname waiting for /sys/class/net device $DEVNAME ready" + break + fi fi hcnlog DEBUG "ofpathname return $?, devname is $DEVNAME rety counter $wait"