PcapPlusPlus icon indicating copy to clipboard operation
PcapPlusPlus copied to clipboard

Porting DPDK application

Open JasMetzger opened this issue 1 year ago • 8 comments

Question

My PCAP++ DPDK application runs on an Ubuntu 20.04 linux . I am trying to run same application in a 20.04 docker container with sufficient mappings and transparency on the host system. At one point I had this working with a bunch of -v options with docker run. But now when I run the app in a docker container I cannot initDPDK for some reason.

[ERROR: /PcapLiveDeviceList.cpp: init:46] Error searching for devices: Can't look for DPDK devices: The configuration file has invalid parameters.

It "Cannot init plugins" and errors.

What is the app missing from the environment?

Operating systems

No response

JasMetzger avatar Jun 19 '24 13:06 JasMetzger

Can you provide the full docker run command you used ? Did you tried to use --net=host and mount -v /dev:/dev for hugepages ?

SesomB avatar Jun 19 '24 21:06 SesomB

Almost. Here is what I did at one point and it worked. But now when I build the image it doesn't and cannot figure out how come:

sudo docker run -d --name dpdk-channel --privileged --net=host -v /dev/hugepages:/dev/hugepages -v /var/run/dpdk:/var/run/dpdk dpdk-channel:1

JasMetzger avatar Jun 19 '24 22:06 JasMetzger

@JasMetzger I never ran DPDK inside docker so I'm not sure how to to make it work, but it seems that @SesomB has some experience, maybe he can help

seladb avatar Jun 20 '24 06:06 seladb

I think it may not be specific to DPDK. The first call was to simply list the PCAP devices PCAPLiveDeviceList and it throws an error librte_pmd_e1000.so cannot open shared object file. This runs fine outside the container.

JasMetzger avatar Jun 20 '24 12:06 JasMetzger

Try to create a custom docker image that contains DPDK installation and PcapPlusPlus. From the error you mentioned I assume DPDK is installed on the host machine but not within the docker image and thus has insufficient mapping to the DPDK's shared libraries. If installing DPDK on the system and just running your containerized application is your intention, we probably need to map RTE_SDK (the location of all DPDK libraries are installed) directory into the container.

SesomB avatar Jun 20 '24 20:06 SesomB

I've gotten a little further. I have a custom docker image with DPDK and PCAP++ application installed. It runs and get through most of the initDPDK but complains about "ZERO DPDK ports are initialized.. Something went wrong while initializing.... I am also able to run dpdk-devbind -s inside the container and it sees the DPDK Intel device bound by the host.

image

JasMetzger avatar Jun 20 '24 21:06 JasMetzger

Can you show us the output of dpdk-devbind.py --status from within the container ?

Also, Try to run with: docker run -it -d --privileged -v /sys/bus/pci/drivers:/sys/bus/pci/drivers -v /sys/kernel/mm/hugepages:/sys/kernel/mm/hugepages -v /sys/devices/system/node:/sys/devices/system/node -v /dev:/dev --name CONTAINER_NAME IMAGE_NAME

SesomB avatar Jun 20 '24 21:06 SesomB

I get lspci errors but it eventually lists the same that it does on host: image

I installed the libkmod into the container as well but still seem to get the lspci errors.

This is when devbind -s on the host: image

It seems to return a count of zero when running inside the container:

in DpdkDeviceList.cpp

#if (RTE_VER_YEAR < 18) || (RTE_VER_YEAR == 18 && RTE_VER_MONTH < 5) int numOfPorts = (int)rte_eth_dev_count(); #else int numOfPorts = (int)rte_eth_dev_count_avail(); #endif

For comparison, When I run outside the container, the output shows the line "EAL: Probe PCI driver: net_i40e (8086:1572) device: 0000:03:00.0 (socket 0)" When I run in the container, this is where it fails, this line does not appear. So it might be related to device driver? Not sure.

I was able to fix the issue but not sure how. When I make the Docker image I include the DPDK build I used when compiling PCAP++ 23.09. From Dockerfile:

ADD dpdk-21.11.6.tgz /usr/local

Somehow the first build I packaged works; my attempts at documenting my initial steps must have failed somwehre. I am not sure what the difference there is between the two compositions but I can say it has something to do with the DPDK 21.11.6 package I used to build and deploy the project.

JasMetzger avatar Jun 20 '24 22:06 JasMetzger

@JasMetzger did you manage to solve it?

While it's an interesting use-case, I don't think it's directly related to the PcapPlusPlus code base - it seems like a mapping/permissions issue related to ruinning DPDK inside a docker container.

I'll close the issue now, please feel free to reopen if you think we need to make any code changes in the library to make it work.

Also - if you managed to figure it out - please free free to post you findings here!

seladb avatar Apr 01 '25 02:04 seladb

Hey, I did not solve it directly but managed to use an image that was working. Since then I've had to backburner the effort but will pick it up again eventually.

Thank you. Please close.

J

From: seladb @.> Sent: Monday, March 31, 2025 10:52 PM To: seladb/PcapPlusPlus @.> Cc: James Metzger @.>; Mention @.> Subject: Re: [seladb/PcapPlusPlus] Porting DPDK application (Issue #1454)

CAUTION: This email originated from outside of Redhorse. Do not click links or open attachments unless you recognize the sender and know the content is safe.

@JasMetzgerhttps://github.com/JasMetzger did you manage to solve it?

While it's an interesting use-case, I don't think it's directly related to the PcapPlusPlus code base - it seems like a mapping/permissions issue related to ruinning DPDK inside a docker container.

I'll close the issue now, please feel free to reopen if you think we need to make any code changes in the library to make it work.

Also - if you managed to figure it out - please free free to post you findings here!

Reply to this email directly, view it on GitHubhttps://github.com/seladb/PcapPlusPlus/issues/1454#issuecomment-2767919412, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AUV3ANBQ7BRI23YKLI5V7FT2XH5N5AVCNFSM6AAAAAB2FXJP36VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONRXHEYTSNBRGI. You are receiving this because you were mentioned.Message ID: @.@.>> [seladb]seladb left a comment (seladb/PcapPlusPlus#1454)https://github.com/seladb/PcapPlusPlus/issues/1454#issuecomment-2767919412

@JasMetzgerhttps://github.com/JasMetzger did you manage to solve it?

While it's an interesting use-case, I don't think it's directly related to the PcapPlusPlus code base - it seems like a mapping/permissions issue related to ruinning DPDK inside a docker container.

I'll close the issue now, please feel free to reopen if you think we need to make any code changes in the library to make it work.

Also - if you managed to figure it out - please free free to post you findings here!

Reply to this email directly, view it on GitHubhttps://github.com/seladb/PcapPlusPlus/issues/1454#issuecomment-2767919412, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AUV3ANBQ7BRI23YKLI5V7FT2XH5N5AVCNFSM6AAAAAB2FXJP36VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONRXHEYTSNBRGI. You are receiving this because you were mentioned.Message ID: @.@.>>

JasMetzger avatar Apr 01 '25 12:04 JasMetzger