Package: ifupdown-extra
Version: 0.32
Hello,
the 10check-duplicate-ip produces errors when used with iputils-arping:
Jan 5 12:56:12 uhlar-nb nm-dispatcher[46938]:
/etc/network/if-up.d/10check-duplicate-ip: 86: cannot create /dev/stdout: No
such device or address
Jan 5 12:56:12 uhlar-nb root[46948]: ERROR: Duplicate address 192.168.0.13
assigned in the network where wlan0 is connected to.
Jan 5 12:56:12 uhlar-nb nm-dispatcher[46948]: <27>Jan 5 12:56:12 root[46948]:
ERROR: Duplicate addres 192.168.0.13 assigned in the network where wlan0 is connected
to.
1.
redirection to /dev/stdout fails, apparently there's no stdout when the
script is run, filedescriptor 1 (stdout) is closed and the redirection fails
because (/dev/stdout points to /proc/self/fd/1 which does not exist.
This issue is (partly) caused by fix for bug #632210, unfortunately this fix
causes an error.
2.
the duplicate address detection reports duplicity.
This seems to be caused by different behaviour of arping and iputils-arping:
- arping returns 0 when ping is successfull, 1 when it's not:
-D
Duplicate address detection mode (DAD). See RFC2131, 4.4.1. Returns
0, if DAD succeeded i.e. no replies are received.
# /usr/sbin/arping -c 2 -w 3 -D -I wlan0 192.168.0.11
!! 0% packet loss (0 extra)
# echo $?
0
# /usr/sbin/arping -c 2 -w 3 -D -I wlan0 192.168.0.12
.. 100% packet loss (0 extra)
Exit 1
- iputils-arping returns 1 when ping is successful, 0 when it's not:
-d Find duplicate replies. Exit with 1 if there are answers from
two different MAC addresses.
# /usr/bin/arping -c 2 -w 3 -D -I wlan0 192.168.0.11
ARPING 192.168.0.11 from 0.0.0.0 wlan0
Unicast reply from 192.168.0.11 [30:3A:64:aa:bb:cc] 85.519ms
Sent 1 probes (1 broadcast(s))
Received 1 response(s)
Exit 1
# /usr/bin/arping -c 2 -w 3 -D -I wlan0 192.168.0.12
ARPING 192.168.0.12 from 0.0.0.0 wlan0
Sent 2 probes (2 broadcast(s))
Received 0 response(s)
# echo $?
0
so, the compared value has to be different for these two commands.
The good info is that arping now supports the "-q" option, so the
redirection is not needed:
# /usr/bin/arping -c 2 -w 3 -D -I wlan0 192.168.0.11 -q
Exit 1
# /usr/bin/arping -c 2 -w 3 -D -I wlan0 192.168.0.12 -q
# echo $?
0
I am attaching patch that:
- removes redirection
- adds -q option for either arping version
- defined return value to compare exit code
This error was also mentioned in bug 993826.
I have tested with both arping and iputils-arping, no duplicities detected
and no errors noticed.
Notes:
- "Exit 1" is produced by my shell when command returns non-zero status
- 192.168.0.11 is alive on my network, 192.168.0.12 is not
--
Matus UHLAR - fantomas, [email protected] ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
I don't have lysdexia. The Dog wouldn't allow that.
--- 10check-duplicate-ip.orig 2021-06-03 08:13:30.000000000 +0200
+++ 10check-duplicate-ip 2022-01-05 13:39:15.087699050 +0100
@@ -83,8 +83,8 @@
# Skip interface is address is IPv6, arping only works for IPv4
if ! echo ${ADDR} | grep -q ":" ; then
[ "$VERBOSITY" -eq 1 ] && $OUTPUT "DEBUG: Sending arp pings through $real_iface (for $IFACE) to detect other systems using $ADDR"
- $ARPING -c $ARP_COUNT -w $ARP_TIMEOUT -D -I $real_iface $ADDR $ARPING_EXTRAOPTS >$ARPING_REDIR
- if [ $? -ne 0 ] ; then
+ $ARPING -c $ARP_COUNT -w $ARP_TIMEOUT -D -I $real_iface $ADDR -q
+ if [ $? -eq $ARPING_DUPLICITY ] ; then
$OUTPUT "ERROR: Duplicate address $ADDR assigned in the network where $real_iface is connected to."
fi
fi
@@ -118,15 +118,13 @@
# We are going to use iputils-arping
ARPING=/usr/bin/arping
ARP_TIMEOUT=${ARP_TIMEOUT:-3} # Time here is measured in seconds
- ARPING_EXTRAOPTS="-q" # Use -q(uiet) in iputil's arping
- ARPING_REDIR="/dev/stdout" # Do not redirect output
+ ARPING_DUPLICITY=1 # iputils-arping returns 1 when duplicity is detected
else
if [ -x /usr/sbin/arping ] ; then
ARPING=/usr/sbin/arping
ARP_TIMEOUT=${ARP_TIMEOUT:-1500} # Time here is measures in milliseconds
# experiments show anything less than 1500 is unreliable.
- ARPING_EXTRAOPTS="" # No '-q' option in arping
- ARPING_REDIR="/dev/null" # Send output to /dev/null if using this program
+ ARPING_DUPLICITY=0 # arping returns 0 when duplicity is detected
else
# Do not continue if ARPING is not available
echo "WARNING: Cannot check for duplicate IP address in the network. The script cannot find the 'arping' program (tried /usr/bin/arping and /usr/sbin/arping. Please either install the iputils-arping or arping packages or disable this test by setting DO_ARPING to 'no' in $DEFAULT ." >&2