core: initrd 阶段等待网卡启动

This commit is contained in:
bin456789
2025-03-26 20:50:45 +08:00
parent d7540ff59c
commit 2a8e760b97
3 changed files with 11 additions and 5 deletions

View File

@@ -42,9 +42,9 @@ get_ethx() {
# 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000\ link/ether 60:45:bd:21:8a:51 brd ff:ff:ff:ff:ff:ff
# 3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP800> mtu 1500 qdisc mq master eth0 state UP qlen 1000\ link/ether 60:45:bd:21:8a:51 brd ff:ff:ff
if false; then
ip -o link | grep -i "$mac_addr" | grep -v master | awk '{print $2}' | cut -d: -f1
ip -o link | grep -i "$mac_addr" | grep -v master | awk '{print $2}' | cut -d: -f1 | grep .
else
ip -o link | grep -i "$mac_addr" | grep -v master | cut -d' ' -f2 | cut -d: -f1
ip -o link | grep -i "$mac_addr" | grep -v master | cut -d' ' -f2 | cut -d: -f1 | grep .
fi
}
@@ -274,7 +274,13 @@ flush_ipv6_config() {
ip -6 route flush dev "$ethx"
}
ethx=$(get_ethx)
for i in $(seq 20); do
if ethx=$(get_ethx); then
break
fi
sleep 1
done
if [ -z "$ethx" ]; then
echo "Not found network card: $mac_addr"
exit