Blame tests/p_tcpdump/03_tcpdump_lo_ipv6.sh

Athmane Madjoudj d5af89
#!/bin/sh
Christoph Galuschka 25699e
# Author: Christoph Galuschka <tigalch@tigalch.org>
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
40b4c8
if [ "$CONTAINERTEST" -eq "1" ]; then
40b4c8
    t_Log "Running in container -> SKIP"
40b4c8
    exit 0
40b4c8
fi
40b4c8
Christoph Galuschka 8f5133
# Grabing IPv6 address of lo to check 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 696d12
  ping6 -q -c $COUNT -i 0.25 ::1 > /dev/null 2>&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