5 # Run specified app using LD_PRELOAD to fetch a page from
6 # nginx running in vpp1 net-namespace.
8 # Specify the following environment variables:
10 # STRACE_ONLY - Run app with strace instead of LD_PRELOAD.
11 # TEST_APP - App to run (default: curl)
14 # Configuration variables.
17 # Comment out the next line to run the VPP release version
19 vpp_app="$WS_ROOT/build-root/install-vpp${debug}-native/vpp/bin/vpp"
22 local grep_for_vpp="ps -eaf|grep -v grep|grep \"bin/vpp\""
23 running_vpp="$(eval $grep_for_vpp)"
27 if [ -z "$WS_ROOT" ] ; then
28 echo "ERROR: WS_ROOT environment variable not set!" >&2
29 echo " Please set WS_ROOT to VPP workspace root directory." >&2
33 if [ -z "$VCL_LDPRELOAD_LIB_DIR" ] ; then
34 echo "ERROR: VCL_LDPRELOAD_LIB_DIR environment variable not set!" >&2
35 echo " Please set VCL_LDPRELOAD_LIB_DIR to " >&2
36 echo " $WS_ROOT/build-root/install-vpp[_debug]-native/vpp/lib." >&2
40 TEST_APP="${TEST_APP:-curl}"
41 LDP_DIR="${WS_ROOT}/extras/vcl-ldpreload"
42 LDP_TEST_DIR="${LDP_TEST_DIR:-${LDP_DIR}/test}"
43 LDP_LIB="${LDP_LIB:-${VCL_LDPRELOAD_LIB_DIR}/libvcl_ldpreload.so.0.0.0}"
45 if [ ! -f "$LDP_LIB" ] ; then
46 echo "ERROR: Missing VCL-LDPRELOAD Library: $LDP_LIB"
47 echo " Run 'cd $WS_ROOT; make build[-release] ' !"
51 if [ -n "$STRACE_ONLY" ] ; then
52 echo "Running strace -tt $TEST_APP http://$nginx_addr"
53 strace -tt $TEST_APP http://$nginx_addr
56 if [ -z "$running_vpp" ] ; then
57 echo -e "\nConfiguring network interfaces"
58 sudo ip link del dev vpp_dk
59 sudo ip link add name vpp_dk type veth peer name vpp1
60 sudo ip link set dev vpp_dk up
61 sudo ethtool --offload vpp_dk rx off tx off
62 sudo ip link set dev vpp1 up
63 sudo ethtool --offload vpp1 rx off tx off
64 sudo ip link set dev lo up
65 sudo brctl addif docker0 vpp_dk
69 sudo xfce4-terminal --title VPP --command "$vpp_app unix { interactive exec $LDP_TEST_DIR/common/vpp_docker.conf full-coredump coredump-size unlimited } api-segment { gid $(id -g) }" &
70 # sudo $vpp_app unix { cli-listen localhost:5002 exec $LDP_TEST_DIR/common/vpp_docker.conf } api-segment { gid $(id -g) }
74 if [ -z "$(docker ps -qf name=$vpp_dk_name)" ] ; then
75 echo -e "\nStarting NGINX in docker container ($vpp_dk_name)"
76 echo "docker run --rm --name $vpp_dk_name -v $LDP_TEST_DIR/common/nginx_welcome.html:/usr/share/nginx/html/index.html:ro -d nginx"
77 docker run --rm --name $vpp_dk_name -v $LDP_TEST_DIR/common/nginx_welcome.html:/usr/share/nginx/html/index.html:ro -d nginx
79 export LD_LIBRARY_PATH="$WS_ROOT/build-root/install-vpp${debug}-native/vpp/lib/:$LDP_DIR/src/.libs:"
81 # Extract nginx IPv4 address from docker bridge
83 nginx_addr=$(docker network inspect bridge | grep IPv4Address | awk -e '{print $2}' | sed -e 's,/16,,' -e 's,",,g' -e 's/,//')
85 if [ -z "$nginx_addr" ] ; then
86 echo "ERROR: Unable to determine docker container address!"
91 echo -e "\nRunning wget"
92 echo -e "LD_PRELOAD=$LDP_LIB $TEST_APP http://$nginx_addr\n"
93 LD_PRELOAD=$LDP_LIB $TEST_APP http://$nginx_addr