Blame tests/p_tcpdump/tcpdump_lo_ipv6.sh
|
Athmane Madjoudj |
d5af89 |
#!/bin/sh
|
|
Athmane Madjoudj |
d5af89 |
# Author: Christoph Galuschka <christoph.galuschka@chello.at>
|
|
Athmane Madjoudj |
d5af89 |
# Athmane Madjoudj <athmanem@gmail.com>
|
|
Athmane Madjoudj |
d5af89 |
|
|
Athmane Madjoudj |
d5af89 |
t_Log "Running $0 - TCPdump test IPv6 to lo"
|
|
Athmane Madjoudj |
d5af89 |
|
|
Athmane Madjoudj |
d5af89 |
# Grabing IPv6 address of lo to checl if IPv6 is enabled
|
|
Athmane Madjoudj |
d5af89 |
IP=$(ip addr list lo | grep 'inet6 ')
|
|
Athmane Madjoudj |
d5af89 |
regex='\t*inet6\ (.*)\/.*'
|
|
Athmane Madjoudj |
d5af89 |
if [[ $IP =~ $regex ]]
|
|
Athmane Madjoudj |
d5af89 |
then
|
|
Athmane Madjoudj |
d5af89 |
t_Log "IPv6 seems to be enabled - runing test"
|
|
Athmane Madjoudj |
d5af89 |
FILE='/var/tmp/lo_test6.pcap'
|
|
Athmane Madjoudj |
d5af89 |
COUNT='4'
|
|
Athmane Madjoudj |
d5af89 |
#Dumping ping6s to loopback to file
|
|
Athmane Madjoudj |
d5af89 |
tcpdump -q -n -p -i lo -w $FILE &
|
|
Athmane Madjoudj |
d5af89 |
# If we don't wait a short time, the first paket will be missed by tcpdump
|
|
Athmane Madjoudj |
d5af89 |
sleep 1
|
|
Athmane Madjoudj |
d5af89 |
ping6 -q -c $COUNT -i 0.25 ::1
|
|
Athmane Madjoudj |
d5af89 |
sleep 1
|
|
Athmane Madjoudj |
d5af89 |
killall -s SIGINT tcpdump
|
|
Athmane Madjoudj |
d5af89 |
sleep 1
|
|
Athmane Madjoudj |
d5af89 |
|
|
Athmane Madjoudj |
d5af89 |
# reading from file, for each ping we should see two pakets
|
|
Athmane Madjoudj |
d5af89 |
WORKING=$( tcpdump -r $FILE | grep -ci icmp6 )
|
|
Athmane Madjoudj |
d5af89 |
if [ $WORKING == $[COUNT*2] ]; then
|
|
Athmane Madjoudj |
d5af89 |
ret_val=0
|
|
Athmane Madjoudj |
d5af89 |
else
|
|
Athmane Madjoudj |
d5af89 |
t_Log "ping6 to loopback droped pakets!! This should not happen on loopback"
|
|
Athmane Madjoudj |
d5af89 |
ret_val=1
|
|
Athmane Madjoudj |
d5af89 |
fi
|
|
Athmane Madjoudj |
d5af89 |
# Remove file afterwards
|
|
Athmane Madjoudj |
d5af89 |
/bin/rm $FILE
|
|
Athmane Madjoudj |
d5af89 |
else
|
|
Athmane Madjoudj |
d5af89 |
t_Log "IPv6 seems to be disabled - skipping test"
|
|
Athmane Madjoudj |
d5af89 |
ret_val=0
|
|
Athmane Madjoudj |
d5af89 |
fi
|
|
Athmane Madjoudj |
d5af89 |
|
|
Athmane Madjoudj |
d5af89 |
t_CheckExitStatus $ret_val
|