Multiple vhostuser ports example with testpmd
To follow this example you should have a system with kubernetes available and configured to support native 1 GB hugepages. You should also have multus-cni and vhost-user-net-plugin up and running. See crd-vhostuser-net.yaml
for example config to use with multus and fix path to vhost tool. If using OVS, check that you have bridge named br0
in your OVS with ovs-vsctl show
and if not, create it with ovs-vsctl add-br br0 -- set bridge br0 datapath_type=netdev
.
Build image from provided Dockerfile and tag it as ubuntu-dpdk
:
docker build . -t ubuntu-dpdk
Copy get-prefix.sh
script from vhost-user-net-plugin repo to /var/lib/cni/vhostuser/
. See pod-multi-vhost.yaml
and start the pod:
kubectl create -f pod-multi-vhost.yaml
Open terminal to the created pod once it is running:
kubectl exec -it multi-vhost-example bash
Launch testpmd and automatically start forwarding packets after sending first burst:
# Get container ID
export ID=$(/vhu/get-prefix.sh)
# Run testpmd with ports created by vhostplugin
# Note: change coremask to suit your system
testpmd \
-d librte_pmd_virtio.so.17.11 \
-m 1024 \
-c 0xC \
--file-prefix=testpmd_ \
--vdev=net_virtio_user0,path=/vhu/${ID}/${ID:0:12}-net1 \
--vdev=net_virtio_user1,path=/vhu/${ID}/${ID:0:12}-net2 \
--no-pci \
-- \
--no-lsc-interrupt \
--auto-start \
--tx-first \
--stats-period 1 \
--disable-hw-vlan;
If packets are not going through, you need to configure direct flows to your switch between the used ports. For example, with OVS as the switch, this is done by getting the port numbers with ovs-ofctl dump-ports br0
and configuring flow, for example, from port 1 to port 2 with ovs-ofctl add-flow br0 in_port=1,action=output:2
and vice versa.
@kangasta : I really like to include this part in the read me file. If you send me a PR, I will merge it . Please let me know you thoughts on it.