Skip to content

Commit

Permalink
retry arping one more time in ifup-eth when sendto failed
Browse files Browse the repository at this point in the history
  • Loading branch information
xanoxes authored and hanhuihui committed Nov 19, 2024
1 parent 5c61fd7 commit bab1ec4
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions network-scripts/ifup-eth
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,18 @@ 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
while [ "${tries}" -le "${ARPING_TRIES}" ]; do
ARPING=$(/sbin/arping -c 2 -w ${ARPING_WAIT:-3} -D -I ${REALDEVICE} ${ipaddr[$idx]})
[ $? = 0 ] && break

Check warning

Code scanning / shellcheck

SC2181 Warning

Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.
ARPINGMAC=$(echo $ARPING | sed -ne 's/.*\[\(.*\)\].*/\1/p')
net_log $"Error, some other host ($ARPINGMAC) already uses address ${ipaddr[$idx]}."
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"
exit 1
fi
fi
Expand Down

0 comments on commit bab1ec4

Please sign in to comment.