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