bstinson / centos / t_functional

Forked from centos/t_functional 4 years ago
Clone

Blame tests/p_tcpdump/tcp6dump_lo.sh

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