From c23189119b988420ffbbb7b88da5fa58fd880a2b Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: May 14 2021 06:14:14 +0000 Subject: Set up bond cmdline by "nmcli --get-values" Resolves: bz1919052 Upstream: Fedora Conflict: None commit d5f6d38173f66c0b45e82cb52a66ba0140b7dd22 Author: Coiby Xu Date: Thu Apr 1 15:32:13 2021 +0800 Set up bond cmdline by "nmcli --get-values" Now kdumpctl will exit if failing to set up bond cmdline. Signed-off-by: Coiby Xu Acked-by: Kairui Song Signed-off-by: Coiby Xu --- diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 6c34760..e29c2de 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -368,7 +368,10 @@ kdump_setup_bridge() { for _dev in `ls /sys/class/net/$_netdev/brif/`; do _kdumpdev=$_dev if kdump_is_bond "$_dev"; then - kdump_setup_bond "$_dev" + $(kdump_setup_bond "$_dev" "$(get_nmcli_connection_show_cmd_by_ifname "$_dev")") + if [[ $? != 0 ]]; then + exit 1 + fi elif kdump_is_team "$_dev"; then kdump_setup_team "$_dev" elif kdump_is_vlan "$_dev"; then @@ -383,9 +386,13 @@ kdump_setup_bridge() { echo " bridge=$_netdev:$(echo $_brif | sed -e 's/,$//')" >> ${initdir}/etc/cmdline.d/41bridge.conf } +# drauct takes bond=[::[:]] syntax to parse +# bond. For example: +# bond=bond0:eth0,eth1:mode=balance-rr kdump_setup_bond() { - local _netdev=$1 - local _dev _mac _slaves _kdumpdev + local _netdev="$1" + local _nm_show_cmd="$2" + local _dev _mac _slaves _kdumpdev _bondoptions for _dev in `cat /sys/class/net/$_netdev/bonding/slaves`; do _mac=$(kdump_get_perm_addr $_dev) _kdumpdev=$(kdump_setup_ifname $_dev) @@ -393,12 +400,21 @@ kdump_setup_bond() { _slaves+="$_kdumpdev," done echo -n " bond=$_netdev:$(echo $_slaves | sed 's/,$//')" >> ${initdir}/etc/cmdline.d/42bond.conf - # Get bond options specified in ifcfg - source_ifcfg_file $_netdev + _bondoptions=$(get_nmcli_value_by_field "$_nm_show_cmd" "bond.options") + + if [[ -z "_bondoptions" ]]; then + dwarning "Failed to get bond configuration via nmlci output. Now try sourcing ifcfg script." + source_ifcfg_file $_netdev + _bondoptions="$(echo $BONDING_OPTS | xargs echo | tr " " ",")" + fi + + if [[ -z "_bondoptions" ]]; then + derror "Get empty bond options" + exit 1 + fi - bondoptions=":$(echo $BONDING_OPTS | xargs echo | tr " " ",")" - echo "$bondoptions" >> ${initdir}/etc/cmdline.d/42bond.conf + echo ":$_bondoptions" >> ${initdir}/etc/cmdline.d/42bond.conf } kdump_setup_team() { @@ -435,7 +451,10 @@ kdump_setup_vlan() { derror "Vlan over bridge is not supported!" exit 1 elif kdump_is_bond "$_phydev"; then - kdump_setup_bond "$_phydev" + $(kdump_setup_bond "$_phydev" "$(get_nmcli_connection_show_cmd_by_ifname "$_phydev")") + if [[ $? != 0 ]]; then + exit 1 + fi echo " vlan=$(kdump_setup_ifname $_netdev):$_phydev" > ${initdir}/etc/cmdline.d/43vlan.conf else _kdumpdev="$(kdump_setup_ifname $_phydev)" @@ -547,7 +566,10 @@ kdump_install_net() { if kdump_is_bridge "$_netdev"; then kdump_setup_bridge "$_netdev" elif kdump_is_bond "$_netdev"; then - kdump_setup_bond "$_netdev" + $(kdump_setup_bond "$_netdev" "$_nm_show_cmd") + if [[ $? != 0 ]]; then + exit 1 + fi elif kdump_is_team "$_netdev"; then kdump_setup_team "$_netdev" elif kdump_is_vlan "$_netdev"; then