examples/ipsec-secgw: clean up test scripts
[dpdk.git] / examples / ipsec-secgw / test / tun_aesgcm_common_defs.sh
1 #! /bin/bash
2 # SPDX-License-Identifier: BSD-3-Clause
3
4 CRYPTO_DEV=${CRYPTO_DEV:-'--vdev="crypto_aesni_gcm0"'}
5
6 #generate cfg file for ipsec-secgw
7 config_secgw()
8 {
9         cat <<EOF > ${SGW_CFG_FILE}
10 #sp in IPv4 rules
11 sp ipv4 in esp protect 7 pri 2 src ${REMOTE_IPV4}/32 dst ${LOCAL_IPV4}/32 \
12 sport 0:65535 dport 0:65535
13 sp ipv4 in esp bypass pri 1 sport 0:65535 dport 0:65535
14
15 #SP out IPv4 rules
16 sp ipv4 out esp protect 7 pri 2 src ${LOCAL_IPV4}/32 dst ${REMOTE_IPV4}/32 \
17 sport 0:65535 dport 0:65535
18 sp ipv4 out esp bypass pri 1 sport 0:65535 dport 0:65535
19
20 #sp in IPv6 rules
21 sp ipv6 in esp protect 9 pri 2 src ${REMOTE_IPV6}/128 dst ${LOCAL_IPV6}/128 \
22 sport 0:65535 dport 0:65535
23 sp ipv6 in esp bypass pri 1 sport 0:65535 dport 0:65535
24
25 #SP out IPv6 rules
26 sp ipv6 out esp protect 9 pri 2 src ${LOCAL_IPV6}/128 dst ${REMOTE_IPV6}/128 \
27 sport 0:65535 dport 0:65535
28 sp ipv6 out esp bypass pri 1 sport 0:65535 dport 0:65535
29
30 #SA in rules
31 sa in 7 aead_algo aes-128-gcm \
32 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
33 mode ipv4-tunnel src ${REMOTE_IPV4} dst ${LOCAL_IPV4} ${SGW_CFG_XPRM_IN}
34
35 sa in 9 aead_algo aes-128-gcm \
36 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
37 mode ipv6-tunnel src ${REMOTE_IPV6} dst ${LOCAL_IPV6} ${SGW_CFG_XPRM_IN}
38
39 #SA out rules
40 sa out 7 aead_algo aes-128-gcm \
41 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
42 mode ipv4-tunnel src ${LOCAL_IPV4} dst ${REMOTE_IPV4} ${SGW_CFG_XPRM_OUT}
43
44 sa out 9 aead_algo aes-128-gcm \
45 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
46 mode ipv6-tunnel src ${LOCAL_IPV6} dst ${REMOTE_IPV6} ${SGW_CFG_XPRM_OUT}
47
48 #Routing rules
49 rt ipv4 dst ${REMOTE_IPV4}/32 port 0
50 rt ipv4 dst ${LOCAL_IPV4}/32 port 1
51
52 rt ipv6 dst ${REMOTE_IPV6}/128 port 0
53 rt ipv6 dst ${LOCAL_IPV6}/128 port 1
54
55 #neighbours
56 neigh port 0 ${REMOTE_MAC}
57 neigh port 1 ${LOCAL_MAC}
58 EOF
59
60         cat ${SGW_CFG_FILE}
61 }
62
63 config_secgw_mixed()
64 {
65         cat <<EOF > ${SGW_CFG_FILE}
66 #sp in IPv4 rules
67 sp ipv4 in esp protect 6 pri 2 src ${REMOTE_IPV4}/32 dst ${LOCAL_IPV4}/32 \
68 sport 0:65535 dport 0:65535
69 sp ipv4 in esp bypass pri 1 sport 0:65535 dport 0:65535
70
71 #SP out IPv4 rules
72 sp ipv4 out esp protect 6 pri 2 src ${LOCAL_IPV4}/32 dst ${REMOTE_IPV4}/32 \
73 sport 0:65535 dport 0:65535
74 sp ipv4 out esp bypass pri 1 sport 0:65535 dport 0:65535
75
76 #sp in IPv6 rules
77 sp ipv6 in esp protect 8 pri 2 src ${REMOTE_IPV6}/128 dst ${LOCAL_IPV6}/128 \
78 sport 0:65535 dport 0:65535
79 sp ipv6 in esp bypass pri 1 sport 0:65535 dport 0:65535
80
81 #SP out IPv6 rules
82 sp ipv6 out esp protect 8 pri 2 src ${LOCAL_IPV6}/128 dst ${REMOTE_IPV6}/128 \
83 sport 0:65535 dport 0:65535
84 sp ipv6 out esp bypass pri 1 sport 0:65535 dport 0:65535
85
86 #SA in rules
87 sa in 8 aead_algo aes-128-gcm \
88 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
89 mode ipv4-tunnel src ${REMOTE_IPV4} dst ${LOCAL_IPV4} ${SGW_CFG_XPRM_IN}
90
91 sa in 6 aead_algo aes-128-gcm \
92 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
93 mode ipv6-tunnel src ${REMOTE_IPV6} dst ${LOCAL_IPV6} ${SGW_CFG_XPRM_IN}
94
95 #SA out rules
96 sa out 8 aead_algo aes-128-gcm \
97 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
98 mode ipv4-tunnel src ${LOCAL_IPV4} dst ${REMOTE_IPV4} ${SGW_CFG_XPRM_OUT}
99
100 sa out 6 aead_algo aes-128-gcm \
101 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
102 mode ipv6-tunnel src ${LOCAL_IPV6} dst ${REMOTE_IPV6} ${SGW_CFG_XPRM_OUT}
103
104 #Routing rules
105 rt ipv4 dst ${REMOTE_IPV4}/32 port 0
106 rt ipv4 dst ${LOCAL_IPV4}/32 port 1
107
108 rt ipv6 dst ${REMOTE_IPV6}/128 port 0
109 rt ipv6 dst ${LOCAL_IPV6}/128 port 1
110
111 #neighbours
112 neigh port 0 ${REMOTE_MAC}
113 neigh port 1 ${LOCAL_MAC}
114 EOF
115
116         cat ${SGW_CFG_FILE}
117 }