Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package powerpc-utils for openSUSE:Factory 
checked in at 2022-01-29 21:01:17
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/powerpc-utils (Old)
 and      /work/SRC/openSUSE:Factory/.powerpc-utils.new.1898 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "powerpc-utils"

Sat Jan 29 21:01:17 2022 rev:123 rq:949632 version:1.3.9

Changes:
--------
--- /work/SRC/openSUSE:Factory/powerpc-utils/powerpc-utils.changes      
2022-01-14 23:13:20.562635738 +0100
+++ /work/SRC/openSUSE:Factory/.powerpc-utils.new.1898/powerpc-utils.changes    
2022-01-29 21:01:54.074746977 +0100
@@ -1,0 +2,21 @@
+Thu Jan 27 09:07:05 UTC 2022 - Michal Suchanek <msucha...@suse.com>
+
+- Add HNV wicked support (bsc#1193543 jsc#SLE-18127).
+   + 0001-Validate-connection-manager.patch
+   + 0002-factor-out-NetworkManager-nmcli-code.patch
+   + 0003-Add-new-wicked-functions-from-suse-to-manage-bonding.patch
+   + 0004-Support-wicked-HNV-using-new-wicked-interfaces-for.patch
+   + 0005-Set-modprobe-bonding-max_bonds-0-option.patch
+   + 0006-cleanup-hcnmgr-distro-and-service-detection.patch
+   + 0007-Remove-wicked-ifup-calls-that-just-run-into-timeouts.patch
+   + 0008-add-note-about-comma-in-hcnmgr-BONDOPTIONS.patch
+   + 0009-Fix-to-call-wicked-ifreload-directly.patch
+   + 0010-Fix-incorrect-parameters-to-suse_ifcfg_bond_create.patch
+   + 0011-Fix-comment-about-setting-primary.patch
+   + 0012-Description-and-indenting-corrections.patch
+   + 0013-adjust-sourcing-path-of-the-functions.suse-library.patch
+   + 0014-Enable-the-network-service-checks.patch
+   + 0015-add-hcn-init.service.suse-service-covering-wicked.patch
+- Install SUSE-specific scripts
+
+-------------------------------------------------------------------

New:
----
  0001-Validate-connection-manager.patch
  0002-factor-out-NetworkManager-nmcli-code.patch
  0003-Add-new-wicked-functions-from-suse-to-manage-bonding.patch
  0004-Support-wicked-HNV-using-new-wicked-interfaces-for.patch
  0005-Set-modprobe-bonding-max_bonds-0-option.patch
  0006-cleanup-hcnmgr-distro-and-service-detection.patch
  0007-Remove-wicked-ifup-calls-that-just-run-into-timeouts.patch
  0008-add-note-about-comma-in-hcnmgr-BONDOPTIONS.patch
  0009-Fix-to-call-wicked-ifreload-directly.patch
  0010-Fix-incorrect-parameters-to-suse_ifcfg_bond_create.patch
  0011-Fix-comment-about-setting-primary.patch
  0012-Description-and-indenting-corrections.patch
  0013-adjust-sourcing-path-of-the-functions.suse-library.patch
  0014-Enable-the-network-service-checks.patch
  0015-add-hcn-init.service.suse-service-covering-wicked.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ powerpc-utils.spec ++++++
--- /var/tmp/diff_new_pack.lbVOeN/_old  2022-01-29 21:01:54.822741948 +0100
+++ /var/tmp/diff_new_pack.lbVOeN/_new  2022-01-29 21:01:54.830741894 +0100
@@ -37,6 +37,21 @@
 Patch11:        lparstat-Fix-reported-online-memory-in-legacy-format.patch
 Patch12:        errinjct-sanitize-devspec-output-of-a-newline-if-one.patch
 Patch14:        fix_kexec_service_name_for_suse.patch
+Patch15:        0001-Validate-connection-manager.patch
+Patch16:        0002-factor-out-NetworkManager-nmcli-code.patch
+Patch17:        0003-Add-new-wicked-functions-from-suse-to-manage-bonding.patch
+Patch18:        0004-Support-wicked-HNV-using-new-wicked-interfaces-for.patch
+Patch19:        0005-Set-modprobe-bonding-max_bonds-0-option.patch
+Patch20:        0006-cleanup-hcnmgr-distro-and-service-detection.patch
+Patch21:        0007-Remove-wicked-ifup-calls-that-just-run-into-timeouts.patch
+Patch22:        0008-add-note-about-comma-in-hcnmgr-BONDOPTIONS.patch
+Patch23:        0009-Fix-to-call-wicked-ifreload-directly.patch
+Patch24:        0010-Fix-incorrect-parameters-to-suse_ifcfg_bond_create.patch
+Patch25:        0011-Fix-comment-about-setting-primary.patch
+Patch26:        0012-Description-and-indenting-corrections.patch
+Patch27:        0013-adjust-sourcing-path-of-the-functions.suse-library.patch
+Patch28:        0014-Enable-the-network-service-checks.patch
+Patch29:        0015-add-hcn-init.service.suse-service-covering-wicked.patch
 BuildRequires:  autoconf
 BuildRequires:  automake
 BuildRequires:  libnuma-devel
@@ -93,6 +108,10 @@
 
 ln -s service %{buildroot}%{_sbindir}/rcsmt_off
 
+install -m 644 systemd/hcn-init.service.suse 
%{buildroot}%{_unitdir}/hcn-init.service
+mkdir -p %{buildroot}/usr/lib/powerpc-utils
+install -m 644 scripts/functions.suse  
%{buildroot}/usr/lib/powerpc-utils/functions.suse
+
 # remove docu installed by make_install as we hand-install them in %%files
 rm -rf %{buildroot}%{_docdir}/%{name}/*
 
@@ -119,6 +138,8 @@
 %endif
 %dir %{_localstatedir}/lib/powerpc-utils
 %ghost %{_localstatedir}/lib/powerpc-utils/smt.state
+%dir /usr/lib/powerpc-utils
+/usr/lib/powerpc-utils/functions.suse
 %{_unitdir}/hcn-init.service
 %{_unitdir}/smt_off.service
 %{_unitdir}/smtstate.service

++++++ 0001-Validate-connection-manager.patch ++++++
>From 8474223e844ecf13606fe9ebab2198838b877947 Mon Sep 17 00:00:00 2001
From: Mingming Cao <m...@linux.vnet.ibm.com>
Date: Thu, 13 Jan 2022 06:18:53 -0800
Subject: [PATCH 01/15] Validate connection manager

Check and validate what OS is on the system and what type
 of connection manager is used: Wicked or NetworkManager

Signed-off-by: Mingming Cao <m...@linux.vnet.ibm.com>
---
 scripts/hcnmgr | 42 +++++++++++++++++++++++++++++++++++++-----
 1 file changed, 37 insertions(+), 5 deletions(-)

diff --git a/scripts/hcnmgr b/scripts/hcnmgr
index 870f544..f9940bb 100644
--- a/scripts/hcnmgr
+++ b/scripts/hcnmgr
@@ -39,6 +39,8 @@ MODE=""
 PHYSLOC=""
 DEVPATH=""
 VIO_TYPE=""
+DISTRO=""
+SERVICES=""
 
 # Usage statements
 usage() {
@@ -627,6 +629,41 @@ scanhcn() {
 
        hcnlog DEBUG "scanhcn: scan for hybrid virtual network finished"
 }
+#function check_network_service
+#      Check what connection manager is used
+#      network manager or wicked (on SuSE)
+#
+
+
+check_network_service() {
+
+       DISTRO="Unknown"
+       if test -f /etc/os-release; then
+               DISTRO=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
+       fi
+
+
+       SERVICES=$(systemctl show -p Id network.service | cut -d '=' -f 2)
+       hcnlog INFO " LPAR is running OS $DISTEO with network service $SERVICES"
+
+       case "$SERVICES" in
+               *wicked.service)
+                               #validate wicked, wicked dd services
+                               #validate yast package
+                               hcnlog INFO "HNV is not supported with Wicked"
+                               ;;
+               *network.service)
+                               #Validate NMCLI packages is install to manage 
networking
+                               if ! nmcli --version >/dev/null 2>&1; then
+                                       err $E_ENETUNREACH
+                               fi
+                               ;;
+               default)
+                               hcnlog INFO "HNV is only supported on 
NetworkManager"
+                               err $E_ENETUNREACH
+                               ;;
+       esac
+}
 
 #
 # Main
@@ -650,11 +687,6 @@ if [ "$platform" != "$PLATFORM_PSERIES_LPAR" ]; then
        exit 0
 fi
 
-#Validate NMCLI packages is install to manage networking
-if ! nmcli --version >/dev/null 2>&1; then
-       err $E_ENETUNREACH
-fi
-
 #Validate bonding module is loaded
 if ! lsmod | grep -q bonding; then
        hcnlog DEBUG "HCNMGR: Bonding module not loaded, load module ..."
-- 
2.34.1


++++++ 0002-factor-out-NetworkManager-nmcli-code.patch ++++++
>From 2a46892673bc081da3a8de57a8ff0466d6ec2c25 Mon Sep 17 00:00:00 2001
From: Mingming Cao <m...@linux.vnet.ibm.com>
Date: Thu, 13 Jan 2022 06:20:28 -0800
Subject: [PATCH 02/15] factor out NetworkManager nmcli code

Signed-off-by:  Mingming Cao <m...@linux.vnet.ibm.com>
---
 scripts/hcnmgr | 131 +++++++++++++++++++++++++++++++------------------
 1 file changed, 82 insertions(+), 49 deletions(-)

diff --git a/scripts/hcnmgr b/scripts/hcnmgr
index f9940bb..14f6e43 100644
--- a/scripts/hcnmgr
+++ b/scripts/hcnmgr
@@ -277,13 +277,13 @@ get_dev_hcn() {
 }
 
 #
-# function do_config_vdevice
+# function do_config_vdevice_nm
 #      configure or create HCN (active-backup bonding)
 #      add device as bonding slave
 #
 #      On enter, the vdevice name, mode, hcnid and drcindex are set
-#
-do_config_vdevice() {
+#      Based on Network Manager nmcli
+do_config_vdevice_nm() {
        hcnlog DEBUG "do_config_vdevice: enter"
 
        BONDNAME=bond$HCNID
@@ -354,6 +354,11 @@ do_config_vdevice() {
        return $E_SUCCESS
 }
 
+do_config_vdevice() {
+       if [[ $SERVICES == "networt.service" ]]; then
+               do_config_vdevice_nm
+       fi
+}
 #
 # function cfghcn
 #      Given device DRC_INDEX, configure or create HCN (active-backup bonding)
@@ -387,6 +392,13 @@ cfghcn() {
 
        return $E_SUCCESS
 }
+
+rmhcn_nm() {
+       for connection in $(nmcli -f NAME con show | grep "$BONDNAME"); do
+               hcnlog INFO "Delete bonding connection $connection"
+               nmcli con delete "$connection"
+       done
+}
 #
 # function rmhcn
 #      Given HCNID, remove HCN
@@ -405,14 +417,23 @@ rmhcn() {
        fi
 
        hcnlog INFO "rmhcn: delete bond $BONDNAME and slaves "
-       for connection in $(nmcli -f NAME con show | grep "$BONDNAME"); do
-               hcnlog INFO "Delete bonding connection $connection"
-               nmcli con delete "$connection"
-       done
+       if [[ $SERVICES == "networt.service" ]]; then
+               rmhcn_nm
+       fi
        hcnlog DEBUG "rmhcn: exit"
        return $E_SUCCESS
 }
 
+qrydev_nm() {
+       if ! nmcli -f DEVICE con show --active | grep -q "$DEVNAME"; then
+               hcnlog DEBUG "network connection $BONDNAME-$DEVNAME is inactive 
or nonexist"
+               hcnlog DEBUG "HCNID $HCNID devname $DEVNAME mode $MODE physloc 
$PHYSLOC DEVPATH $DEVPATH"
+               hcnlog DEBUG "qryhcn: exit"
+               # In this case, tell HMC to do rmdev and okay to migrate
+               return $E_SUCCESS
+       fi
+}
+
 #
 #function qrydev
 #      Called by HMC right before migration, to see if it is safe to
@@ -440,12 +461,8 @@ qrydev() {
        BOND_PATH=$BOND_BASEPATH/$BONDNAME/bonding
 
        hcnlog DEBUG "check if the network interface for this SR_IOV is not up, 
return success"
-       if ! nmcli -f DEVICE con show --active | grep -q "$DEVNAME"; then
-               hcnlog DEBUG "network connection $BONDNAME-$DEVNAME is inactive 
or nonexist"
-               hcnlog DEBUG "HCNID $HCNID devname $DEVNAME mode $MODE physloc 
$PHYSLOC DEVPATH $DEVPATH"
-               hcnlog DEBUG "qryhcn: exit"
-               # In this case, tell HMC to do rmdev and okay to migrate
-               return $E_SUCCESS
+       if [[ $SERVICES == "networt.service" ]]; then
+               qrydev_nm
        fi
 
        hcnlog DEBUG "check if there is bond for this $HCNID"
@@ -479,8 +496,10 @@ qrydev() {
 #
 show_hcnstatus() {
        hcnlog DEBUG "log connection and device status to $LOG_FILE"
-       nmcli connection show >>$LOG_FILE
-       nmcli device status >>$LOG_FILE
+       if [[ $SERVICES == "networt.service" ]]; then
+               nmcli connection show >>$LOG_FILE
+               nmcli device status >>$LOG_FILE
+       fi
        ip addr show >>$LOG_FILE
 }
 
@@ -493,6 +512,12 @@ check_eth() {
        nmcli -f DEVICE con show | grep -q "$1"
 }
 
+rmdev_nm {
+       if check_eth "$DEVNAME"; then
+               hcnlog INFO "rmdev: delete $BONDNAME-$DEVNAME connection"
+               nmcli con delete "$BONDNAME-$DEVNAME"
+       fi
+}
 #
 #function rmdev
 #      this is called at pre-migration time, remove sr-iov from HCN
@@ -510,14 +535,38 @@ rmdev() {
        if [[ $HCNID != "$2" ]]; then
                hcnlog WARN "rmdev: mismatch drc index $1 HCNID $2"
        fi
-       if check_eth "$DEVNAME"; then
-               hcnlog INFO "rmdev: delete $BONDNAME-$DEVNAME connection"
-               nmcli con delete "$BONDNAME-$DEVNAME"
+
+       if [[ $SERVICES == "networt.service" ]]; then
+               rmdev_nm
        fi
+
        hcnlog DEBUG "rmdev: exit"
        return $E_SUCCESS
 }
 
+scanhcn_cleanup_old_hnv_nm() {
+       # After online from inactive migration, destination
+       # LPAR may have same mvf devname but associated with different
+       # bonding than from source LPAR
+       # clean up expired bonding SR_IOV connections
+
+
+       for cfg in $(ls $IFCONFIG_PATH | grep "$DEVNAME" | grep "bond"); do
+               hid=$(echo "$cfg" | sed -e 's/ifcfg-//' | cut -d '-' -f 1 | sed 
-e 's/bond//')
+               if [ -e "$IFCONFIG_PATH/ifcfg-$DEVNAME" ]; then
+                       rm "$IFCONFIG_PATH/ifcfg-$DEVNAME"
+               fi
+               if [[ $hid != "" && $hid != "$HCNID" ]] ; then
+                       hcnlog INFO "Delete dead bonding slave ifcfg file 
$IFCONFIG_PATH/$cfg"
+                       rm $IFCONFIG_PATH/"$cfg"
+
+                       if nmcli -f NAME con show | grep -q 
"bond$hid-$DEVNAME\s"; then
+                               hcnlog INFO "Delete dead bonding connection 
$connection"
+                               nmcli con delete "bond$hid-$DEVNAME"
+                       fi
+               fi
+       done
+}
 #
 # function scanhcn
 #      HMC supports adding migratable sr-iov when LPAR is inactive. This 
allows LPAR
@@ -551,27 +600,9 @@ scanhcn() {
                        [ -d "$dev" ] || continue
                        if [ -e "$dev"/ibm,hcn-id ] && get_dev_hcn "$dev"; then
                                hcnlog DEBUG "scanhcn found sr-iov device with 
hcnid "
-
-                               # After online from inactive migration, 
destination
-                               # LPAR may have same mvf devname but associated 
with different
-                               # bonding than from source LPAR
-                               # clean up expired bonding SR_IOV connections
-
-                               for cfg in $(ls $IFCONFIG_PATH | grep 
"$DEVNAME" | grep "bond"); do
-                                       hid=$(echo "$cfg" | sed -e 's/ifcfg-//' 
| cut -d '-' -f 1 | sed -e 's/bond//')
-                                       if [ -e "$IFCONFIG_PATH/ifcfg-$DEVNAME" 
]; then
-                                               rm 
"$IFCONFIG_PATH/ifcfg-$DEVNAME"
-                                       fi
-                                       if [[ $hid != "" && $hid != "$HCNID" ]] 
; then
-                                               hcnlog INFO "Delete dead 
bonding slave ifcfg file $IFCONFIG_PATH/$cfg"
-                                               rm $IFCONFIG_PATH/"$cfg"
-                                               if nmcli -f NAME con show | 
grep -q "bond$hid-$DEVNAME\s"; then
-                                                       hcnlog INFO "Delete 
dead bonding connection $connection"
-                                                       nmcli con delete 
"bond$hid-$DEVNAME"
-                                               fi
-                                       fi
-                               done
-
+                               if [[ $SERVICES == "networt.service" ]]; then
+                                       scanhcn_cleanup_old_hnv_nm
+                               fi
                                hcnlog INFO "scanhcn configure HCN and sr-iov 
device"
                                do_config_vdevice
                                # Save found HCN ids in array HcnIds
@@ -616,16 +647,18 @@ scanhcn() {
 
        # list of all HCN ids
        ids="${HcnIds[*]}"
-       # After inactive migration, LPAR may have old bonding connections
-       # with network device on original LPAR
-    # clean up dead bonding connections
-       for connection in $(nmcli -f NAME con show | grep "${ids// /\\|}"); do
-               dev=$(echo "$connection" | cut -d '-' -f 2)
-               if [[ $dev != "NAME" && ! -e /sys/class/net/"$dev" ]]; then
-                       hcnlog INFO "Delete dead bonding connection $connection"
-                       nmcli con delete "$connection"
-               fi
-       done
+       if [[ $SERVICES == "networt.service" ]]; then
+               # After inactive migration, LPAR may have old bonding 
connections
+               # with network device on original LPAR
+          # clean up dead bonding connections
+               for connection in $(nmcli -f NAME con show | grep "${ids// 
/\\|}"); do
+                       dev=$(echo "$connection" | cut -d '-' -f 2)
+                       if [[ $dev != "NAME" && ! -e /sys/class/net/"$dev" ]]; 
then
+                               hcnlog INFO "Delete dead bonding connection 
$connection"
+                               nmcli con delete "$connection"
+                       fi
+               done
+       fi
 
        hcnlog DEBUG "scanhcn: scan for hybrid virtual network finished"
 }
-- 
2.34.1


++++++ 0003-Add-new-wicked-functions-from-suse-to-manage-bonding.patch ++++++
>From aeaf71efb4a761892f566f996d70d60e4233958e Mon Sep 17 00:00:00 2001
From: Mingming Cao <m...@linux.vnet.ibm.com>
Date: Thu, 13 Jan 2022 06:22:46 -0800
Subject: [PATCH 03/15] Add new wicked functions from suse to manage bonding 
 interfaces

suse specific hcnmgr utilities to manipulate suse ifcfg files
as supported by yast2 network.

Signed-off-by:   Marius Tomaschewski <m...@suse.com>
---
 scripts/functions.suse | 400 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 400 insertions(+)
 create mode 100644 scripts/functions.suse

diff --git a/scripts/functions.suse b/scripts/functions.suse
new file mode 100644
index 0000000..4001bb8
--- /dev/null
+++ b/scripts/functions.suse
@@ -0,0 +1,400 @@
+#! /bin/bash
+#  ^^^^^^^^^
+#
+# Copyright (c) 2021 SUSE LLC
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+#
+# Authors:
+#      Marius Tomaschewski <m...@suse.com>
+#
+# suse specific hcnmgr utilities to manipulate suse ifcfg files
+# as supported by yast2 network.
+#
+
+suse_ifcfg_config_dir="/etc/sysconfig/network"
+
+suse_wlist_find()
+{
+        local item want="$1" ; shift
+        for item in $* ; do
+                [ X"$want" = X"$item" ] && return 0
+        done
+        return 1
+}
+suse_wlist_uniq()
+{
+       local item list=()
+        for item in $* ; do
+                suse_wlist_find "$item" "$list" && continue
+               list+=("$item")
+        done
+        echo "${list[*]}"
+}
+suse_ifcfg_unquote()
+{
+       # Ifcfg variables contain sh compatible/sourceable key=values,
+       # but without the full quote and (variable) expansion magic
+       # and the values aren't/don't need to be evaluated by a shell.
+       # Values can contain a space-separated world list, like e.g.:
+       #   "arp_interval arp_ip_target=1.2.3.4,1.2.3.5"
+       # They need quotes, but no nested "foo \"bar baz\"" or escapes
+       # are considered. A value like ' \o/ ' (e.g. a wireless essid)
+       # needs single quotes...
+       local val="$1"
+       case $val in
+       "'"*)  val="${val#"'"}" ; val="${val%"'"*}" ; echo "$val" ;;
+       "\""*) val="${val#\"}"  ; val="${val%\"*}"  ; echo "$val" ;;
+       [[:alpha:]]*) echo "${val%%[[:space:]#]*}" ;;
+       esac
+}
+
+suse_ifcfg_file_name()
+{
+       [ X"$1" != X ] && echo "${suse_ifcfg_config_dir}/ifcfg-${1}"
+}
+suse_ifcfg_file_exists()
+{
+       local file=$(suse_ifcfg_file_name "$1")
+       [ X"$file" != X -a -f "$file" ] && echo "$file"
+}
+suse_ifcfg_file_delete()
+{
+       local file=$(suse_ifcfg_file_name "$1")
+       [ X"$file" != X ] && rm -f -- "$file"
+}
+suse_ifcfg_file_mktemp()
+{
+       local temp="${suse_ifcfg_config_dir}/.ifcfg-${1}.XXXXXX"
+       [ X"$1" != X -a X"$temp" != X ] && mktemp -q -- "$temp" 2>/dev/null
+}
+suse_ifcfg_grep()
+{
+       LANG=C LC_ALL=C grep --no-filename -E "$@"
+}
+
+suse_ifcfg_is_bond_master()
+{
+       local bond="$1"
+       local file=$(suse_ifcfg_file_name "$bond")
+       local line key val=""
+       local BONDING_MASTER="no"
+
+       [ X"$file" != X ] || return 1
+       while read line ; do
+               key="${line%%=*}"
+               val=$(suse_ifcfg_unquote "${line#${key}=}")
+               case $val in
+                       yes|YES) BONDING_MASTER="yes" ;;
+                       *)       BONDING_MASTER="no"  ;;
+               esac
+       done < <(suse_ifcfg_grep -e '^[ \t]*BONDING_MASTER=' -- \
+                       "$file" 2>/dev/null)
+
+       [ X"$BONDING_MASTER" = X"yes" ]
+}
+
+suse_ifcfg_bond_master_template()
+{
+       local slaves=($(suse_wlist_uniq $1))
+       local options=($2)
+       local num=0
+
+       if [ X"${options[*]}" = X ] ; then
+               # default options as used by the hcnmgr
+               options=(mode=active-backup miimon=100 fail_over_mac=follow)
+               # set 1st slave as primary to inherit the mac from (by default)
+               if [ X"${slaves[0]}" != X ] ; then
+                       options+=("primary=${slaves[0]}")
+               fi
+       fi
+
+       echo "STARTMODE='auto'"
+       echo "BOOTPROTO='none'"
+
+       echo "BONDING_MASTER='yes'"
+       echo "BONDING_MODULE_OPTS='${options[*]}'"
+       for slave in "${slaves[@]}" ; do
+               ((num++))
+               echo "BONDING_SLAVE_${num}='$slave'"
+       done
+}
+
+suse_ifcfg_bond_get_options()
+{
+       local bond="$1"
+       local file=$(suse_ifcfg_file_exists "$bond")
+       local line key val=""
+
+       [ X"$file" != X ] || return 1
+       while read line ; do
+               key="${line%%=*}"
+               if [ X"$key" != X ] ; then
+                       val=$(suse_ifcfg_unquote "${line#${key}=}")
+               fi
+       done < <(suse_ifcfg_grep -e '^[ \t]*BONDING_MODULE_OPTS=' -- \
+                       "$file" 2>/dev/null)
+       echo "$val"
+}
+
+suse_ifcfg_bond_set_options()
+{
+       local bond="$1"
+       local options="$2"
+       local file=$(suse_ifcfg_file_exists "$bond")
+       [ X"$file" != X -a X"$options" != X ] || return 1
+
+       local temp=$(suse_ifcfg_file_mktemp "$bond")
+       [ X"$temp" != X ] || return 1
+
+       if suse_ifcfg_grep -v -e '^[ \t]*BONDING_MODULE_OPTS=' -- \
+               "$file" >> "$temp" 2>/dev/null ; then
+
+               echo "BONDING_MODULE_OPTS='$options'" >>"$temp"
+
+               mv -f -- "$temp" "$file" && return 0
+       fi
+       rm -f -- "$temp"
+       return 1
+}
+
+suse_ifcfg_bond_get_primary()
+{
+       local bond="$1"
+       local file=$(suse_ifcfg_file_exists "$bond")
+       [ X"$file" != X ] || return 1
+
+       local options=($(suse_ifcfg_bond_get_options "$bond"))
+       local opt primary=""
+       for opt in "${options[@]}" ; do
+               case $opt in
+                       primary=*)
+                               primary="${opt#*=}"
+                       ;;
+               esac
+       done
+       [ X"$primary" != X ] && echo "$primary"
+}
+
+suse_ifcfg_bond_set_primary()
+{
+       local bond="$1"
+       local primary="$2"
+
+       local file=$(suse_ifcfg_file_name "$bond")
+       [ X"$file" != X ] || return 1
+
+       local options=($(suse_ifcfg_bond_get_options "$bond"))
+       local opt opts=()
+       for opt in "${options[@]}" ; do
+               case $opt in
+                       primary=*) ;;
+                       *) opts+=("$opt") ;;
+               esac
+       done
+       if [ X"$primary" != X ] ; then
+               opts+=("primary=$primary")
+       fi
+       suse_ifcfg_bond_set_options "$bond" "${opts[*]}"
+}
+
+suse_ifcfg_bond_get_slaves()
+{
+       local bond="$1"
+       local file=$(suse_ifcfg_file_name "$bond")
+       local line var key val="" ${!BONDING_SLAVE*}
+
+       [ X"$file" != X ] || return 1
+       unset ${!BONDING_SLAVE*}
+       while read -r line ; do
+               key="${line%%=*}"
+               val=$(suse_ifcfg_unquote "${line#${key}=}")
+               eval local "${key}='${val}'"
+       done < <(suse_ifcfg_grep -e '^[ \t]*BONDING_SLAVE[[:alnum:]_]*=' -- \
+                       "$file" 2>/dev/null)
+       for var in ${!BONDING_SLAVE*} ; do
+               [ X"${!var}" != X ] && echo "${!var}"
+       done
+}
+
+suse_ifcfg_bond_add_slave()
+{
+       local bond="$1"
+       local nslave="$2"
+       local file=$(suse_ifcfg_file_name "$bond")
+       [ X"$nslave" != X -a X"$file" != X ] || return 1
+
+       local oslaves=($(suse_ifcfg_bond_get_slaves "$bond"))
+       suse_wlist_find "$nslave" "${oslaves[@]}"  && return 0
+       local nslaves=("${oslaves[@]}" "$nslave")
+       local slave num=0
+
+       local temp=$(suse_ifcfg_file_mktemp "$bond")
+       [ X"$temp" != X ] || return 1
+
+       if suse_ifcfg_grep -v -e '^[ \t]*BONDING_SLAVE[[:alnum:]_]*=' -- \
+               "$file" >> "$temp" 2>/dev/null ; then
+
+               for slave in "${nslaves[@]}" ; do
+                       ((num++))
+                       echo "BONDING_SLAVE_${num}='$slave'"
+               done >> "$temp" 2>/dev/null
+
+               mv -f -- "$temp" "$file" && return 0
+       fi
+       rm -f -- "$temp"
+       return 1
+}
+
+suse_ifcfg_bond_del_slave()
+{
+       local bond="$1"
+       local oslave="$2"
+       local file=$(suse_ifcfg_file_exists "$bond")
+       [ X"$oslave" != X -a X"$file" != X ] || return 1
+
+       local oslaves=($(suse_ifcfg_bond_get_slaves "$bond"))
+       local slave num=0 nslaves=()
+       for slave in "${oslaves[@]}" ; do
+               if [ X"$slave" != X"$oslave" ] ; then
+                       nslaves+=("${slave}")
+               else
+                       suse_ifcfg_file_delete "$slave"
+               fi
+       done
+
+       local primary=$(suse_ifcfg_bond_get_primary "$bond")
+       if [ X"$primary" = X"$oslave" ] ; then
+               suse_ifcfg_bond_set_primary "$bond" ""
+       fi
+
+       local temp=$(suse_ifcfg_file_mktemp "$bond")
+       [ X"$temp" != X ] || return 1
+
+       if suse_ifcfg_grep -v -e '^[ \t]*BONDING_SLAVE[[:alnum:]_]*=' -- \
+               "$file" >> "$temp" 2>/dev/null ; then
+
+               for slave in "${nslaves[@]}" ; do
+                       ((num++))
+                       echo "BONDING_SLAVE_${num}='$slave'"
+               done >> "$temp" 2>/dev/null
+
+               mv -f -- "$temp" "$file" && return 0
+       fi
+       rm -f -- "$temp"
+       return 1
+}
+
+suse_ifcfg_bond_create()
+{
+       local bond="$1" ; shift
+       local file=$(suse_ifcfg_file_name "$bond")
+       local temp=$(suse_ifcfg_file_mktemp "$bond")
+
+       [ X"$temp" != X ] || return 1
+       if suse_ifcfg_bond_master_template "$@" >> "$temp" ; then
+               mv -f -- "$temp" "$file" && return 0
+       fi
+       rm -f -- "$temp"
+       return 1
+}
+
+suse_ifcfg_bond_delete()
+{
+       local bond="$1"
+       local file=$(suse_ifcfg_file_name "$bond")
+       local slaves=($(suse_ifcfg_bond_get_slaves "$bond"))
+       local slave
+
+       # delete explicit slave configs if any
+       for slave in "${slaves[@]}" ; do
+               suse_ifcfg_file_delete "$slave"
+       done
+
+       # delete the bond master config file
+       [ X"$file" != X ] && rm -f -- "$file"
+
+       # TODO: cleanup interfaces on top of the bond
+       #               _if_ the hnv setup permit to use them
+       # e.g.: brX { bondX }, brN { bondX.N }
+}
+
+suse_ifcfg_bond_modify()
+{
+       local bond="$1"
+       local nslaves=($(suse_wlist_uniq $2))
+       local noptions=($3)
+
+       if ! suse_ifcfg_is_bond_master "$bond" ; then
+               suse_ifcfg_bond_create "$bond" "${nslaves[*]}" "${noptions[*]}"
+               return $?
+       fi
+
+       local temp=$(suse_ifcfg_file_mktemp "$bond")
+       [ X"$temp" != X ] || return 1
+
+       local options=($(suse_ifcfg_bond_get_options "$bond"))
+       local slaves=($(suse_ifcfg_bond_get_slaves "$bond"))
+       local file=$(suse_ifcfg_file_name "$bond")
+       local slave num=0
+       for slave in "${slaves[@]}" ; do
+               suse_wlist_find "$slave" "${nslaves[*]}" || \
+                       suse_ifcfg_file_delete "$slave"
+       done
+
+       if [ X"${noptions[*]}" = X ] ; then
+               local opt primary="" noptions=""
+               for opt in "${options[@]}" ; do
+                       case $opt in
+                               primary=*) primary="${opt#*=}" ;;
+                               *)         noptions+=("$opt")  ;;
+                       esac
+               done
+               if [ X"${noptions[*]}" = X ] ; then
+                       noptions=(mode=active-backup miimon=100 
fail_over_mac=follow)
+               fi
+               if [ X"$primary" != X ] ; then
+                       if suse_wlist_find "$primary" "${nslaves[*]}" ; then
+                               noptions+=("primary=$primary")
+                       elif [ X"${nslaves[0]}" != X ] ; then
+                               noptions+=("primary=${nslaves[0]}")
+                       fi
+               fi
+       fi
+
+       if suse_ifcfg_grep -v -e '^[ \t]*BONDING_[[:alnum:]_]+=' -- \
+               "$file" >> "$temp" 2>/dev/null ; then
+
+               echo "BONDING_MASTER='yes'"                 >> "$temp"
+               echo "BONDING_MODULE_OPTS='${noptions[*]}'" >> "$temp"
+               for slave in "${nslaves[@]}" ; do
+                       ((num++))
+                       echo "BONDING_SLAVE_${num}='$slave'"
+               done >> "$temp" 2>/dev/null
+
+               mv -f -- "$temp" "$file" && return 0
+       fi
+       rm -f -- "$temp"
+       return 1
+}
+
+wicked_reload()
+{
+       if [ $# -eq 0 ] ; then
+               rcnetwork reload
+       elif systemctl_is_active wicked.service ; then
+               wicked ifreload -- "$@"
+       fi
+}
+
-- 
2.34.1


++++++ 0004-Support-wicked-HNV-using-new-wicked-interfaces-for.patch ++++++
>From ee5dc5c4aa9da2c1c1d975c2d03e6ea8e73cdbd3 Mon Sep 17 00:00:00 2001
From: Mingming Cao <m...@linux.vnet.ibm.com>
Date: Thu, 13 Jan 2022 06:24:48 -0800
Subject: [PATCH 04/15] Support wicked HNV using new wicked interfaces for 
 bonding

Signed-off-by: Mingming Cao <m...@linux.vnet.ibm.com>
---
 scripts/hcnmgr | 88 +++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 83 insertions(+), 5 deletions(-)

diff --git a/scripts/hcnmgr b/scripts/hcnmgr
index 14f6e43..0aa6ee8 100644
--- a/scripts/hcnmgr
+++ b/scripts/hcnmgr
@@ -42,6 +42,8 @@ VIO_TYPE=""
 DISTRO=""
 SERVICES=""
 
+source /usr/sbins/functions.suse
+
 # Usage statements
 usage() {
        echo "$HCNMGR contains a set of commands to support migratable SR_IOV 
logical port."
@@ -354,10 +356,53 @@ do_config_vdevice_nm() {
        return $E_SUCCESS
 }
 
+# function do_config_vdevice_wicked
+#      configure or create HCN (active-backup bonding)
+#      add device as bonding slave
+#
+#      On enter, the vdevice name, mode, hcnid and drcindex are set
+#
+do_config_vdevice_wicked() {
+       hcnlog DEBUG "do_config_vdevice: enter"
+
+       BONDNAME=bond$HCNID
+       BOND_PATH=$BOND_BASEPATH/$BONDNAME/bonding
+
+       hcnlog DEBUG "Check if there is bond $BONDNAME with hcn id $HCNID"
+
+       if ! suse_ifcfg_is_bond_master "$BONDNAME"; then
+               hcnlog INFO "create bonding for $BONDNAME with bond.options 
$BONDOPTIONS "
+               suse_ifcfg_bond_create "$BONDNAME" "$BONDING_MODULE_OPTS"
+        wicked ifup "$BONDNAME"
+       fi
+
+       # Add device to the bond
+       hcnlog INFO "suse_ifcfg_bond_add_slave $BONDNAME $DEVNAME"
+       if ! suse_ifcfg_bond_add_slave "$BONDNAME" "$DEVNAME"; then
+               hcnlog DEBUG "enslave $DEVNAME failed"
+               return $E_ENODEV
+       fi
+       hcnlog DEBUG "Bring up the $DEVNAME interface"
+
+
+       # if the device is primary, and link is up, force it as primary se
+       if [[ $MODE == "primary" ]]; then
+               hcnlog INFO "Change bonding primary slave to $DEVNAME"
+#              echo "$DEVNAME" >"$BOND_PATH"/active_slave
+               suse_ifcfg_bond_set_primary "$BONDNAME" "$DEVNAME"
+        wicked ifup "$BONDNAME"
+       fi
+       wicked_reload "$BONDNAME"
+       hcnlog DEBUG "do_config_vdevice: exit"
+       return $E_SUCCESS
+}
+s
 do_config_vdevice() {
        if [[ $SERVICES == "networt.service" ]]; then
                do_config_vdevice_nm
-       fi
+       else
+        do_config_vdevice_wicked
+    fi
 }
 #
 # function cfghcn
@@ -399,6 +444,12 @@ rmhcn_nm() {
                nmcli con delete "$connection"
        done
 }
+
+rmhcn_wicked() {
+       hcnlog INFO "Delete bonding $BONDNAME"
+       suse_ifcfg_bond_delete "$BONDNAME"
+       wicked_reload "$BONDNAME"
+}
 #
 # function rmhcn
 #      Given HCNID, remove HCN
@@ -419,6 +470,8 @@ rmhcn() {
        hcnlog INFO "rmhcn: delete bond $BONDNAME and slaves "
        if [[ $SERVICES == "networt.service" ]]; then
                rmhcn_nm
+       else
+               rmhcn_wicked
        fi
        hcnlog DEBUG "rmhcn: exit"
        return $E_SUCCESS
@@ -433,7 +486,15 @@ qrydev_nm() {
                return $E_SUCCESS
        fi
 }
-
+qrydev_wicked() {
+       if ! wicked ifstatus $DEVNAME |grep link |grep up; then
+               hcnlog DEBUG "network connection $BONDNAME-$DEVNAME is inactive 
or nonexist"
+               hcnlog DEBUG "HCNID $HCNID devname $DEVNAME mode $MODE physloc 
$PHYSLOC DEVPATH $DEVPATH"
+               hcnlog DEBUG "qryhcn: exit"
+               # In this case, tell HMC to do rmdev and okay to migrate
+               return $E_SUCCESS
+       fi
+}
 #
 #function qrydev
 #      Called by HMC right before migration, to see if it is safe to
@@ -463,6 +524,8 @@ qrydev() {
        hcnlog DEBUG "check if the network interface for this SR_IOV is not up, 
return success"
        if [[ $SERVICES == "networt.service" ]]; then
                qrydev_nm
+       else
+               qrydev_wicked
        fi
 
        hcnlog DEBUG "check if there is bond for this $HCNID"
@@ -499,7 +562,9 @@ show_hcnstatus() {
        if [[ $SERVICES == "networt.service" ]]; then
                nmcli connection show >>$LOG_FILE
                nmcli device status >>$LOG_FILE
-       fi
+       else
+        wicked ifstatus all >>$LOG_FILE
+    fi
        ip addr show >>$LOG_FILE
 }
 
@@ -512,12 +577,23 @@ check_eth() {
        nmcli -f DEVICE con show | grep -q "$1"
 }
 
-rmdev_nm {
+rmdev_nm() {
+       hcnlog DEBUG "rmdev_nm: enter"
        if check_eth "$DEVNAME"; then
                hcnlog INFO "rmdev: delete $BONDNAME-$DEVNAME connection"
                nmcli con delete "$BONDNAME-$DEVNAME"
        fi
 }
+
+rmdev_wicked() {
+       hcnlog DEBUG "rmdev_wicked: enter"
+       suse_ifcfg_bond_del_slave "$BONDNAME" "$DEVNAME"
+    wicked ifup "$BONDNAME"
+    wicked_reload "$BONDNAME"
+       hcnlog DEBUG "rmdev_wicked: exit"
+       return $E_SUCCESS
+}
+
 #
 #function rmdev
 #      this is called at pre-migration time, remove sr-iov from HCN
@@ -538,7 +614,9 @@ rmdev() {
 
        if [[ $SERVICES == "networt.service" ]]; then
                rmdev_nm
-       fi
+       else
+        rmdev_wicked
+    fi
 
        hcnlog DEBUG "rmdev: exit"
        return $E_SUCCESS
-- 
2.34.1


++++++ 0005-Set-modprobe-bonding-max_bonds-0-option.patch ++++++
>From 7f4602d7df66aa42c5b269a9cdc5e6c8e1cb30e2 Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <m...@suse.de>
Date: Mon, 24 Jan 2022 17:50:05 +0100
Subject: [PATCH 05/15] Set modprobe bonding max_bonds=0 option

Avoid bond0 interface creation while module init in the kernel.
---
 scripts/hcnmgr | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/hcnmgr b/scripts/hcnmgr
index 0aa6ee8..6c56508 100644
--- a/scripts/hcnmgr
+++ b/scripts/hcnmgr
@@ -24,6 +24,7 @@
 FEATURES="vnic"
 PATH=$PATH:/bin:/usr/bin:/sbin:/usr/sbin
 BOND_BASEPATH="/sys/class/net"
+BOND_MODPROBE_OPTS="max_bonds=0"
 BONDOPTIONS="mode=1,miimon=100,fail_over_mac=2"
 IFCONFIG_PATH="/etc/sysconfig/network-scripts"
 PSERIES_PLATFORM=$(dirname "$0")/pseries_platform
@@ -801,7 +802,7 @@ fi
 #Validate bonding module is loaded
 if ! lsmod | grep -q bonding; then
        hcnlog DEBUG "HCNMGR: Bonding module not loaded, load module ..."
-       if ! modprobe bonding; then
+       if ! modprobe bonding $BOND_MODPROBE_OPTS; then
                err $E_NOMODULE
        fi
 fi
-- 
2.34.1


++++++ 0006-cleanup-hcnmgr-distro-and-service-detection.patch ++++++
>From 6106b6bbedbe1a90054f8749abc036ce6d299e8e Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <m...@suse.de>
Date: Mon, 24 Jan 2022 20:20:35 +0100
Subject: [PATCH 06/15] cleanup hcnmgr distro and service detection

---
 scripts/hcnmgr | 153 ++++++++++++++++++++++++++++++-------------------
 1 file changed, 93 insertions(+), 60 deletions(-)

diff --git a/scripts/hcnmgr b/scripts/hcnmgr
index 6c56508..c3cbf7b 100644
--- a/scripts/hcnmgr
+++ b/scripts/hcnmgr
@@ -41,7 +41,7 @@ PHYSLOC=""
 DEVPATH=""
 VIO_TYPE=""
 DISTRO=""
-SERVICES=""
+SERVICE=""
 
 source /usr/sbins/functions.suse
 
@@ -88,7 +88,7 @@ E_BUSY=16         # Device busy
 E_ENODEV=19       # Failed get device name
 E_NOMODULE=5      # Failed to load bonding module
 E_INVAL_DEV=6     # Vdevice not supported
-E_ENETUNREACH=101 # No network management command nmcli
+E_ENETUNREACH=101 # No supported network service enabled or management command 
not found
 
 #
 # err
@@ -98,6 +98,7 @@ E_ENETUNREACH=101 # No network management command nmcli
 err() {
        local e_mesg
        local eno=$1
+       local msg=$2
 
        case $eno in
        "$E_INVAL")
@@ -119,7 +120,7 @@ err() {
                e_mesg="$HCNCMD:error code $eno, Failed to load bonding module"
                ;;
        "$E_ENETUNREACH")
-               e_mesg="$HCNCMD:error code $eno, nmcli command not installed"
+               e_mesg="$HCNCMD:error code $eno, ${msg:-No supported network 
service enabled or management command not found}"
                ;;
        *)
                e_mesg="$HCNCMD:error code $eno"
@@ -397,13 +398,16 @@ do_config_vdevice_wicked() {
        hcnlog DEBUG "do_config_vdevice: exit"
        return $E_SUCCESS
 }
-s
+
 do_config_vdevice() {
-       if [[ $SERVICES == "networt.service" ]]; then
-               do_config_vdevice_nm
-       else
-        do_config_vdevice_wicked
-    fi
+       case $SERVICE in
+               NetworkManager.service)
+                       do_config_vdevice_nm
+                       ;;
+               wicked.service)
+                       do_config_vdevice_wicked
+                       ;;
+       esac
 }
 #
 # function cfghcn
@@ -451,6 +455,7 @@ rmhcn_wicked() {
        suse_ifcfg_bond_delete "$BONDNAME"
        wicked_reload "$BONDNAME"
 }
+
 #
 # function rmhcn
 #      Given HCNID, remove HCN
@@ -469,11 +474,14 @@ rmhcn() {
        fi
 
        hcnlog INFO "rmhcn: delete bond $BONDNAME and slaves "
-       if [[ $SERVICES == "networt.service" ]]; then
-               rmhcn_nm
-       else
-               rmhcn_wicked
-       fi
+       case $SERVICE in
+               NetworkManager.service)
+                       rmhcn_nm
+                       ;;
+               wicked.service)
+                       rmhcn_wicked
+                       ;;
+       esac
        hcnlog DEBUG "rmhcn: exit"
        return $E_SUCCESS
 }
@@ -523,11 +531,14 @@ qrydev() {
        BOND_PATH=$BOND_BASEPATH/$BONDNAME/bonding
 
        hcnlog DEBUG "check if the network interface for this SR_IOV is not up, 
return success"
-       if [[ $SERVICES == "networt.service" ]]; then
-               qrydev_nm
-       else
-               qrydev_wicked
-       fi
+       case $SERVICE in
+               NetworkManager.service)
+                       qrydev_nm
+                       ;;
+               wicked.service)
+                       qrydev_wicked
+                       ;;
+       esac
 
        hcnlog DEBUG "check if there is bond for this $HCNID"
        if [ ! -d "$BOND_PATH" ]; then
@@ -560,12 +571,17 @@ qrydev() {
 #
 show_hcnstatus() {
        hcnlog DEBUG "log connection and device status to $LOG_FILE"
-       if [[ $SERVICES == "networt.service" ]]; then
-               nmcli connection show >>$LOG_FILE
-               nmcli device status >>$LOG_FILE
-       else
-        wicked ifstatus all >>$LOG_FILE
-    fi
+
+       case $SERVICE in
+               NetworkManager.service)
+                       nmcli connection show >>$LOG_FILE
+                       nmcli device status >>$LOG_FILE
+                       ;;
+               wicked.service)
+                       wicked ifstatus all >>$LOG_FILE
+                       ;;
+       esac
+
        ip addr show >>$LOG_FILE
 }
 
@@ -613,11 +629,14 @@ rmdev() {
                hcnlog WARN "rmdev: mismatch drc index $1 HCNID $2"
        fi
 
-       if [[ $SERVICES == "networt.service" ]]; then
-               rmdev_nm
-       else
-        rmdev_wicked
-    fi
+       case $SERVICE in
+               NetworkManager.service)
+                       rmdev_nm
+                       ;;
+               wicked.service)
+                       rmdev_wicked
+                       ;;
+       esac
 
        hcnlog DEBUG "rmdev: exit"
        return $E_SUCCESS
@@ -663,7 +682,7 @@ scanhcn_cleanup_old_hnv_nm() {
 #      For each matching primary and backup virtual device with same ibm 
property
 #      ibm,hcn-id, if the hybrid network has not been created, create HCN
 #      (active-backup bonding) for them.
-#s
+#
 scanhcn() {
        local HcnIds=()
 
@@ -679,9 +698,11 @@ scanhcn() {
                        [ -d "$dev" ] || continue
                        if [ -e "$dev"/ibm,hcn-id ] && get_dev_hcn "$dev"; then
                                hcnlog DEBUG "scanhcn found sr-iov device with 
hcnid "
-                               if [[ $SERVICES == "networt.service" ]]; then
-                                       scanhcn_cleanup_old_hnv_nm
-                               fi
+                               case $SERVICE in
+                                       NetworkManager.service)
+                                               scanhcn_cleanup_old_hnv_nm
+                                               ;;
+                               esac
                                hcnlog INFO "scanhcn configure HCN and sr-iov 
device"
                                do_config_vdevice
                                # Save found HCN ids in array HcnIds
@@ -726,10 +747,11 @@ scanhcn() {
 
        # list of all HCN ids
        ids="${HcnIds[*]}"
-       if [[ $SERVICES == "networt.service" ]]; then
+       case $SERVICE in
+               NetworkManager.service)
                # After inactive migration, LPAR may have old bonding 
connections
                # with network device on original LPAR
-          # clean up dead bonding connections
+               # clean up dead bonding connections
                for connection in $(nmcli -f NAME con show | grep "${ids// 
/\\|}"); do
                        dev=$(echo "$connection" | cut -d '-' -f 2)
                        if [[ $dev != "NAME" && ! -e /sys/class/net/"$dev" ]]; 
then
@@ -737,16 +759,17 @@ scanhcn() {
                                nmcli con delete "$connection"
                        fi
                done
-       fi
+               ;;
+       esac
 
        hcnlog DEBUG "scanhcn: scan for hybrid virtual network finished"
 }
-#function check_network_service
+
+# function check_network_service
 #      Check what connection manager is used
-#      network manager or wicked (on SuSE)
+#      On SUSE, it's wicked.sevice (SLES) or NetworkManager.service (SLED)
+#      with the network.service alias pointing to the enabled service.
 #
-
-
 check_network_service() {
 
        DISTRO="Unknown"
@@ -754,27 +777,37 @@ check_network_service() {
                DISTRO=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
        fi
 
+       #Validate distro service CLI packages is installed to manage networking
+       case $DISTRO in
+               sles)
+                       SERVICE=$(systemctl show -P Id network.service 
2>/dev/null)
+                       case $SERVICE in
+                               wicked.service)
+                                       if ! wicked --version >/dev/null 2>&1; 
then
+                                               err $E_ENETUNREACH "wicked 
management command not installed"
+                                       fi
+                                       ;;
+                               NetworkManager.service)
+                                       if ! nmcli --version >/dev/null 2>&1; 
then
+                                               err $E_ENETUNREACH "nmcli 
management command not installed"
+                                       fi
+                                       ;;
+                               *)
+                                       err $E_ENETUNREACH "HNV is only 
supported on wicked and NetworkManager"
+                                       ;;
+                       esac
+                       ;;
+               *)
+                       if ! nmcli --version >/dev/null 2>&1; then
+                               err $E_ENETUNREACH "HNV is only supported on 
NetworkManager"
+                       fi
 
-       SERVICES=$(systemctl show -p Id network.service | cut -d '=' -f 2)
-       hcnlog INFO " LPAR is running OS $DISTEO with network service $SERVICES"
-
-       case "$SERVICES" in
-               *wicked.service)
-                               #validate wicked, wicked dd services
-                               #validate yast package
-                               hcnlog INFO "HNV is not supported with Wicked"
-                               ;;
-               *network.service)
-                               #Validate NMCLI packages is install to manage 
networking
-                               if ! nmcli --version >/dev/null 2>&1; then
-                                       err $E_ENETUNREACH
-                               fi
-                               ;;
-               default)
-                               hcnlog INFO "HNV is only supported on 
NetworkManager"
-                               err $E_ENETUNREACH
-                               ;;
+                       # Assume it's NetworkManager.service -- at least the 
cli is available
+                       SERVICE=NetworkManager.service
+                       ;;
        esac
+
+       hcnlog INFO " LPAR is running OS $DISTRO with network service 
${SERVICE%.service}"
 }
 
 #
-- 
2.34.1


++++++ 0007-Remove-wicked-ifup-calls-that-just-run-into-timeouts.patch ++++++
>From 79a030172b31b07753aee4c9ec38700733dff37f Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <m...@suse.de>
Date: Mon, 24 Jan 2022 20:24:12 +0100
Subject: [PATCH 07/15] Remove wicked ifup calls that just run into timeouts

Setting up a bonding without any slave will never reach
an link-up state as the bond can't detect carrier and
it requires one slave.
---
 scripts/hcnmgr | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/scripts/hcnmgr b/scripts/hcnmgr
index c3cbf7b..ffcd4d6 100644
--- a/scripts/hcnmgr
+++ b/scripts/hcnmgr
@@ -375,7 +375,6 @@ do_config_vdevice_wicked() {
        if ! suse_ifcfg_is_bond_master "$BONDNAME"; then
                hcnlog INFO "create bonding for $BONDNAME with bond.options 
$BONDOPTIONS "
                suse_ifcfg_bond_create "$BONDNAME" "$BONDING_MODULE_OPTS"
-        wicked ifup "$BONDNAME"
        fi
 
        # Add device to the bond
@@ -384,17 +383,17 @@ do_config_vdevice_wicked() {
                hcnlog DEBUG "enslave $DEVNAME failed"
                return $E_ENODEV
        fi
-       hcnlog DEBUG "Bring up the $DEVNAME interface"
-
 
-       # if the device is primary, and link is up, force it as primary se
+       # if the device is primary, and link is up, force it as primary
        if [[ $MODE == "primary" ]]; then
                hcnlog INFO "Change bonding primary slave to $DEVNAME"
 #              echo "$DEVNAME" >"$BOND_PATH"/active_slave
                suse_ifcfg_bond_set_primary "$BONDNAME" "$DEVNAME"
-        wicked ifup "$BONDNAME"
        fi
+
+       hcnlog DEBUG "Bring up the $BONDNAME interface"
        wicked_reload "$BONDNAME"
+
        hcnlog DEBUG "do_config_vdevice: exit"
        return $E_SUCCESS
 }
-- 
2.34.1


++++++ 0008-add-note-about-comma-in-hcnmgr-BONDOPTIONS.patch ++++++
>From ea4f6a210d8ef27dbfa02e7706f404e638e20e46 Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <m...@suse.de>
Date: Mon, 24 Jan 2022 20:43:42 +0100
Subject: [PATCH 08/15] add note about comma in hcnmgr BONDOPTIONS

---
 scripts/hcnmgr | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/scripts/hcnmgr b/scripts/hcnmgr
index ffcd4d6..03b65c5 100644
--- a/scripts/hcnmgr
+++ b/scripts/hcnmgr
@@ -374,7 +374,10 @@ do_config_vdevice_wicked() {
 
        if ! suse_ifcfg_is_bond_master "$BONDNAME"; then
                hcnlog INFO "create bonding for $BONDNAME with bond.options 
$BONDOPTIONS "
-               suse_ifcfg_bond_create "$BONDNAME" "$BONDING_MODULE_OPTS"
+               # Note: wicked needs spaces in BONDING_MODULE_OPTS as comma is
+               #       used/reserved to separate multiple arp_ip_targets, thus
+               #       this could result in invalid options...:
+               suse_ifcfg_bond_create "$BONDNAME" "${BONDOPTIONS//,/ }"
        fi
 
        # Add device to the bond
-- 
2.34.1


++++++ 0009-Fix-to-call-wicked-ifreload-directly.patch ++++++
>From c6eb3f4b817d641ce84172566cb9ab308cadbb51 Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <m...@suse.de>
Date: Wed, 26 Jan 2022 18:26:40 +0100
Subject: [PATCH 09/15] Fix to call wicked ifreload directly

The wicked_reload() wrapper function were not working as it
were using a function from a not included library.
---
 scripts/functions.suse | 9 ---------
 scripts/hcnmgr         | 7 +++----
 2 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/scripts/functions.suse b/scripts/functions.suse
index 4001bb8..c70323a 100644
--- a/scripts/functions.suse
+++ b/scripts/functions.suse
@@ -389,12 +389,3 @@ suse_ifcfg_bond_modify()
        return 1
 }
 
-wicked_reload()
-{
-       if [ $# -eq 0 ] ; then
-               rcnetwork reload
-       elif systemctl_is_active wicked.service ; then
-               wicked ifreload -- "$@"
-       fi
-}
-
diff --git a/scripts/hcnmgr b/scripts/hcnmgr
index 03b65c5..9b94be9 100644
--- a/scripts/hcnmgr
+++ b/scripts/hcnmgr
@@ -395,7 +395,7 @@ do_config_vdevice_wicked() {
        fi
 
        hcnlog DEBUG "Bring up the $BONDNAME interface"
-       wicked_reload "$BONDNAME"
+       wicked ifreload "$BONDNAME"
 
        hcnlog DEBUG "do_config_vdevice: exit"
        return $E_SUCCESS
@@ -455,7 +455,7 @@ rmhcn_nm() {
 rmhcn_wicked() {
        hcnlog INFO "Delete bonding $BONDNAME"
        suse_ifcfg_bond_delete "$BONDNAME"
-       wicked_reload "$BONDNAME"
+       wicked ifreload "$BONDNAME"
 }
 
 #
@@ -607,8 +607,7 @@ rmdev_nm() {
 rmdev_wicked() {
        hcnlog DEBUG "rmdev_wicked: enter"
        suse_ifcfg_bond_del_slave "$BONDNAME" "$DEVNAME"
-    wicked ifup "$BONDNAME"
-    wicked_reload "$BONDNAME"
+       wicked ifreload "$BONDNAME"
        hcnlog DEBUG "rmdev_wicked: exit"
        return $E_SUCCESS
 }
-- 
2.34.1


++++++ 0010-Fix-incorrect-parameters-to-suse_ifcfg_bond_create.patch ++++++
>From 59b9469dc1496f376dcf659c93db10d38e3fcff9 Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <m...@suse.de>
Date: Wed, 26 Jan 2022 18:30:12 +0100
Subject: [PATCH 10/15] Fix incorrect parameters to suse_ifcfg_bond_create

---
 scripts/hcnmgr | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/hcnmgr b/scripts/hcnmgr
index 9b94be9..475092e 100644
--- a/scripts/hcnmgr
+++ b/scripts/hcnmgr
@@ -377,7 +377,7 @@ do_config_vdevice_wicked() {
                # Note: wicked needs spaces in BONDING_MODULE_OPTS as comma is
                #       used/reserved to separate multiple arp_ip_targets, thus
                #       this could result in invalid options...:
-               suse_ifcfg_bond_create "$BONDNAME" "${BONDOPTIONS//,/ }"
+               suse_ifcfg_bond_create "$BONDNAME" "" "${BONDOPTIONS//,/ }"
        fi
 
        # Add device to the bond
-- 
2.34.1


++++++ 0011-Fix-comment-about-setting-primary.patch ++++++
>From 5428ce5a46cf51d17bfb85db03569b251fd5b0a1 Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <m...@suse.de>
Date: Wed, 26 Jan 2022 18:34:13 +0100
Subject: [PATCH 11/15] Fix comment about setting primary

The suse_ifcfg_bond_set_primary adjusts it in the config only
(the bond may not exist yet), the following wicked ifreload
call is applying the config to wicked adjusting the kernel.
---
 scripts/hcnmgr | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/hcnmgr b/scripts/hcnmgr
index 475092e..565c3ff 100644
--- a/scripts/hcnmgr
+++ b/scripts/hcnmgr
@@ -387,13 +387,13 @@ do_config_vdevice_wicked() {
                return $E_ENODEV
        fi
 
-       # if the device is primary, and link is up, force it as primary
+       # if the device is primary, adjust it in the config
        if [[ $MODE == "primary" ]]; then
                hcnlog INFO "Change bonding primary slave to $DEVNAME"
-#              echo "$DEVNAME" >"$BOND_PATH"/active_slave
                suse_ifcfg_bond_set_primary "$BONDNAME" "$DEVNAME"
        fi
 
+       # Apply the config changes to wicked
        hcnlog DEBUG "Bring up the $BONDNAME interface"
        wicked ifreload "$BONDNAME"
 
-- 
2.34.1


++++++ 0012-Description-and-indenting-corrections.patch ++++++
>From a533e59f09b05c1cb1876b82a6f0498941562864 Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <m...@suse.de>
Date: Wed, 26 Jan 2022 18:40:08 +0100
Subject: [PATCH 12/15] Description and indenting corrections

---
 scripts/functions.suse | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/scripts/functions.suse b/scripts/functions.suse
index c70323a..57a95db 100644
--- a/scripts/functions.suse
+++ b/scripts/functions.suse
@@ -1,7 +1,7 @@
 #! /bin/bash
 #  ^^^^^^^^^
 #
-# Copyright (c) 2021 SUSE LLC
+# Copyright (c) 2022 SUSE LLC
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -19,28 +19,29 @@
 # Authors:
 #      Marius Tomaschewski <m...@suse.com>
 #
-# suse specific hcnmgr utilities to manipulate suse ifcfg files
-# as supported by yast2 network.
+# Bash function library for hcnmgr providing utilities to manipulate
+# suse ifcfg config files as supported by yast2 network and wicked.
 #
+###
 
 suse_ifcfg_config_dir="/etc/sysconfig/network"
 
 suse_wlist_find()
 {
-        local item want="$1" ; shift
-        for item in $* ; do
-                [ X"$want" = X"$item" ] && return 0
-        done
-        return 1
+       local item want="$1" ; shift
+       for item in $* ; do
+               [ X"$want" = X"$item" ] && return 0
+       done
+       return 1
 }
 suse_wlist_uniq()
 {
        local item list=()
-        for item in $* ; do
-                suse_wlist_find "$item" "$list" && continue
+       for item in $* ; do
+               suse_wlist_find "$item" "$list" && continue
                list+=("$item")
-        done
-        echo "${list[*]}"
+       done
+       echo "${list[*]}"
 }
 suse_ifcfg_unquote()
 {
@@ -326,7 +327,7 @@ suse_ifcfg_bond_delete()
        [ X"$file" != X ] && rm -f -- "$file"
 
        # TODO: cleanup interfaces on top of the bond
-       #               _if_ the hnv setup permit to use them
+       #       _if_ the hnv setup permit to use them
        # e.g.: brX { bondX }, brN { bondX.N }
 }
 
-- 
2.34.1


++++++ 0013-adjust-sourcing-path-of-the-functions.suse-library.patch ++++++
>From d8c65364ed7e1b3144b55526dccdff6ce1947c47 Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <m...@suse.de>
Date: Wed, 26 Jan 2022 18:43:04 +0100
Subject: [PATCH 13/15] adjust sourcing path of the functions.suse library

Use /usr/lib/powerpc-utils/functions.suse (libexecdir)
---
 scripts/hcnmgr | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/hcnmgr b/scripts/hcnmgr
index 565c3ff..8c01c86 100644
--- a/scripts/hcnmgr
+++ b/scripts/hcnmgr
@@ -43,7 +43,7 @@ VIO_TYPE=""
 DISTRO=""
 SERVICE=""
 
-source /usr/sbins/functions.suse
+source /usr/lib/powerpc-utils/functions.suse
 
 # Usage statements
 usage() {
-- 
2.34.1


++++++ 0014-Enable-the-network-service-checks.patch ++++++
>From 2822ad29d29f9b6e24f0a386c1fd7d99931e249a Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <m...@suse.de>
Date: Wed, 26 Jan 2022 18:54:35 +0100
Subject: [PATCH 14/15] Enable the network service checks

---
 scripts/hcnmgr | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/scripts/hcnmgr b/scripts/hcnmgr
index 8c01c86..f8e0c6a 100644
--- a/scripts/hcnmgr
+++ b/scripts/hcnmgr
@@ -393,9 +393,14 @@ do_config_vdevice_wicked() {
                suse_ifcfg_bond_set_primary "$BONDNAME" "$DEVNAME"
        fi
 
-       # Apply the config changes to wicked
-       hcnlog DEBUG "Bring up the $BONDNAME interface"
-       wicked ifreload "$BONDNAME"
+       # Prepare configuration while hcn-init.service run, but do not try
+       # to apply when the wicked.service aka network.service is active.
+       # The network.service start at boot (or next one) will apply it.
+       if systemctl is-active -q wicked.service ; then
+               # Apply the config changes to wicked
+               hcnlog DEBUG "Bring up the $BONDNAME interface"
+               wicked ifreload "$BONDNAME"
+       fi
 
        hcnlog DEBUG "do_config_vdevice: exit"
        return $E_SUCCESS
@@ -787,11 +792,16 @@ check_network_service() {
                                        if ! wicked --version >/dev/null 2>&1; 
then
                                                err $E_ENETUNREACH "wicked 
management command not installed"
                                        fi
+                                       # hcn-init.service starts before wicked
                                        ;;
                                NetworkManager.service)
                                        if ! nmcli --version >/dev/null 2>&1; 
then
                                                err $E_ENETUNREACH "nmcli 
management command not installed"
                                        fi
+                                       # hcn-init.service starts after network 
manager
+                                       if ! systemctl is-active -q "$SERVICE" 
; then
+                                               err $E_ENETUNREACH 
"NetworkManager.service not active"
+                                       fi
                                        ;;
                                *)
                                        err $E_ENETUNREACH "HNV is only 
supported on wicked and NetworkManager"
@@ -805,6 +815,9 @@ check_network_service() {
 
                        # Assume it's NetworkManager.service -- at least the 
cli is available
                        SERVICE=NetworkManager.service
+                       if ! systemctl is-active -q "$SERVICE" ; then
+                               err $E_ENETUNREACH "NetworkManager.service not 
active"
+                       fi
                        ;;
        esac
 
@@ -833,6 +846,9 @@ if [ "$platform" != "$PLATFORM_PSERIES_LPAR" ]; then
        exit 0
 fi
 
+#Init the distribution and the network service
+check_network_service
+
 #Validate bonding module is loaded
 if ! lsmod | grep -q bonding; then
        hcnlog DEBUG "HCNMGR: Bonding module not loaded, load module ..."
-- 
2.34.1


++++++ 0015-add-hcn-init.service.suse-service-covering-wicked.patch ++++++
>From a831053d868f806a61ee06b88a3ee917a42586b4 Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <m...@suse.de>
Date: Wed, 26 Jan 2022 22:10:36 +0100
Subject: [PATCH 15/15] add hcn-init.service.suse service covering wicked

While hcnmgr -s needs to communicate with NetworkManager and
thus the hcn-init.service has to start after it, in wicked
case, we can prepare the actually needed configuration and
let wicked.service starting after apply it.
This avoids to try to setup a potentially obsolete bonding
first (and maybe even run into timeouts) and then modify it
to the current hcn state in device-tree.
---
 configure.ac                     |  2 +-
 systemd/hcn-init.service.suse.in | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
 create mode 100644 systemd/hcn-init.service.suse.in

diff --git a/configure.ac b/configure.ac
index 79d6cf7..fd275be 100644
--- a/configure.ac
+++ b/configure.ac
@@ -117,5 +117,5 @@ LOCAL_CHECK_FLAGS
 
 AC_CONFIG_FILES([Makefile powerpc-utils.spec systemd/smt_off.service])
 AC_CONFIG_FILES([systemd/smtstate.service scripts/smtstate])
-AC_CONFIG_FILES([systemd/hcn-init.service])
+AC_CONFIG_FILES([systemd/hcn-init.service systemd/hcn-init.service.suse])
 AC_OUTPUT
diff --git a/systemd/hcn-init.service.suse.in b/systemd/hcn-init.service.suse.in
new file mode 100644
index 0000000..f841755
--- /dev/null
+++ b/systemd/hcn-init.service.suse.in
@@ -0,0 +1,13 @@
+[Unit]
+Description=hybrid virtual network scan and config
+After=network-pre.target NetworkManager.service
+Before=wicked.service
+Requisite=network.service
+PartOf=network.service
+
+[Service]
+Type=oneshot
+ExecStart=@sbindir@/hcnmgr -s
+
+[Install]
+WantedBy=multi-user.target network.target
-- 
2.34.1

Reply via email to