3 #check that env vars are properly defined
6 if [[ -z "${SGW_PATH}" || ! -x ${SGW_PATH} ]]; then
7 echo "SGW_PATH is invalid"
12 if [[ -z "${ETH_DEV}" ]]; then
13 echo "ETH_DEV is invalid"
18 SGW_LCORE=${SGW_LCORE:-0}
20 #check that REMOTE_HOST is reachable
21 ssh ${REMOTE_HOST} echo
23 if [[ $st -ne 0 ]]; then
24 echo "host ${REMOTE_HOST} is not reachable"
28 #get ether addr of REMOTE_HOST
29 REMOTE_MAC=`ssh ${REMOTE_HOST} ip addr show dev ${REMOTE_IFACE}`
31 REMOTE_MAC=`echo ${REMOTE_MAC} | sed -e 's/^.*ether //' -e 's/ brd.*$//'`
32 if [[ $st -ne 0 || -z "${REMOTE_MAC}" ]]; then
33 echo "coouldn't retrieve ether addr from ${REMOTE_IFACE}"
39 LOCAL_MAC="00:64:74:61:70:30"
41 REMOTE_IPV4=192.168.31.14
42 LOCAL_IPV4=192.168.31.92
44 REMOTE_IPV6=fd12:3456:789a:0031:0000:0000:0000:0014
45 LOCAL_IPV6=fd12:3456:789a:0031:0000:0000:0000:0092
47 DPDK_PATH=${RTE_SDK:-${PWD}}
48 DPDK_BUILD=${RTE_TARGET:-x86_64-native-linux-gcc}
50 SGW_OUT_FILE=./ipsec-secgw.out1
52 SGW_CMD_EAL_PRM="--lcores=${SGW_LCORE} -n 4 ${ETH_DEV}"
53 SGW_CMD_CFG="(0,0,${SGW_LCORE}),(1,0,${SGW_LCORE})"
54 SGW_CMD_PRM="-p 0x3 -u 1 -P --config=\"${SGW_CMD_CFG}\""
56 SGW_CFG_FILE=$(mktemp)
58 # configure local host/ifaces
61 ifconfig ${LOCAL_IFACE} ${LOCAL_IPV4}/24 mtu 1400 up
62 ifconfig ${LOCAL_IFACE}
64 ip neigh flush dev ${LOCAL_IFACE}
65 ip neigh add ${REMOTE_IPV4} dev ${LOCAL_IFACE} lladdr ${REMOTE_MAC}
66 ip neigh show dev ${LOCAL_IFACE}
73 sysctl -w net.ipv6.conf.${LOCAL_IFACE}.disable_ipv6=0
74 ip addr add ${LOCAL_IPV6}/64 dev ${LOCAL_IFACE}
76 sysctl -w net.ipv6.conf.${LOCAL_IFACE}.mtu=1300
78 ip -6 neigh add ${REMOTE_IPV6} dev ${LOCAL_IFACE} lladdr ${REMOTE_MAC}
79 ip neigh show dev ${LOCAL_IFACE}
82 #configure remote host/iface
85 ssh ${REMOTE_HOST} ifconfig ${REMOTE_IFACE} down
86 ssh ${REMOTE_HOST} ifconfig ${REMOTE_IFACE} ${REMOTE_IPV4}/24 up
87 ssh ${REMOTE_HOST} ifconfig ${REMOTE_IFACE}
89 ssh ${REMOTE_HOST} ip neigh flush dev ${REMOTE_IFACE}
91 # by some reason following ip neigh doesn't work for me here properly:
92 #ssh ${REMOTE_HOST} ip neigh add ${LOCAL_IPV4} \
93 # dev ${REMOTE_IFACE} lladr ${LOCAL_MAC}
94 # so used arp instead.
95 ssh ${REMOTE_HOST} arp -i ${REMOTE_IFACE} -s ${LOCAL_IPV4} ${LOCAL_MAC}
96 ssh ${REMOTE_HOST} ip neigh show dev ${REMOTE_IFACE}
98 ssh ${REMOTE_HOST} iptables --flush
101 config6_remote_iface()
105 ssh ${REMOTE_HOST} sysctl -w \
106 net.ipv6.conf.${REMOTE_IFACE}.disable_ipv6=0
107 ssh ${REMOTE_HOST} ip addr add ${REMOTE_IPV6}/64 dev ${REMOTE_IFACE}
109 ssh ${REMOTE_HOST} ip -6 neigh add ${LOCAL_IPV6} \
110 dev ${REMOTE_IFACE} lladdr ${LOCAL_MAC}
111 ssh ${REMOTE_HOST} ip neigh show dev ${REMOTE_IFACE}
113 ssh ${REMOTE_HOST} ip6tables --flush
116 #configure remote and local host/iface
132 SGW_EXEC_FILE=$(mktemp)
133 cat <<EOF > ${SGW_EXEC_FILE}
134 ${SGW_PATH} ${SGW_CMD_EAL_PRM} ${CRYPTO_DEV} \
135 --vdev="net_tap0,mac=fixed" \
136 -- ${SGW_CMD_PRM} ${SGW_CMD_XPRM} -f ${SGW_CFG_FILE} > \
137 ${SGW_OUT_FILE} 2>&1 &
143 SGW_PID=`/bin/bash -x ${SGW_EXEC_FILE}`
145 # wait till ipsec-secgw start properly
148 while [[ $i -ne 10 && st -ne 0 ]]; do
150 ifconfig ${LOCAL_IFACE}
156 #stop ipsec-secgw and cleanup
160 rm -f ${SGW_EXEC_FILE}
161 rm -f ${SGW_CFG_FILE}