ab0e4d
From e7f4acb6f7f902715277048be7cdba49c61189dd Mon Sep 17 00:00:00 2001
ab0e4d
From: Rumbaut Thomas <Thomas.Rumbaut@digipolis.gent>
ab0e4d
Date: Fri, 23 Oct 2020 12:38:04 +0200
ab0e4d
Subject: [PATCH] Configure the runner for team interfaces
ab0e4d
ab0e4d
https://bugzilla.redhat.com/show_bug.cgi?id=1881463
ab0e4d
(cherry picked from commit e4483e5917b59918260ff0f0345abbea4a537f12)
ab0e4d
ab0e4d
Resolves: #1881463
ab0e4d
---
ab0e4d
 dracut.cmdline.7.asc                     |  6 +++++-
ab0e4d
 modules.d/35network-legacy/parse-team.sh | 18 +++++++++++++-----
ab0e4d
 2 files changed, 18 insertions(+), 6 deletions(-)
ab0e4d
ab0e4d
diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc
ab0e4d
index 9003c430..e220defb 100644
ab0e4d
--- a/dracut.cmdline.7.asc
ab0e4d
+++ b/dracut.cmdline.7.asc
ab0e4d
@@ -593,9 +593,13 @@ interface name. Better name it "bootnet" or "bluesocket".
ab0e4d
     Bond without parameters assumes
ab0e4d
     bond=bond0:eth0,eth1:mode=balance-rr
ab0e4d
 
ab0e4d
-**team=**__<teammaster>__:__<teamslaves>__::
ab0e4d
+**team=**__<teammaster>__:__<teamslaves>__[:__<teamrunner>__]::
ab0e4d
     Setup team device <teammaster> on top of <teamslaves>.
ab0e4d
     <teamslaves> is a comma-separated list of physical (ethernet) interfaces.
ab0e4d
+    <teamrunner> is the runner type to be used (see *teamd.conf*(5)); defaults to
ab0e4d
+    activebackup.
ab0e4d
+    Team without parameters assumes
ab0e4d
+    team=team0:eth0,eth1:activebackup
ab0e4d
 
ab0e4d
 **bridge=**__<bridgename>__:__<ethnames>__::
ab0e4d
     Setup bridge <bridgename> with <ethnames>. <ethnames> is a comma-separated
ab0e4d
diff --git a/modules.d/35network-legacy/parse-team.sh b/modules.d/35network-legacy/parse-team.sh
ab0e4d
index a6eef18e..03fbcf20 100755
ab0e4d
--- a/modules.d/35network-legacy/parse-team.sh
ab0e4d
+++ b/modules.d/35network-legacy/parse-team.sh
ab0e4d
@@ -1,9 +1,12 @@
ab0e4d
 #!/bin/sh
ab0e4d
 #
ab0e4d
 # Format:
ab0e4d
-#       team=<teammaster>:<teamslaves>
ab0e4d
+#       team=<teammaster>:<teamslaves>[:<teamrunner>]
ab0e4d
 #
ab0e4d
 #       teamslaves is a comma-separated list of physical (ethernet) interfaces
ab0e4d
+#       teamrunner is the runner type to be used (see teamd.conf(5)); defaults to activebackup
ab0e4d
+#
ab0e4d
+#       team without parameters assumes team=team0:eth0,eth1:activebackup
ab0e4d
 #
ab0e4d
 
ab0e4d
 parseteam() {
ab0e4d
@@ -15,8 +18,11 @@ parseteam() {
ab0e4d
     done
ab0e4d
 
ab0e4d
     case $# in
ab0e4d
-    2)  teammaster=$1; teamslaves=$(str_replace "$2" "," " ") ;;
ab0e4d
-    *)  die "team= requires two parameters" ;;
ab0e4d
+    0)  teammaster=team0; teamslaves="eth0 eth1"; teamrunner="activebackup" ;;
ab0e4d
+    1)  teammaster=$1; teamslaves="eth0 eth1"; teamrunner="activebackup" ;;
ab0e4d
+    2)  teammaster=$1; teamslaves=$(str_replace "$2" "," " "); teamrunner="activebackup" ;;
ab0e4d
+    3)  teammaster=$1; teamslaves=$(str_replace "$2" "," " "); teamrunner=$3 ;;
ab0e4d
+    *)  die "team= requires zero to three parameters" ;;
ab0e4d
     esac
ab0e4d
     return 0
ab0e4d
 }
ab0e4d
@@ -26,16 +32,18 @@ for team in $(getargs team); do
ab0e4d
 
ab0e4d
     unset teammaster
ab0e4d
     unset teamslaves
ab0e4d
+    unset teamrunner
ab0e4d
 
ab0e4d
     parseteam "$team" || continue
ab0e4d
 
ab0e4d
     echo "teammaster=$teammaster" > /tmp/team.${teammaster}.info
ab0e4d
     echo "teamslaves=\"$teamslaves\"" >> /tmp/team.${teammaster}.info
ab0e4d
+    echo "teamrunner=\"$teamrunner\"" >> /tmp/team.${teammaster}.info
ab0e4d
 
ab0e4d
     if ! [ -e /etc/teamd/${teammaster}.conf ]; then
ab0e4d
-        warn "Team master $teammaster specified, but no /etc/teamd/$teammaster.conf present. Using activebackup."
ab0e4d
+        warn "Team master $teammaster specified, but no /etc/teamd/$teammaster.conf present. Using $teamrunner."
ab0e4d
         mkdir -p /etc/teamd
ab0e4d
-        printf -- "%s" '{"runner": {"name": "activebackup"}, "link_watch": {"name": "ethtool"}}' > "/etc/teamd/${teammaster}.conf"
ab0e4d
+        printf -- "%s" "{\"runner\": {\"name\": \"$teamrunner\"}, \"link_watch\": {\"name\": \"ethtool\"}}" > "/tmp/${teammaster}.conf"
ab0e4d
     fi
ab0e4d
 done
ab0e4d
 
ab0e4d