This is the 1st commit message:

Adding tests

CoreOS/libpcap/Regression/bz1025841-Unable-to-filter-packets-by-VLAN-tag
CoreOS/libpcap/Regression/bz1427251-tcpdump-incorrectly-shows-0x8100-tag-for-802-1ad
CoreOS/libpcap/Regression/bz1785330-Invalid-IPv4-addresses-are-accepted-without
CoreOS/libpcap/Regression/libpcap-creation-invalid-pcap-files
CoreOS/libpcap/Regression/tcpdump-icmp6-option-can-t-catch-icmpv6-package-with-large-mtu
This commit is contained in:
František Hrdina 2023-05-10 09:40:20 +02:00
commit f4e81933a6
14 changed files with 516 additions and 0 deletions

View file

@ -0,0 +1,33 @@
summary: Test for BZ#1025841 (Unable to filter packets by VLAN tag)
description: |
Bug summary: Unable to filter packets by VLAN tag
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1025841
contact: fhrdina@redhat.com
component:
- libpcap
test: ./runtest.sh
framework: beakerlib
require:
- library(distribution/epel)
recommend:
- libpcap
- tcpdump
- tcpreplay
- kernel
duration: 10m
enabled: true
link:
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1025841
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1063328
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1079525
adjust:
- enabled: false
when: distro < rhel-6
continue: false
- enabled: false
when: arch != x86_64 and arch != ppc64
continue: false
extra-nitrate: TC#0463568
extra-summary: /CoreOS/libpcap/Regression/bz1025841-Unable-to-filter-packets-by-VLAN-tag
extra-task: /CoreOS/libpcap/Regression/bz1025841-Unable-to-filter-packets-by-VLAN-tag
id: 61445ec5-c269-44cf-bf58-e3ea1f5db1d2

View file

@ -0,0 +1,83 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/libpcap/Regression/bz1025841-Unable-to-filter-packets-by-VLAN-tag
# Description: Test for BZ#1025841 (Unable to filter packets by VLAN tag)
# Author: Tomas Dolezal <todoleza@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2015 Red Hat, Inc.
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="libpcap"
TESTD=$PWD
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlAssertRpm kernel
if ! rpm -q tcpreplay; then
rlRun "rlImport distribution/epel" || rlDie
rlRun "yum install -y tcpreplay --enablerepo epel"
fi
rlAssertRpm tcpreplay
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlRun "cp $TESTD/*xz ."
rlRun "cp $TESTD/pckts.pcap ."
rlRun "unxz *xz" 0 "extract pcap files"
rlPhaseEnd
rlPhaseStartTest
# it has negative offset
testfunc() {
capfile="$1" #file to replay traffic
filter="$2" #filter for tcpdump
numlines="$3" #number of packets equal to filter
count="$4" #number of packets in .pcap file
tcpdump -B 4096 -ilo -enn "$filter" -c "$count" > tcpdump.log &
sleep 5
rlRun "tcpreplay -ilo '$capfile'" 0 "replay $file traffic"
sleep 10
tail tcpdump.log; echo --end/tail
grep -c . tcpdump.log #debug info
echo $numlines #debug info
rlRun "[[ \$(grep -c . tcpdump.log) -eq $numlines ]]" 0 "Match number of pkts for '$filter'"
}
testfunc pckts.pcap "port 443" 86 86
testfunc pckts.pcap "src port 443" 46 46
testfunc vlan.pcap "vlan 32 and ip" 213 213
testfunc QinQ.pcap "vlan and vlan 200" 2 2
testfunc QinQ.pcap "vlan 200" 0 0
testfunc QinQ.pcap "vlan 100" 2 2
testfunc QinQ.pcap "vlan 100 and vlan 200" 2 2
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,24 @@
summary: Test for BZ#1427251 (tcpdump incorrectly shows 0x8100 tag for 802.1ad)
description: |
Bug summary: tcpdump incorrectly shows 0x8100 tag for 802.1ad frames
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1427251
contact: fhrdina@redhat.com
component:
- libpcap
test: ./runtest.sh
framework: beakerlib
recommend:
- libpcap
- tcpdump
duration: 5m
enabled: true
link:
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1427251
adjust:
- enabled: false
when: distro < rhel-7
continue: false
extra-nitrate: TC#0563142
extra-summary: /CoreOS/libpcap/Regression/bz1427251-tcpdump-incorrectly-shows-0x8100-tag-for-802-1ad
extra-task: /CoreOS/libpcap/Regression/bz1427251-tcpdump-incorrectly-shows-0x8100-tag-for-802-1ad
id: b95e3bda-8d3d-4e29-bfb3-4781b039dbfa

View file

@ -0,0 +1,40 @@
#!/usr/bin/env bash
if ! which tcpdump >/dev/null; then
yum -y install tcpdump
fi
ip link add foo-v1 type veth peer name foo-v2
ip link add link foo-v1 name foo-v1.4094 type vlan id 4094 protocol 802.1ad
ip link add link foo-v1.4094 name foo-v1.4094.100 type vlan id 100 protocol 802.1q
ip link set foo-v1 up
ip link set foo-v1.4094 up
ip link set foo-v1.4094.100 up
ip addr add 10.0.0.1/24 dev foo-v1.4094.100
ip netns add foobar
ip link set foo-v2 netns foobar
ip netns exec foobar ip link add link foo-v2 name foo-v2.4094 type vlan id 4094 protocol 802.1ad
ip netns exec foobar ip link add link foo-v2.4094 name foo-v2.4094.100 type vlan id 100 protocol 802.1q
ip netns exec foobar ip link set foo-v2 up
ip netns exec foobar ip link set foo-v2.4094 up
ip netns exec foobar ip link set foo-v2.4094.100 up
ip netns exec foobar ip addr add 10.0.0.2/24 dev foo-v2.4094.100
ip netns exec foobar ping -c 20 -q 10.0.0.1 >/dev/null &
tcpdump -xx -c 1 -i foo-v1 "vlan 4094 && vlan 100" |grep "88a8 0ffe"
RTN=$?
kill $(jobs -p)
ip link del foo-v1
ip netns del foobar
echo
echo --
if [ $RTN -eq 0 ]; then
echo "Passed."
else
echo "Failed."
fi
exit $RTN

View file

@ -0,0 +1,69 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/libpcap/Regression/bz1427251-tcpdump-incorrectly-shows-0x8100-tag-for-802-1ad
# Description: Test for BZ#1427251 (tcpdump incorrectly shows 0x8100 tag for 802.1ad)
# Author: Vaclav Danek <vdanek@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2017 Red Hat, Inc.
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="libpcap"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlRun "ip link add foo-v1 type veth peer name foo-v2"
rlRun "ip link add link foo-v1 name foo-v1.4094 type vlan id 4094 protocol 802.1ad"
rlRun "ip link add link foo-v1.4094 name foo-v1.4094.100 type vlan id 100 protocol 802.1q"
rlRun "ip link set foo-v1 up"
rlRun "ip link set foo-v1.4094 up"
rlRun "ip link set foo-v1.4094.100 up"
rlRun "ip addr add 10.0.0.1/24 dev foo-v1.4094.100"
rlRun "ip netns add foobar"
rlRun "ip link set foo-v2 netns foobar"
rlRun "ip netns exec foobar ip link add link foo-v2 name foo-v2.4094 type vlan id 4094 protocol 802.1ad"
rlRun "ip netns exec foobar ip link add link foo-v2.4094 name foo-v2.4094.100 type vlan id 100 protocol 802.1q"
rlRun "ip netns exec foobar ip link set foo-v2 up"
rlRun "ip netns exec foobar ip link set foo-v2.4094 up"
rlRun "ip netns exec foobar ip link set foo-v2.4094.100 up"
rlRun "ip netns exec foobar ip addr add 10.0.0.2/24 dev foo-v2.4094.100"
rlPhaseEnd
rlPhaseStartTest
ip netns exec foobar ping -c 20 -q 10.0.0.1 >/dev/null &
rlRun 'tcpdump -xx -c 1 -i foo-v1 "vlan 4094 && vlan 100" |grep "88a8 0ffe"'
rlPhaseEnd
rlPhaseStartCleanup
sleep 30
rlRun "ip link del foo-v1"
rlRun "ip netns del foobar"
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,24 @@
summary: Test for BZ#1785330 (Invalid IPv4 addresses are accepted without)
description: |
Bug summary: Invalid IPv4 addresses are accepted without reporting even a warning
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1785330
contact: something else <rhack@redhat.com>
component:
- libpcap
test: ./runtest.sh
framework: beakerlib
recommend:
- libpcap
- tcpdump
duration: 5m
enabled: true
link:
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1785330
adjust:
- enabled: false
when: distro < rhel-8
continue: false
extra-nitrate: TC#0607561
extra-summary: /CoreOS/libpcap/Regression/bz1785330-Invalid-IPv4-addresses-are-accepted-without
extra-task: /CoreOS/libpcap/Regression/bz1785330-Invalid-IPv4-addresses-are-accepted-without
id: 9c16f9d4-9ead-4510-885d-71c4aaf5187e

View file

@ -0,0 +1,49 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/libpcap/Regression/bz1785330-Invalid-IPv4-addresses-are-accepted-without
# Description: Test for BZ#1785330 (Invalid IPv4 addresses are accepted without)
# Author: something else <rhack@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2020 Red Hat, Inc.
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="libpcap"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlPhaseEnd
rlPhaseStartTest
rlRun "timeout 10 tcpdump host 192.168.355.25" 1 "Should fail"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,30 @@
summary: Test for BZ#20279937 A centos patch on libpcap version 1.5.3 causes the creation
of invalid pcap files with packet length < capture length when capturing on the
"any" interface
description: |
Bug summary: libpcap 1.5.3 with distro patch applied writes pcap file with broken pkthdr
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=2027937
contact: František Hrdina <fhrdina@redhat.com>
component:
- libpcap
test: ./runtest.sh
framework: beakerlib
recommend:
- libpcap
- tcpdump
- ping
duration: 15m
enabled: true
tag:
- Tier1
tier: '1'
link:
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=2027937
adjust:
- enabled: false
when: distro < rhel-6
continue: false
extra-nitrate: TC#0613058
extra-summary: /CoreOS/libpcap/Regression/libpcap-creation-invalid-pcap-files
extra-task: /CoreOS/libpcap/Regression/libpcap-creation-invalid-pcap-files
id: 2cdbdca3-f02f-4ff2-90aa-320722e189c5

View file

@ -0,0 +1,60 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/libpcap/Regression/libpcap-creation-invalid-pcap-files
# Description: Test for BZ#20279937 A centos patch on libpcap version 1.5.3 causes the creation of invalid pcap files with packet length < capture length when capturing on the "any" interface
# Author: František Hrdina <fhrdina@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2022 Red Hat, Inc.
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="libpcap"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlPhaseEnd
rlPhaseStartTest
rlRun "tcpdump -i any -w ping.pcap --immediate-mode -c 1 icmp &> listening.log &" 0 "Listening"
rlRun "sleep 5"
rlRun "ping -c 1 -p ff 127.0.0.1 &> ping.log" 0 "Sending packet to listening interface"
rlRun "sleep 5"
rlRun "cat listening.log | grep \"1 packet capture\"" 0 "Checking if packet was captured by tcpdump"
rlRun "cat ping.log | grep \"1 packets transmitted, 1 received, 0% packet loss\"" 0 "Checking if packet was transmitred in ping log"
rlRun "tcpdump -X -r ping.pcap" 0 "Reading ping.pcap"
rlRun "tcpdump -X -r ping.pcap | grep \"0x0060: 0000 0000\"" 1 "This zeroes should not be in input"
if rlIsRHEL; then
rlRun "tcpdump -X -r ping.pcap | grep \"0x0050: ffff ffff ....\"" 0 "Checking if output is as expected"
fi
rlRun "kill $(pidof tcpdump)" 0-2 "Kill listening tcpdump if ping was not succesful"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,27 @@
summary: Test for BZ#723108 (tcpdump icmp6 option can't catch icmpv6 package)
description: |
Bug summary: tcpdump icmp6 option can't catch icmpv6 package larger than 1460
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=723108
contact: fhrdina@redhat.com
component:
- libpcap
test: ./runtest.sh
framework: beakerlib
recommend:
- libpcap
- tcpdump
duration: 5m
enabled: true
tag:
- TIPfail_infra
- TIPpass
link:
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=723108
adjust:
- enabled: false
when: distro < rhel-6
continue: false
extra-nitrate: TC#0310523
extra-summary: /CoreOS/libpcap/Regression/tcpdump-icmp6-option-can-t-catch-icmpv6-package-with-large-mtu
extra-task: /CoreOS/libpcap/Regression/tcpdump-icmp6-option-can-t-catch-icmpv6-package-with-large-mtu
id: e50160e4-f698-4486-827f-ee520262192a

View file

@ -0,0 +1,77 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/libpcap/Regression/tcpdump-icmp6-option-can-t-catch-icmpv6-package-with-large-mtu
# Description: Test for BZ#723108 (tcpdump icmp6 option can't catch icmpv6 package)
# Author: Robin Hack <rhack@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2013 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="libpcap"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlRun "LO_MTU=$(cat /sys/class/net/lo/mtu)"
rlLogInfo "Loopback mtu is: ${LO_MTU}"
OLD_MTU=$LO_MTU
if [[ $LO_MTU > 32768 ]] ; then
rlRun "echo 32768 > /sys/class/net/lo/mtu" 0 "Lowering loopback MTU to 32768"
rlRun "LO_MTU=$(cat /sys/class/net/lo/mtu)"
rlLogInfo "Loopback MTU is now: ${LO_MTU}"
fi
(tcpdump icmp6 -i lo -vvv &> TESTOUT) &
sleep 2;
rlRun "TCPDUMP_PID=$!"
rlPhaseEnd
rlPhaseStartTest
rlRun "ping6 ::1 -I lo -c 2 -s ${LO_MTU}"
rlRun "kill ${TCPDUMP_PID}"
rlAssertNotGrep "^0 packets captured" TESTOUT
rlAssertNotGrep "^0 packets received by filter" TESTOUT
rlAssertGrep "next-header Fragment" TESTOUT
cat TESTOUT
rlPhaseEnd
rlPhaseStartCleanup
if [[ $LO_MTU != $OLD_MTU ]] ; then
rlRun "echo $OLD_MTU > /sys/class/net/lo/mtu" 0 "Resetting loopback MTU to $OLD_MTU"
rlRun "LO_MTU=$(cat /sys/class/net/lo/mtu)"
rlLogInfo "Loopback MTU is now: ${LO_MTU}"
fi
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd