Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected addr offset on handle_receive_packets #448

Open
DragosFalk opened this issue Nov 15, 2024 · 1 comment
Open

Unexpected addr offset on handle_receive_packets #448

DragosFalk opened this issue Nov 15, 2024 · 1 comment

Comments

@DragosFalk
Copy link

I have a similar setup where I follow the same aproach like in [advanced03-AF_XDP] . I give the frames through the fill queue where lets say that the frames offsets(addr) are something like 0 2048 4096 and so on. When I get back the frames like via handle_receive_packets the addr that I get is shifted by 256 (0+256 2048+256 4096+256) . From what I read there is 256 XDP_HEADROOM but if I look in the memory it seems empty. My main question is it correct also in advanced03-AF_XDP the fact that when xsk_free_umem_frame(xsk, addr); is done to give back the frame it is done with the extra offset of 256 ?
Anyone else experienced this and can advise a bit on what is the proper way to handle this case?

@derlaft
Copy link

derlaft commented Nov 27, 2024

From what I read there is 256 XDP_HEADROOM but if I look in the memory it seems empty

This is designed to give you room as a user to store some extra data (if you want to encapsulate a packet and RX it, you don't need to allocate an extra frame). So it's expected to not hold any useful data at the time of receive.

My main question is it correct also in advanced03-AF_XDP the fact that when xsk_free_umem_frame(xsk, addr); is done to give back the frame it is done with the extra offset of 256?

Looks like so. It's fine, because kernel knows where exactly each frame starts (at the start of the 2048/4096 page) and will adjust the address correspondingly.

Another implementation I've seen clears headroom on allocating a new frame.

https://docs.ebpf.io/linux/concepts/af_xdp/#headroom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants