5c6c2a
From 50d75a50fbebf96fe2937352aa2ea10e467b7ebd Mon Sep 17 00:00:00 2001
5c6c2a
From: Imran Haider <imran1008@gmail.com>
5c6c2a
Date: Mon, 16 May 2016 00:14:58 -0400
5c6c2a
Subject: [PATCH] add 'mtu' parameter for bond options
5c6c2a
5c6c2a
Signed-off-by: Imran Haider <imran1008@gmail.com>
5c6c2a
5c6c2a
Cherry-picked from: 292548be6ec8e701dab1a532ca072707e890b12e
5c6c2a
Resolves: #1494265
5c6c2a
---
5c6c2a
 modules.d/40network/ifup.sh       | 3 +++
5c6c2a
 modules.d/40network/parse-bond.sh | 9 +++++++--
5c6c2a
 2 files changed, 10 insertions(+), 2 deletions(-)
5c6c2a
5c6c2a
diff --git a/modules.d/40network/ifup.sh b/modules.d/40network/ifup.sh
5c6c2a
index f2b5894d..38c7b709 100755
5c6c2a
--- a/modules.d/40network/ifup.sh
5c6c2a
+++ b/modules.d/40network/ifup.sh
5c6c2a
@@ -249,6 +249,9 @@ if [ -z "$NO_BOND_MASTER" ]; then
5c6c2a
                 linkup $slave
5c6c2a
             done
5c6c2a
 
5c6c2a
+            # Set mtu on bond master
5c6c2a
+            [ -n "$bondmtu" ] && ip link set mtu $bondmtu dev $netif
5c6c2a
+
5c6c2a
             # add the bits to setup the needed post enslavement parameters
5c6c2a
             for arg in $bondoptions ; do
5c6c2a
                 key=${arg%%=*};
5c6c2a
diff --git a/modules.d/40network/parse-bond.sh b/modules.d/40network/parse-bond.sh
5c6c2a
index 80b3b077..48e548b9 100755
5c6c2a
--- a/modules.d/40network/parse-bond.sh
5c6c2a
+++ b/modules.d/40network/parse-bond.sh
5c6c2a
@@ -1,7 +1,7 @@
5c6c2a
 #!/bin/sh
5c6c2a
 #
5c6c2a
 # Format:
5c6c2a
-#       bond=<bondname>[:<bondslaves>:[:<options>]]
5c6c2a
+#       bond=<bondname>[:<bondslaves>:[:<options>[:<mtu>]]]
5c6c2a
 #
5c6c2a
 #       bondslaves is a comma-separated list of physical (ethernet) interfaces
5c6c2a
 #       options is a comma-separated list on bonding options (modinfo bonding for details) in format compatible with initscripts
5c6c2a
@@ -9,6 +9,8 @@
5c6c2a
 #
5c6c2a
 #       bond without parameters assumes bond=bond0:eth0,eth1:mode=balance-rr
5c6c2a
 #
5c6c2a
+#       if the mtu is specified, it will be set on the bond master
5c6c2a
+#
5c6c2a
 
5c6c2a
 # We translate list of slaves to space-separated here to mwke it easier to loop over them in ifup
5c6c2a
 # Ditto for bonding options
5c6c2a
@@ -25,15 +27,17 @@ parsebond() {
5c6c2a
     1)  bondname=$1; bondslaves="eth0 eth1" ;;
5c6c2a
     2)  bondname=$1; bondslaves=$(str_replace "$2" "," " ") ;;
5c6c2a
     3)  bondname=$1; bondslaves=$(str_replace "$2" "," " "); bondoptions=$(str_replace "$3" "," " ") ;;
5c6c2a
+    4)  bondname=$1; bondslaves=$(str_replace "$2" "," " "); bondoptions=$(str_replace "$3" "," " "); bondmtu=$4;;
5c6c2a
     *)  die "bond= requires zero to four parameters" ;;
5c6c2a
     esac
5c6c2a
 }
5c6c2a
 
5c6c2a
-# Parse bond for bondname, bondslaves, bondmode and bondoptions
5c6c2a
+# Parse bond for bondname, bondslaves, bondmode, bondoptions and bondmtu
5c6c2a
 for bond in $(getargs bond=); do
5c6c2a
     unset bondname
5c6c2a
     unset bondslaves
5c6c2a
     unset bondoptions
5c6c2a
+    unset bondmtu
5c6c2a
     if [ "$bond" != "bond" ]; then
5c6c2a
         parsebond "$bond"
5c6c2a
     fi
5c6c2a
@@ -47,4 +51,5 @@ for bond in $(getargs bond=); do
5c6c2a
     echo "bondname=$bondname" > /tmp/bond.${bondname}.info
5c6c2a
     echo "bondslaves=\"$bondslaves\"" >> /tmp/bond.${bondname}.info
5c6c2a
     echo "bondoptions=\"$bondoptions\"" >> /tmp/bond.${bondname}.info
5c6c2a
+    echo "bondmtu=\"$bondmtu\"" >> /tmp/bond.${bondname}.info
5c6c2a
 done