VPP/HostStack/TestProxy

From fd.io
< VPP‎ | HostStack
Revision as of 07:33, 13 June 2018 by Bhesmans (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This is a test application that acts as a transport layer proxy. Note that is has only been tested with a TCP transport.

One simple way to test the application is to add a tap interface to vpp, start a python SimpleHTTPServer that listens for connections incoming on the tap interface and, finally, a client that connects via a second vpp interface to the proxied content. The second interface can be a dpdk interface or another tap interface. In the example below, we use a dpdk interface.

Start vpp with a dpdk interface and add a tap interface:

# set int ip address <dpdk-interface> 6.0.1.1/24 
# set int state <dpdk-interface> up
# create tap host-ip4-addr 6.0.2.2/24
# set int ip addr tap0 6.0.2.1/24
# set int state tap0 up

Start the proxy app on the host:

# test proxy server server-uri tcp://0.0.0.0/80 client-uri tcp://6.0.2.2/80

From a different host with connectivity to the dpdk-interface:

$ wget http://6.0.1.1/test-content

Note that this assumes that a file named "test-content" exists in the folder wherefrom the SimpleHTTPServer was started.


Test the proxy with namespaces

In this example, we create two namespaces, one from the client and an other one for the server, both are connected through a VPP instance that will proxy a tcp connection.

Create the client namespace:

# ip netns add client
# ip link add vpp0 type veth peer name client
# ip link set dev client netns client
# ip netns exec client ip link set dev lo up
# ip netns exec client ip link set dev client up
# ip netns exec client ip addr add 10.0.0.1/24 dev client
# ip link set dev vpp0 up

Create the server namespace:

# ip netns add server
# ip link add vpp1 type veth peer name server
# ip link set dev server netns server
# ip netns exec server ip link set dev lo up
# ip netns exec server ip link set dev server up
# ip netns exec server ip addr add 10.0.1.1/24 dev server
# ip link set dev vpp1 up

Run and configure VPP:

# vpp unix { cli-listen /run/vpp/cli-vpp1.sock } api-segment { prefix vpp1 }
# vppctl -s /run/vpp/cli-vpp1.sock create host-interface name vpp0
# vppctl -s /run/vpp/cli-vpp1.sock set interface state host-vpp0 up
# vppctl -s /run/vpp/cli-vpp1.sock set interface ip address host-vpp0 10.0.0.2/24
# vppctl -s /run/vpp/cli-vpp1.sock create host-interface name vpp1
# vppctl -s /run/vpp/cli-vpp1.sock set interface state host-vpp1 up
# vppctl -s /run/vpp/cli-vpp1.sock set interface ip address host-vpp1 10.0.1.2/24

Run the proxy:

# vppctl -s /run/vpp/cli-vpp1.sock test proxy server server-uri tcp://10.0.0.2/555 client-uri tcp://10.0.1.1/666

And test it:

# ip netns exec server truncate -s 10M 10M
# ip netns exec server python -m SimpleHTTPServer 666 &
# ip netns exec client wget 10.0.0.2:555/10M -O rcv.img