Bug#990428: ifenslave: Bonding not working on bullseye (using bond-slaves config)

2021-06-28 Thread Claudio Kuenzler
Package: ifenslave
Version: 2.12
Severity: important

Dear Maintainer,

Bonding on Debian 11 Bullseye is not working, when using "bond-slaves int1 
int2" syntax on the bonding interface.
However it seems to work, when defining bonding the other way around using 
"bond-master bond1" on the interfaces which make up the bonding interface.

I came across bug #968368 and modified the ifenslave pre-up.d script, hence the 
changes below.

The same config (using bond-slaves) was working fine in Debian Buster. In 
Bullseye the bond interface stays DOWN and /proc/net/bonding/bond* also shows 
mii-status down.

-- System Information:
Debian Release: 11.0
  APT prefers testing-security
  APT policy: (500, 'testing-security'), (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 5.10.0-7-amd64 (SMP w/24 CPU threads)
Kernel taint flags: TAINT_FIRMWARE_WORKAROUND
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages ifenslave depends on:
ii  ifupdown  0.8.36
ii  iproute2  5.10.0-4

Versions of packages ifenslave recommends:
ii  net-tools  1.60+git20181103.0eebece-1

ifenslave suggests no packages.

-- Configuration Files:
/etc/network/if-pre-up.d/ifenslave changed:
[ "$VERBOSITY" = 1 ] && set -x
[ "$ADDRFAM" = meta ] && exit 0
add_master()
{
# Return if $IFACE is already a bonding interface.
[ -f "/sys/class/net/$IFACE/bonding/slaves" ] && return
ip link add dev "$IFACE" type bond
}
sysfs_change_down()
{
# Called with :
# $1 = basename of the file in bonding/ to write to.
# $2 = value to write. Won't write if $2 is empty.
if [ -n "$2" ] ; then
# If the value we plan to write is different from the current 
one...
if ! grep -sq "\\<$2\\>" 
"/sys/class/net/$BOND_MASTER/bonding/$1" ; then
# ...and the master is up...
if ip link show "$BOND_MASTER" | grep -sq '[<,]UP[,>]' 
; then
# ...bring the master down.
ip link set dev "$BOND_MASTER" down
fi
fi
sysfs "$1" "$2"
fi
}
sysfs()
{
# Called with :
# $1 = basename of the file in bonding/ to write to.
# $2 = value to write. Won't write if $2 is empty.
if [ -n "$2" ] ; then
echo "$2" > "/sys/class/net/$BOND_MASTER/bonding/$1"
return $?
fi
return 0
}
sysfs_add()
{
#??Called with :
# $1 = target filename.
# $2 = values to write.
for value in $2; do
# Do not add $2 to $1 if already present.
if ! grep -sq "\\<$value\\>" 
"/sys/class/net/$BOND_MASTER/bonding/$1"
then
sysfs "$1" "+$value"
fi
done
}
early_setup_master()
{
# Warning: the order in which we write into the sysfs files is 
important.
# Double check in drivers/net/bonding/bond_sysfs.c in the Linux kernel 
source tree
# before changing anything here.
# fail_over_mac must be set before enslavement of any slaves.
sysfs fail_over_mac "$IF_BOND_FAIL_OVER_MAC"
}
enslave_slaves()
{
case "$BOND_SLAVES" in
none)
BOND_SLAVES=""
;;
all)
BOND_SLAVES=$(sed -ne 's/ *\(eth[^:]*\):.*/\1/p' 
/proc/net/dev)
;;
esac
[ "$VERBOSITY" = 1 ] && v=-v
for slave in $BOND_SLAVES ; do
export IFENSLAVE_ENV_NAME="IFUPDOWN_$slave"
IFUPDOWN_IFACE="$(printenv "$IFENSLAVE_ENV_NAME")"
unset IFENSLAVE_ENV_NAME
#if ifquery --state "$slave" 2>/dev/null || [ -n 
"$IFUPDOWN_IFACE" ] ; then
if ifquery --state "$slave" 2>/dev/null ; then
# Skipping interface that's already up or being 
configured
continue
else
# Ensure $slave is down.
ip link set "$slave" down 2>/dev/null
if ! sysfs_add slaves "$slave" 2>/dev/null ; then
echo "Failed to enslave $slave to $BOND_MASTER. 
Is $BOND_MASTER ready and a bonding interface ?" >&2
else
# Bring up slave if it is the target of an 
allow-bondX stanza.
# This is useful to bring up slaves that need 
extra setup.
ifup $v --allow "$BOND_MASTER" "$slave"
fi
fi
done
}
setup_master()
{
# Warning: the order in which we write into the sysfs files is 
important.
# Double check in drivers/net/bonding/bond_s

Bug#990428: Additional information

2021-06-28 Thread Claudio Kuenzler
Non-working bonding config in /etc/network/interfaces:

auto enp4s0f0
iface enp4s0f0 inet manual

auto enp4s0f1
iface enp4s0f1 inet manual

auto bond1
iface bond1 inet static
  address 192.168.12.4/24
  gateway 192.168.12.1
  slaves enp4s0f0 enp4s0f1
  bond-mode 802.3ad
  bond-miimon 100
  bond-downdelay 200
  bond-updelay 200

(also mentioned in https://wiki.debian.org/Bonding)


Working config:

auto enp4s0f0
iface enp4s0f0 inet manual
  bond-master bond1

auto enp4s0f1
iface enp4s0f1 inet manual
  bond-master bond1

auto bond1
iface bond1 inet static
  address 192.168.12.4/24
  gateway 192.168.12.1
  bond-slaves none
  bond-mode 802.3ad
  bond-miimon 100
  bond-downdelay 200
  bond-updelay 200


Bug#990428: ifenslave: Bonding not working on bullseye (using bond-slaves config)

2021-09-01 Thread Claudio Kuenzler
> In your case you could simply remove the stanzas for enp4s0f0 and enp4s0f1 
> which would leave you with just the stanza for bond1:

> iface bond1 inet static
>   bond-slaves enp4s0f0 enp4s0f1

Thank you Oleander. It works with this hint (the physical interfaces
were left out of the config).
Working config:
=
ck@bullseye:~$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

auto bond0
iface bond0 inet static
  address 192.168.12.4/24
  gateway 192.168.12.1
  bond-slaves enp3s0f0 enp3s0f1
  bond-mode 802.3ad
  bond-miimon 100
  bond-lacp-rate 1
=

> That should work but it is still a regression as it breaks configuration 
> which worked before.

Yes, agree. Do you know if your patch (I have not tested) will be
included in the next point release?

> https://serverfault.com/a/1075192/267378
>
> Best regards,
> Arunas

You mention both bond-master of the physical devices and blond-slaves
on the bond interface. This causes networking service to hiccup in my
case:

Sep 01 15:58:23 irczsrvp09 systemd[1]: Starting Raise network interfaces...
Sep 01 15:58:23 irczsrvp09 ifup[1251]: No iface stanza found for master bond0
Sep 01 15:58:23 irczsrvp09 ifup[1249]: run-parts:
/etc/network/if-pre-up.d/ifenslave exited with return code 1
Sep 01 15:58:23 irczsrvp09 ifup[1242]: ifup: failed to bring up enp3s0f0
Sep 01 15:58:23 irczsrvp09 ifup[1256]: No iface stanza found for master bond0
Sep 01 15:58:23 irczsrvp09 ifup[1254]: run-parts:
/etc/network/if-pre-up.d/ifenslave exited with return code 1
Sep 01 15:58:23 irczsrvp09 ifup[1242]: ifup: failed to bring up enp3s0f1
Sep 01 15:58:23 irczsrvp09 ifup[1261]: No iface stanza found for master bond1
Sep 01 15:58:23 irczsrvp09 ifup[1259]: run-parts:
/etc/network/if-pre-up.d/ifenslave exited with return code 1
Sep 01 15:58:23 irczsrvp09 ifup[1242]: ifup: failed to bring up enp4s0f0
Sep 01 15:58:23 irczsrvp09 ifup[1266]: No iface stanza found for master bond1
Sep 01 15:58:23 irczsrvp09 ifup[1264]: run-parts:
/etc/network/if-pre-up.d/ifenslave exited with return code 1
Sep 01 15:58:23 irczsrvp09 ifup[1242]: ifup: failed to bring up enp4s0f1

Although the bonding interface seems to work with your workaround, the
Systemd service (networking) is stuck at failed state.

So for now the "proper" way to fix this seems to be to remove the
physical device stanzas and only use the bonding interfaces - until
this bug is fixed.