Unnamed repository
Go to file
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
tests selftest: replace qemu-kvm with one based on dracut's run-qemu 2021-03-24 15:51:02 +08:00
.gitignore .gitignore: Update to make it more generic 2016-05-16 10:15:01 +08:00
60-kdump.install Add a kernel install hook to clean up kdump initramfs 2020-08-27 11:22:03 +08:00
98-kexec.rules Make udev reload rules quiet during bootup 2018-12-06 17:44:03 +08:00
98-kexec.rules.ppc64 Stop reloading kdump service on CPU hotplug event for FADump 2021-03-10 16:24:42 +08:00
dracut-early-kdump-module-setup.sh module-setup.sh: don't polute the namespace unnecessarily 2021-01-20 14:14:08 +08:00
dracut-early-kdump.sh logger: source the logger file individually 2021-01-20 14:13:44 +08:00
dracut-kdump-capture.service dracut-kdump-capture.service: Use OnFailureJobMode instead of deprecated OnFailureIsolate 2019-06-14 09:44:09 +08:00
dracut-kdump-emergency.service kdump-emergency: fix "Transaction is destructive" emergency failure 2017-03-31 11:54:30 +08:00
dracut-kdump-emergency.target kdump-emergency: fix "Transaction is destructive" emergency failure 2017-03-31 11:54:30 +08:00
dracut-kdump-error-handler.service kdump-error-handler.service: Remove ExecStopPost 2019-11-28 17:46:00 +08:00
dracut-kdump-error-handler.sh Add failure_action as alias of default and make default obsolete 2019-01-22 17:57:53 +08:00
dracut-kdump.sh Fix incorrect vmcore permissions when dumped through ssh 2021-03-23 16:10:43 +08:00
dracut-module-setup.sh Implement IP netmask calculation to replace "ipcalc -m" 2021-04-16 18:51:34 +08:00
dracut-monitor_dd_progress monitor-dd-progress fix 2013-06-25 16:45:59 +08:00
early-kdump-howto.txt Improves the early-kdump-howto.txt document in several points: 2020-03-12 23:31:34 +08:00
fadump-howto.txt fadump: improve fadump-howto.txt about remote dump target setup 2021-02-23 16:18:54 +08:00
kdump-dep-generator.sh logger: source the logger file individually 2021-01-20 14:13:44 +08:00
kdump-in-cluster-environment.txt Add fence_kdump support for generic clusters 2014-04-03 14:43:06 +08:00
kdump-lib-initramfs.sh Fix incorrect permissions on kdump dmesg file 2021-03-23 16:39:18 +08:00
kdump-lib.sh kdumpctl: enable secure boot on ppc64le LPARs 2021-02-23 09:45:54 +08:00
kdump-logger.sh Capitalize the configuration name of log level 2020-11-13 02:49:35 +08:00
kdump-udev-throttler Make udev reload rules quiet during bootup 2018-12-06 17:44:03 +08:00
kdump.conf kdump.conf: add ipv6 example for nfs and ssh dump 2021-01-21 15:36:27 +08:00
kdump.conf.5 kdump.conf: Update doc about core_collector for ssh target 2021-01-12 16:12:32 +08:00
kdump.service kdump.service: use ConditionKernelCommandLine=crashkernel 2020-10-27 12:22:36 -04:00
kdump.sysconfig Update the kdump sysconfig 2020-11-13 02:49:56 +08:00
kdump.sysconfig.aarch64 Update the kdump sysconfig 2020-11-13 02:49:56 +08:00
kdump.sysconfig.i386 Update the kdump sysconfig 2020-11-13 02:49:56 +08:00
kdump.sysconfig.ppc64 Update the kdump sysconfig 2020-11-13 02:49:56 +08:00
kdump.sysconfig.ppc64le Update the kdump sysconfig 2020-11-13 02:49:56 +08:00
kdump.sysconfig.s390x Update the kdump sysconfig 2020-11-13 02:49:56 +08:00
kdump.sysconfig.x86_64 Update the kdump sysconfig 2020-11-13 02:49:56 +08:00
kdumpctl kdumpctl: enable secure boot on ppc64le LPARs 2021-02-23 09:45:54 +08:00
kdumpctl.8 Update man page for new kdumpctl command: reload / rebuild 2019-04-05 02:02:58 +08:00
kexec-kdump-howto.txt Doc: Improve the kdump sysconfig document 2021-01-12 16:46:44 +08:00
kexec-tools-2.0.20-makedumpfile-printk-add-support-for-lockless-ringbuffer.patch makedumpfile: printk: add support for lockless ringbuffer 2020-12-23 17:26:11 +08:00
kexec-tools-2.0.20-makedumpfile-printk-use-committed-finalized-state-value.patch makedumpfile: printk: use committed/finalized state values 2020-12-23 17:27:10 +08:00
kexec-tools-2.0.20-Remove-duplicated-variable-declarations.patch Fix builing failure on Fedora 32 2020-01-29 14:43:47 +08:00
kexec-tools-2.0.21-makedumpfile-make-use-of-uts_namespace.name-offset-in-VMCOR.patch makedumpfile: make use of 'uts_namespace.name' offset in VMCOREINFO 2021-01-08 11:05:05 +08:00
kexec-tools.spec Release 2.0.21-8 2021-04-05 02:33:21 +08:00
live-image-kdump-howto.txt Revert "kdumpctl: filter 'root' kernel parameter when running in live images" 2017-04-11 16:03:12 +08:00
mkdumprd mkdumprd: prompt the user to install nfs-utils when mounting NFS fs failed 2021-03-24 15:34:37 +08:00
mkdumprd.8 Doc: improve mkdumprd man page 2020-12-11 14:05:08 +08:00
README README: Add a README file 2014-04-02 10:45:36 +08:00
sources Release 2.0.21-8 2021-04-05 02:33:21 +08:00
zanata-notes.txt Add a notes for zanata process 2012-12-05 01:23:09 -05:00

Adding a patch to kexec-tools
=============================
There is a mailing list kexec@lists.fedoraproject.org where all the dicussion
related to fedora kexec-tools happen. All the patches are posted there for
inclusion and committed to kexec-tools after review.

So if you want your patches to be included in fedora kexec-tools package,
post these to kexec@lists.fedoraproject.org.

One can subscribe to list and browse through archives here.

https://admin.fedoraproject.org/mailman/listinfo/kexec