clinuxdockernetwork-programmingdpdk

How to intercept all packets from eth0 of container interface by dpdk application in docker container


I have setup hugepages, created container and deployed dpdk application to container, but my application return 0 for rte_eth_dev_count_avail, what could I miss

/usr/bin/fwdd -l 0-3 -n 4 --vdev=net_tap0,iface=eth0
function setup_hugepages()
{
    echo "Setup hugepages"
    sysctl -w vm.nr_hugepages=1024
    echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages

    MOUNT_POINT="/mnt/huge"
    if [ ! $(mountpoint -q "${MOUNT_POINT}") ]; then
        echo "Mounting hugepages"
        mkdir -p ${MOUNT_POINT}
        mount -t hugetlbfs nodev ${MOUNT_POINT}
    else
        echo "Hugepages are already mounted at ${MOUNT_POINT}"
    fi
}
docker run -itd --privileged --cap-add=ALL \
    -v /sys/bus/pci/devices:/sys/bus/pci/devices \
    -v /sys/kernel/mm/hugepages:/sys/kernel/mm/hugepages \
    -v /sys/devices/system/node:/sys/devices/system/node \
    -v /dev:/dev \
    -v /mnt/huge:/mnt/huge \
    -v /sys/fs/cgroup:/sys/fs/cgroup:ro \
    --name nstk nstk_image
int main(int argc, char* argv[])
{
    int ret = rte_eal_init(argc, argv);
    if (ret < 0) {
        NSTK_LOG_DEBUG("Error: EAL initialization failed");
        return EXIT_FAILURE;
    }

    if (rte_eth_dev_count_avail() == 0) {
        NSTK_LOG_DEBUG("Error: No available Ethernet ports");
        return EXIT_FAILURE;
    }
...

Solution

  • Why not --vdev=net_af_packet0,iface=eth0 or --vdev=net_af_xdp0,iface=eth0?