Hi Coiby,
On Tue, 21 Jun 2022 14:57:28 +0800
Coiby Xu <coxu(a)redhat.com> wrote:
> /usr/lib/udev/ccw_init [1] shipped by s390utils extracts the values of
> SUBCHANNELS, NETTYPE and LAYER2 from /etc/sysconfig/network-scripts/ifcfg-*
> or /etc/NetworkManager/system-connections/*.nmconnection to activate znet
> network device. If the connection profile is copied to initrd,
> there is no need to set up the "rd.znet" dracut cmdline parameter.
>
> There are two cases addressed by this commit,
> 1. znet network interface is a slave of bonding/teaming/vlan/bridging
> network. The connection profile has been copied to initrd by
> kdump_copy_nmconnection_file and it contains the info needed by
> ccw_init.
> 2. znet network interface is a slave of bonding/teaming/vlan/bridging
> network. The corresponding ifcfg-*/*.nmconnection file may not contain
> info like SUBCHANNELS [2]. In this case, copy the ifcfg-*/*.nmconnection
> file that has this info to the kdump initrd. Also to prevent the copied
> connection profile from being chosen by NM, set
> connection.autoconnect=false for this connection profile.
>
> Note
> 1. ccw_init doesn't care if SUBCHANNELS, NETTYPE and LAYER2 comes from
> an active NM profile or not. If an inactive NM profile contains this
> info, it needs to be copied to the kdump initrd as well.
> 2. "rd.znet_ifname=$_netdev:${SUBCHANNELS}" is no needed because now
> there is no renaming of s390x network interfaces when reusing
> NetworkManager profiles. rd.znet_ifname was introduced in commit
> ce0305d ("Add a new option 'rd.znet_ifname' in order to use it in
udev
> rules") to address the special case of non-persistent MAC address by
> renaming a network interface by SUBCHANNELS.
>
> [1]
https://src.fedoraproject.org/rpms/s390utils/blob/rawhide/f/ccw_init
> [2]
https://bugzilla.redhat.com/show_bug.cgi?id=2064708
>
> Signed-off-by: Coiby Xu <coxu(a)redhat.com>
> ---
> dracut-module-setup.sh | 70 ++++++++++++++++++++++--------------------
> 1 file changed, 37 insertions(+), 33 deletions(-)
>
> diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
> index 1a8f55f..12b658a 100755
> --- a/dracut-module-setup.sh
> +++ b/dracut-module-setup.sh
> @@ -434,34 +434,46 @@ find_online_znet_device() {
> echo -n "$ifname"
> }
>
> -# setup s390 znet cmdline
> -# $1: netdev (ifname)
> -# $2: nmcli connection path
> +_find_znet_nmconnection() {
> + LANG=C grep -s -E -i -l \
> + "^s390-subchannels=([0-9]\.[0-9]\.[a-f0-9]+;){0,2}" \
> + "$1"/*.nmconnection | LC_ALL=C sed -e "$2"
> +}
> +
> +# setup s390 znet
> +#
> +# Note part of code is extracted from ccw_init provided by s390utils
> kdump_setup_znet() {
> - local _netdev="$1"
> - local _conpath="$2"
> - local s390_prefix="802-3-ethernet.s390-"
> - local _options=""
> - local NETTYPE
> - local SUBCHANNELS
> -
> - NETTYPE=$(get_nmcli_field_by_conpath "${s390_prefix}nettype"
"$_conpath")
> - SUBCHANNELS=$(get_nmcli_field_by_conpath "${s390_prefix}subchannels"
"$_conpath")
> - _options=$(get_nmcli_field_by_conpath "${s390_prefix}options"
"$_conpath")
> -
> - if [[ -z $NETTYPE || -z $SUBCHANNELS || -z $_options ]]; then
> - dwarning "Failed to get znet configuration via nmlci output. Now try
sourcing ifcfg script."
> - source_ifcfg_file "$_netdev"
> - for i in $OPTIONS; do
> - _options=${_options},$i
> - done
> + local _config_file _uniq_name _NM_conf_dir
s/uniq_name/unique_name/