Fix boot-time bonding interface cleanup and avoid use ifcfg

This commit is contained in:
Than Ngo 2021-02-08 10:31:24 +01:00
parent 21f6067965
commit c47724cdaf
2 changed files with 102 additions and 1 deletions

View File

@ -0,0 +1,96 @@
commit bfabc531021ee9cfc4c8dd83803e9daf7e45d91e
Author: Mingming Cao <mmc@linux.vnet.ibm.com>
Date: Thu Jan 28 12:49:07 2021 -0800
Fix boot-time bonding interface cleanup and avoid use ifcfg
This patch fix three issues
1) Avoid cleanup bond interface at the boot time when there is no HNV exists
2) Using nmcli instead of ifconfig file to check bond configuration as it
has been officially deprecated. This makes HNV configure bonding
indpendant of where bonding cfg file located.
3) At the time of calling ofpathname to look up for devicename, wait
for sys fs device ready. Otherwise the OS may in the middle of device
renaming.
Signed-off-by: Mingming Cao <mmc@linux.vnet.ibm.com>
diff --git a/scripts/hcnmgr b/scripts/hcnmgr
index a76505e..e4b56d6 100644
--- a/scripts/hcnmgr
+++ b/scripts/hcnmgr
@@ -241,7 +241,10 @@ get_dev_hcn() {
# Let's retry a few times.
while [ $wait != 0 ]; do
if DEVNAME=$(ofpathname -l "$(echo "$1" | sed -e "s/\/proc\/device-tree//")" 2>/dev/null); then
- break
+ if [ -e /sys/class/net/"$DEVNAME" ]; then
+ hcnlog DEBUG "ofpathname waiting for /sys/class/net device $DEVNAME ready"
+ break
+ fi
fi
hcnlog DEBUG "ofpathname return $?, devname is $DEVNAME rety counter $wait"
@@ -278,9 +281,7 @@ do_config_vdevice() {
BOND_PATH=$BOND_BASEPATH/$BONDNAME/bonding
hcnlog DEBUG "Check if there is bond $BONDNAME with hcn id $HCNID"
-
- hcnlog DEBUG "ifconfig file $IFCONFIG_PATH/ifconfig-$BONDNAME"
- if [ ! -e "$IFCONFIG_PATH/ifcfg-$BONDNAME" ]; then
+ if ! nmcli -f NAME con show --active | grep -q "$BONDNAME\s"; then
hcnlog INFO "nmcli con add type bond con-name $BONDNAME ifname $BONDNAME"
nmcli con add type bond con-name "$BONDNAME" ifname "$BONDNAME"
@@ -375,7 +376,10 @@ rmhcn() {
fi
hcnlog INFO "rmhcn: delete bond $BONDNAME and slaves "
- nmcli -f NAME con show | grep "$BONDNAME" | xargs sudo nmcli con delete
+ for connection in $(nmcli -f NAME con show | grep "$BONDNAME"); do
+ hcnlog INFO "Delete bonding connection $connection"
+ nmcli con delete "$connection"
+ done
hcnlog DEBUG "rmhcn: exit"
return $E_SUCCESS
}
@@ -576,19 +580,24 @@ scanhcn() {
fi
# Next clean up dead connections left from orgitinal LPAR after inactive miration
-
- # 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
+ # Only do this when the HNV ID array is not empty
+
+ if [[ ${HcnIds[[@]} ]]; then
+ hcnlog INFO "hcnscan finished. Found HNV devices on this LPAR"
+
+ # 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
+ fi
hcnlog DEBUG "scanhcn: scan for hybrid virtual network finished"
}

View File

@ -1,6 +1,6 @@
Name: powerpc-utils
Version: 1.3.8
Release: 5%{?dist}
Release: 6%{?dist}
Summary: PERL-based scripts for maintaining and servicing PowerPC systems
License: GPLv2
@ -36,6 +36,7 @@ Patch9: 0002-sys_ident--skip-length-field-from-search.patch
Patch10: powerpc-utils-1.3.8-f1ec5f04fdac3e87c3c85c2d85f79339d916e864.patch
Patch11: powerpc-utils-1.3.8-4b2d10942e2d964ecc1fe58c9460c34993ff10be.patch
Patch12: powerpc-utils-1.3.8-e51995667279164a6c8ce4c3ba0217fffda22d6d.patch
Patch13: powerpc-utils-1.3.8-fix_boot-time_bonding_interface_cleanup_and_avoid_use_ifcfg.patch
%description
PERL-based scripts for maintaining and servicing PowerPC systems.
@ -96,6 +97,7 @@ rm -rf $RPM_BUILD_ROOT/etc/init.d/ibmvscsis.sh $RPM_BUILD_ROOT/usr/sbin/vscsisad
# nvsetenv is just a wrapper to nvram
ln -s nvram.8.gz $RPM_BUILD_ROOT/%{_mandir}/man8/nvsetenv.8.gz
# symlink uspchrp
ln -s serv_config %{buildroot}%{_sbindir}/uspchrp
ln -s serv_config.8 %{buildroot}%{_mandir}/man8/uspchrp.8
@ -208,6 +210,9 @@ systemctl daemon-reload >/dev/null 2>&1 || :
%changelog
* Mon Feb 08 2021 Than Ngo <than@redhat.com> - 1.3.8-6
- Fix boot-time bonding interface cleanup and avoid use ifcfg
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.3.8-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild