From a62a07902e9bb4c874d4d5f09c3462ed05bb35dd Mon Sep 17 00:00:00 2001 From: xanoxes <857063495@qq.com> Date: Wed, 25 Sep 2024 16:05:53 +0800 Subject: [PATCH 1/2] retry arping one more time in ifup-eth when sendto failed --- network-scripts/ifup-eth | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/network-scripts/ifup-eth b/network-scripts/ifup-eth index de6af876..a9c78e1e 100755 --- a/network-scripts/ifup-eth +++ b/network-scripts/ifup-eth @@ -293,10 +293,21 @@ else if ! LC_ALL=C ip addr ls ${REALDEVICE} | LC_ALL=C grep -q "${ipaddr[$idx]}/${prefix[$idx]}" ; then if [ "${REALDEVICE}" != "lo" ] && ! is_false "${arpcheck[$idx]}"; then - ARPING=$(/sbin/arping -c 2 -w ${ARPING_WAIT:-3} -D -I ${REALDEVICE} ${ipaddr[$idx]}) - if [ $? = 1 ]; then - ARPINGMAC=$(echo $ARPING | sed -ne 's/.*\[\(.*\)\].*/\1/p') - net_log $"Error, some other host ($ARPINGMAC) already uses address ${ipaddr[$idx]}." + while [ "${tries}" -le "${ARPING_TRIES}" ]; do + ARPING=$(/sbin/arping -c 2 -w ${ARPING_WAIT:-3} -D -I ${REALDEVICE} ${ipaddr[$idx]}) + if [ $? = 1 ]; then + ARPINGMAC=$(echo $ARPING | sed -ne 's/.*\[\(.*\)\].*/\1/p') + if [ -n "${ARPINGMAC}" ]; then + net_log $"Error, some other host ($ARPINGMAC) already uses address ${ipaddr[$idx]}." + break + fi + tries=$((tries+1)) + else + break + fi + done + if [ "${tries}" -gt "${ARPING_TRIES}" ]; then + net_log $"arping failed after $tries tries" exit 1 fi fi From f4a6ef39442073ff66c71f1cc32cc546ebf38bff Mon Sep 17 00:00:00 2001 From: xanoxes <31799613+xanoxes@users.noreply.github.com> Date: Tue, 19 Nov 2024 17:42:36 +0800 Subject: [PATCH 2/2] flip to [ $? = 0 ] && break --- network-scripts/ifup-eth | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/network-scripts/ifup-eth b/network-scripts/ifup-eth index a9c78e1e..f5c6af12 100755 --- a/network-scripts/ifup-eth +++ b/network-scripts/ifup-eth @@ -295,16 +295,13 @@ else if [ "${REALDEVICE}" != "lo" ] && ! is_false "${arpcheck[$idx]}"; then while [ "${tries}" -le "${ARPING_TRIES}" ]; do ARPING=$(/sbin/arping -c 2 -w ${ARPING_WAIT:-3} -D -I ${REALDEVICE} ${ipaddr[$idx]}) - if [ $? = 1 ]; then - ARPINGMAC=$(echo $ARPING | sed -ne 's/.*\[\(.*\)\].*/\1/p') - if [ -n "${ARPINGMAC}" ]; then - net_log $"Error, some other host ($ARPINGMAC) already uses address ${ipaddr[$idx]}." - break - fi - tries=$((tries+1)) - else + [ $? = 0 ] && break + ARPINGMAC=$(echo $ARPING | sed -ne 's/.*\[\(.*\)\].*/\1/p') + if [ -n "${ARPINGMAC}" ]; then + net_log $"Error, some other host ($ARPINGMAC) already uses address ${ipaddr[$idx]}." break fi + tries=$((tries+1)) done if [ "${tries}" -gt "${ARPING_TRIES}" ]; then net_log $"arping failed after $tries tries"