1 #!/bin/sh 2 # Copyright (c) 2016 Red Hat Inc., All Rights Reserved. 3 # Copyright (c) International Business Machines Corp., 2005 4 # 5 # This program is free software; you can redistribute it and/or 6 # modify it under the terms of the GNU General Public License as 7 # published by the Free Software Foundation; either version 2 of 8 # the License, or (at your option) any later version. 9 # 10 # This program is distributed in the hope that it would be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this program; if not, see <http://www.gnu.org/licenses/>. 17 # 18 # Author: Hangbin Liu <haliu (at] redhat.com> 19 # 20 ################################################################################ 21 TCID=${TCID:-icmp-uni-basic} 22 TST_TOTAL=1 23 TST_COUNT=1 24 TST_CLEANUP="tst_ipsec_cleanup" 25 26 . ipsec_lib.sh 27 28 while getopts "hl:m:p:s:S:6" opt; do 29 case "$opt" in 30 h) 31 echo "Usage:" 32 echo "h help" 33 echo "l n n is the number of test link when tests run" 34 echo "m x x is ipsec mode, could be transport / tunnel" 35 echo "p x x is ipsec protocol, could be ah / esp / ipcomp" 36 echo "s x x is icmp messge size array" 37 echo "S n n is IPsec SPI value" 38 echo "6 run over IPv6" 39 exit 0 40 ;; 41 l) LINK_NUM=$OPTARG ;; 42 m) IPSEC_MODE=$OPTARG ;; 43 p) IPSEC_PROTO=$OPTARG ;; 44 s) ICMP_SIZE_ARRAY=$OPTARG ;; 45 S) SPI=$OPTARG ;; 46 6) # skip, test_net library already processed it 47 ;; 48 *) tst_brkm TBROK "unknown option: $opt" ;; 49 esac 50 done 51 52 SPI=${SPI:-1000} 53 LINK_NUM=${LINK_NUM:-0} 54 DO_IPSEC=${DO_IPSEC:-false} 55 ICMP_SIZE_ARRAY=${ICMP_SIZE_ARRAY:-"10 100 1000 10000 65507"} 56 [ -n "$IPSEC_MODE" -a -n "$IPSEC_PROTO" ] && DO_IPSEC=true || DO_IPSEC=false 57 58 # Test description 59 tst_resm TINFO "Sending ICMP messages with the following conditions" 60 tst_resm TINFO "- Version of IP is IPv${TST_IPV6:-4}" 61 tst_resm TINFO "- Size of packets are ( $ICMP_SIZE_ARRAY )" 62 63 if $DO_IPSEC; then 64 case $IPSEC_PROTO in 65 ah) tst_resm TINFO "- IPsec [ AH / $IPSEC_MODE ]" ;; 66 esp) tst_resm TINFO "- IPsec [ ESP / $IPSEC_MODE ]" ;; 67 ipcomp) tst_resm TINFO "- IPcomp [ $IPSEC_MODE ]" ;; 68 esac 69 fi 70 71 # name of interface of the local/remote host 72 lhost_ifname=$(tst_iface lhost $LINK_NUM) 73 rhost_ifname=$(tst_iface rhost $LINK_NUM) 74 75 lhost_addr=$(tst_ipaddr) 76 rhost_addr=$(tst_ipaddr rhost) 77 78 # Configure SAD/SPD 79 if $DO_IPSEC ; then 80 tst_ipsec lhost $IPSEC_PROTO $IPSEC_MODE $SPI $lhost_addr $rhost_addr 81 tst_ipsec rhost $IPSEC_PROTO $IPSEC_MODE $SPI $rhost_addr $lhost_addr 82 fi 83 84 tst_ping $lhost_ifname $rhost_addr $ICMP_SIZE_ARRAY 85 if [ $? -ne 0 ]; then 86 tst_resm TFAIL "Checked IPv${TST_IPV6:-4} $IPSEC_PROTO $IPSEC_MODE" 87 else 88 tst_resm TPASS "Checked IPv${TST_IPV6:-4} $IPSEC_PROTO $IPSEC_MODE" 89 fi 90 91 tst_exit 92