2011-08-01 09:19:24 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-01-19 14:23:16 +00:00
|
|
|
kdump_module_init() {
|
|
|
|
if ! [[ -d "${initdir}/tmp" ]]; then
|
|
|
|
mkdir -p "${initdir}/tmp"
|
|
|
|
fi
|
2012-01-27 14:59:43 +00:00
|
|
|
|
2021-01-19 14:23:16 +00:00
|
|
|
. /lib/kdump/kdump-lib.sh
|
|
|
|
}
|
2015-02-12 06:40:27 +00:00
|
|
|
|
2011-08-01 09:19:24 +00:00
|
|
|
check() {
|
|
|
|
[[ $debug ]] && set -x
|
|
|
|
#kdumpctl sets this explicitly
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ -z $IN_KDUMP ]] || [[ ! -f /etc/kdump.conf ]]; then
|
2011-08-01 09:19:24 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2012-01-27 14:59:43 +00:00
|
|
|
depends() {
|
2018-12-25 14:51:35 +00:00
|
|
|
local _dep="base shutdown"
|
|
|
|
|
2021-01-19 14:23:16 +00:00
|
|
|
kdump_module_init
|
|
|
|
|
2020-10-15 10:16:43 +00:00
|
|
|
add_opt_module() {
|
|
|
|
[[ " $omit_dracutmodules " != *\ $1\ * ]] && _dep="$_dep $1"
|
|
|
|
}
|
|
|
|
|
2021-06-23 14:36:48 +00:00
|
|
|
if is_squash_available; then
|
2020-10-15 10:16:43 +00:00
|
|
|
add_opt_module squash
|
2018-12-25 14:51:35 +00:00
|
|
|
else
|
|
|
|
dwarning "Required modules to build a squashed kdump image is missing!"
|
|
|
|
fi
|
2013-06-05 08:01:17 +00:00
|
|
|
|
2020-10-15 10:16:44 +00:00
|
|
|
if is_wdt_active; then
|
|
|
|
add_opt_module watchdog
|
|
|
|
fi
|
|
|
|
|
2020-10-15 10:16:42 +00:00
|
|
|
if is_ssh_dump_target; then
|
|
|
|
_dep="$_dep ssh-client"
|
|
|
|
fi
|
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ "$(uname -m)" == "s390x" ]]; then
|
2020-10-15 10:16:42 +00:00
|
|
|
_dep="$_dep znet"
|
|
|
|
fi
|
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ -n "$(ls -A /sys/class/drm 2> /dev/null)" ]] || [[ -d /sys/module/hyperv_fb ]]; then
|
2020-10-15 10:16:43 +00:00
|
|
|
add_opt_module drm
|
2013-06-13 08:44:23 +00:00
|
|
|
fi
|
|
|
|
|
2019-10-22 08:03:57 +00:00
|
|
|
if is_generic_fence_kdump || is_pcs_fence_kdump; then
|
2013-12-20 09:41:29 +00:00
|
|
|
_dep="$_dep network"
|
|
|
|
fi
|
|
|
|
|
2021-09-08 09:21:41 +00:00
|
|
|
echo "$_dep"
|
2012-01-27 14:59:43 +00:00
|
|
|
}
|
|
|
|
|
2012-05-14 02:36:18 +00:00
|
|
|
kdump_is_bridge() {
|
2021-09-13 18:25:40 +00:00
|
|
|
[[ -d /sys/class/net/"$1"/bridge ]]
|
2012-01-27 14:59:43 +00:00
|
|
|
}
|
|
|
|
|
2012-05-14 02:36:18 +00:00
|
|
|
kdump_is_bond() {
|
2021-09-13 18:25:40 +00:00
|
|
|
[[ -d /sys/class/net/"$1"/bonding ]]
|
2011-08-01 09:19:24 +00:00
|
|
|
}
|
|
|
|
|
2012-12-13 14:36:05 +00:00
|
|
|
kdump_is_team() {
|
2021-09-13 18:25:40 +00:00
|
|
|
[[ -f /usr/bin/teamnl ]] && teamnl "$1" ports &> /dev/null
|
2012-12-13 14:36:05 +00:00
|
|
|
}
|
|
|
|
|
2012-06-10 10:24:36 +00:00
|
|
|
kdump_is_vlan() {
|
2021-09-13 18:25:40 +00:00
|
|
|
[[ -f /proc/net/vlan/"$1" ]]
|
2012-06-10 10:24:36 +00:00
|
|
|
}
|
|
|
|
|
2016-06-06 05:01:59 +00:00
|
|
|
# $1: netdev name
|
|
|
|
source_ifcfg_file() {
|
|
|
|
local ifcfg_file
|
|
|
|
|
2021-04-01 07:32:14 +00:00
|
|
|
dwarning "Network Scripts are deprecated. You are encouraged to set up network by NetworkManager."
|
2021-09-08 09:21:41 +00:00
|
|
|
ifcfg_file=$(get_ifcfg_filename "$1")
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ -f ${ifcfg_file} ]]; then
|
2021-09-08 09:21:41 +00:00
|
|
|
. "${ifcfg_file}"
|
2016-06-06 05:01:59 +00:00
|
|
|
else
|
|
|
|
dwarning "The ifcfg file of $1 is not found!"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-04-01 07:32:12 +00:00
|
|
|
# $1: nmcli connection show output
|
2012-07-12 03:15:35 +00:00
|
|
|
kdump_setup_dns() {
|
2021-04-01 07:32:12 +00:00
|
|
|
local _netdev="$1"
|
|
|
|
local _nm_show_cmd="$2"
|
|
|
|
local _nameserver _dns _tmp array
|
2015-06-30 09:45:15 +00:00
|
|
|
local _dnsfile=${initdir}/etc/cmdline.d/42dns.conf
|
2016-06-06 05:01:59 +00:00
|
|
|
|
2021-04-01 07:32:12 +00:00
|
|
|
_tmp=$(get_nmcli_value_by_field "$_nm_show_cmd" "IP4.DNS")
|
2021-09-08 09:21:41 +00:00
|
|
|
# shellcheck disable=SC2206
|
2021-09-13 18:25:40 +00:00
|
|
|
array=(${_tmp//|/ })
|
2021-08-04 07:47:43 +00:00
|
|
|
if [[ ${array[*]} ]]; then
|
2021-09-13 18:25:40 +00:00
|
|
|
for _dns in "${array[@]}"; do
|
2021-04-01 07:32:12 +00:00
|
|
|
echo "nameserver=$_dns" >> "$_dnsfile"
|
|
|
|
done
|
|
|
|
else
|
|
|
|
dwarning "Failed to get DNS info via nmcli output. Now try sourcing ifcfg script"
|
|
|
|
source_ifcfg_file "$_netdev"
|
2021-09-13 18:25:40 +00:00
|
|
|
[[ -n $DNS1 ]] && echo "nameserver=$DNS1" > "$_dnsfile"
|
|
|
|
[[ -n $DNS2 ]] && echo "nameserver=$DNS2" >> "$_dnsfile"
|
2021-04-01 07:32:12 +00:00
|
|
|
fi
|
2015-06-30 09:45:15 +00:00
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
while read -r content; do
|
2021-09-08 09:21:41 +00:00
|
|
|
_nameserver=$(echo "$content" | grep ^nameserver)
|
2021-09-13 18:25:40 +00:00
|
|
|
[[ -z $_nameserver ]] && continue
|
2015-06-30 09:45:15 +00:00
|
|
|
|
2021-09-08 09:21:41 +00:00
|
|
|
_dns=$(echo "$_nameserver" | awk '{print $2}')
|
2021-09-13 18:25:40 +00:00
|
|
|
[[ -z $_dns ]] && continue
|
2015-06-30 09:45:15 +00:00
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ ! -f $_dnsfile ]] || ! grep -q "$_dns" "$_dnsfile"; then
|
2015-06-30 09:45:15 +00:00
|
|
|
echo "nameserver=$_dns" >> "$_dnsfile"
|
|
|
|
fi
|
|
|
|
done < "/etc/resolv.conf"
|
2012-07-12 03:15:35 +00:00
|
|
|
}
|
|
|
|
|
2021-04-08 03:44:26 +00:00
|
|
|
# $1: repeat times
|
|
|
|
# $2: string to be repeated
|
|
|
|
# $3: separator
|
|
|
|
repeatedly_join_str() {
|
|
|
|
local _count="$1"
|
|
|
|
local _str="$2"
|
|
|
|
local _separator="$3"
|
|
|
|
local i _res
|
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ $_count -le 0 ]]; then
|
2021-04-08 03:44:26 +00:00
|
|
|
echo -n ""
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
i=0
|
|
|
|
_res="$_str"
|
|
|
|
((_count--))
|
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
while [[ $i -lt $_count ]]; do
|
2021-04-08 03:44:26 +00:00
|
|
|
((i++))
|
|
|
|
_res="${_res}${_separator}${_str}"
|
|
|
|
done
|
|
|
|
echo -n "$_res"
|
|
|
|
}
|
|
|
|
|
|
|
|
# $1: prefix
|
|
|
|
# $2: ipv6_flag="-6" indicates it's IPv6
|
|
|
|
# Given a prefix, calculate the netmask (equivalent of "ipcalc -m")
|
|
|
|
# by concatenating three parts,
|
|
|
|
# 1) the groups with all bits set 1
|
|
|
|
# 2) a group with partial bits set to 0
|
|
|
|
# 3) the groups with all bits set to 0
|
|
|
|
cal_netmask_by_prefix() {
|
|
|
|
local _prefix="$1"
|
|
|
|
local _ipv6_flag="$2" _ipv6
|
|
|
|
local _bits_per_octet=8
|
|
|
|
local _count _res _octets_per_group _octets_total _seperator _total_groups
|
|
|
|
local _max_group_value _max_group_value_repr _bits_per_group _tmp _zero_bits
|
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ $_ipv6_flag == "-6" ]]; then
|
2021-04-08 03:44:26 +00:00
|
|
|
_ipv6=1
|
|
|
|
else
|
|
|
|
_ipv6=0
|
|
|
|
fi
|
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ $_prefix -lt 0 || $_prefix -gt 128 ]] \
|
|
|
|
|| ( ((!_ipv6)) && [[ $_prefix -gt 32 ]]); then
|
2021-04-08 03:44:26 +00:00
|
|
|
derror "Bad prefix:$_prefix for calculating netmask"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ((_ipv6)); then
|
|
|
|
_octets_per_group=2
|
|
|
|
_octets_total=16
|
|
|
|
_seperator=":"
|
|
|
|
else
|
|
|
|
_octets_per_group=1
|
|
|
|
_octets_total=4
|
|
|
|
_seperator="."
|
|
|
|
fi
|
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
_total_groups=$((_octets_total / _octets_per_group))
|
2021-04-08 03:44:26 +00:00
|
|
|
_bits_per_group=$((_octets_per_group * _bits_per_octet))
|
|
|
|
_max_group_value=$(((1 << _bits_per_group) - 1))
|
|
|
|
|
|
|
|
if ((_ipv6)); then
|
|
|
|
_max_group_value_repr=$(printf "%x" $_max_group_value)
|
|
|
|
else
|
|
|
|
_max_group_value_repr="$_max_group_value"
|
|
|
|
fi
|
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
_count=$((_prefix / _octets_per_group / _bits_per_octet))
|
2021-04-08 03:44:26 +00:00
|
|
|
_first_part=$(repeatedly_join_str "$_count" "$_max_group_value_repr" "$_seperator")
|
|
|
|
_res="$_first_part"
|
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
_tmp=$((_octets_total * _bits_per_octet - _prefix))
|
2021-08-04 07:18:59 +00:00
|
|
|
_zero_bits=$((_tmp % _bits_per_group))
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ $_zero_bits -ne 0 ]]; then
|
2021-04-08 03:44:26 +00:00
|
|
|
_second_part=$((_max_group_value >> _zero_bits << _zero_bits))
|
|
|
|
if ((_ipv6)); then
|
|
|
|
_second_part=$(printf "%x" $_second_part)
|
|
|
|
fi
|
|
|
|
((_count++))
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ -z $_first_part ]]; then
|
2021-04-08 03:44:26 +00:00
|
|
|
_res="$_second_part"
|
|
|
|
else
|
|
|
|
_res="${_first_part}${_seperator}${_second_part}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
_count=$((_total_groups - _count))
|
|
|
|
if [[ $_count -eq 0 ]]; then
|
2021-04-08 03:44:26 +00:00
|
|
|
echo -n "$_res"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
if ((_ipv6)) && [[ $_count -gt 1 ]]; then
|
2021-04-08 03:44:26 +00:00
|
|
|
# use condensed notion for IPv6
|
|
|
|
_third_part=":"
|
|
|
|
else
|
|
|
|
_third_part=$(repeatedly_join_str "$_count" "0" "$_seperator")
|
|
|
|
fi
|
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ -z $_res ]] && ((!_ipv6)); then
|
2021-04-08 03:44:26 +00:00
|
|
|
echo -n "${_third_part}"
|
|
|
|
else
|
|
|
|
echo -n "${_res}${_seperator}${_third_part}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-05-25 06:16:20 +00:00
|
|
|
#$1: netdev name
|
2014-05-27 14:45:40 +00:00
|
|
|
#$2: srcaddr
|
2012-05-25 06:16:20 +00:00
|
|
|
#if it use static ip echo it, or echo null
|
|
|
|
kdump_static_ip() {
|
rd.route should use the name from kdump_setup_ifname
This fixes bz1854037 which happens because kexec-tools generates rd.route for
eth0 instead of for kdump-eth0,
1. "rd.route=168.63.129.16:10.0.0.1:eth0 rd.route=169.254.169.254:10.0.0.1:eth0" is passed to the dracut cmdline by kexec-tools
2. In the 2rd kernel, dracut/modules.d/35network-manager/nm-config.sh calls
/usr/libexec/nm-initrd-generator to generate two .nmconnection files
based on the dracut cmdline, i.e. kdump-eth0.nmconnection and eth0.nmconnection,
- /run/NetworkManager/system-connections/kdump-eth0.nmconnection
[connection]
id=kdump-eth0
uuid=3ef53b1b-3908-437e-a15f-cf1f3ea2678b
type=ethernet
autoconnect-retries=1
interface-name=kdump-eth0
multi-connect=1
permissions=
wait-device-timeout=60000
[ethernet]
mac-address-blacklist=
[ipv4]
address1=10.0.0.4/24,10.0.0.1
dhcp-timeout=90
dns=168.63.129.16;
dns-search=
may-fail=false
method=manual
[ipv6]
addr-gen-mode=eui64
dhcp-timeout=90
dns-search=
method=disabled
[proxy]
- /run/NetworkManager/system-connections/eth0.nmconnection
[connection]
id=eth0
uuid=f224dc22-2891-4d7b-8f66-745029df4b53
type=ethernet
autoconnect-retries=1
interface-name=eth0
multi-connect=1
permissions=
[ethernet]
mac-address-blacklist=
[ipv4]
dhcp-timeout=90
dns=168.63.129.16;
dns-search=
method=auto
route1=168.63.129.16/32,10.0.0.1
route2=169.254.169.254/32,10.0.0.1
[ipv6]
addr-gen-mode=eui64
dhcp-timeout=90
dns-search=
method=auto
[proxy]
3. Since there's eth0.nmconnection, NetworkManager will try to get an IP for eth0 regardless of the fact it's a slave NIC and time out
```
$ ip link show
2: kdump-eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether 00:0d:3a:11:86:8b brd ff:ff:ff:ff:ff:ff
3: eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master kdump-eth0 state UP mode DEFAULT group default qlen 1000
```
Reported-by: Huijing Hei <hhei@redhat.com>
Signed-off-by: Coiby Xu <coxu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2021-05-06 01:20:27 +00:00
|
|
|
local _netdev="$1" _srcaddr="$2" kdumpnic="$3" _ipv6_flag
|
2021-04-08 03:44:26 +00:00
|
|
|
local _netmask _gateway _ipaddr _target _nexthop _prefix
|
2015-07-23 10:29:24 +00:00
|
|
|
|
2021-09-08 09:21:41 +00:00
|
|
|
_ipaddr=$(ip addr show dev "$_netdev" permanent | awk "/ $_srcaddr\/.* /{print \$2}")
|
2015-07-23 10:29:24 +00:00
|
|
|
|
2021-09-08 09:21:41 +00:00
|
|
|
if is_ipv6_address "$_srcaddr"; then
|
2015-07-23 10:29:24 +00:00
|
|
|
_ipv6_flag="-6"
|
|
|
|
fi
|
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ -n $_ipaddr ]]; then
|
|
|
|
_gateway=$(ip $_ipv6_flag route list dev "$_netdev" \
|
|
|
|
| awk '/^default /{print $3}' | head -n 1)
|
2015-07-23 10:29:24 +00:00
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ "x" != "x"$_ipv6_flag ]]; then
|
2015-07-23 10:29:24 +00:00
|
|
|
# _ipaddr="2002::56ff:feb6:56d5/64", _netmask is the number after "/"
|
|
|
|
_netmask=${_ipaddr#*\/}
|
|
|
|
_srcaddr="[$_srcaddr]"
|
|
|
|
_gateway="[$_gateway]"
|
|
|
|
else
|
2021-04-08 03:44:26 +00:00
|
|
|
_prefix=$(cut -d'/' -f2 <<< "$_ipaddr")
|
2021-09-08 09:23:16 +00:00
|
|
|
if ! _netmask=$(cal_netmask_by_prefix "$_prefix" "$_ipv6_flag"); then
|
2021-04-08 03:44:26 +00:00
|
|
|
derror "Failed to calculate netmask for $_ipaddr"
|
|
|
|
exit 1
|
|
|
|
fi
|
2015-07-23 10:29:24 +00:00
|
|
|
fi
|
|
|
|
echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
|
2012-05-25 06:16:20 +00:00
|
|
|
fi
|
2015-07-13 09:17:32 +00:00
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
/sbin/ip $_ipv6_flag route show | grep -v default \
|
|
|
|
| grep ".*via.* $_netdev " | grep -v "^[[:space:]]*nexthop" \
|
|
|
|
| while read -r _route; do
|
|
|
|
_target=$(echo "$_route" | awk '{print $1}')
|
|
|
|
_nexthop=$(echo "$_route" | awk '{print $3}')
|
|
|
|
if [[ "x" != "x"$_ipv6_flag ]]; then
|
|
|
|
_target="[$_target]"
|
|
|
|
_nexthop="[$_nexthop]"
|
|
|
|
fi
|
|
|
|
echo "rd.route=$_target:$_nexthop:$kdumpnic"
|
|
|
|
done >> "${initdir}/etc/cmdline.d/45route-static.conf"
|
2018-11-12 12:27:18 +00:00
|
|
|
|
2021-09-08 09:21:41 +00:00
|
|
|
kdump_handle_mulitpath_route "$_netdev" "$_srcaddr" "$kdumpnic"
|
2018-11-12 12:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
kdump_handle_mulitpath_route() {
|
rd.route should use the name from kdump_setup_ifname
This fixes bz1854037 which happens because kexec-tools generates rd.route for
eth0 instead of for kdump-eth0,
1. "rd.route=168.63.129.16:10.0.0.1:eth0 rd.route=169.254.169.254:10.0.0.1:eth0" is passed to the dracut cmdline by kexec-tools
2. In the 2rd kernel, dracut/modules.d/35network-manager/nm-config.sh calls
/usr/libexec/nm-initrd-generator to generate two .nmconnection files
based on the dracut cmdline, i.e. kdump-eth0.nmconnection and eth0.nmconnection,
- /run/NetworkManager/system-connections/kdump-eth0.nmconnection
[connection]
id=kdump-eth0
uuid=3ef53b1b-3908-437e-a15f-cf1f3ea2678b
type=ethernet
autoconnect-retries=1
interface-name=kdump-eth0
multi-connect=1
permissions=
wait-device-timeout=60000
[ethernet]
mac-address-blacklist=
[ipv4]
address1=10.0.0.4/24,10.0.0.1
dhcp-timeout=90
dns=168.63.129.16;
dns-search=
may-fail=false
method=manual
[ipv6]
addr-gen-mode=eui64
dhcp-timeout=90
dns-search=
method=disabled
[proxy]
- /run/NetworkManager/system-connections/eth0.nmconnection
[connection]
id=eth0
uuid=f224dc22-2891-4d7b-8f66-745029df4b53
type=ethernet
autoconnect-retries=1
interface-name=eth0
multi-connect=1
permissions=
[ethernet]
mac-address-blacklist=
[ipv4]
dhcp-timeout=90
dns=168.63.129.16;
dns-search=
method=auto
route1=168.63.129.16/32,10.0.0.1
route2=169.254.169.254/32,10.0.0.1
[ipv6]
addr-gen-mode=eui64
dhcp-timeout=90
dns-search=
method=auto
[proxy]
3. Since there's eth0.nmconnection, NetworkManager will try to get an IP for eth0 regardless of the fact it's a slave NIC and time out
```
$ ip link show
2: kdump-eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether 00:0d:3a:11:86:8b brd ff:ff:ff:ff:ff:ff
3: eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master kdump-eth0 state UP mode DEFAULT group default qlen 1000
```
Reported-by: Huijing Hei <hhei@redhat.com>
Signed-off-by: Coiby Xu <coxu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2021-05-06 01:20:27 +00:00
|
|
|
local _netdev="$1" _srcaddr="$2" kdumpnic="$3" _ipv6_flag
|
2018-11-12 12:27:18 +00:00
|
|
|
local _target _nexthop _route _weight _max_weight _rule
|
|
|
|
|
2021-09-08 09:21:41 +00:00
|
|
|
if is_ipv6_address "$_srcaddr"; then
|
2018-11-12 12:27:18 +00:00
|
|
|
_ipv6_flag="-6"
|
|
|
|
fi
|
|
|
|
|
2021-08-04 07:50:30 +00:00
|
|
|
while IFS="" read -r _route; do
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ $_route =~ [[:space:]]+nexthop ]]; then
|
2021-08-04 07:46:27 +00:00
|
|
|
_route=${_route##[[:space:]]}
|
2018-11-12 12:27:18 +00:00
|
|
|
# Parse multipath route, using previous _target
|
2021-09-13 18:25:40 +00:00
|
|
|
[[ $_target == 'default' ]] && continue
|
|
|
|
[[ $_route =~ .*via.*\ $_netdev ]] || continue
|
2018-11-12 12:27:18 +00:00
|
|
|
|
2021-09-07 17:48:52 +00:00
|
|
|
_weight=$(echo "$_route" | cut -d ' ' -f7)
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ $_weight -gt $_max_weight ]]; then
|
2021-09-07 17:48:52 +00:00
|
|
|
_nexthop=$(echo "$_route" | cut -d ' ' -f3)
|
2018-11-12 12:27:18 +00:00
|
|
|
_max_weight=$_weight
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ "x" != "x"$_ipv6_flag ]]; then
|
rd.route should use the name from kdump_setup_ifname
This fixes bz1854037 which happens because kexec-tools generates rd.route for
eth0 instead of for kdump-eth0,
1. "rd.route=168.63.129.16:10.0.0.1:eth0 rd.route=169.254.169.254:10.0.0.1:eth0" is passed to the dracut cmdline by kexec-tools
2. In the 2rd kernel, dracut/modules.d/35network-manager/nm-config.sh calls
/usr/libexec/nm-initrd-generator to generate two .nmconnection files
based on the dracut cmdline, i.e. kdump-eth0.nmconnection and eth0.nmconnection,
- /run/NetworkManager/system-connections/kdump-eth0.nmconnection
[connection]
id=kdump-eth0
uuid=3ef53b1b-3908-437e-a15f-cf1f3ea2678b
type=ethernet
autoconnect-retries=1
interface-name=kdump-eth0
multi-connect=1
permissions=
wait-device-timeout=60000
[ethernet]
mac-address-blacklist=
[ipv4]
address1=10.0.0.4/24,10.0.0.1
dhcp-timeout=90
dns=168.63.129.16;
dns-search=
may-fail=false
method=manual
[ipv6]
addr-gen-mode=eui64
dhcp-timeout=90
dns-search=
method=disabled
[proxy]
- /run/NetworkManager/system-connections/eth0.nmconnection
[connection]
id=eth0
uuid=f224dc22-2891-4d7b-8f66-745029df4b53
type=ethernet
autoconnect-retries=1
interface-name=eth0
multi-connect=1
permissions=
[ethernet]
mac-address-blacklist=
[ipv4]
dhcp-timeout=90
dns=168.63.129.16;
dns-search=
method=auto
route1=168.63.129.16/32,10.0.0.1
route2=169.254.169.254/32,10.0.0.1
[ipv6]
addr-gen-mode=eui64
dhcp-timeout=90
dns-search=
method=auto
[proxy]
3. Since there's eth0.nmconnection, NetworkManager will try to get an IP for eth0 regardless of the fact it's a slave NIC and time out
```
$ ip link show
2: kdump-eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether 00:0d:3a:11:86:8b brd ff:ff:ff:ff:ff:ff
3: eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master kdump-eth0 state UP mode DEFAULT group default qlen 1000
```
Reported-by: Huijing Hei <hhei@redhat.com>
Signed-off-by: Coiby Xu <coxu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2021-05-06 01:20:27 +00:00
|
|
|
_rule="rd.route=[$_target]:[$_nexthop]:$kdumpnic"
|
2018-11-12 12:27:18 +00:00
|
|
|
else
|
rd.route should use the name from kdump_setup_ifname
This fixes bz1854037 which happens because kexec-tools generates rd.route for
eth0 instead of for kdump-eth0,
1. "rd.route=168.63.129.16:10.0.0.1:eth0 rd.route=169.254.169.254:10.0.0.1:eth0" is passed to the dracut cmdline by kexec-tools
2. In the 2rd kernel, dracut/modules.d/35network-manager/nm-config.sh calls
/usr/libexec/nm-initrd-generator to generate two .nmconnection files
based on the dracut cmdline, i.e. kdump-eth0.nmconnection and eth0.nmconnection,
- /run/NetworkManager/system-connections/kdump-eth0.nmconnection
[connection]
id=kdump-eth0
uuid=3ef53b1b-3908-437e-a15f-cf1f3ea2678b
type=ethernet
autoconnect-retries=1
interface-name=kdump-eth0
multi-connect=1
permissions=
wait-device-timeout=60000
[ethernet]
mac-address-blacklist=
[ipv4]
address1=10.0.0.4/24,10.0.0.1
dhcp-timeout=90
dns=168.63.129.16;
dns-search=
may-fail=false
method=manual
[ipv6]
addr-gen-mode=eui64
dhcp-timeout=90
dns-search=
method=disabled
[proxy]
- /run/NetworkManager/system-connections/eth0.nmconnection
[connection]
id=eth0
uuid=f224dc22-2891-4d7b-8f66-745029df4b53
type=ethernet
autoconnect-retries=1
interface-name=eth0
multi-connect=1
permissions=
[ethernet]
mac-address-blacklist=
[ipv4]
dhcp-timeout=90
dns=168.63.129.16;
dns-search=
method=auto
route1=168.63.129.16/32,10.0.0.1
route2=169.254.169.254/32,10.0.0.1
[ipv6]
addr-gen-mode=eui64
dhcp-timeout=90
dns-search=
method=auto
[proxy]
3. Since there's eth0.nmconnection, NetworkManager will try to get an IP for eth0 regardless of the fact it's a slave NIC and time out
```
$ ip link show
2: kdump-eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether 00:0d:3a:11:86:8b brd ff:ff:ff:ff:ff:ff
3: eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master kdump-eth0 state UP mode DEFAULT group default qlen 1000
```
Reported-by: Huijing Hei <hhei@redhat.com>
Signed-off-by: Coiby Xu <coxu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2021-05-06 01:20:27 +00:00
|
|
|
_rule="rd.route=$_target:$_nexthop:$kdumpnic"
|
2018-11-12 12:27:18 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
else
|
2021-09-13 18:25:40 +00:00
|
|
|
[[ -n $_rule ]] && echo "$_rule"
|
2021-09-07 17:48:52 +00:00
|
|
|
_target=$(echo "$_route" | cut -d ' ' -f1)
|
2018-11-12 12:27:18 +00:00
|
|
|
_rule="" _max_weight=0 _weight=0
|
|
|
|
fi
|
2021-09-13 18:25:40 +00:00
|
|
|
done >> "${initdir}/etc/cmdline.d/45route-static.conf" \
|
2020-03-11 18:35:11 +00:00
|
|
|
<<< "$(/sbin/ip $_ipv6_flag route show)"
|
2018-11-12 12:27:18 +00:00
|
|
|
|
2021-09-08 09:21:41 +00:00
|
|
|
[[ -n $_rule ]] && echo "$_rule" >> "${initdir}/etc/cmdline.d/45route-static.conf"
|
2012-05-25 06:16:20 +00:00
|
|
|
}
|
|
|
|
|
2012-06-10 10:24:34 +00:00
|
|
|
kdump_get_mac_addr() {
|
2021-09-08 09:21:41 +00:00
|
|
|
cat "/sys/class/net/$1/address"
|
2012-06-10 10:24:34 +00:00
|
|
|
}
|
|
|
|
|
2012-12-13 14:36:05 +00:00
|
|
|
#Bonding or team master modifies the mac address
|
|
|
|
#of its slaves, we should use perm address
|
|
|
|
kdump_get_perm_addr() {
|
2021-08-17 18:04:45 +00:00
|
|
|
local addr
|
|
|
|
addr=$(ethtool -P "$1" | sed -e 's/Permanent address: //')
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ -z $addr ]] || [[ $addr == "00:00:00:00:00:00" ]]; then
|
2012-12-13 14:36:05 +00:00
|
|
|
derror "Can't get the permanent address of $1"
|
|
|
|
else
|
|
|
|
echo "$addr"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-06-23 08:00:58 +00:00
|
|
|
# Prefix kernel assigned names with "kdump-". EX: eth0 -> kdump-eth0
|
|
|
|
# Because kernel assigned names are not persistent between 1st and 2nd
|
|
|
|
# kernel. We could probably end up with eth0 being eth1, eth0 being
|
|
|
|
# eth1, and naming conflict happens.
|
|
|
|
kdump_setup_ifname() {
|
|
|
|
local _ifname
|
|
|
|
|
kdump/fadump: fix network interface name when switching from fadump to kdump
When a remote dump target is specified, kdump dracut module prefixes
'kdump-' to network interface name (ifname) as kernel assigned names
are not persistent. In fadump mode, kdump dracut module is added to
the default initrd, which adds the 'kdump-' prefix to the ifname of
the prodcution kernel itself. If fadump mode is disabled after this,
kdump dracut module picks the ifname that is already prefixed with
'kdump-' in the production kernel and adds another 'kdump-' to it,
making the ifname something like kdump-kdump-eth0 for kdump kernel.
Eventually, kdump kernel fails with below traces:
dracut-initqueue[246]: RTNETLINK answers: Network is unreachable
dracut-initqueue[246]: arping: Device kdump-kdump-eth0 not available.
The ip command shows the below:
kdump:/# ip addr show kdump-kdump-eth0
2: kdump-kdump-eth: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 \
qdisc pfifo_fast state UNKNOWN qlen 1000
link/ether 22:82:87:7b:98:02 brd ff:ff:ff:ff:ff:ff
inet6 2002:903:15f:550:2082:87ff:fe7b:9802/64 scope global \
mngtmpaddr dynamic
valid_lft 2591890sec preferred_lft 604690sec
inet6 fe80::2082:87ff:fe7b:9802/64 scope link
valid_lft forever preferred_lft forever
kdump:/#
The trailing 0 from kdump-kdump-eth0 is missing in the ifname, probably
truncated owing to ifname length limit, while setting.
This patch fixes this by avoiding addition of the prefix 'kdump-' when
such prefix is already present in the ifname.
Signed-off-by: Hari Bathini <hbathini@linux.vnet.ibm.com>
Acked-by: Dave Young <dyoung@redhat.com>
2016-11-03 18:46:14 +00:00
|
|
|
# If ifname already has 'kdump-' prefix, we must be switching from
|
|
|
|
# fadump to kdump. Skip prefixing 'kdump-' in this case as adding
|
|
|
|
# another prefix may truncate the ifname. Since an ifname with
|
|
|
|
# 'kdump-' is already persistent, this should be fine.
|
|
|
|
if [[ $1 =~ eth* ]] && [[ ! $1 =~ ^kdump-* ]]; then
|
2015-06-23 08:00:58 +00:00
|
|
|
_ifname="kdump-$1"
|
|
|
|
else
|
|
|
|
_ifname="$1"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "$_ifname"
|
|
|
|
}
|
|
|
|
|
2012-06-10 10:24:34 +00:00
|
|
|
kdump_setup_bridge() {
|
2021-04-28 07:00:15 +00:00
|
|
|
local _netdev=$1
|
|
|
|
local _brif _dev _mac _kdumpdev
|
2021-08-04 08:16:44 +00:00
|
|
|
for _dev in "/sys/class/net/$_netdev/brif/"*; do
|
|
|
|
[[ -e $_dev ]] || continue
|
|
|
|
_dev=${_dev##*/}
|
dracut-module-setup: NIC renamed with prefix "kdump-" for native ethX
We met a problem that eth0 ends up being eth1 and eth1 being eth0
between 1st and 2nd kernel. Because we pass ifname=eth0:$mac to force
it's named eth0 and since "eth0"is already taken by the other NIC, udev
fails to bring up the NIC we want, thus kdump fails.
kernel assigned network interface names are not persistent. So if first
kernel is using kernel assigned interface names, then force it to use
"kdump-" prefixed names in second kernel.
For ethX, we put a prefix "kdump-" before it, so in 2nd kernel, ethX
will name to "kdump-ethX". So that we can avoid the naming conflict.
We only need to change the ethernet card name, that means, for bridge,
vlan, bond, team devices' names , we never prefix them. Because these
names are assigned when they're created by userspace.
Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-07-21 07:10:05 +00:00
|
|
|
_kdumpdev=$_dev
|
2013-04-08 10:02:21 +00:00
|
|
|
if kdump_is_bond "$_dev"; then
|
2021-09-08 09:23:16 +00:00
|
|
|
(kdump_setup_bond "$_dev" "$(get_nmcli_connection_show_cmd_by_ifname "$_dev")") || exit 1
|
2013-04-08 10:02:21 +00:00
|
|
|
elif kdump_is_team "$_dev"; then
|
|
|
|
kdump_setup_team "$_dev"
|
|
|
|
elif kdump_is_vlan "$_dev"; then
|
|
|
|
kdump_setup_vlan "$_dev"
|
|
|
|
else
|
2021-09-08 09:21:41 +00:00
|
|
|
_mac=$(kdump_get_mac_addr "$_dev")
|
|
|
|
_kdumpdev=$(kdump_setup_ifname "$_dev")
|
|
|
|
echo -n " ifname=$_kdumpdev:$_mac" >> "${initdir}/etc/cmdline.d/41bridge.conf"
|
2013-04-08 10:02:21 +00:00
|
|
|
fi
|
dracut-module-setup: NIC renamed with prefix "kdump-" for native ethX
We met a problem that eth0 ends up being eth1 and eth1 being eth0
between 1st and 2nd kernel. Because we pass ifname=eth0:$mac to force
it's named eth0 and since "eth0"is already taken by the other NIC, udev
fails to bring up the NIC we want, thus kdump fails.
kernel assigned network interface names are not persistent. So if first
kernel is using kernel assigned interface names, then force it to use
"kdump-" prefixed names in second kernel.
For ethX, we put a prefix "kdump-" before it, so in 2nd kernel, ethX
will name to "kdump-ethX". So that we can avoid the naming conflict.
We only need to change the ethernet card name, that means, for bridge,
vlan, bond, team devices' names , we never prefix them. Because these
names are assigned when they're created by userspace.
Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-07-21 07:10:05 +00:00
|
|
|
_brif+="$_kdumpdev,"
|
2012-06-10 10:24:34 +00:00
|
|
|
done
|
2021-08-04 07:46:27 +00:00
|
|
|
echo " bridge=$_netdev:${_brif%,}" >> "${initdir}/etc/cmdline.d/41bridge.conf"
|
2012-06-10 10:24:34 +00:00
|
|
|
}
|
|
|
|
|
2021-04-01 07:32:13 +00:00
|
|
|
# drauct takes bond=<bondname>[:<bondslaves>:[:<options>]] syntax to parse
|
|
|
|
# bond. For example:
|
|
|
|
# bond=bond0:eth0,eth1:mode=balance-rr
|
2012-06-10 10:24:35 +00:00
|
|
|
kdump_setup_bond() {
|
2021-04-01 07:32:13 +00:00
|
|
|
local _netdev="$1"
|
|
|
|
local _nm_show_cmd="$2"
|
|
|
|
local _dev _mac _slaves _kdumpdev _bondoptions
|
2021-09-08 09:21:41 +00:00
|
|
|
for _dev in $(cat "/sys/class/net/$_netdev/bonding/slaves"); do
|
|
|
|
_mac=$(kdump_get_perm_addr "$_dev")
|
|
|
|
_kdumpdev=$(kdump_setup_ifname "$_dev")
|
|
|
|
echo -n " ifname=$_kdumpdev:$_mac" >> "${initdir}/etc/cmdline.d/42bond.conf"
|
dracut-module-setup: NIC renamed with prefix "kdump-" for native ethX
We met a problem that eth0 ends up being eth1 and eth1 being eth0
between 1st and 2nd kernel. Because we pass ifname=eth0:$mac to force
it's named eth0 and since "eth0"is already taken by the other NIC, udev
fails to bring up the NIC we want, thus kdump fails.
kernel assigned network interface names are not persistent. So if first
kernel is using kernel assigned interface names, then force it to use
"kdump-" prefixed names in second kernel.
For ethX, we put a prefix "kdump-" before it, so in 2nd kernel, ethX
will name to "kdump-ethX". So that we can avoid the naming conflict.
We only need to change the ethernet card name, that means, for bridge,
vlan, bond, team devices' names , we never prefix them. Because these
names are assigned when they're created by userspace.
Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-07-21 07:10:05 +00:00
|
|
|
_slaves+="$_kdumpdev,"
|
2012-06-10 10:24:35 +00:00
|
|
|
done
|
2021-08-04 07:46:27 +00:00
|
|
|
echo -n " bond=$_netdev:${_slaves%,}" >> "${initdir}/etc/cmdline.d/42bond.conf"
|
2016-06-06 05:01:59 +00:00
|
|
|
|
2021-04-01 07:32:13 +00:00
|
|
|
_bondoptions=$(get_nmcli_value_by_field "$_nm_show_cmd" "bond.options")
|
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ -z $_bondoptions ]]; then
|
2021-04-01 07:32:13 +00:00
|
|
|
dwarning "Failed to get bond configuration via nmlci output. Now try sourcing ifcfg script."
|
2021-09-08 09:21:41 +00:00
|
|
|
source_ifcfg_file "$_netdev"
|
|
|
|
_bondoptions="$(echo "$BONDING_OPTS" | xargs echo | tr " " ",")"
|
2021-04-01 07:32:13 +00:00
|
|
|
fi
|
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ -z $_bondoptions ]]; then
|
2021-04-01 07:32:13 +00:00
|
|
|
derror "Get empty bond options"
|
|
|
|
exit 1
|
|
|
|
fi
|
2016-06-06 05:01:59 +00:00
|
|
|
|
2021-09-08 09:21:41 +00:00
|
|
|
echo ":$_bondoptions" >> "${initdir}/etc/cmdline.d/42bond.conf"
|
2012-06-10 10:24:35 +00:00
|
|
|
}
|
|
|
|
|
2012-12-13 14:36:05 +00:00
|
|
|
kdump_setup_team() {
|
2021-04-28 07:00:15 +00:00
|
|
|
local _netdev=$1
|
|
|
|
local _dev _mac _slaves _kdumpdev
|
2021-09-08 09:21:41 +00:00
|
|
|
for _dev in $(teamnl "$_netdev" ports | awk -F':' '{print $2}'); do
|
|
|
|
_mac=$(kdump_get_perm_addr "$_dev")
|
|
|
|
_kdumpdev=$(kdump_setup_ifname "$_dev")
|
|
|
|
echo -n " ifname=$_kdumpdev:$_mac" >> "${initdir}/etc/cmdline.d/44team.conf"
|
dracut-module-setup: NIC renamed with prefix "kdump-" for native ethX
We met a problem that eth0 ends up being eth1 and eth1 being eth0
between 1st and 2nd kernel. Because we pass ifname=eth0:$mac to force
it's named eth0 and since "eth0"is already taken by the other NIC, udev
fails to bring up the NIC we want, thus kdump fails.
kernel assigned network interface names are not persistent. So if first
kernel is using kernel assigned interface names, then force it to use
"kdump-" prefixed names in second kernel.
For ethX, we put a prefix "kdump-" before it, so in 2nd kernel, ethX
will name to "kdump-ethX". So that we can avoid the naming conflict.
We only need to change the ethernet card name, that means, for bridge,
vlan, bond, team devices' names , we never prefix them. Because these
names are assigned when they're created by userspace.
Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-07-21 07:10:05 +00:00
|
|
|
_slaves+="$_kdumpdev,"
|
2012-12-13 14:36:05 +00:00
|
|
|
done
|
2021-08-04 07:46:27 +00:00
|
|
|
echo " team=$_netdev:${_slaves%,}" >> "${initdir}/etc/cmdline.d/44team.conf"
|
2012-12-13 14:36:05 +00:00
|
|
|
#Buggy version teamdctl outputs to stderr!
|
|
|
|
#Try to use the latest version of teamd.
|
2021-09-08 09:23:16 +00:00
|
|
|
if ! teamdctl "$_netdev" config dump > "${initdir}/tmp/$$-$_netdev.conf"; then
|
2012-12-13 14:36:05 +00:00
|
|
|
derror "teamdctl failed."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
inst_dir /etc/teamd
|
2021-09-08 09:21:41 +00:00
|
|
|
inst_simple "${initdir}/tmp/$$-$_netdev.conf" "/etc/teamd/$_netdev.conf"
|
|
|
|
rm -f "${initdir}/tmp/$$-$_netdev.conf"
|
2012-12-13 14:36:05 +00:00
|
|
|
}
|
|
|
|
|
2012-06-10 10:24:36 +00:00
|
|
|
kdump_setup_vlan() {
|
2021-04-28 07:00:15 +00:00
|
|
|
local _netdev=$1
|
2021-08-17 18:04:45 +00:00
|
|
|
local _phydev
|
|
|
|
local _netmac
|
dracut-module-setup: NIC renamed with prefix "kdump-" for native ethX
We met a problem that eth0 ends up being eth1 and eth1 being eth0
between 1st and 2nd kernel. Because we pass ifname=eth0:$mac to force
it's named eth0 and since "eth0"is already taken by the other NIC, udev
fails to bring up the NIC we want, thus kdump fails.
kernel assigned network interface names are not persistent. So if first
kernel is using kernel assigned interface names, then force it to use
"kdump-" prefixed names in second kernel.
For ethX, we put a prefix "kdump-" before it, so in 2nd kernel, ethX
will name to "kdump-ethX". So that we can avoid the naming conflict.
We only need to change the ethernet card name, that means, for bridge,
vlan, bond, team devices' names , we never prefix them. Because these
names are assigned when they're created by userspace.
Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-07-21 07:10:05 +00:00
|
|
|
local _kdumpdev
|
2012-06-26 10:45:04 +00:00
|
|
|
|
2021-08-17 18:04:45 +00:00
|
|
|
_phydev="$(awk '/^Device:/{print $2}' /proc/net/vlan/"$_netdev")"
|
|
|
|
_netmac="$(kdump_get_mac_addr "$_phydev")"
|
|
|
|
|
2020-11-16 10:55:24 +00:00
|
|
|
#Just support vlan over bond and team
|
2012-06-26 10:45:04 +00:00
|
|
|
if kdump_is_bridge "$_phydev"; then
|
|
|
|
derror "Vlan over bridge is not supported!"
|
|
|
|
exit 1
|
|
|
|
elif kdump_is_bond "$_phydev"; then
|
2021-09-08 09:23:16 +00:00
|
|
|
(kdump_setup_bond "$_phydev" "$(get_nmcli_connection_show_cmd_by_ifname "$_phydev")") || exit 1
|
2021-09-08 09:21:41 +00:00
|
|
|
echo " vlan=$(kdump_setup_ifname "$_netdev"):$_phydev" > "${initdir}/etc/cmdline.d/43vlan.conf"
|
2012-06-26 10:45:04 +00:00
|
|
|
else
|
2021-09-08 09:21:41 +00:00
|
|
|
_kdumpdev="$(kdump_setup_ifname "$_phydev")"
|
|
|
|
echo " vlan=$(kdump_setup_ifname "$_netdev"):$_kdumpdev ifname=$_kdumpdev:$_netmac" > "${initdir}/etc/cmdline.d/43vlan.conf"
|
2012-06-26 10:45:04 +00:00
|
|
|
fi
|
2012-06-10 10:24:36 +00:00
|
|
|
}
|
|
|
|
|
2021-06-06 23:26:03 +00:00
|
|
|
# find online znet device
|
|
|
|
# return ifname (_netdev)
|
|
|
|
# code reaped from the list_configured function of
|
|
|
|
# https://github.com/hreinecke/s390-tools/blob/master/zconf/znetconf
|
|
|
|
find_online_znet_device() {
|
2021-09-13 18:25:40 +00:00
|
|
|
local CCWGROUPBUS_DEVICEDIR="/sys/bus/ccwgroup/devices"
|
|
|
|
local NETWORK_DEVICES d ifname ONLINE
|
|
|
|
|
|
|
|
[[ ! -d $CCWGROUPBUS_DEVICEDIR ]] && return
|
|
|
|
NETWORK_DEVICES=$(find $CCWGROUPBUS_DEVICEDIR)
|
|
|
|
for d in $NETWORK_DEVICES; do
|
|
|
|
[[ ! -f "$d/online" ]] && continue
|
|
|
|
read -r ONLINE < "$d/online"
|
|
|
|
if [[ $ONLINE -ne 1 ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
# determine interface name, if there (only for qeth and if
|
|
|
|
# device is online)
|
|
|
|
if [[ -f $d/if_name ]]; then
|
|
|
|
read -r ifname < "$d/if_name"
|
|
|
|
elif [[ -d $d/net ]]; then
|
|
|
|
ifname=$(ls "$d/net/")
|
|
|
|
fi
|
|
|
|
[[ -n $ifname ]] && break
|
|
|
|
done
|
|
|
|
echo -n "$ifname"
|
2021-06-06 23:26:03 +00:00
|
|
|
}
|
|
|
|
|
2012-06-22 06:50:40 +00:00
|
|
|
# setup s390 znet cmdline
|
2021-04-01 07:32:11 +00:00
|
|
|
# $1: netdev (ifname)
|
|
|
|
# $2: nmcli connection show output
|
2012-06-22 06:50:40 +00:00
|
|
|
kdump_setup_znet() {
|
2021-04-01 07:32:11 +00:00
|
|
|
local _netdev="$1"
|
|
|
|
local _nmcli_cmd="$2"
|
|
|
|
local s390_prefix="802-3-ethernet.s390-"
|
2012-06-22 06:50:40 +00:00
|
|
|
local _options=""
|
2021-04-01 07:32:11 +00:00
|
|
|
local NETTYPE
|
|
|
|
local SUBCHANNELS
|
|
|
|
|
|
|
|
NETTYPE=$(get_nmcli_value_by_field "$_nmcli_cmd" "${s390_prefix}nettype")
|
|
|
|
SUBCHANNELS=$(get_nmcli_value_by_field "$_nmcli_cmd" "${s390_prefix}subchannels")
|
|
|
|
_options=$(get_nmcli_value_by_field "$_nmcli_cmd" "${s390_prefix}options")
|
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ -z $NETTYPE || -z $SUBCHANNELS || -z $_options ]]; then
|
2021-04-01 07:32:11 +00:00
|
|
|
dwarning "Failed to get znet configuration via nmlci output. Now try sourcing ifcfg script."
|
2021-09-08 09:21:41 +00:00
|
|
|
source_ifcfg_file "$_netdev"
|
2021-04-01 07:32:11 +00:00
|
|
|
for i in $OPTIONS; do
|
|
|
|
_options=${_options},$i
|
|
|
|
done
|
|
|
|
fi
|
2016-06-06 05:01:59 +00:00
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ -z $NETTYPE || -z $SUBCHANNELS || -z $_options ]]; then
|
2021-04-01 07:32:11 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2016-06-06 05:01:59 +00:00
|
|
|
|
2021-09-08 09:21:41 +00:00
|
|
|
echo "rd.znet=${NETTYPE},${SUBCHANNELS},${_options} rd.znet_ifname=$_netdev:${SUBCHANNELS}" > "${initdir}/etc/cmdline.d/30znet.conf"
|
2012-06-22 06:50:40 +00:00
|
|
|
}
|
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
kdump_get_ip_route() {
|
2021-09-08 09:23:16 +00:00
|
|
|
local _route
|
|
|
|
if ! _route=$(/sbin/ip -o route get to "$1" 2>&1); then
|
2021-03-26 02:22:09 +00:00
|
|
|
derror "Bad kdump network destination: $1"
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-09-08 09:21:41 +00:00
|
|
|
echo "$_route"
|
2019-06-30 16:41:07 +00:00
|
|
|
}
|
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
kdump_get_ip_route_field() {
|
2021-08-03 18:59:43 +00:00
|
|
|
echo "$1" | sed -n -e "s/^.*\<$2\>\s\+\(\S\+\).*$/\1/p"
|
2019-06-30 16:41:07 +00:00
|
|
|
}
|
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
kdump_get_remote_ip() {
|
2021-08-17 18:04:45 +00:00
|
|
|
local _remote _remote_temp
|
|
|
|
_remote=$(get_remote_host "$1")
|
2021-09-08 09:21:41 +00:00
|
|
|
if is_hostname "$_remote"; then
|
|
|
|
_remote_temp=$(getent ahosts "$_remote" | grep -v : | head -n 1)
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ -z $_remote_temp ]]; then
|
2021-09-08 09:21:41 +00:00
|
|
|
_remote_temp=$(getent ahosts "$_remote" | head -n 1)
|
2019-06-30 16:41:07 +00:00
|
|
|
fi
|
2021-09-08 09:21:41 +00:00
|
|
|
_remote=$(echo "$_remote_temp" | awk '{print $1}')
|
2019-06-30 16:41:07 +00:00
|
|
|
fi
|
2021-09-08 09:21:41 +00:00
|
|
|
echo "$_remote"
|
2019-06-30 16:41:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Setup dracut to bring up network interface that enable
|
|
|
|
# initramfs accessing giving destination
|
|
|
|
# $1: destination host
|
|
|
|
kdump_install_net() {
|
2021-04-01 07:32:11 +00:00
|
|
|
local _destaddr _srcaddr _route _netdev _nm_show_cmd kdumpnic
|
2013-12-20 10:06:17 +00:00
|
|
|
local _static _proto _ip_conf _ip_opts _ifname_opts
|
2021-06-06 23:26:03 +00:00
|
|
|
local _znet_netdev _nm_show_cmd_znet
|
2019-06-30 16:41:07 +00:00
|
|
|
|
2021-09-08 09:21:41 +00:00
|
|
|
_destaddr=$(kdump_get_remote_ip "$1")
|
|
|
|
_route=$(kdump_get_ip_route "$_destaddr")
|
2019-06-30 16:41:07 +00:00
|
|
|
_srcaddr=$(kdump_get_ip_route_field "$_route" "src")
|
|
|
|
_netdev=$(kdump_get_ip_route_field "$_route" "dev")
|
2021-04-01 07:32:11 +00:00
|
|
|
_nm_show_cmd=$(get_nmcli_connection_show_cmd_by_ifname "$_netdev")
|
2021-09-08 09:21:41 +00:00
|
|
|
_netmac=$(kdump_get_mac_addr "$_netdev")
|
|
|
|
kdumpnic=$(kdump_setup_ifname "$_netdev")
|
2012-05-22 21:34:02 +00:00
|
|
|
|
2021-06-06 23:26:03 +00:00
|
|
|
_znet_netdev=$(find_online_znet_device)
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ -n $_znet_netdev ]]; then
|
2021-06-06 23:26:03 +00:00
|
|
|
_nm_show_cmd_znet=$(get_nmcli_connection_show_cmd_by_ifname "$_znet_netdev")
|
2021-09-08 09:23:16 +00:00
|
|
|
if ! (kdump_setup_znet "$_znet_netdev" "$_nm_show_cmd_znet"); then
|
2021-04-01 07:32:11 +00:00
|
|
|
derror "Failed to set up znet"
|
|
|
|
exit 1
|
|
|
|
fi
|
2012-06-22 06:50:40 +00:00
|
|
|
fi
|
|
|
|
|
2021-09-08 09:21:41 +00:00
|
|
|
_static=$(kdump_static_ip "$_netdev" "$_srcaddr" "$kdumpnic")
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ -n $_static ]]; then
|
2012-05-25 06:16:20 +00:00
|
|
|
_proto=none
|
2021-09-08 09:21:41 +00:00
|
|
|
elif is_ipv6_address "$_srcaddr"; then
|
2020-12-07 04:53:47 +00:00
|
|
|
_proto=auto6
|
2012-05-25 06:16:20 +00:00
|
|
|
else
|
|
|
|
_proto=dhcp
|
|
|
|
fi
|
|
|
|
|
2013-12-20 10:06:17 +00:00
|
|
|
_ip_conf="${initdir}/etc/cmdline.d/40ip.conf"
|
2021-05-06 01:20:26 +00:00
|
|
|
_ip_opts=" ip=${_static}$kdumpnic:${_proto}"
|
2013-12-20 10:06:17 +00:00
|
|
|
|
|
|
|
# dracut doesn't allow duplicated configuration for same NIC, even they're exactly the same.
|
|
|
|
# so we have to avoid adding duplicates
|
2014-09-22 07:46:57 +00:00
|
|
|
# We should also check /proc/cmdline for existing ip=xx arg.
|
|
|
|
# For example, iscsi boot will specify ip=xxx arg in cmdline.
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ ! -f $_ip_conf ]] || ! grep -q "$_ip_opts" "$_ip_conf" \
|
|
|
|
&& ! grep -q "ip=[^[:space:]]*$_netdev" /proc/cmdline; then
|
2021-09-08 09:21:41 +00:00
|
|
|
echo "$_ip_opts" >> "$_ip_conf"
|
2013-12-20 10:06:17 +00:00
|
|
|
fi
|
2012-05-22 21:34:02 +00:00
|
|
|
|
|
|
|
if kdump_is_bridge "$_netdev"; then
|
2021-04-28 07:00:15 +00:00
|
|
|
kdump_setup_bridge "$_netdev"
|
2012-05-22 21:34:02 +00:00
|
|
|
elif kdump_is_bond "$_netdev"; then
|
2021-09-08 09:23:16 +00:00
|
|
|
(kdump_setup_bond "$_netdev" "$_nm_show_cmd") || exit 1
|
2012-12-13 14:36:05 +00:00
|
|
|
elif kdump_is_team "$_netdev"; then
|
2021-04-28 07:00:15 +00:00
|
|
|
kdump_setup_team "$_netdev"
|
2012-06-10 10:24:36 +00:00
|
|
|
elif kdump_is_vlan "$_netdev"; then
|
2021-04-28 07:00:15 +00:00
|
|
|
kdump_setup_vlan "$_netdev"
|
2012-05-22 21:34:02 +00:00
|
|
|
else
|
2021-05-06 01:20:26 +00:00
|
|
|
_ifname_opts=" ifname=$kdumpnic:$_netmac"
|
2021-09-08 09:21:41 +00:00
|
|
|
echo "$_ifname_opts" >> "$_ip_conf"
|
2012-05-22 21:34:02 +00:00
|
|
|
fi
|
2012-07-12 03:15:35 +00:00
|
|
|
|
2021-04-01 07:32:12 +00:00
|
|
|
kdump_setup_dns "$_netdev" "$_nm_show_cmd"
|
2012-05-22 21:34:02 +00:00
|
|
|
|
2021-09-08 09:20:51 +00:00
|
|
|
if [[ ! -f ${initdir}/etc/cmdline.d/50neednet.conf ]]; then
|
2020-05-27 18:20:20 +00:00
|
|
|
# network-manager module needs this parameter
|
2021-09-08 09:21:41 +00:00
|
|
|
echo "rd.neednet" >> "${initdir}/etc/cmdline.d/50neednet.conf"
|
2020-05-27 18:20:20 +00:00
|
|
|
fi
|
|
|
|
|
2019-06-30 16:41:07 +00:00
|
|
|
# Save netdev used for kdump as cmdline
|
2013-12-20 09:41:29 +00:00
|
|
|
# Whoever calling kdump_install_net() is setting up the default gateway,
|
|
|
|
# ie. bootdev/kdumpnic. So don't override the setting if calling
|
|
|
|
# kdump_install_net() for another time. For example, after setting eth0 as
|
|
|
|
# the default gate way for network dump, eth1 in the fence kdump path will
|
|
|
|
# call kdump_install_net again and we don't want eth1 to be the default
|
|
|
|
# gateway.
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ ! -f ${initdir}/etc/cmdline.d/60kdumpnic.conf ]] \
|
|
|
|
&& [[ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]]; then
|
2021-09-08 09:21:41 +00:00
|
|
|
echo "kdumpnic=$kdumpnic" > "${initdir}/etc/cmdline.d/60kdumpnic.conf"
|
|
|
|
echo "bootdev=$kdumpnic" > "${initdir}/etc/cmdline.d/70bootdev.conf"
|
2013-12-20 09:41:29 +00:00
|
|
|
fi
|
2012-05-14 02:36:18 +00:00
|
|
|
}
|
|
|
|
|
2020-06-05 02:22:35 +00:00
|
|
|
# install etc/kdump/pre.d and /etc/kdump/post.d
|
|
|
|
kdump_install_pre_post_conf() {
|
2021-09-08 09:20:51 +00:00
|
|
|
if [[ -d /etc/kdump/pre.d ]]; then
|
2020-06-05 02:22:35 +00:00
|
|
|
for file in /etc/kdump/pre.d/*; do
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ -x $file ]]; then
|
2021-09-08 09:21:41 +00:00
|
|
|
dracut_install "$file"
|
2021-09-08 09:20:51 +00:00
|
|
|
elif [[ $file != "/etc/kdump/pre.d/*" ]]; then
|
2021-09-13 18:25:40 +00:00
|
|
|
echo "$file is not executable"
|
2020-06-05 02:22:35 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2021-09-08 09:20:51 +00:00
|
|
|
if [[ -d /etc/kdump/post.d ]]; then
|
2020-06-05 02:22:35 +00:00
|
|
|
for file in /etc/kdump/post.d/*; do
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ -x $file ]]; then
|
2021-09-08 09:21:41 +00:00
|
|
|
dracut_install "$file"
|
2021-09-08 09:20:51 +00:00
|
|
|
elif [[ $file != "/etc/kdump/post.d/*" ]]; then
|
2020-06-05 02:22:35 +00:00
|
|
|
echo "$file is not executable"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
default_dump_target_install_conf() {
|
2014-04-11 12:27:02 +00:00
|
|
|
local _target _fstype
|
2015-04-17 08:26:28 +00:00
|
|
|
local _mntpoint _save_path
|
2014-04-11 12:27:02 +00:00
|
|
|
|
|
|
|
is_user_configured_dump_target && return
|
|
|
|
|
2021-09-08 09:21:41 +00:00
|
|
|
_save_path=$(get_bind_mount_source "$(get_save_path)")
|
|
|
|
_target=$(get_target_from_path "$_save_path")
|
|
|
|
_mntpoint=$(get_mntpoint_from_target "$_target")
|
2015-04-17 08:26:28 +00:00
|
|
|
|
2021-09-08 09:21:41 +00:00
|
|
|
_fstype=$(get_fs_type_from_target "$_target")
|
|
|
|
if is_fs_type_nfs "$_fstype"; then
|
kdumpctl: remove "root=X" for kdump boot
Since the current dracut of Fedora already supports not always
mounting root device, we can remove "root=X" from the command
line directly, and always get the dump target specified in
"/etc/kdump.conf" and mount it. If the dump target is located
at root filesystem, we will add the root mount info explicitly
from kdump side instead of from dracut side.
For example, in case of nfs/ssh/usb/raw/etc(non-root) dumping,
kdump will not mount the unnecessary root fs after this change.
This patch removes "root=X" via the "KDUMP_COMMANDLINE_REMOVE"
(if "default dump_to_rootfs" is specified, don't remove "root=X"),
and mounts non-root target under "/kdumproot", the root target
still under "/sysroot"(to be align with systemd sysroot.mount).
After removing "root=X", we now add root fs mount information
explicitly from the kdump side.
Changed check_dump_fs_modified() a little to avoid rebuild when
dump target is root, since we add root fs mount explicitly now.
Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Pratyush Anand <panand@redhat.com>
Acked-by:Dave Young <dyoung@redhat.com>
2017-04-05 11:34:12 +00:00
|
|
|
kdump_install_net "$_target"
|
|
|
|
_fstype="nfs"
|
|
|
|
else
|
2021-09-08 09:21:41 +00:00
|
|
|
_target=$(kdump_get_persistent_dev "$_target")
|
kdumpctl: remove "root=X" for kdump boot
Since the current dracut of Fedora already supports not always
mounting root device, we can remove "root=X" from the command
line directly, and always get the dump target specified in
"/etc/kdump.conf" and mount it. If the dump target is located
at root filesystem, we will add the root mount info explicitly
from kdump side instead of from dracut side.
For example, in case of nfs/ssh/usb/raw/etc(non-root) dumping,
kdump will not mount the unnecessary root fs after this change.
This patch removes "root=X" via the "KDUMP_COMMANDLINE_REMOVE"
(if "default dump_to_rootfs" is specified, don't remove "root=X"),
and mounts non-root target under "/kdumproot", the root target
still under "/sysroot"(to be align with systemd sysroot.mount).
After removing "root=X", we now add root fs mount information
explicitly from the kdump side.
Changed check_dump_fs_modified() a little to avoid rebuild when
dump target is root, since we add root fs mount explicitly now.
Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Pratyush Anand <panand@redhat.com>
Acked-by:Dave Young <dyoung@redhat.com>
2017-04-05 11:34:12 +00:00
|
|
|
fi
|
2014-04-11 12:27:02 +00:00
|
|
|
|
2021-09-08 09:21:41 +00:00
|
|
|
echo "$_fstype $_target" >> "${initdir}/tmp/$$-kdump.conf"
|
2014-04-11 12:27:02 +00:00
|
|
|
|
kdumpctl: remove "root=X" for kdump boot
Since the current dracut of Fedora already supports not always
mounting root device, we can remove "root=X" from the command
line directly, and always get the dump target specified in
"/etc/kdump.conf" and mount it. If the dump target is located
at root filesystem, we will add the root mount info explicitly
from kdump side instead of from dracut side.
For example, in case of nfs/ssh/usb/raw/etc(non-root) dumping,
kdump will not mount the unnecessary root fs after this change.
This patch removes "root=X" via the "KDUMP_COMMANDLINE_REMOVE"
(if "default dump_to_rootfs" is specified, don't remove "root=X"),
and mounts non-root target under "/kdumproot", the root target
still under "/sysroot"(to be align with systemd sysroot.mount).
After removing "root=X", we now add root fs mount information
explicitly from the kdump side.
Changed check_dump_fs_modified() a little to avoid rebuild when
dump target is root, since we add root fs mount explicitly now.
Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Pratyush Anand <panand@redhat.com>
Acked-by:Dave Young <dyoung@redhat.com>
2017-04-05 11:34:12 +00:00
|
|
|
# don't touch the path under root mount
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ $_mntpoint != "/" ]]; then
|
2015-04-10 08:18:57 +00:00
|
|
|
_save_path=${_save_path##"$_mntpoint"}
|
2015-04-17 08:26:28 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
#erase the old path line, then insert the parsed path
|
2021-09-08 09:21:41 +00:00
|
|
|
sed -i "/^path/d" "${initdir}/tmp/$$-kdump.conf"
|
|
|
|
echo "path $_save_path" >> "${initdir}/tmp/$$-kdump.conf"
|
2015-04-17 08:26:28 +00:00
|
|
|
}
|
|
|
|
|
2012-05-14 02:36:18 +00:00
|
|
|
#install kdump.conf and what user specifies in kdump.conf
|
|
|
|
kdump_install_conf() {
|
2016-11-17 04:52:35 +00:00
|
|
|
local _opt _val _pdev
|
2021-08-03 11:49:51 +00:00
|
|
|
|
|
|
|
kdump_read_conf > "${initdir}/tmp/$$-kdump.conf"
|
2012-05-14 02:36:18 +00:00
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
while read -r _opt _val; do
|
2013-09-26 11:46:48 +00:00
|
|
|
# remove inline comments after the end of a directive.
|
2016-11-17 04:52:35 +00:00
|
|
|
case "$_opt" in
|
2021-09-13 18:25:40 +00:00
|
|
|
raw)
|
|
|
|
_pdev=$(persistent_policy="by-id" kdump_get_persistent_dev "$_val")
|
|
|
|
sed -i -e "s#^${_opt}[[:space:]]\+$_val#$_opt $_pdev#" "${initdir}/tmp/$$-kdump.conf"
|
|
|
|
;;
|
|
|
|
ext[234] | xfs | btrfs | minix)
|
|
|
|
_pdev=$(kdump_get_persistent_dev "$_val")
|
|
|
|
sed -i -e "s#^${_opt}[[:space:]]\+$_val#$_opt $_pdev#" "${initdir}/tmp/$$-kdump.conf"
|
|
|
|
;;
|
|
|
|
ssh | nfs)
|
|
|
|
kdump_install_net "$_val"
|
|
|
|
;;
|
|
|
|
dracut_args)
|
|
|
|
if [[ $(get_dracut_args_fstype "$_val") == nfs* ]]; then
|
|
|
|
kdump_install_net "$(get_dracut_args_target "$_val")"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
kdump_pre | kdump_post | extra_bins)
|
|
|
|
dracut_install "$_val"
|
|
|
|
;;
|
|
|
|
core_collector)
|
|
|
|
dracut_install "${_val%%[[:blank:]]*}"
|
|
|
|
;;
|
2011-08-01 16:33:14 +00:00
|
|
|
esac
|
2021-08-03 11:49:51 +00:00
|
|
|
done <<< "$(kdump_read_conf)"
|
2011-08-01 16:33:14 +00:00
|
|
|
|
2020-06-05 02:22:35 +00:00
|
|
|
kdump_install_pre_post_conf
|
|
|
|
|
2014-04-11 12:27:02 +00:00
|
|
|
default_dump_target_install_conf
|
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
kdump_configure_fence_kdump "${initdir}/tmp/$$-kdump.conf"
|
2015-02-12 06:40:27 +00:00
|
|
|
inst "${initdir}/tmp/$$-kdump.conf" "/etc/kdump.conf"
|
2021-09-08 09:21:41 +00:00
|
|
|
rm -f "${initdir}/tmp/$$-kdump.conf"
|
2012-05-14 02:36:18 +00:00
|
|
|
}
|
|
|
|
|
2021-04-19 15:00:10 +00:00
|
|
|
# Default sysctl parameters should suffice for kdump kernel.
|
|
|
|
# Remove custom configurations sysctl.conf & sysctl.d/*
|
|
|
|
remove_sysctl_conf() {
|
|
|
|
|
2014-12-08 11:59:08 +00:00
|
|
|
# As custom configurations like vm.min_free_kbytes can lead
|
|
|
|
# to OOM issues in kdump kernel, avoid them
|
|
|
|
rm -f "${initdir}/etc/sysctl.conf"
|
|
|
|
rm -rf "${initdir}/etc/sysctl.d"
|
|
|
|
rm -rf "${initdir}/run/sysctl.d"
|
|
|
|
rm -rf "${initdir}/usr/lib/sysctl.d"
|
|
|
|
}
|
|
|
|
|
2012-05-25 14:40:25 +00:00
|
|
|
kdump_iscsi_get_rec_val() {
|
|
|
|
|
|
|
|
local result
|
|
|
|
|
|
|
|
# The open-iscsi 742 release changed to using flat files in
|
|
|
|
# /var/lib/iscsi.
|
|
|
|
|
2021-09-08 09:21:41 +00:00
|
|
|
result=$(/sbin/iscsiadm --show -m session -r "$1" | grep "^${2} = ")
|
2012-05-25 14:40:25 +00:00
|
|
|
result=${result##* = }
|
2021-09-08 09:21:41 +00:00
|
|
|
echo "$result"
|
2012-05-25 14:40:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
kdump_get_iscsi_initiator() {
|
|
|
|
local _initiator
|
|
|
|
local initiator_conf="/etc/iscsi/initiatorname.iscsi"
|
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
[[ -f $initiator_conf ]] || return 1
|
2012-05-25 14:40:25 +00:00
|
|
|
|
2021-08-04 07:50:30 +00:00
|
|
|
while read -r _initiator; do
|
2021-09-13 18:25:40 +00:00
|
|
|
[[ -z ${_initiator%%#*} ]] && continue # Skip comment lines
|
2012-05-25 14:40:25 +00:00
|
|
|
|
|
|
|
case $_initiator in
|
|
|
|
InitiatorName=*)
|
|
|
|
initiator=${_initiator#InitiatorName=}
|
|
|
|
echo "rd.iscsi.initiator=${initiator}"
|
2021-09-13 18:25:40 +00:00
|
|
|
return 0
|
|
|
|
;;
|
2012-05-25 14:40:25 +00:00
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
done < ${initiator_conf}
|
|
|
|
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2016-07-01 02:34:22 +00:00
|
|
|
# Figure out iBFT session according to session type
|
|
|
|
is_ibft() {
|
2021-09-13 18:25:40 +00:00
|
|
|
[[ "$(kdump_iscsi_get_rec_val "$1" "node.discovery_type")" == fw ]]
|
2016-07-01 02:34:22 +00:00
|
|
|
}
|
|
|
|
|
2012-05-25 14:40:25 +00:00
|
|
|
kdump_setup_iscsi_device() {
|
|
|
|
local path=$1
|
2021-09-13 18:25:40 +00:00
|
|
|
local tgt_name
|
|
|
|
local tgt_ipaddr
|
|
|
|
local username
|
|
|
|
local password
|
|
|
|
local userpwd_str
|
|
|
|
local username_in
|
|
|
|
local password_in
|
|
|
|
local userpwd_in_str
|
|
|
|
local netroot_str
|
|
|
|
local initiator_str
|
2012-05-25 14:40:25 +00:00
|
|
|
local netroot_conf="${initdir}/etc/cmdline.d/50iscsi.conf"
|
|
|
|
local initiator_conf="/etc/iscsi/initiatorname.iscsi"
|
|
|
|
|
|
|
|
dinfo "Found iscsi component $1"
|
|
|
|
|
2017-07-24 13:31:39 +00:00
|
|
|
# Check once before getting explicit values, so we can bail out early,
|
|
|
|
# e.g. in case of pure-hardware(all-offload) iscsi.
|
2021-09-13 18:25:40 +00:00
|
|
|
if ! /sbin/iscsiadm -m session -r "$path" &> /dev/null; then
|
2012-05-25 14:40:25 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2021-09-08 09:21:41 +00:00
|
|
|
if is_ibft "$path"; then
|
2016-07-01 02:34:22 +00:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2017-09-06 06:44:47 +00:00
|
|
|
# Remove software iscsi cmdline generated by 95iscsi,
|
|
|
|
# and let kdump regenerate here.
|
2021-09-08 09:21:41 +00:00
|
|
|
rm -f "${initdir}/etc/cmdline.d/95iscsi.conf"
|
2017-09-06 06:44:47 +00:00
|
|
|
|
2021-09-08 09:21:41 +00:00
|
|
|
tgt_name=$(kdump_iscsi_get_rec_val "$path" "node.name")
|
|
|
|
tgt_ipaddr=$(kdump_iscsi_get_rec_val "$path" "node.conn\[0\].address")
|
2012-05-25 14:40:25 +00:00
|
|
|
|
|
|
|
# get and set username and password details
|
2021-09-08 09:21:41 +00:00
|
|
|
username=$(kdump_iscsi_get_rec_val "$path" "node.session.auth.username")
|
2021-09-13 18:25:40 +00:00
|
|
|
[[ $username == "<empty>" ]] && username=""
|
2021-09-08 09:21:41 +00:00
|
|
|
password=$(kdump_iscsi_get_rec_val "$path" "node.session.auth.password")
|
2021-09-13 18:25:40 +00:00
|
|
|
[[ $password == "<empty>" ]] && password=""
|
2021-09-08 09:21:41 +00:00
|
|
|
username_in=$(kdump_iscsi_get_rec_val "$path" "node.session.auth.username_in")
|
2021-09-13 18:25:40 +00:00
|
|
|
[[ -n $username ]] && userpwd_str="$username:$password"
|
2012-05-25 14:40:25 +00:00
|
|
|
|
|
|
|
# get and set incoming username and password details
|
2021-09-13 18:25:40 +00:00
|
|
|
[[ $username_in == "<empty>" ]] && username_in=""
|
2021-09-08 09:21:41 +00:00
|
|
|
password_in=$(kdump_iscsi_get_rec_val "$path" "node.session.auth.password_in")
|
2021-09-13 18:25:40 +00:00
|
|
|
[[ $password_in == "<empty>" ]] && password_in=""
|
2012-05-25 14:40:25 +00:00
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
[[ -n $username_in ]] && userpwd_in_str=":$username_in:$password_in"
|
2012-05-25 14:40:25 +00:00
|
|
|
|
2019-06-30 16:41:07 +00:00
|
|
|
kdump_install_net "$tgt_ipaddr"
|
2012-05-25 14:40:25 +00:00
|
|
|
|
|
|
|
# prepare netroot= command line
|
|
|
|
# FIXME: Do we need to parse and set other parameters like protocol, port
|
|
|
|
# iscsi_iface_name, netdev_name, LUN etc.
|
|
|
|
|
2021-09-08 09:21:41 +00:00
|
|
|
if is_ipv6_address "$tgt_ipaddr"; then
|
2015-07-23 10:29:26 +00:00
|
|
|
tgt_ipaddr="[$tgt_ipaddr]"
|
|
|
|
fi
|
2012-05-25 14:40:25 +00:00
|
|
|
netroot_str="netroot=iscsi:${userpwd_str}${userpwd_in_str}@$tgt_ipaddr::::$tgt_name"
|
|
|
|
|
2021-09-08 09:21:41 +00:00
|
|
|
[[ -f $netroot_conf ]] || touch "$netroot_conf"
|
2012-05-25 14:40:25 +00:00
|
|
|
|
|
|
|
# If netroot target does not exist already, append.
|
2021-09-08 09:21:41 +00:00
|
|
|
if ! grep -q "$netroot_str" "$netroot_conf"; then
|
2021-09-13 18:25:40 +00:00
|
|
|
echo "$netroot_str" >> "$netroot_conf"
|
|
|
|
dinfo "Appended $netroot_str to $netroot_conf"
|
2012-05-25 14:40:25 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Setup initator
|
2021-09-08 09:23:16 +00:00
|
|
|
if ! initiator_str=$(kdump_get_iscsi_initiator); then
|
|
|
|
derror "Failed to get initiator name"
|
|
|
|
return 1
|
|
|
|
fi
|
2012-05-25 14:40:25 +00:00
|
|
|
|
|
|
|
# If initiator details do not exist already, append.
|
2021-09-08 09:21:41 +00:00
|
|
|
if ! grep -q "$initiator_str" "$netroot_conf"; then
|
2021-09-13 18:25:40 +00:00
|
|
|
echo "$initiator_str" >> "$netroot_conf"
|
|
|
|
dinfo "Appended $initiator_str to $netroot_conf"
|
2012-05-25 14:40:25 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
kdump_check_iscsi_targets() {
|
2012-05-25 14:40:25 +00:00
|
|
|
# If our prerequisites are not met, fail anyways.
|
2021-09-13 18:25:40 +00:00
|
|
|
type -P iscsistart > /dev/null || return 1
|
2012-05-25 14:40:25 +00:00
|
|
|
|
|
|
|
kdump_check_setup_iscsi() (
|
|
|
|
local _dev
|
2012-08-28 03:02:42 +00:00
|
|
|
_dev=$1
|
2012-05-25 14:40:25 +00:00
|
|
|
|
|
|
|
[[ -L /sys/dev/block/$_dev ]] || return
|
2021-08-04 08:29:55 +00:00
|
|
|
cd "$(readlink -f "/sys/dev/block/$_dev")" || return 1
|
2012-05-25 14:40:25 +00:00
|
|
|
until [[ -d sys || -d iscsi_session ]]; do
|
|
|
|
cd ..
|
|
|
|
done
|
|
|
|
[[ -d iscsi_session ]] && kdump_setup_iscsi_device "$PWD"
|
|
|
|
)
|
|
|
|
|
|
|
|
[[ $hostonly ]] || [[ $mount_needs ]] && {
|
2012-08-28 03:02:42 +00:00
|
|
|
for_each_host_dev_and_slaves_all kdump_check_setup_iscsi
|
2012-05-25 14:40:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-26 09:03:12 +00:00
|
|
|
# hostname -a is deprecated, do it by ourself
|
|
|
|
get_alias() {
|
|
|
|
local ips
|
|
|
|
local entries
|
|
|
|
local alias_set
|
|
|
|
|
|
|
|
ips=$(hostname -I)
|
2021-09-13 18:25:40 +00:00
|
|
|
for ip in $ips; do
|
|
|
|
# in /etc/hosts, alias can come at the 2nd column
|
|
|
|
if entries=$(grep "$ip" /etc/hosts | awk '{ $1=""; print $0 }'); then
|
|
|
|
alias_set="$alias_set $entries"
|
|
|
|
fi
|
2019-08-26 09:03:12 +00:00
|
|
|
done
|
|
|
|
|
2021-09-08 09:21:41 +00:00
|
|
|
echo "$alias_set"
|
2019-08-26 09:03:12 +00:00
|
|
|
}
|
|
|
|
|
2019-08-01 02:34:05 +00:00
|
|
|
is_localhost() {
|
2021-08-17 18:04:45 +00:00
|
|
|
local hostnames
|
|
|
|
local shortnames
|
|
|
|
local aliasname
|
2019-08-01 02:34:05 +00:00
|
|
|
local nodename=$1
|
|
|
|
|
2021-08-17 18:04:45 +00:00
|
|
|
hostnames=$(hostname -A)
|
|
|
|
shortnames=$(hostname -A -s)
|
|
|
|
aliasname=$(get_alias)
|
2019-08-26 09:03:12 +00:00
|
|
|
hostnames="$hostnames $shortnames $aliasname"
|
2019-08-01 02:34:05 +00:00
|
|
|
|
|
|
|
for name in ${hostnames}; do
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ $name == "$nodename" ]]; then
|
2019-08-01 02:34:05 +00:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2014-04-02 08:33:47 +00:00
|
|
|
# retrieves fence_kdump nodes from Pacemaker cluster configuration
|
|
|
|
get_pcs_fence_kdump_nodes() {
|
2013-12-20 09:41:29 +00:00
|
|
|
local nodes
|
|
|
|
|
2020-04-20 03:16:00 +00:00
|
|
|
pcs cluster sync > /dev/null 2>&1 && pcs cluster cib-upgrade > /dev/null 2>&1
|
2013-12-20 09:41:29 +00:00
|
|
|
# get cluster nodes from cluster cib, get interface and ip address
|
2021-09-07 17:48:52 +00:00
|
|
|
nodelist=$(pcs cluster cib | xmllint --xpath "/cib/status/node_state/@uname" -)
|
2013-12-20 09:41:29 +00:00
|
|
|
|
|
|
|
# nodelist is formed as 'uname="node1" uname="node2" ... uname="nodeX"'
|
|
|
|
# we need to convert each to node1, node2 ... nodeX in each iteration
|
|
|
|
for node in ${nodelist}; do
|
|
|
|
# convert $node from 'uname="nodeX"' to 'nodeX'
|
2021-09-08 09:21:41 +00:00
|
|
|
eval "$node"
|
|
|
|
nodename="$uname"
|
2013-12-20 09:41:29 +00:00
|
|
|
# Skip its own node name
|
2021-09-08 09:21:41 +00:00
|
|
|
if is_localhost "$nodename"; then
|
2013-12-20 09:41:29 +00:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
nodes="$nodes $nodename"
|
2014-04-02 08:33:47 +00:00
|
|
|
done
|
|
|
|
|
2021-09-08 09:21:41 +00:00
|
|
|
echo "$nodes"
|
2014-04-02 08:33:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# retrieves fence_kdump args from config file
|
|
|
|
get_pcs_fence_kdump_args() {
|
2021-09-08 09:20:51 +00:00
|
|
|
if [[ -f $FENCE_KDUMP_CONFIG_FILE ]]; then
|
2021-09-08 09:21:41 +00:00
|
|
|
. "$FENCE_KDUMP_CONFIG_FILE"
|
|
|
|
echo "$FENCE_KDUMP_OPTS"
|
2014-04-02 08:33:47 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-08-26 09:03:13 +00:00
|
|
|
get_generic_fence_kdump_nodes() {
|
|
|
|
local filtered
|
|
|
|
local nodes
|
|
|
|
|
kdump-lib.sh: add a config value retrive helper
Add a helper kdump_get_conf_val to replace get_option_value.
It can help cover more corner cases in the code, like when there are
multiple spaces in config file, config value separated by a tab,
heading spaces, or trailing comments.
And this uses "sed group command" and "sed hold buffer", make it much
faster than previous `grep <config> | tail -1`.
This helper is supposed to provide a universal way for kexec-tools
scripts to read in config value. Currently, different scripts are
reading the config in many different fragile ways.
For example, following codes are found in kexec-tools script code base:
1. grep ^force_rebuild $KDUMP_CONFIG_FILE
echo $_force_rebuild | cut -d' ' -f2
2. grep ^kdump_post $KDUMP_CONFIG_FILE | cut -d\ -f2
3. awk '/^sshkey/ {print $2}' $conf_file
4. grep ^path $KDUMP_CONFIG_FILE | cut -d' ' -f2-
1, 2, and 4 will fail if the space is replaced by, e.g. a tab
1 and 2 might fail if there are multiple spaces between config name
and config value:
"kdump_post /var/crash/scripts/kdump-post.sh"
A space will be read instead of config value.
1, 2, 3 will fail if there are space in file path, like:
"kdump_post /var/crash/scripts dir/kdump-post.sh"
4 will fail if there are trailing comments:
"path /var/crash # some comment here"
And all will fail if there are heading space,
" path /var/crash"
And all will most likely cause problems if the config file contains
the same option more than once.
And all of them are slower than the new sed call. Old get_option_value
is also very slow and doesn't handle heading space.
Although we never claim to support heading space or tailing comments
before, it's harmless to be more robust on config reading, and many
conf files in /etc support heading spaces. And have a faster and
safer config reading helper makes it easier to clean up the code.
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Philipp Rudo <prudo@redhat.com>
2021-08-16 15:25:14 +00:00
|
|
|
nodes=$(kdump_get_conf_val "fence_kdump_nodes")
|
2019-08-26 09:03:13 +00:00
|
|
|
for node in ${nodes}; do
|
|
|
|
# Skip its own node name
|
2021-09-08 09:21:41 +00:00
|
|
|
if is_localhost "$node"; then
|
2019-08-26 09:03:13 +00:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
filtered="$filtered $node"
|
|
|
|
done
|
2021-09-08 09:21:41 +00:00
|
|
|
echo "$filtered"
|
2019-08-26 09:03:13 +00:00
|
|
|
}
|
|
|
|
|
2014-04-02 08:33:47 +00:00
|
|
|
# setup fence_kdump in cluster
|
|
|
|
# setup proper network and install needed files
|
2021-09-13 18:25:40 +00:00
|
|
|
kdump_configure_fence_kdump() {
|
2014-04-02 08:33:47 +00:00
|
|
|
local kdump_cfg_file=$1
|
|
|
|
local nodes
|
|
|
|
local args
|
|
|
|
|
|
|
|
if is_generic_fence_kdump; then
|
2019-08-26 09:03:13 +00:00
|
|
|
nodes=$(get_generic_fence_kdump_nodes)
|
2014-04-02 08:33:47 +00:00
|
|
|
|
|
|
|
elif is_pcs_fence_kdump; then
|
|
|
|
nodes=$(get_pcs_fence_kdump_nodes)
|
|
|
|
|
|
|
|
# set appropriate options in kdump.conf
|
2021-09-08 09:21:41 +00:00
|
|
|
echo "fence_kdump_nodes $nodes" >> "${kdump_cfg_file}"
|
2014-04-02 08:33:47 +00:00
|
|
|
|
|
|
|
args=$(get_pcs_fence_kdump_args)
|
2021-09-13 18:25:40 +00:00
|
|
|
if [[ -n $args ]]; then
|
2021-09-08 09:21:41 +00:00
|
|
|
echo "fence_kdump_args $args" >> "${kdump_cfg_file}"
|
2014-04-02 08:33:47 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
else
|
|
|
|
# fence_kdump not configured
|
|
|
|
return 1
|
|
|
|
fi
|
2013-12-20 09:41:29 +00:00
|
|
|
|
2014-04-02 08:33:47 +00:00
|
|
|
# setup network for each node
|
|
|
|
for node in ${nodes}; do
|
2021-09-08 09:21:41 +00:00
|
|
|
kdump_install_net "$node"
|
2013-12-20 09:41:29 +00:00
|
|
|
done
|
|
|
|
|
2018-06-22 02:34:17 +00:00
|
|
|
dracut_install /etc/hosts
|
|
|
|
dracut_install /etc/nsswitch.conf
|
2021-09-08 09:21:41 +00:00
|
|
|
dracut_install "$FENCE_KDUMP_SEND"
|
2013-12-20 09:41:29 +00:00
|
|
|
}
|
|
|
|
|
2014-01-29 08:24:33 +00:00
|
|
|
# Install a random seed used to feed /dev/urandom
|
|
|
|
# By the time kdump service starts, /dev/uramdom is already fed by systemd
|
|
|
|
kdump_install_random_seed() {
|
2021-08-04 07:14:00 +00:00
|
|
|
local poolsize
|
|
|
|
|
2021-09-13 18:25:40 +00:00
|
|
|
poolsize=$(< /proc/sys/kernel/random/poolsize)
|
2014-01-29 08:24:33 +00:00
|
|
|
|
2021-09-08 09:21:41 +00:00
|
|
|
if [[ ! -d "${initdir}/var/lib/" ]]; then
|
|
|
|
mkdir -p "${initdir}/var/lib/"
|
2014-01-29 08:24:33 +00:00
|
|
|
fi
|
|
|
|
|
2021-09-08 09:21:41 +00:00
|
|
|
dd if=/dev/urandom of="${initdir}/var/lib/random-seed" \
|
2021-09-13 18:25:40 +00:00
|
|
|
bs="$poolsize" count=1 2> /dev/null
|
2014-01-29 08:24:33 +00:00
|
|
|
}
|
|
|
|
|
2020-08-11 09:50:07 +00:00
|
|
|
kdump_install_systemd_conf() {
|
|
|
|
# Kdump turns out to require longer default systemd mount timeout
|
|
|
|
# than 1st kernel(90s by default), we use default 300s for kdump.
|
2021-09-08 09:23:16 +00:00
|
|
|
if ! grep -q -r "^[[:space:]]*DefaultTimeoutStartSec=" "${initdir}/etc/systemd/system.conf"*; then
|
2021-09-08 09:21:41 +00:00
|
|
|
mkdir -p "${initdir}/etc/systemd/system.conf.d"
|
|
|
|
echo "[Manager]" > "${initdir}/etc/systemd/system.conf.d/kdump.conf"
|
|
|
|
echo "DefaultTimeoutStartSec=300s" >> "${initdir}/etc/systemd/system.conf.d/kdump.conf"
|
2020-08-11 09:50:07 +00:00
|
|
|
fi
|
|
|
|
|
2020-10-27 07:00:45 +00:00
|
|
|
# Forward logs to console directly, and don't read Kmsg, this avoids
|
|
|
|
# unneccessary memory consumption and make console output more useful.
|
2020-08-11 09:50:07 +00:00
|
|
|
# Only do so for non fadump image.
|
2021-09-08 09:21:41 +00:00
|
|
|
mkdir -p "${initdir}/etc/systemd/journald.conf.d"
|
|
|
|
echo "[Journal]" > "${initdir}/etc/systemd/journald.conf.d/kdump.conf"
|
|
|
|
echo "Storage=volatile" >> "${initdir}/etc/systemd/journald.conf.d/kdump.conf"
|
|
|
|
echo "ReadKMsg=no" >> "${initdir}/etc/systemd/journald.conf.d/kdump.conf"
|
|
|
|
echo "ForwardToConsole=yes" >> "${initdir}/etc/systemd/journald.conf.d/kdump.conf"
|
2020-08-11 09:50:07 +00:00
|
|
|
}
|
|
|
|
|
2012-05-14 02:36:18 +00:00
|
|
|
install() {
|
2021-01-19 14:23:16 +00:00
|
|
|
kdump_module_init
|
2012-05-14 02:36:18 +00:00
|
|
|
kdump_install_conf
|
2021-04-19 15:00:10 +00:00
|
|
|
remove_sysctl_conf
|
2013-08-02 06:52:32 +00:00
|
|
|
|
2012-11-14 05:58:37 +00:00
|
|
|
if is_ssh_dump_target; then
|
2014-01-29 08:24:33 +00:00
|
|
|
kdump_install_random_seed
|
2012-11-14 05:58:37 +00:00
|
|
|
fi
|
2013-08-02 06:22:22 +00:00
|
|
|
dracut_install -o /etc/adjtime /etc/localtime
|
2012-04-28 10:01:18 +00:00
|
|
|
inst "$moddir/monitor_dd_progress" "/kdumpscripts/monitor_dd_progress"
|
2021-09-08 09:21:41 +00:00
|
|
|
chmod +x "${initdir}/kdumpscripts/monitor_dd_progress"
|
2012-04-28 10:01:18 +00:00
|
|
|
inst "/bin/dd" "/bin/dd"
|
|
|
|
inst "/bin/tail" "/bin/tail"
|
2011-08-01 09:19:24 +00:00
|
|
|
inst "/bin/date" "/bin/date"
|
|
|
|
inst "/bin/sync" "/bin/sync"
|
2012-02-22 03:16:09 +00:00
|
|
|
inst "/bin/cut" "/bin/cut"
|
2015-07-23 10:29:23 +00:00
|
|
|
inst "/bin/head" "/bin/head"
|
2019-11-30 16:00:50 +00:00
|
|
|
inst "/bin/awk" "/bin/awk"
|
|
|
|
inst "/bin/sed" "/bin/sed"
|
2021-09-13 19:00:48 +00:00
|
|
|
inst "/bin/stat" "/bin/stat"
|
2011-08-01 09:19:24 +00:00
|
|
|
inst "/sbin/makedumpfile" "/sbin/makedumpfile"
|
2013-05-13 03:13:27 +00:00
|
|
|
inst "/sbin/vmcore-dmesg" "/sbin/vmcore-dmesg"
|
2020-10-27 09:04:25 +00:00
|
|
|
inst "/usr/bin/printf" "/sbin/printf"
|
|
|
|
inst "/usr/bin/logger" "/sbin/logger"
|
2021-03-18 08:52:46 +00:00
|
|
|
inst "/usr/bin/chmod" "/sbin/chmod"
|
2014-05-08 11:37:14 +00:00
|
|
|
inst "/lib/kdump/kdump-lib-initramfs.sh" "/lib/kdump-lib-initramfs.sh"
|
2020-10-27 09:04:25 +00:00
|
|
|
inst "/lib/kdump/kdump-logger.sh" "/lib/kdump-logger.sh"
|
2014-05-08 11:37:16 +00:00
|
|
|
inst "$moddir/kdump.sh" "/usr/bin/kdump.sh"
|
|
|
|
inst "$moddir/kdump-capture.service" "$systemdsystemunitdir/kdump-capture.service"
|
2020-12-14 07:10:28 +00:00
|
|
|
systemctl -q --root "$initdir" add-wants initrd.target kdump-capture.service
|
kdump-emergency: fix "Transaction is destructive" emergency failure
We met a problem that the kdump emergency service failed to
start when the target dump timeout(we passed "rd.timeout=30"
to kdump), it reported "Transaction is destructive" messages:
[ TIME ] Timed out waiting for device dev-mapper-fedora\x2droot.device.
[DEPEND] Dependency failed for Initrd Root Device.
[ SKIP ] Ordering cycle found, skipping System Initialization
[DEPEND] Dependency failed for /sysroot.
[DEPEND] Dependency failed for Initrd Root File System.
[DEPEND] Dependency failed for Reload Configuration from the Real Root.
[ SKIP ] Ordering cycle found, skipping System Initialization
[ SKIP ] Ordering cycle found, skipping Initrd Default Target
[DEPEND] Dependency failed for File System Check on /dev/mapper/fedora-root.
[ OK ] Reached target Initrd File Systems.
[ OK ] Stopped dracut pre-udev hook.
[ OK ] Stopped dracut cmdline hook.
Starting Setup Virtual Console...
Starting Kdump Emergency...
[ OK ] Reached target Initrd Default Target.
[ OK ] Stopped dracut initqueue hook.
Failed to start kdump-error-handler.service: Transaction is destructive.
See system logs and 'systemctl status kdump-error-handler.service' for details.
[FAILED] Failed to start Kdump Emergency.
See 'systemctl status emergency.service' for details.
[DEPEND] Dependency failed for Emergency Mode.
This is because in case of root failure, initrd-root-fs.target
will trigger systemd emergency target which requires the systemd
emergency service actually is kdump-emergency.service, then our
kdump-emergency.service starts kdump-error-handler.service with
"systemctl isolate"(see 99kdumpbase/kdump-emergency.service, we
replace systemd's with this one under kdump).
This will lead to systemd two contradictable jobs queued as an
atomic transaction:
job 1) the emergency service gets started by initrd-root-fs.target
job 2) the emergency service gets stopped due to "systemctl isolate"
thereby throwing "Transaction is destructive".
In order to solve it, we can utilize "IgnoreOnIsolate=yes" for both
kdump-emergency.service and kdump-emergency.target. Unit with attribute
"IgnoreOnIsolate=yes" won't be stopped when isolating another unit,
they can keep going as expected in case be triggered by any failure.
We add kdump-emergency.target dedicated to kdump the similar way
as did for kdump-emergency.service(i.e. will replace systemd's
emergency.target with kdump-emergency.target under kdump), and
adds "IgnoreOnIsolate=yes" into both of them.
Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
Acked-by: Pratyush Anand <panand@redhat.com>
[bhe: improve the patch log about IgnoreOnIsolate="]
2017-03-27 04:07:32 +00:00
|
|
|
# Replace existing emergency service and emergency target
|
Introduce kdump error handling service
Now upon failure kdump script might not be called at all and it might
not be able to execute default action. It results in a hang.
Because we disable emergency shell and rely on kdump.sh being invoked
through dracut-pre-pivot hook. But it might happen that we never call
into dracut-pre-pivot hook because certain systemd targets could not
reach due to failure in their dependencies. In those cases error
handling code does not run and system hangs. For example:
sysroot-var-crash.mount --> initrd-root-fs.target --> initrd.target \
--> dracut-pre-pivot.service --> kdump.sh
If /sysroot/var/crash mount fails, initrd-root-fs.target will not be
reached. And then initrd.target will not be reached,
dracut-pre-pivot.service wouldn't run. Finally kdump.sh wouldn't run.
To solve this problem, we need to separate the error handling code from
dracut-pre-pivot hook, and every time when a failure shows up, the
separated code can be called by the emergency service.
By default systemd provides an emergency service which will drop us into
shell every time upon a critical failure. It's very convenient for us to
re-use the framework of systemd emergency, because we don't have to
touch the other parts of systemd. We can use our own script instead of
the default one.
This new scheme will overwrite emergency shell and replace with kdump
error handling code. And this code will do the error handling as needed.
Now, we will not rely on dracut-pre-pivot hook running always. Instead
whenever error happens and it is serious enough that emergency shell
needed to run, now kdump error handler will run.
dracut-emergency is also replaced by kdump error handler and it's
enabled again all the way down. So all the failure (including systemd
and dracut) in 2nd kernel could be captured, and trigger kdump error
handler.
dracut-initqueue is a special case, which calls "systemctl start
emergency" directly, not via "OnFailure=emergency". In case of failure,
emergency is started, but not in a isolation mode, which means
dracut-initqueue is still running. On the other hand, emergency will
call dracut-initqueue again when default action is dump_to_rootfs.
systemd would block on the last dracut-initqueue, waiting for the first
instance to exit, which leaves us hang. It looks like the following:
dracut-initqueue (running)
--> call dracut-emergency:
--> dracut-emergency (running)
--> kdump-error-handler.sh (running)
--> call dracut-initqueue:
--> blocking and waiting for the original instance to exit.
To fix this, I'd like to introduce a wrapper emergency service. This
emegency service will replace both the systemd and dracut emergency. And
this service does nothing but to isolate to real kdump error handler
service:
dracut-initqueue (running)
--> call dracut-emergency:
--> dracut-emergency isolate to kdump-error-handler.service
--> dracut-emergency and dracut-initqueue will both be stopped
and kdump-error-handler.service will run kdump-error-handler.sh.
In a normal failure case, this still works:
foo.service fails
--> trigger emergency.service
--> emergency.service isolates to kdump-error-handler.service
--> kdump-error-handler.service will run kdump-error-handler.sh
Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2014-05-08 11:37:15 +00:00
|
|
|
cp "$moddir/kdump-emergency.service" "$initdir/$systemdsystemunitdir/emergency.service"
|
kdump-emergency: fix "Transaction is destructive" emergency failure
We met a problem that the kdump emergency service failed to
start when the target dump timeout(we passed "rd.timeout=30"
to kdump), it reported "Transaction is destructive" messages:
[ TIME ] Timed out waiting for device dev-mapper-fedora\x2droot.device.
[DEPEND] Dependency failed for Initrd Root Device.
[ SKIP ] Ordering cycle found, skipping System Initialization
[DEPEND] Dependency failed for /sysroot.
[DEPEND] Dependency failed for Initrd Root File System.
[DEPEND] Dependency failed for Reload Configuration from the Real Root.
[ SKIP ] Ordering cycle found, skipping System Initialization
[ SKIP ] Ordering cycle found, skipping Initrd Default Target
[DEPEND] Dependency failed for File System Check on /dev/mapper/fedora-root.
[ OK ] Reached target Initrd File Systems.
[ OK ] Stopped dracut pre-udev hook.
[ OK ] Stopped dracut cmdline hook.
Starting Setup Virtual Console...
Starting Kdump Emergency...
[ OK ] Reached target Initrd Default Target.
[ OK ] Stopped dracut initqueue hook.
Failed to start kdump-error-handler.service: Transaction is destructive.
See system logs and 'systemctl status kdump-error-handler.service' for details.
[FAILED] Failed to start Kdump Emergency.
See 'systemctl status emergency.service' for details.
[DEPEND] Dependency failed for Emergency Mode.
This is because in case of root failure, initrd-root-fs.target
will trigger systemd emergency target which requires the systemd
emergency service actually is kdump-emergency.service, then our
kdump-emergency.service starts kdump-error-handler.service with
"systemctl isolate"(see 99kdumpbase/kdump-emergency.service, we
replace systemd's with this one under kdump).
This will lead to systemd two contradictable jobs queued as an
atomic transaction:
job 1) the emergency service gets started by initrd-root-fs.target
job 2) the emergency service gets stopped due to "systemctl isolate"
thereby throwing "Transaction is destructive".
In order to solve it, we can utilize "IgnoreOnIsolate=yes" for both
kdump-emergency.service and kdump-emergency.target. Unit with attribute
"IgnoreOnIsolate=yes" won't be stopped when isolating another unit,
they can keep going as expected in case be triggered by any failure.
We add kdump-emergency.target dedicated to kdump the similar way
as did for kdump-emergency.service(i.e. will replace systemd's
emergency.target with kdump-emergency.target under kdump), and
adds "IgnoreOnIsolate=yes" into both of them.
Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
Acked-by: Pratyush Anand <panand@redhat.com>
[bhe: improve the patch log about IgnoreOnIsolate="]
2017-03-27 04:07:32 +00:00
|
|
|
cp "$moddir/kdump-emergency.target" "$initdir/$systemdsystemunitdir/emergency.target"
|
Introduce kdump error handling service
Now upon failure kdump script might not be called at all and it might
not be able to execute default action. It results in a hang.
Because we disable emergency shell and rely on kdump.sh being invoked
through dracut-pre-pivot hook. But it might happen that we never call
into dracut-pre-pivot hook because certain systemd targets could not
reach due to failure in their dependencies. In those cases error
handling code does not run and system hangs. For example:
sysroot-var-crash.mount --> initrd-root-fs.target --> initrd.target \
--> dracut-pre-pivot.service --> kdump.sh
If /sysroot/var/crash mount fails, initrd-root-fs.target will not be
reached. And then initrd.target will not be reached,
dracut-pre-pivot.service wouldn't run. Finally kdump.sh wouldn't run.
To solve this problem, we need to separate the error handling code from
dracut-pre-pivot hook, and every time when a failure shows up, the
separated code can be called by the emergency service.
By default systemd provides an emergency service which will drop us into
shell every time upon a critical failure. It's very convenient for us to
re-use the framework of systemd emergency, because we don't have to
touch the other parts of systemd. We can use our own script instead of
the default one.
This new scheme will overwrite emergency shell and replace with kdump
error handling code. And this code will do the error handling as needed.
Now, we will not rely on dracut-pre-pivot hook running always. Instead
whenever error happens and it is serious enough that emergency shell
needed to run, now kdump error handler will run.
dracut-emergency is also replaced by kdump error handler and it's
enabled again all the way down. So all the failure (including systemd
and dracut) in 2nd kernel could be captured, and trigger kdump error
handler.
dracut-initqueue is a special case, which calls "systemctl start
emergency" directly, not via "OnFailure=emergency". In case of failure,
emergency is started, but not in a isolation mode, which means
dracut-initqueue is still running. On the other hand, emergency will
call dracut-initqueue again when default action is dump_to_rootfs.
systemd would block on the last dracut-initqueue, waiting for the first
instance to exit, which leaves us hang. It looks like the following:
dracut-initqueue (running)
--> call dracut-emergency:
--> dracut-emergency (running)
--> kdump-error-handler.sh (running)
--> call dracut-initqueue:
--> blocking and waiting for the original instance to exit.
To fix this, I'd like to introduce a wrapper emergency service. This
emegency service will replace both the systemd and dracut emergency. And
this service does nothing but to isolate to real kdump error handler
service:
dracut-initqueue (running)
--> call dracut-emergency:
--> dracut-emergency isolate to kdump-error-handler.service
--> dracut-emergency and dracut-initqueue will both be stopped
and kdump-error-handler.service will run kdump-error-handler.sh.
In a normal failure case, this still works:
foo.service fails
--> trigger emergency.service
--> emergency.service isolates to kdump-error-handler.service
--> kdump-error-handler.service will run kdump-error-handler.sh
Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2014-05-08 11:37:15 +00:00
|
|
|
# Also redirect dracut-emergency to kdump error handler
|
|
|
|
ln_r "$systemdsystemunitdir/emergency.service" "$systemdsystemunitdir/dracut-emergency.service"
|
2012-05-25 14:40:25 +00:00
|
|
|
|
|
|
|
# Check for all the devices and if any device is iscsi, bring up iscsi
|
|
|
|
# target. Ideally all this should be pushed into dracut iscsi module
|
|
|
|
# at some point of time.
|
|
|
|
kdump_check_iscsi_targets
|
2017-03-29 08:16:57 +00:00
|
|
|
|
2020-08-11 09:50:07 +00:00
|
|
|
kdump_install_systemd_conf
|
|
|
|
|
2019-12-03 05:02:00 +00:00
|
|
|
# nfs/ssh dump will need to get host ip in second kernel and need to call 'ip' tool, see get_host_ip for more detail
|
|
|
|
if is_nfs_dump_target || is_ssh_dump_target; then
|
|
|
|
inst "ip"
|
|
|
|
fi
|
|
|
|
|
2017-03-29 08:16:57 +00:00
|
|
|
# For the lvm type target under kdump, in /etc/lvm/lvm.conf we can
|
|
|
|
# safely replace "reserved_memory=XXXX"(default value is 8192) with
|
|
|
|
# "reserved_memory=1024" to lower memory pressure under kdump. We do
|
|
|
|
# it unconditionally here, if "/etc/lvm/lvm.conf" doesn't exist, it
|
|
|
|
# actually does nothing.
|
|
|
|
sed -i -e \
|
2021-09-13 18:25:40 +00:00
|
|
|
's/\(^[[:space:]]*reserved_memory[[:space:]]*=\)[[:space:]]*[[:digit:]]*/\1 1024/' \
|
|
|
|
"${initdir}/etc/lvm/lvm.conf" &> /dev/null
|
mkdumprd: use 300s as the default systemd unit timeout for kdump mount
Currently, systemd uses 90s as the default mount unit timeout
(see "man 5 systemd-system.conf " for "DefaultTimeoutStartSec"),
in some cases, although it works well in 1st kernel, it's not
enough under kdump and results in mount timeout, further results
in kdump dumping failure.
We've met several such issues, we decided to enlarge this default
value a little for kdump.
We know that dracut has a default initqueue timeout value of 180s
("rd.retry"), we finalized a little larger value 300s as kdump's
default timeout if there is no explicit "DefaultTimeoutStartSec=X,
specified by users.
"DefaultTimeoutStartSec=X" can be overridden by individual mount
option "x-systemd.device-timeout=X", users can specify their own
values as needed.
This patch achieves the purpose by creating a dedicated conf file
"/etc/systemd/system.conf.d/kdump.conf" which has the content of
"DefaultTimeoutStartSec=300s", this is based on the fact that all
the conf files will be parsed by systemd and the last parsed one
will be used if there are duplicate definitions.
Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2017-08-01 10:30:38 +00:00
|
|
|
|
2020-08-11 09:50:07 +00:00
|
|
|
# Save more memory by dropping switch root capability
|
2021-06-23 14:36:48 +00:00
|
|
|
dracut_no_switch_root
|
2011-08-01 09:19:24 +00:00
|
|
|
}
|