1.8-2
Add OSCI gating tests Resolves: rhbz#1958933 Signed-off-by: Hangbin Liu <haliu@redhat.com>
This commit is contained in:
parent
22267a540d
commit
3cd4145f6e
@ -1,6 +1,6 @@
|
||||
Name: libndp
|
||||
Version: 1.8
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
Summary: Library for Neighbor Discovery Protocol
|
||||
License: LGPLv2+
|
||||
URL: http://www.libndp.org/
|
||||
@ -46,6 +46,9 @@ find $RPM_BUILD_ROOT -name \*.la -delete
|
||||
%{_libdir}/pkgconfig/*.pc
|
||||
|
||||
%changelog
|
||||
* Wed May 26 2021 Hangbin Liu <haliu@redhat.com> - 1.8-2
|
||||
- Add OSCI gating tests (rhbz#1958933)
|
||||
|
||||
* Fri May 21 2021 Hangbin Liu <haliu@redhat.com> - 1.8-1
|
||||
- 1.8 release (rhbz#1958933)
|
||||
- libndp,ndptool: use poll() instead of select()
|
||||
|
BIN
tests/basic/nd.pcap
Normal file
BIN
tests/basic/nd.pcap
Normal file
Binary file not shown.
133
tests/basic/send_monitor_nd.sh
Executable file
133
tests/basic/send_monitor_nd.sh
Executable file
@ -0,0 +1,133 @@
|
||||
#!/bin/sh
|
||||
|
||||
ret=0
|
||||
nsuccess=0
|
||||
nfail=0
|
||||
NETNS_0="ns-$(mktemp -u XXXXXX)"
|
||||
NETNS_1="ns-$(mktemp -u XXXXXX)"
|
||||
|
||||
# $1: return value
|
||||
# $2: log message
|
||||
libndp_log() {
|
||||
local rc=$1
|
||||
local msg="$2"
|
||||
|
||||
if [ $rc -eq 0 ]; then
|
||||
printf "[libndp gating]: %-30s [ PASS ]\n" "$msg"
|
||||
nsuccess=$((nsuccess+1))
|
||||
else
|
||||
printf "[libndp gating]: %-30s [ FAIL ]\n" "$msg"
|
||||
nfail=$((nfail+1)) && ret=1
|
||||
fi
|
||||
}
|
||||
|
||||
install_tcpreplay() {
|
||||
which tcpreplay && return 0
|
||||
wget https://github.com/appneta/tcpreplay/releases/download/v4.3.0/tcpreplay-4.3.0.tar.xz
|
||||
tar xf tcpreplay-4.3.0.tar.xz
|
||||
cd tcpreplay-4.3.0
|
||||
./configure && make && make install
|
||||
cd ../
|
||||
which tcpreplay
|
||||
}
|
||||
|
||||
clean_up() {
|
||||
ip netns del ${NETNS_0} &> /dev/null
|
||||
ip netns del ${NETNS_1} &> /dev/null
|
||||
ip link del veth0 &> /dev/null
|
||||
ip link del veth1 &> /dev/null
|
||||
}
|
||||
|
||||
trap clean_up EXIT
|
||||
|
||||
setup() {
|
||||
install_tcpreplay &> tcpreplay.log || \
|
||||
{ libndp_log $? "Install tcpreplay" && cat tcpreplay.log; return 1; }
|
||||
|
||||
clean_up
|
||||
|
||||
ip netns add "${NETNS_0}"
|
||||
ip netns add "${NETNS_1}"
|
||||
ip -netns "${NETNS_0}" link set lo up
|
||||
ip -netns "${NETNS_1}" link set lo up
|
||||
|
||||
ip link add type veth
|
||||
ip link set veth0 netns "${NETNS_0}"
|
||||
ip link set veth1 netns "${NETNS_1}"
|
||||
ip -netns "${NETNS_0}" link set veth0 addr 00:00:00:00:00:01
|
||||
ip -netns "${NETNS_1}" link set veth1 addr 00:00:00:00:00:02
|
||||
ip -netns "${NETNS_0}" link set veth0 up
|
||||
ip -netns "${NETNS_1}" link set veth1 up
|
||||
}
|
||||
|
||||
monitor_nd()
|
||||
{
|
||||
ip netns exec "${NETNS_1}" unbuffer ndptool -i veth1 monitor &> monitor.log &
|
||||
sleep 2
|
||||
# TODO: maybe fuzz the pcap file and see if ndptool still works
|
||||
ip netns exec "${NETNS_0}" tcpreplay -l 2 -i veth0 nd.pcap
|
||||
sleep 2 && kill -9 $!
|
||||
|
||||
grep -q "Type: NS" monitor.log; libndp_log $? "Monitor NS"
|
||||
grep -q "Type: NA" monitor.log; libndp_log $? "Monitor NA"
|
||||
# commit this due to bug 1082933
|
||||
# grep -q "Type: RS" monitor.log; libndp_log $? "Monitor RS"
|
||||
grep -q "Type: RA" monitor.log; libndp_log $? "Monitor RA"
|
||||
# TODO: add ICMPv6 redirect support
|
||||
|
||||
}
|
||||
|
||||
send_nd()
|
||||
{
|
||||
ip netns exec "${NETNS_1}" tcpdump -i veth1 -nn -l &> rs.log &
|
||||
sleep 2
|
||||
ip netns exec "${NETNS_0}" ndptool -i veth0 -t rs send
|
||||
sleep 2 && kill -9 $!
|
||||
|
||||
#ip netns exec "${NETNS_0}" ndptool -i veth0 -t ra send
|
||||
|
||||
ip netns exec "${NETNS_1}" tcpdump -i veth1 -nn -l &> ns.log &
|
||||
sleep 2
|
||||
ip netns exec "${NETNS_0}" ndptool -i veth0 -t ns send
|
||||
sleep 2 && kill -9 $!
|
||||
|
||||
ip netns exec "${NETNS_1}" tcpdump -i veth1 -nn -l &> ns_t.log &
|
||||
sleep 2
|
||||
ip netns exec "${NETNS_0}" ndptool -i veth0 -t ns -T fe80::200:ff:fe00:2 send
|
||||
sleep 2 && kill -9 $!
|
||||
|
||||
#ip netns exec "${NETNS_0}" ndptool -i veth0 -t na send
|
||||
|
||||
ip netns exec "${NETNS_1}" tcpdump -i veth1 -nn -l &> na_d_t.log &
|
||||
sleep 2
|
||||
ip netns exec "${NETNS_0}" ndptool -i veth0 -t na -D fe80::200:ff:fe00:2 -T fe80::200:ff:fe00:1 send
|
||||
sleep 2 && kill -9 $!
|
||||
|
||||
ip netns exec "${NETNS_1}" tcpdump -i veth1 -nn -l &> na_u.log &
|
||||
sleep 2
|
||||
ip netns exec "${NETNS_0}" ndptool -i veth0 -U -t na send
|
||||
sleep 2 && kill -9 $!
|
||||
|
||||
grep -q "fe80::200:ff:fe00:1 > ff02::2: ICMP6, router solicitation" rs.log; libndp_log $? "Send RS"
|
||||
grep -q "fe80::200:ff:fe00:1 > ff02::1: ICMP6, neighbor solicitation, who has ::" ns.log; libndp_log $? "Send NS"
|
||||
grep -q "fe80::200:ff:fe00:1 > ff02::1:ff00:2: ICMP6, neighbor solicitation, who has fe80::200:ff:fe00:2" ns_t.log; libndp_log $? "Send NS with target"
|
||||
grep -q "fe80::200:ff:fe00:1 > fe80::200:ff:fe00:2: ICMP6, neighbor advertisement, tgt is fe80::200:ff:fe00:1" na_d_t.log; libndp_log $? "Send NA with dest and target"
|
||||
grep -q "fe80::200:ff:fe00:1 > ff02::1: ICMP6, neighbor advertisement, tgt is ::" na_u.log; libndp_log $? "Send unsolicited NA"
|
||||
}
|
||||
|
||||
setup || exit 1
|
||||
monitor_nd
|
||||
send_nd
|
||||
|
||||
printf "\nTests passed: %3d\n" ${nsuccess}
|
||||
printf "Tests failed: %3d\n" ${nfail}
|
||||
|
||||
if [ ${nfail} -ne 0 ]; then
|
||||
echo -e "\nDEBUG INFO:\n"
|
||||
for log in `ls *.log`; do
|
||||
echo "# cat $log"
|
||||
cat $log
|
||||
done
|
||||
fi
|
||||
|
||||
exit $ret
|
17
tests/tests.yml
Normal file
17
tests/tests.yml
Normal file
@ -0,0 +1,17 @@
|
||||
# Tests for libndp
|
||||
- hosts: localhost
|
||||
roles:
|
||||
- role: standard-test-basic
|
||||
required_packages:
|
||||
- expect
|
||||
- gcc
|
||||
- libpcap-devel
|
||||
- make
|
||||
- tcpdump
|
||||
- wget
|
||||
tags:
|
||||
- classic
|
||||
tests:
|
||||
- sanity-tests:
|
||||
dir: basic
|
||||
run: sh send_monitor_nd.sh
|
Loading…
Reference in New Issue
Block a user