naccyde / rpms / systemd

Forked from rpms/systemd a year ago
Clone
Petr Šabata d9a596
#!/bin/bash
Petr Šabata d9a596
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
Petr Šabata d9a596
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Petr Šabata d9a596
#
Petr Šabata d9a596
#   runtest.sh of /CoreOS/iproute/Sanity/ip-rule-sanity-test
Petr Šabata d9a596
#   Description: Test basic ip rule funcionality
Petr Šabata d9a596
#   Author: Jaroslav Aster <jaster@redhat.com>
Petr Šabata d9a596
#
Petr Šabata d9a596
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Petr Šabata d9a596
#
Petr Šabata d9a596
#   Copyright (c) 2014 Red Hat, Inc. All rights reserved.
Petr Šabata d9a596
#
Petr Šabata d9a596
#   This copyrighted material is made available to anyone wishing
Petr Šabata d9a596
#   to use, modify, copy, or redistribute it subject to the terms
Petr Šabata d9a596
#   and conditions of the GNU General Public License version 2.
Petr Šabata d9a596
#
Petr Šabata d9a596
#   This program is distributed in the hope that it will be
Petr Šabata d9a596
#   useful, but WITHOUT ANY WARRANTY; without even the implied
Petr Šabata d9a596
#   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
Petr Šabata d9a596
#   PURPOSE. See the GNU General Public License for more details.
Petr Šabata d9a596
#
Petr Šabata d9a596
#   You should have received a copy of the GNU General Public
Petr Šabata d9a596
#   License along with this program; if not, write to the Free
Petr Šabata d9a596
#   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Petr Šabata d9a596
#   Boston, MA 02110-1301, USA.
Petr Šabata d9a596
#
Petr Šabata d9a596
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Petr Šabata d9a596
Petr Šabata d9a596
# Include Beaker environment
Petr Šabata d9a596
. /usr/bin/rhts-environment.sh || exit 1
Petr Šabata d9a596
. /usr/share/beakerlib/beakerlib.sh || exit 1
Petr Šabata d9a596
Petr Šabata d9a596
PACKAGE="iproute"
Petr Šabata d9a596
DEFAULT_IFACE="$(ip route show | grep default | sed 's/.*dev \([^ ]\+\) .*/\1/' | head -n 1)"
Petr Šabata d9a596
rlIsRHEL '>=7' && IP_RULE_MANPAGE="ip-rule" || IP_RULE_MANPAGE="ip"
Petr Šabata d9a596
Petr Šabata d9a596
Petr Šabata d9a596
rlJournalStart
Petr Šabata d9a596
    rlPhaseStartSetup
Petr Šabata d9a596
        rlCheckRpm "$PACKAGE"
Petr Šabata d9a596
    rlPhaseEnd
Petr Šabata d9a596
Petr Šabata d9a596
    rlPhaseStartTest "Basic sanity test"
Petr Šabata d9a596
        rlRun "ip rule list"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip rule add from 172.29.0.0/24 to 172.29.1.0/24 table 1110"
Petr Šabata d9a596
        rlRun "ip rule add not from 172.29.0.0/24 to 172.29.1.0/24 table 1111"
Petr Šabata d9a596
        rlRun "ip -6 rule add from 2404:6800:4003:801::1015/32 to 2404:6800:4003:801::1014/32 table 1111"
Petr Šabata d9a596
        rlIsRHEL '>=7' && rlRun "ip rule add oif ${DEFAULT_IFACE} table 1111"
Petr Šabata d9a596
        rlRun "ip rule add iif ${DEFAULT_IFACE} tos 10 table 1112"
Petr Šabata d9a596
        rlRun "ip rule add fwmark 123 pref 100 table 1112"
Petr Šabata d9a596
        rlRun "ip rule add not fwmark 124 pref 101 unreachable"
Petr Šabata d9a596
        rlRun "ip rule add fwmark 125 pref 102 prohibit"
Petr Šabata d9a596
        rlRun "ip rule add fwmark 126 pref 103 unicast"
Petr Šabata d9a596
        rlRun "ip rule add from 172.29.2.0/24 tos 10 blackhole"
Petr Šabata d9a596
        rlRun "ip rule add from 172.29.0.0/24 tos 6 prio 99 goto 103"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip rule list"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip rule list | grep 'from 172.29.0.0/24 to 172.29.1.0/24'"
Petr Šabata d9a596
        rlRun "ip rule list | grep 'not from 172.29.0.0/24 to 172.29.1.0/24'"
Petr Šabata d9a596
        rlRun "ip -6 rule list | grep 'from 2404:6800:4003:801::1015/32 to 2404:6800:4003:801::1014/32'"
Petr Šabata d9a596
        rlIsRHEL '>=7' && rlRun "ip rule list | grep 'oif ${DEFAULT_IFACE}'"
Petr Šabata d9a596
        ! rlIsFedora && rlRun "ip rule list | grep 'tos lowdelay iif ${DEFAULT_IFACE}'"
Petr Šabata d9a596
        rlRun "ip rule list | grep 'from all fwmark 0x7b'"
Petr Šabata d9a596
        rlRun "ip rule list | grep 'not from all fwmark 0x7c unreachable'"
Petr Šabata d9a596
        rlRun "ip rule list | grep 'from all fwmark 0x7d prohibit'"
Petr Šabata d9a596
        rlRun "ip rule list | grep 'from all fwmark 0x7e'"
Petr Šabata d9a596
        ! rlIsFedora && rlRun "ip rule list | grep 'from 172.29.2.0/24 tos lowdelay blackhole'"
Petr Šabata d9a596
        rlRun "ip rule list | grep 'from 172.29.0.0/24 tos 0x06 goto 103'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip rule list"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip rule del from 172.29.0.0/24 to 172.29.1.0/24"
Petr Šabata d9a596
        rlRun "ip rule del not from 172.29.0.0/24 to 172.29.1.0/24"
Petr Šabata d9a596
        rlRun "ip -6 rule del from 2404:6800:4003:801::1015/32 to 2404:6800:4003:801::1014/32"
Petr Šabata d9a596
        rlIsRHEL '>=7' && rlRun "ip rule del oif ${DEFAULT_IFACE}"
Petr Šabata d9a596
        ! rlIsFedora && rlRun "ip rule del iif ${DEFAULT_IFACE} tos lowdelay"
Petr Šabata d9a596
        rlRun "ip rule del fwmark 123 pref 100"
Petr Šabata d9a596
        rlRun "ip rule del not fwmark 124 pref 101 unreachable"
Petr Šabata d9a596
        rlRun "ip rule del fwmark 125 pref 102 prohibit"
Petr Šabata d9a596
        rlRun "ip rule del fwmark 126 pref 103 unicast"
Petr Šabata d9a596
        rlRun "ip rule del from 172.29.2.0/24 tos 10 blackhole"
Petr Šabata d9a596
        rlRun "ip rule del from 172.29.0.0/24 tos 6 prio 99 goto 103"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip rule list"
Petr Šabata d9a596
    rlPhaseEnd
Petr Šabata d9a596
Petr Šabata d9a596
    if rlIsRHEL '>=7'; then
Petr Šabata d9a596
        rlPhaseStartTest
Petr Šabata d9a596
            saved_rule=$(ip rule list | grep '^0' | cut -d : -f 2 | head -n 1)
Petr Šabata d9a596
            rlRun "ip rule del prio 0" 0 "Removing rule with prio 0."
Petr Šabata d9a596
            rlRun "ip rule add prio 0 ${saved_rule}" 0 "Re-creating rule with prio 0."
Petr Šabata d9a596
            rlRun "man ${IP_RULE_MANPAGE} | col -b | grep 'Rule 0 is special. It cannot be deleted or overridden.'" 1
Petr Šabata d9a596
        rlPhaseEnd
Petr Šabata d9a596
    fi
Petr Šabata d9a596
Petr Šabata d9a596
    rlPhaseStartTest
Petr Šabata d9a596
        rlRun "man ${IP_RULE_MANPAGE} | col -b | grep 'reject'" 1
Petr Šabata d9a596
        rlRun "ip rule help 2>&1 | grep 'reject'" 1
Petr Šabata d9a596
    rlPhaseEnd
Petr Šabata d9a596
Petr Šabata d9a596
    rlPhaseStartCleanup
Petr Šabata d9a596
    rlPhaseEnd
Petr Šabata d9a596
Petr Šabata d9a596
    rlJournalPrintText
Petr Šabata d9a596
rlJournalEnd