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