summaryrefslogtreecommitdiff
path: root/recipes-core/init-ifupdown/files/bonding.up
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2017-02-13 14:25:26 -0600
committerJohn Klug <john.klug@multitech.com>2017-02-13 14:25:26 -0600
commita6ce3e3dc0def6ca7ea46b07cf28b1cf292b108b (patch)
tree94a70c972dfcd9aee17aa8e9bd7980b69b02707c /recipes-core/init-ifupdown/files/bonding.up
parentd5ec24692d94485163799cf42018012b86571054 (diff)
downloadmeta-mlinux-a6ce3e3dc0def6ca7ea46b07cf28b1cf292b108b.tar.gz
meta-mlinux-a6ce3e3dc0def6ca7ea46b07cf28b1cf292b108b.tar.bz2
meta-mlinux-a6ce3e3dc0def6ca7ea46b07cf28b1cf292b108b.zip
Add bonding ifup ifdown
Diffstat (limited to 'recipes-core/init-ifupdown/files/bonding.up')
-rw-r--r--recipes-core/init-ifupdown/files/bonding.up45
1 files changed, 45 insertions, 0 deletions
diff --git a/recipes-core/init-ifupdown/files/bonding.up b/recipes-core/init-ifupdown/files/bonding.up
new file mode 100644
index 0000000..f10152c
--- /dev/null
+++ b/recipes-core/init-ifupdown/files/bonding.up
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+[ "$IF_VERBOSITY" = 1 ] && set -x
+
+sysfs()
+{
+ # Called with :
+ # $1 = value to write. Won't write if $1 is empty.
+ # $2 = basename of the file in bonding/ to write to.
+ if [ "$1" ] ; then
+ echo "$1" > "/sys/class/net/$IFACE/master/bonding/$2"
+ return $?
+ fi
+ return 0
+}
+
+# If the stanza bond-give-a-chance is set for a slave interface,
+# then force $IFACE to be the primary for some time, then restore primary to it previous value.
+
+# This stanza is designed to workaround a bug in wpa_supplicant, when used with bonding :
+
+# wpa_supplicant expect wifi authentication packets on the bond interface, but also send wifi authentication packets on the bond interface.
+# If the active interface is not the wifi interface at the time wpa_supplicant try to authenticate, the wifi AP won't receive anything, causing the authentication to fail.
+
+# In order for the wifi authentication to succeed, one need to give a chance to the wifi interface to send authentication packets.
+# "bond-give-a-chance 10" will set the wifi interface as the primary interface for 10 seconds, then restore the previous primary interface.
+# This is supposed to be enought to give a chance to wifi to authenticate properly.
+
+if [ "$IF_BOND_GIVE_A_CHANCE" ] ; then
+ read primary < "/sys/class/net/$IFACE/master/bonding/primary"
+ # Set the temporary primary.
+ sysfs "$IFACE" primary
+
+ # Wait for the link to be setup, but not longer that $IF_BOND_GIVE_A_CHANGE seconds.
+ while [ "$IF_BOND_GIVE_A_CHANCE" -gt 0 ] ; do
+ if ip link show $IFACE | grep -sq 'state UP'; then
+ break
+ fi
+ sleep 1
+ IF_BOND_GIVE_A_CHANCE=`expr $IF_BOND_GIVE_A_CHANCE - 1`
+ done
+
+ # Restore the previous primary.
+ sysfs "$primary" primary
+fi