Commit Graph

168 Commits

Author SHA1 Message Date
Kairui Song
8d0ef743e0 Revert "get kdump ifname once in kdump_install_net"
This reverts commit afda4f4961.
2021-04-28 15:18:53 +08:00
Kairui Song
b0156e9b64 Revert "pass kdumpnic to kdump_setup_/bond/bridge/vlan directly"
This reverts commit 586d767697.
2021-04-28 15:18:53 +08:00
Kairui Song
4753ab2c70 Revert "rd.route should use the name from kdump_setup_ifname"
This reverts commit 18ffd3cb17.
2021-04-28 15:18:53 +08:00
Coiby Xu
18ffd3cb17 rd.route should use the name from kdump_setup_ifname
This fix 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/40network/net-lib.sh will write /tmp/net.route.eth0 based on rd.route
    - dracut/modules.d/45ifcfg/write-ifcfg.sh will copy /tmp/net.route.eth0 to /tmp/icfg and then copytree /tmp/ifcfg to /run/initramfs/state/etc/sysconfig/network-scripts
 3. 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-04-25 16:56:32 +08:00
Coiby Xu
586d767697 pass kdumpnic to kdump_setup_/bond/bridge/vlan directly
This avoids calling kdump_setup_ifname repeatedly.

Signed-off-by: Coiby Xu <coxu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com
2021-04-25 16:52:29 +08:00
Coiby Xu
afda4f4961 get kdump ifname once in kdump_install_net
Signed-off-by: Coiby Xu <coxu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com
2021-04-25 16:52:21 +08:00
Coiby Xu
1ca1b71780 Implement IP netmask calculation to replace "ipcalc -m"
Recently, dracut-network drops depedency on dhcp-client which requires
ipcalc. Thus the dependency chain
"kexec-tools -> dracut-network -> dhcp-client -> ipcalc"
is broken. When NIC is configured to a static IP, kexec-tools depended
on "ipcalc -m" to get netmask. This commit implements the shell
equivalent of "ipcalc -m".

The following test code shows cal_netmask_by_prefix is consistent with
"ipcalc -m",

    #!/bin/bash
    . dracut-module-setup.sh

    for i in {0..128}; do
        mask_expected=$(ipcalc -m fe::/$i| cut -d"=" -f2)
        mask_actual=$(cal_netmask_by_prefix $i "-6")
        if [[ "$mask_expected" != "$mask_actual" ]]; then
            echo "prefix="$i, "expected="$mask_expected, "acutal="$mask_actual
            exit
        fi
    done

    echo "IPv6 tests passed"

    for i in {0..32}; do
        mask_expected=$(ipcalc -m 8.8.8.8/$i| cut -d"=" -f2)
        mask_actual=$(cal_netmask_by_prefix $i "")
        if [[ "$mask_expected" != "$mask_actual" ]]; then
            echo "prefix="$i, "expected="$mask_expected, "acutal="$mask_actual
            exit
        fi
    done

    echo "IPv4 tests passed"

    i=-2
    res=$(cal_netmask_by_prefix "$i" "")
    if [[ $? -ne 1 ]]; then
        echo "cal_netmask_by_prefix should exit when prefix<0"
        exit
    fi

    res=$(cal_netmask_by_prefix "$i" "")
    if [[ $? -ne 1 ]]; then
        echo "cal_netmask_by_prefix should exit when prefix<0"
        exit
    fi

    i=33
    $(cal_netmask_by_prefix $i "")
    if [[ $? -ne 1 ]]; then
        echo "cal_netmask_by_prefix should exit when prefix>32 for IPv4"
        exit
    fi

    i=129
    $(cal_netmask_by_prefix $i "-6")
    if [[ $? -ne 1 ]]; then
        echo "cal_netmask_by_prefix should exit when prefix>128 for IPv4"
        exit
    fi

    echo "Bad prefixes tests passed"

    echo "All tests passed"

Reported-by: Jie Li <jieli@redhat.com>
Signed-off-by: Coiby Xu <coxu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2021-04-16 18:51:34 +08:00
Coiby Xu
8b4b7bf808 Don't use die in dracut-module-setup.sh
die (in dracut-lib.sh) is supposed to be used in the initramfs environment.

Signed-off-by: Coiby Xu <coxu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2021-04-16 18:02:32 +08:00
Kairui Song
c6021648f1 Don't iterate the whole /sys/devices just to find drm device
On some large systems, /sys/devices is huge and it's not a wise idea to
iterate it. `find` may cause tremendous contention on the kernfs_mutex
when there are already stress on /sys, and it will perform very very
poorly.

Simply check if drm class presents should be good enough.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2021-04-16 17:47:27 +08:00
Tao Liu
91c802ff52 Fix incorrect permissions on kdump dmesg file
Also known as CVE-2021-20269. The kdump dmesg log files(kexec-dmesg.log,
vmcore-dmesg.txt) are generated by shell redirection, which take the
default umask value, making the files readable for group and others.

This patch chmod these files, making them only accessible to owner.

Signed-off-by: Tao Liu <ltao@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2021-03-23 16:39:18 +08:00
Pingfan Liu
24bbe9c05e dracut-module-setup.sh: enable ForwardToConsole=yes in fadump mode
In fadump mode, it is also useful to observe kdump message through
console. Hence enable it.

Signed-off-by: Pingfan Liu <piliu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2021-01-22 14:16:17 +08:00
Kairui Song
88f787e1f5 module-setup.sh: don't polute the namespace unnecessarily
Only source kdump libs when building a kdump initramfs.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2021-01-20 14:14:08 +08:00
Kairui Song
d49a5015d8 module-setup.sh: don't source $dracutfunctions
There is no need to source the file manually, dracut will always
prepare the dracut lib before calling a module-setup.sh

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2021-01-20 14:14:03 +08:00
Kairui Song
24c6b3027f Merge #4 Make dracut-squash a weak dep 2021-01-10 19:18:23 +00:00
Kairui Song
fa9797ec9d dracut-module-setup.sh: Use systemctl call to replace ln_r
systemctl -q --root "$initdir" add-wants X.target X.service is the
recommanded way to add service dependency, and it covers more corner
cases.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-12-15 10:13:08 +08:00
Pingfan Liu
eaf0e813a2 dracut-module-setup.sh: use auto6 for ipv6
The parameter either6 is introduced to dracut by
commit 67354eebbcd4c358b8194ba5fd1ab1cf7dbd42aa
Author: Pingfan Liu <piliu@redhat.com>
Date:   Tue Apr 24 16:41:21 2018 +0800

    40network: introduce ip=either6 option

But it turns out needless.

On a sensible ipv6 network environment, DHCPv6 can not work properly alone,
because DHCPv6 protocol has no info about the gateway.

An reasonalbe process of ipv6 address set up should look like
   host send: Router Solicitation
   router reply: Router Advertisements

"Router Advertisements" carries many info like gateway, and if it has
other-config flag set, it carries DNS info etc.  As for DHCPv6 address
allocation, it will only start if "Router Advertisements" has the 'managed'
flag set, which directs the host to start a stateful address allocation
from DHCPv6 server.

For more info:
rfc4861: Neighbor Discovery for IP version 6 (IPv6)
rfc5175: IPv6 Router Advertisement Flags Option

Signed-off-by: Pingfan Liu <piliu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2020-12-07 14:59:57 +08:00
Pingfan Liu
6f9235887f module-setup.sh: enable vlan on team interface
Dracut has switch network-legacy to network-manager by default, which makes
vlan on team easy. So it can be enabled.

Testing network topology with two VMs.
VM1
            ens2-\         /----> VLAN8 (192.168.120.50)
                  ---> team0
            ens3-/     (192.168.122.10)

VM2
            ens2-\         /----> VLAN8 (192.168.120.100)
                  ---> team0
            ens3-/      (192.168.122.20)

Both of ens2/ens3 in VM1/VM2 are connected to virbr0.

During test, dump target is set as root@192.168.120.100:/var/crash
then crashing in VM1

Signed-off-by: Pingfan Liu <piliu@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-11-30 15:27:00 +08:00
Lianbo Jiang
e345ed18e2 Add the rd.kdumploglvl option to control log level in the second kernel
Let's add the rd.kdumploglvl option to control log level in the second
kernel, which can make us avoid rebuilding the kdump initramfs after we
change the log level in /etc/sysconfig/kdump.

Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2020-11-13 02:43:49 +08:00
Kairui Song
69bf81bc8b Move watchdog detect and install code to module-setup.sh
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-11-12 14:03:40 +08:00
Kairui Song
bc639c9763 Add a helper to omit non-mandatory dracut module
Use dracut_args to omit some non-mandatory modules.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-11-12 14:03:35 +08:00
Kairui Song
08de712528 Move some dracut module dependencies checks to module-setup.sh
depend() in module-setup.sh is a better place to setup dracut module
dependency, it will do early check, and fail early if needed module is
missing. Also remove a unneeded helper add_dracut_module.

Also remove the unnecessary return in depend() function.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-11-12 14:03:19 +08:00
Jonathan Lebon
c9a0df1ccb Make dracut-squash a weak dep
The dracut module is opportunistic about using the built-in squashfs
support only when available, but the spec file hard requires it. Demote
it to a weak dep to truly make it optional.

This caters to environments which strive to stay minimal, like FCOS and
RHCOS. See https://github.com/coreos/fedora-coreos-config/pull/708 for
details.
2020-10-28 16:36:05 -04:00
Kairui Song
46cc7f46b2 module-setup.sh: Instead of drop journalctl log, just don't read kmsg
Previously journalctl logs are directly dropped to save memory, but this
make journalctl unusable in kdump kernel and diffcult to debug. So
instead just don't let it read kmsg but keep other logs stored as volatile.

Kernel message are already stored in the kernel log ring buffer,
no need to let journalctl make a copy, especially when in kdump
kernel, ususlly there won't be too much kernel log overlapping
the old ring buffer.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-10-27 17:34:15 +08:00
Lianbo Jiang
d7054f4cd8 Improve debugging in the kdump kernel
Let's use the logger in the second kernel and collect the kernel ring
buffer(dmesg) of the second kernel.

Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2020-10-27 17:34:07 +08:00
Kairui Song
041ba89902 Don't drop journalctl content if failure action is "shell"
If failure action is set to "shell", user will need more debug info
available in kdump kernel. Especially when serial console is not
available, manually retrieve the log from journalctl is very useful
for debugging kdump issue.

Else, we can still drop journalctl content to save memory assuming
nothing will use it.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-09-17 10:43:07 +08:00
Kairui Song
bcaa4358b1 dracut-module-install: Move systemd conf install code to a function
No feature change.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-09-17 10:43:07 +08:00
Pingfan Liu
bdbddbff73 module-setup.sh: suppress false alarm
Even if the directory "/etc/kdump/pre.d/" is empty, the following false
alarm can be observed during building kdump.initrd:
  "/etc/kdump/pre.d/* is not executable"

Suppress it.

Signed-off-by: Pingfan Liu <piliu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2020-07-20 16:17:53 +08:00
Kairui Song
a29de38da5 Always wrap up call to dracut get_persistent_dev function
Dracut get_persistent_dev function don't recognize UUID= or LABEL=
format, so caller should conver it to the path to the block device
before calling it. There is already such a helper
"kdump_get_persistent_dev", just move it to kdump-lib.sh and rename
it to reuse it,

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2020-06-22 19:58:08 +08:00
onitsuka.shinic@fujitsu.com
4246f26725 dracut-module-setup.sh: Install files under /etc/kdump/{pre.d,post.d} into kdump initramfs
This patch installs the binary and script files under /etc/kdump/{pre.d,post.d}
into new initramfs of kdump.

Signed-off-by: Shinichi Onitsuka <onitsuka.shinic@fujitsu.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-06-11 12:58:48 +08:00
Kairui Song
e05c550144 Drop switch root capability for non fadump initramfs
Switch root is never used for kdump image, and this will be helpful to
reduce the initramfs size.

Also increase dracut dependency version and the function is
dracut_no_switch_root is new introduced.

This commit is applied to RHEL some time ago, but missing in Fedora as
Fedora's Dracut didn't backport this feature at that time. Now apply
this missing commit.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-06-10 22:37:34 +08:00
Kairui Song
0cc3b85d0d module-setup.sh: Add "rd.neednet" parameter if network is needed
Upstream dracut now use network-manager module by default and since
upstream commit 3dcaa97, network-manager expects user to pass "rd.neednet"
to indicate network is required.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2020-05-28 16:26:06 +08:00
Kairui Song
cfd93e2b7e Revert "Add a hook to wait for kdump target in initqueue"
This reverts commit cee618593c.

Upstream dracut have provided a parameter for adding mandantory network
requirement by appending "rd.neednet" parameter, so we should use that
instead.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2020-05-28 16:26:00 +08:00
Lianbo Jiang
ce0305d4f9 Add a new option 'rd.znet_ifname' in order to use it in udev rules
In most cases, it always provides a persistent MAC address. But for
the s390 Arch, sometimes, kernel could run in the LPAR mode and it
doesn't provide a persistent MAC address, which caused the kdump
failure.

Currently, some rules rely on the persistent MAC address, for the
above case, which won't work in kdump kernel because non-persistent
MAC could not match with udev rules.

To fix this issue, need to add a new option 'rd.znet_ifname' in order
to provide extra parameters such as 'ifname' and 'subchannels' for
some rules, which ensures kdump can also work appropriately without
the persistent MAC. Please refer to the following commit in dracut:

872eb69936bd ("95znet: Add a rd.znet_ifname= option")

Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2020-04-27 18:21:22 +08:00
Pingfan Liu
f33f30eb61 dracut-module-setup.sh: fix breakage in get_pcs_fence_kdump_nodes()
pcs cluster and cluster cib-upgrade may throw some information and disturb
the parsing. Mute them

Signed-off-by: Pingfan Liu <piliu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2020-04-20 11:24:46 +08:00
Pingfan Liu
6348398743 dracut-module-setup.sh: ensure cluster info is ready before query
There is a race issue between "pcs" and "kdumpctl restart"

-1. set up cluster
 # pcs cluster setup --start mycluster node1 node2
 # pcs stonith create kdump fence_kdump pcmk_reboot_action="off"
 # pcs stonith level add 1 node1 kdump
 # pcs stonith level add 1 node2 kdump

-2. Then here comes the command _immediately_ in kdumpctl
 # pcs cluster cib

But due to some pcs internal mechanism, "pcs cluster cib" can not
fetch the updated info in time.

Fix these issue by forcing the upgrade of cib.

Signed-off-by: Pingfan Liu <piliu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2020-04-08 15:46:06 +08:00
Kairui Song
3b09c4910d Remove adjust_bind_mount_path call
If user configured target is used, path should be used as the absolute
path within the dump target direct, and user should be fully aware of
the path structure within the target device. The adjust_bind_mount_path
call here make it very hard to control the behavior.

Especially, if it's a cross device bind mount, this will likely create a
invalid path in the target. And for atomic case, adjust_bind_mount_path call
here assumes user will always pass root device as the explicitly configured
dump target, which is not true.

If user configured target device is used, the path is always be the
absolute path inside of given target. If user don't know about the path
structure in the target device, then user should either use the path
based config, or carefully exam the target device before using it as a
dump target.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-03-30 22:06:46 +08:00
Kairui Song
bde4b7af3b No longer treat atomic/silverblue specially
This commit remove almost all special workaround for atomic, and treat
all bind mounts in any environment equally.

Use a helper get_bind_mount_directory_from_path to get the bind mount
source path of given path.

is_atomic function now only used to determine the right /boot path
for atomic/silverblue environment.

And remove get_mntpoint_from_path(), it's the only function that never
ignore bind mount, and it have no caller after this clean up.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-03-30 22:06:37 +08:00
Pingfan Liu
3be5f74df0 dracut-module-setup.sh: improve get_alias()
In /etc/hosts, the alias name can come at the 2nd column, regardless of the
recommendation.

E.g. the following format is valid although not recommended
cat /etc/hosts
        127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
        ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
        192.168.22.21	fastvm-rhel-7-6-21	fastvm-rhel-7-6-21.localdomain
        192.168.22.22	fastvm-rhel-7-6-22	fastvm-rhel-7-6-22.localdomain

        192.168.22.21   node1_hb
        192.168.22.22   node2_hb

So filtering out both 2nd and 3rd column for matching.

Signed-off-by: Pingfan Liu <piliu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2020-03-24 15:36:26 +08:00
Kairui Song
424ac0bf80 Fix a potential syntax error
Process substitution is not POSIX standard syntax, so if bash is configured
to strictly follow POSIC, this will fail.

Just use a POSIX friendly syntax instead.

Fixes: bz1708321

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-03-23 10:26:20 +08:00
Kairui Song
e78639b46f Use read_strip_comments to filter the installed kdump.conf
This help remove redundant spaces and tailing comment in installed
kdump.conf, currently installed kdump.conf always contain extra empty
lines.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-03-23 10:26:08 +08:00
Kairui Song
c9c50f9a36 dracut-module-setup.sh: Ensure initrd.target.wants dir exists
Latest dracut release stopped creating
$systemdsystemunitdir/initrd.target.wants dir for us, so ensure it
exists before creating the symlink.

Signed-off-by: Kairui Song <kasong@redhat.com>
Tested-and-Reviewed-by: Bhupesh Sharma <bhsharma@redhat.com>
2020-03-18 15:10:59 +08:00
Bhupesh Sharma
a01270b64e kexec-tools/module-setup: Ensure eth devices get IP address for VLAN
Currently while trying to save vmcore via vlan eth interface, the Kdump
kernel fails with network unreachable message.

This is because mkdumprd produces a vlan config that does not get
ip address for vlan on eth device.

Fix the same via this patch.

Signed-off-by: Bhupesh Sharma <bhsharma@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2020-02-13 14:13:59 +08:00
Kairui Song
cee618593c Add a hook to wait for kdump target in initqueue
The dracut initqueue may quit immediately and won't trigger any hook if
there is no "finished" hook still pending (finished hook will be deleted
once it return 0).

This issue start to appear with latest dracut, latest dracut use
network-manager to configure the network,
network-manager module only install "settled" hook, and we didn't
install any other hook. So NFS/SSH dump will fail. iSCSI dump works
because dracut iscsi module will install a "finished" hook to detect if
the iscsi target is up.

So for NFS/SSH we keep initqueue running until the host successfully get
a valid IP address, which means the network is ready.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-01-29 08:12:45 +08:00
Kairui Song
24b00298d0 Always install sed and awk
sed and awk is heavily used everywhere in the code, but it's not
explicitely installed by kdump dracut module. If the module in dracut
stop installing them (which already happened with latest dracut
upstream), kdump will break.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-01-03 16:35:19 +08:00
Kairui Song
bcdcf35759 Fix potential ssh/nfs kdump failure of missing "ip" command
For ssh/nfs dump, kdump need the 'ip' tool to get the host ip address
for naming the vmcore. But kdump-module-setup.sh never installed this
tool. kdump-module-setup.sh worked so far as dracut network module will
help install it.

After dracut changed to use 35network-manager for network setup, "ip"
command won't be installed in second kernel by default. So need to
ensure "ip" is installed when installing kdump dracut module.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-01-03 16:35:15 +08:00
Kairui Song
03111c797b Always use get_save_path to get the 'path' option
This help deduplicate the code. Use a single function instead of
repeat the same logic.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-01-03 16:35:07 +08:00
Kairui Song
5633e83318 Always set vm.zone_reclaim_mode = 3 in kdump kernel
By default kernel have vm.zone_reclaim_mode = 0 and large page
allocation might fail as kernel is very conservative on memory
reclaiming. If the page allocation failure is not handled carefully
it could lead to more serious problems.

This issue can be reproduced by change with following steps:

- Fill up page cache use:
  # dd if=/dev/urandom of=/test bs=1M count=1300

- Now the memory is filled with write cache:
  # free -m
                total        used        free      shared  buff/cache   available
  Mem:           1790         184         132           2        1473        1348
  Swap:          2119           7        2112

- Insert a module which simply calls "kmalloc(SZ_1M, GFP_KERNEL)" for
  512 times: (Notice: vmalloc don't have such problem)
  # insmod debug_module.ko

- Got following allocation failure:
  insmod: page allocation failure: order:8, mode:0x40cc0(GFP_KERNEL|__GFP_COMP), nodemask=(null),cpuset=/,mems_allowed=0

- Clean up and repeat again with vm.zone_reclaim_mode = 3, OOM is not
  observed.

In kdump kernel there is usually only one online CPU and limited memory,
so we set vm.zone_reclaim_mode = 3 to let kernel reclaim memory more
aggresively to avoid such issue.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2019-11-13 11:35:46 +08:00
Kairui Song
5e76e53a70 module-setup.sh: Simplify the network setup code
Merge kdump_setup_netdev into kdump_install_net.

kdump_install_net is a wrapper of calling kdump_setup_netdev, and
it do following three extra things:

  1. Sanitize and resolve the hostname
  2. Resolve the route to the destination
  3. Set the default gateway for once

There is currently only one caller of kdump_setup_netdev, the iscsi
network setup code, and it's doing 1 and 2 by itself. And there should
only be one default gateway in kdump enviroment, so applying 3 here is
fine.

And the comment of kdump_install_net is wrong and obsoleted, update the
comment too.

Just merge kdump_setup_netdev into kdump_install_net and always use
kdump_install_net instead.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2019-10-24 17:00:02 +08:00
Pingfan Liu
882b920c2f module-setup: re-fix 99kdumpbase network dependency
In commit a431a7e354 (module-setup: fix 99kdumpbase network dependency),
the statement for OR operation is still wrong.

The OR condition statement should be:  if a || b

Signed-off-by: Pingfan Liu <piliu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2019-10-22 16:09:43 +08:00
Kairui Song
75297d6f20 dracut-module-setup: fix bond ifcfg processing
Bond options in ifcfg is space separated, dracut expected it to be comma
separated, so it have to be parsed and converted during initramfs
building.

The currently parsing and convert pattern is flawed, for example:
" downdelay=0 miimon=100 mode=802.3ad updelay=0 "

is converted to :
":,downdelay=0 miimon=100 mode=802.3ad updelay=0 "

should be:
":downdelay=0,miimon=100,mode=802.3ad,updelay=0"

So fix this issue by using more simple but robust method for processing
the options.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2019-09-02 17:05:43 +08:00