简体   繁体   中英

How to receive data from tun interface to dpdk binded NIC?

I want to have any Traffic generator(say iperf,D-ITG or even ping) to send data to a tun interface. This tun interface should automatically forward to NIC which is binded to DPDK. I want to run l3fwd example which picks up data from the interface.

I used the option --vdev=net_tun0 in commandline which creates tun interface. I thought tun/tap PMD will automatically poll the packets at tun/tap interface and redirect to/from NIC. But, that's not happening. I am not able to receive any packets.

I require dpdk and traffic generator to run on the same PC. DPDK should pick the traffic at the userspace.

Since the question is not that clear (whether it is DPDK RX-TX or Kernel RX-TX), here are the answers for DPDK application point of view

  • DPDK TUN PMD allows creating Kernel TUN interface with ip layer onwards (there is no MAC Layer). just like all PMD devices, you have to poll with rte_eth_rx_burst and use rte_eth_tx_burst inside DPDK Application.
  • Similarly, if you plan to use TAP PMD, dpdk will create Kernel TAP the interface which has to be polled with rte_eth_rx_burst and rte_eth_tx_burst inside DPDK application.

Once you use vdev=net_tap0 this creates Kernel tap interface dtap0 . So to grab packets received to Kernel interface you have call rte_eth_rx_burst to send a specific packet to Kernel TAP interface you need to use rte_eth_tx_burst .

as per your requirement which is to direct any traffic generator to kernel to TAP interface, then send to physical NIC bound with DPDK, this what you have to do

  1. make use a simple application like examples/skeleton or testpmd or examples/l2fwd with no mac update`
  2. ensure you pass the vdev=net_tap0,iface=<your desired name for interface> to the DPDK application.
  3. Using ip or ifconfig bring up the interface with ip address and the state as up (Promisc mode is optional).
  4. ensure your destination address route is through tap interface by cross-checking route -n .
  5. now kick start your traffic generator with dest-ip and interface as required.

Note: In my deployment case, I ended up setting static ARP too.

This will send the packet to kernel TAP interface, which is then intercepted by DPDK application via rx_burst calls. Using port to port forward behaviour this is then forwarded to DPDK Physical NIC. In reverse direction, the packet received from physical nic is bought into the application by rx_burst and then tx_burst to TAP PMD. this will then inject to the kernel TAP interface.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM