Unnamed repository
Go to file
Coiby Xu 54611cd628 Implement IP netmask calculation to replace "ipcalc -m"
Resolves: bz1947347
Upstream: Fedora
Conflict: None

commit 1ca1b71780
Author: Coiby Xu <coxu@redhat.com>
Date:   Thu Apr 8 11:44:26 2021 +0800

    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>

Signed-off-by: Coiby Xu <coxu@redhat.com>
2021-05-11 06:38:58 +00:00
tests Merged update from upstream sources 2020-11-20 12:35:49 +00:00
.gitignore RHEL 9.0.0 Alpha bootstrap 2020-10-15 14:45:57 +02:00
60-kdump.install RHEL 9.0.0 Alpha bootstrap 2020-10-15 14:45:57 +02:00
98-kexec.rules RHEL 9.0.0 Alpha bootstrap 2020-10-15 14:45:57 +02:00
98-kexec.rules.ppc64 RHEL 9.0.0 Alpha bootstrap 2020-10-15 14:45:57 +02:00
README RHEL 9.0.0 Alpha bootstrap 2020-10-15 14:45:57 +02:00
dracut-early-kdump-module-setup.sh Merged update from upstream sources 2021-01-22 08:12:00 +00:00
dracut-early-kdump.sh Merged update from upstream sources 2021-01-22 08:12:00 +00:00
dracut-kdump-capture.service RHEL 9.0.0 Alpha bootstrap 2020-10-15 14:45:57 +02:00
dracut-kdump-emergency.service RHEL 9.0.0 Alpha bootstrap 2020-10-15 14:45:57 +02:00
dracut-kdump-emergency.target RHEL 9.0.0 Alpha bootstrap 2020-10-15 14:45:57 +02:00
dracut-kdump-error-handler.service RHEL 9.0.0 Alpha bootstrap 2020-10-15 14:45:57 +02:00
dracut-kdump-error-handler.sh RHEL 9.0.0 Alpha bootstrap 2020-10-15 14:45:57 +02:00
dracut-kdump.sh Fix incorrect vmcore permissions when dumped through ssh 2021-04-20 16:29:34 +08:00
dracut-module-setup.sh Implement IP netmask calculation to replace "ipcalc -m" 2021-05-11 06:38:58 +00:00
dracut-monitor_dd_progress RHEL 9.0.0 Alpha bootstrap 2020-10-15 14:45:57 +02:00
early-kdump-howto.txt RHEL 9.0.0 Alpha bootstrap 2020-10-15 14:45:57 +02:00
fadump-howto.txt Merged update from upstream sources 2020-11-30 11:50:38 +00:00
kdump-dep-generator.sh Merged update from upstream sources 2021-01-22 08:12:00 +00:00
kdump-in-cluster-environment.txt RHEL 9.0.0 Alpha bootstrap 2020-10-15 14:45:57 +02:00
kdump-lib-initramfs.sh Fix incorrect permissions on kdump dmesg file 2021-04-20 16:29:24 +08:00
kdump-lib.sh kdump-lib.sh: introduce functions to return recommened mem size 2021-04-27 10:20:25 +08:00
kdump-logger.sh Merged update from upstream sources 2020-11-20 12:35:49 +00:00
kdump-udev-throttler RHEL 9.0.0 Alpha bootstrap 2020-10-15 14:45:57 +02:00
kdump.conf Merged update from upstream sources 2021-01-22 08:12:00 +00:00
kdump.conf.5 Merged update from upstream sources 2021-01-22 08:12:00 +00:00
kdump.service Merged update from upstream sources 2020-11-05 05:34:29 +00:00
kdump.sysconfig Merged update from upstream sources 2020-11-20 12:35:49 +00:00
kdump.sysconfig.aarch64 Merged update from upstream sources 2020-11-20 12:35:49 +00:00
kdump.sysconfig.i386 Merged update from upstream sources 2020-11-20 12:35:49 +00:00
kdump.sysconfig.ppc64 Merged update from upstream sources 2020-11-20 12:35:49 +00:00
kdump.sysconfig.ppc64le Merged update from upstream sources 2020-11-20 12:35:49 +00:00
kdump.sysconfig.s390x Merged update from upstream sources 2020-11-20 12:35:49 +00:00
kdump.sysconfig.x86_64 Merged update from upstream sources 2020-11-20 12:35:49 +00:00
kdumpctl Merged update from upstream sources 2021-01-22 08:12:00 +00:00
kdumpctl.8 RHEL 9.0.0 Alpha bootstrap 2020-10-15 14:45:57 +02:00
kexec-kdump-howto.txt Merged update from upstream sources 2021-01-22 08:12:00 +00:00
kexec-tools-2.0.20-Remove-duplicated-variable-declarations.patch RHEL 9.0.0 Alpha bootstrap 2020-10-15 14:45:57 +02:00
kexec-tools-2.0.20-eppic-Remove-duplicated-variable-declaration.patch RHEL 9.0.0 Alpha bootstrap 2020-10-15 14:45:57 +02:00
kexec-tools-2.0.20-makedumpfile-printk-add-support-for-lockless-ringbuffer.patch Merged update from upstream sources 2020-12-23 10:00:07 +00:00
kexec-tools-2.0.20-makedumpfile-printk-use-committed-finalized-state-value.patch Merged update from upstream sources 2020-12-23 10:00:07 +00:00
kexec-tools-2.0.21-makedumpfile-make-use-of-uts_namespace.name-offset-in-VMCOR.patch Merged update from upstream sources 2021-01-08 13:46:38 +00:00
kexec-tools.spec Release 2.0.21-7 2021-04-25 14:52:55 +08:00
live-image-kdump-howto.txt RHEL 9.0.0 Alpha bootstrap 2020-10-15 14:45:57 +02:00
mkdumprd Merged update from upstream sources 2021-01-22 08:12:00 +00:00
mkdumprd.8 Merged update from upstream sources 2020-12-23 10:00:07 +00:00
sources Merged update from upstream sources 2020-12-23 10:00:07 +00:00
zanata-notes.txt RHEL 9.0.0 Alpha bootstrap 2020-10-15 14:45:57 +02:00

README

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