[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#968368: ifenslave: Option bond-master fails to add interface to bond



This regression is currently up for release in the next stable release
this week!

Thanks for your patch Sami.
We've found a small issue with it as the order of redirections is
significant. „2>&1 >/dev/null“ does only redirect the standard output
to /dev/null. Please find attached a modified version of the patch
which fixes this order („>/dev/null 2>&1“) and redirects also stderr
as desired.
Furthermore it passes -v to to subsequent calls of ifup when needed.

Best regards
Oleander
diff --git a/debian/ifenslave.if-pre-up b/debian/ifenslave.if-pre-up
index 7579d68..ce8b161 100755
--- a/debian/ifenslave.if-pre-up
+++ b/debian/ifenslave.if-pre-up
@@ -151,13 +151,14 @@ setup_master()
 	# active_slave must be set after mode and after enslavement.
 	# The slave must be up and the underlying link must be up too.
 	# FIXME: We should have a way to write an empty string to active_slave, to set the active_slave to none.
+	[ "$VERBOSITY" = 1 ] && v=-v
 	if [ -n "$IF_BOND_ACTIVE_SLAVE" ] ; then
 		if [ "$IF_BOND_ACTIVE_SLAVE" = "none" ] ; then
 			sysfs active_slave ""
 		else
 			# Need to force interface up before. Bonding will refuse to activate a down interface.
-			if ifquery -l "$IF_BOND_ACTIVE_SLAVE" 2>/dev/null ; then
-				ifup "$IF_BOND_ACTIVE_SLAVE"
+			if ifquery -l "$IF_BOND_ACTIVE_SLAVE" >/dev/null 2>&1; then
+				ifup $v "$IF_BOND_ACTIVE_SLAVE"
 			else
 				ip link set "$IF_BOND_ACTIVE_SLAVE" up
 			fi
@@ -194,7 +195,7 @@ setup_master_device() {
 
 setup_slave_device() {
 	# Require the bond master to have an iface stanza
-	if ! ifstate -l "$IF_BOND_MASTER" 2>/dev/null ; then
+	if ! ifquery -l "$IF_BOND_MASTER" >/dev/null 2>&1; then
 		echo "No iface stanza found for master $IF_BOND_MASTER" >&2
 		exit 1
 	fi
@@ -203,14 +204,15 @@ setup_slave_device() {
 	export IFENSLAVE_ENV_NAME="IFUPDOWN_$IF_BOND_MASTER"
 	IFUPDOWN_IF_BOND_MASTER="$(printenv "$IFENSLAVE_ENV_NAME")"
 	unset IFENSLAVE_ENV_NAME
+	[ "$VERBOSITY" = 1 ] && v=-v
 	if [ -z "$IFUPDOWN_IF_BOND_MASTER" ] ; then
-		ifquery --state "$IF_BOND_MASTER" 2>/dev/null || ifup "$IF_BOND_MASTER"
+		ifquery --state "$IF_BOND_MASTER" >/dev/null 2>&1 || ifup $v "$IF_BOND_MASTER"
 	fi
 
 	# Enslave it to the master
-	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." >&2
+	ip link set "$1" down 2>/dev/null
+	if ! sysfs_add slaves "$1" 2>/dev/null ; then
+		echo "Failed to enslave $1 to $BOND_MASTER." >&2
 	fi
 
 	setup_primary

Reply to: