Package: ifupdown-extra
Version: 0.28
Severity: important
Tags: patch

Dear Maintainer,

00check-network-cable checks whether the interface it wants to check is an
ethernet interface and it will bail out if this is not the case.

It only checks for classic interface names (eth*, e.g. eth0) and not for new
style "predictable" interface names (enp*, e.g. enp0s31f6).


The "Configuration Files:" section of this report contains a patched version of
the config file. It has the following patch applied to fix the problem:

--- a/00check-network-cable     2020-09-15 09:18:03.105795364 +0200
+++ b/00check-network-cable     2020-09-15 09:41:07.803352174 +0200
@@ -145,7 +145,7 @@
 
 # Check our IFACE name, if it does not start with eth, bail out
 case $IFACE in
-       eth*)
+       enp* | eth*)
                check_status || [ "$ABORT_NO_LINK" != "yes" ] || exit 1
                ;;
        bond*)

-- System Information:
Debian Release: 10.5
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.19.0-10-amd64 (SMP w/8 CPU cores)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_GB:en (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages ifupdown-extra depends on:
ii  bind9-host [host]            1:9.11.5.P4+dfsg-5.1+deb10u2
ii  curl                         7.64.0-4+deb10u1
ii  dpkg                         1.19.7
ii  iproute2                     4.20.0-2
ii  iputils-arping               3:20180629-2+deb10u1
ii  iputils-ping [ping]          3:20180629-2+deb10u1
ii  lsb-base                     10.2019051400
ii  net-tools                    1.60+git20180626.aebd88e-1
ii  netcat                       1.10-41.1
ii  netcat-traditional [netcat]  1.10-41.1

Versions of packages ifupdown-extra recommends:
ii  ethtool  1:4.19-1
ii  ndisc6   1.0.4-1

ifupdown-extra suggests no packages.

-- Configuration Files:
/etc/network/if-up.d/00check-network-cable changed:
rc="/etc/default/network-test"
ETHTOOL=/sbin/ethtool
alt_et=/usr/sbin/ethtool
[ -x "$ETHTOOL" ] || [ ! -x "$alt_et" ] || ETHTOOL=$alt_et
MIITOOL=/sbin/mii-tool
IPTOOL=/sbin/ip
DO_SYSLOG=yes
ABORT_NO_LINK=no
[ -r "$rc" ] && . "$rc"
if [ "$DO_SYSLOG" = yes ]; then
        OUTPUT="logger -i -p daemon.err -s"
else
        OUTPUT=echo
fi
LC_ALL=C
export LC_ALL
check_status_miitool() {
        local status=0
        if $MIITOOL "$IFACE" 2>&1 | grep -q "no link" ; then
                status=1
        fi
        return $status
}
check_status_ethtool() {
        local status=0
        local LINK="$($ETHTOOL "$IFACE" 2>&1 | grep "Link detected" 2>/dev/null 
|| :)"
        # If ethtool fails to print out the link line we break off
        # notice that ethtool cannot get the link status out of all
        # possible network interfaces
        [ -n "$LINK" ] || return 1
        if ! echo $LINK | grep -q "Link detected: yes" ; then
                status=1
        fi
        return $status
}
check_status_iplink() {
        local status=0
        local info=""
        [ -x "$IPTOOL" ] || return 0
        info=$($IPTOOL link show "$IFACE" 2>&1 | grep "$IFACE:" 2>/dev/null)
        if echo $info | grep -qE "NO-CARRIER|state DOWN|state LOWERLAYERDOWN" ; 
then
                status=1
        fi
        return $status
}
check_status() {
        local status=0 myid=$(id -u)
        ifconfig "$IFACE" >/dev/null 2>&1 || {
                $OUTPUT "ERROR: Interface $IFACE does not seem to be present" \
                        "in the system"
                return 0
        }
        # Use ethtool if installed (preferable to mii-tool)
        # If none are installed (or not running as root) we will test using
        # 'ip link show'
        if [ -x "$ETHTOOL" ] && [ $myid -eq 0 ]; then
                check_status_ethtool || status=$?
        elif [ -x "$MIITOOL" ] && [ $myid -eq 0 ]; then
                check_status_miitool || status=$?
        else
                check_status_iplink || status=$?
        fi
        [ $status -eq 0 ] ||
                $OUTPUT "WARNING: Initialising interface $IFACE which does" \
                        "not have a link"
        return $status
}
check_bond_status() {
        local status=1 inf slaves slave_iface
        slaves="/sys/class/net/$IFACE/bonding/slaves"
        [ -e "$slaves" ] || return 0
        # Loop over the list of slaves
        while read slave_ifaces; do
                for inf in $slave_ifaces; do
                        # Use ":" command to silence slaves. Run in subshell to 
preserve IFACE
                        (OUTPUT=: IFACE="$inf" check_status); status=$?
                        # One functional slave will suffice
                        [ $status -ne 0 ] || return 0
                done
        done <$slaves
        $OUTPUT "WARNING: Initialising bond $IFACE which does not have link" \
                "on any slave"
        return $status
}
[ "$IFACE" ] || {
    $OUTPUT "ERROR: Variable IFACE not set in environment"
    exit 1
}
case $IFACE in
        enp* | eth*)
                check_status || [ "$ABORT_NO_LINK" != "yes" ] || exit 1
                ;;
        bond*)
                check_bond_status || [ "$ABORT_NO_LINK" != "yes" ] || exit 1
                ;;
esac


-- no debconf information

Reply via email to