[Why] The `run-ipconfig` step is the IP configuration step for initramfs; The `[ -z "$net_devices"]` step is check whether the network is normal.
Now the `check normal` step is before 'ip configuration' step, so we encounter the following error: + export NO_NETWORK=1 + echo export NO_NETWORK=1 due to no net devices + return
[Debug Msg] + [ ! -e /usr/share/initramfs-tools/scripts/functions ] + get_net_devices + local net_devices + local i + [ /sys/class/net/enp0s1/ != /sys/class/net/enp0s1/ ] + [ /sys/class/net/enp0s1/ != /sys/class/net/enp0s1/ ] + [ p0s1/ != /sys/class/net/enp0s1/ ] + basename /sys/class/net/enp0s1/ + net_devices= enp0s1 + [ != /sys/class/net/lo/ ] + continue + echo enp0s1 + local net_devices= enp0s1 + [ -z ] + warn_no_eth0 + [ -f /proc/config.gz ] + return + echo ls /sys/class/net + ls /sys/class/net + is_virt + [ -n ] + [ -n ] + has_cmd virt-what + command -v virt-what + grep -q -w hypervisor /proc/cpuinfo + return 0 + export NO_NETWORK=1 + echo export NO_NETWORK=1 due to no net devices + return
Signed-off-by: Yu Chuan 13186087857@163.com --- lib/bootstrap.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/bootstrap.sh b/lib/bootstrap.sh index 7d15bb370fa9..770d550724f1 100755 --- a/lib/bootstrap.sh +++ b/lib/bootstrap.sh @@ -160,6 +160,9 @@ setup_network() return }
+ $LKP_DEBUG_PREFIX $LKP_SRC/bin/run-ipconfig + network_ok && return + local net_devices=$(get_net_devices) if [ -z "$net_devices" ]; then
@@ -181,9 +184,6 @@ setup_network() fi fi
- $LKP_DEBUG_PREFIX $LKP_SRC/bin/run-ipconfig - network_ok && return - local err_msg='IP-Config: Auto-configuration of network failed' dmesg | grep -q -F "$err_msg" || { # Include $err_msg in the error message so that it matches
On Mon, Jan 04, 2021 at 03:47:44PM +0800, Yu Chuan wrote:
[Why] The `run-ipconfig` step is the IP configuration step for initramfs; The `[ -z "$net_devices"]` step is check whether the network is normal.
Now the `check normal` step is before 'ip configuration' step, so we encounter the following error:
- export NO_NETWORK=1
- echo export NO_NETWORK=1 due to no net devices
- return
[Debug Msg]
- [ ! -e /usr/share/initramfs-tools/scripts/functions ]
- get_net_devices
- local net_devices
- local i
- [ /sys/class/net/enp0s1/ != /sys/class/net/enp0s1/ ]
- [ /sys/class/net/enp0s1/ != /sys/class/net/enp0s1/ ]
- [ p0s1/ != /sys/class/net/enp0s1/ ]
- basename /sys/class/net/enp0s1/
- net_devices= enp0s1
- [ != /sys/class/net/lo/ ]
- continue
- echo enp0s1
- local net_devices= enp0s1
- [ -z ]
- warn_no_eth0
- [ -f /proc/config.gz ]
- return
- echo ls /sys/class/net
- ls /sys/class/net
- is_virt
- [ -n ]
- [ -n ]
- has_cmd virt-what
- command -v virt-what
- grep -q -w hypervisor /proc/cpuinfo
- return 0
- export NO_NETWORK=1
- echo export NO_NETWORK=1 due to no net devices
- return
Signed-off-by: Yu Chuan 13186087857@163.com
lib/bootstrap.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/bootstrap.sh b/lib/bootstrap.sh index 7d15bb370fa9..770d550724f1 100755 --- a/lib/bootstrap.sh +++ b/lib/bootstrap.sh @@ -160,6 +160,9 @@ setup_network() return }
- $LKP_DEBUG_PREFIX $LKP_SRC/bin/run-ipconfig
- network_ok && return
- local net_devices=$(get_net_devices) if [ -z "$net_devices" ]; then
The patch moved around the $net_devices test. What line of code will set $net_devices (or somehow affect its setting)? That fact will answer the question "why the move (hence this patch) helps"?
Thanks, Fengguang
@@ -181,9 +184,6 @@ setup_network() fi fi
- $LKP_DEBUG_PREFIX $LKP_SRC/bin/run-ipconfig
- network_ok && return
- local err_msg='IP-Config: Auto-configuration of network failed' dmesg | grep -q -F "$err_msg" || { # Include $err_msg in the error message so that it matches
-- 2.23.0
- $LKP_DEBUG_PREFIX $LKP_SRC/bin/run-ipconfig
- network_ok && return
- local net_devices=$(get_net_devices) if [ -z "$net_devices" ]; then
The patch moved around the $net_devices test. What line of code will set $net_devices (or somehow affect its setting)? That fact will answer the question "why the move (hence this patch) helps"?
OMG! The real root reason is because of dash and the follow line: local net_devices=$(get_net_devices)
Explain: 1. get_net_devices is a function, and it return " enp0s1", 2. in dash, local net_devices=$(get_net_devices) => local net_devices= enp0s1 => net_devices will be none! 3. test code: + local ycb= asf + echo ycb: : ycb: :
Conclusion: We only need add double quote for the follow code to solve this problem: before: local net_devices=$(get_net_devices) after: local net_devices="$(get_net_devices)"
-------- Thanks Yu Chuan
Thanks, Fengguang
@@ -181,9 +184,6 @@ setup_network() fi fi
- $LKP_DEBUG_PREFIX $LKP_SRC/bin/run-ipconfig
- network_ok && return
- local err_msg='IP-Config: Auto-configuration of network failed' dmesg | grep -q -F "$err_msg" || { # Include $err_msg in the error message so that it matches
-- 2.23.0
TO ALL.
On Mon, Jan 04, 2021 at 06:45:59PM +0800, Yu Chuan wrote:
- $LKP_DEBUG_PREFIX $LKP_SRC/bin/run-ipconfig
- network_ok && return
- local net_devices=$(get_net_devices) if [ -z "$net_devices" ]; then
The patch moved around the $net_devices test. What line of code will set $net_devices (or somehow affect its setting)? That fact will answer the question "why the move (hence this patch) helps"?
OMG! The real root reason is because of dash and the follow line: local net_devices=$(get_net_devices)
Explain:
- get_net_devices is a function, and it return " enp0s1",
- in dash, local net_devices=$(get_net_devices) => local net_devices= enp0s1 => net_devices will be none!
- test code:
ycb: :
- local ycb= asf
- echo ycb: :
Conclusion: We only need add double quote for the follow code to solve this problem: before: local net_devices=$(get_net_devices) after: local net_devices="$(get_net_devices)"
Good catch! 我们将来需要这样刨根问底的fix,避免稀里糊涂的“好像这样就行了”的fix. 预防的方法,就是要求在changelog里给出一个明确的root cause.
Thanks, Fengguang
@@ -181,9 +184,6 @@ setup_network() fi fi
- $LKP_DEBUG_PREFIX $LKP_SRC/bin/run-ipconfig
- network_ok && return
- local err_msg='IP-Config: Auto-configuration of network failed' dmesg | grep -q -F "$err_msg" || { # Include $err_msg in the error message so that it matches
-- 2.23.0