xdp-project / xdp-tutorial

XDP tutorial
2.43k stars 574 forks source link

Some times packets are not receiving in AF_XDP socket #223

Open Adarsh97 opened 3 years ago

Adarsh97 commented 3 years ago

I am trying to write AF_XDP program for passing only packets having specific udp port with bpf_redirect_map, but sometimes no packets are coming to AF_XDP socket. My sender and receiver are connected with a switch. Any protocol like ARP is missing is the reason ? I am doing XDP_PASS for all other packets, but still i am unable to receive packets some time. My code is based on this example. https://github.com/timfehr/xdp/blob/master/reqrouter_kern.c May I know the reason for it. I am unable to see those packets in wireshark also. I can see some ICMP messages poping up in wireshark during that time, not sure is this has a role in the issue.

tohojo commented 3 years ago

Maybe @magnus-karlsson or @bjoto have an idea; otherwise I'd suggest posting to xdp-newbies@vger.kernel.org with a description of your problem.

In either case, "sometimes I don't get packets" is not going to cut it as a problem description. You'll need to provide some more details such as:

Adarsh97 commented 3 years ago

Hi, Kernel version is 5+ (I am using ubuntu 20.x). Nic driver is ixgbe. No compile issues i am seeing. Some times means, if i am sending packets 10 times, out of these I am not receiving 10 times, sometimes in the first try I won't receive the packet, sometime after some try i won't get packets. My code is available here - https://github.com/Adarsh97/XDP

Please let me know if you need more details.

tohojo commented 3 years ago

You're using rxq_index as your xsk map key. What mechanism are you using to ensure packets always arrive on queue idx 0?

Adarsh97 commented 3 years ago

I am using " ethtool -L interface combined 1", for ensuring only one queue is present. Any issue with that ?

Adarsh97 commented 3 years ago

@tohojo any idea why it is happening like that ?

tohojo commented 3 years ago

Adarsh Sunilkumar @.***> writes:

@tohojo any idea why it is happening like that ?

Not really, no... some issue with how your userspace program is reading packets from the ringbuffer? Does the xdpsock example in the kernel samples directory work?

magnus-karlsson commented 3 years ago

On Sun, Jun 13, 2021 at 10:04 PM Toke Høiland-Jørgensen < @.***> wrote:

Adarsh Sunilkumar @.***> writes:

@tohojo any idea why it is happening like that ?

Not really, no... some issue with how your userspace program is reading packets from the ringbuffer? Does the xdpsock example in the kernel samples directory work?

Adarsh,

As Toke suggests, please try the standard xdpsock program and check if it exhibits the same behaviour. If not, then add your code to that in small pieces to check where the error is coming from. One question is if your packets are really dropped or if they arrive later in batches of X packets?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/xdp-project/xdp-tutorial/issues/223#issuecomment-860263110, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASGUEMGYE76CBXMLOFXKXDTSUFLPANCNFSM46S3S3YQ .