summaryrefslogtreecommitdiff
path: root/meta-google
diff options
context:
space:
mode:
Diffstat (limited to 'meta-google')
-rwxr-xr-xmeta-google/recipes-google/networking/google-usb-network/usb_network.sh17
1 files changed, 10 insertions, 7 deletions
diff --git a/meta-google/recipes-google/networking/google-usb-network/usb_network.sh b/meta-google/recipes-google/networking/google-usb-network/usb_network.sh
index ba271b7cf9..ec9c2cf559 100755
--- a/meta-google/recipes-google/networking/google-usb-network/usb_network.sh
+++ b/meta-google/recipes-google/networking/google-usb-network/usb_network.sh
@@ -95,13 +95,16 @@ EOF
ln -s "${func_dir}" "${config_dir}" || return
echo "${BIND_DEVICE}" >${gadget_dir}/UDC || return
- local ifname
- ifname="$(<"${func_dir}"/ifname)" || return
- if [ "${IFACE_NAME}" != "$ifname" ]; then
- # We don't care if downing the interface fails, only the rename
- ip link set dev "$ifname" down || true
- ip link set dev "$ifname" name "${IFACE_NAME}" || return
- fi
+ # Try to reconfigure a few times in case we race with systemd-networkd
+ local start=$SECONDS
+ while (( SECONDS - start < 5 )); do
+ local ifname
+ ifname="$(<"${func_dir}"/ifname)" || return
+ [ "${IFACE_NAME}" = "$ifname" ] && break
+ ip link set dev "$ifname" down && \
+ ip link set dev "$ifname" name "${IFACE_NAME}" && break
+ sleep 1
+ done
ip link set dev "$IFACE_NAME" up || return
}