-
Notifications
You must be signed in to change notification settings - Fork 87
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
[help] AF_XDP-forwarding don't forward packet.(tcpdump capture nothing) #94
Comments
Hi @xjj210130 I presume eth4 is some sort of physical driver and you are using AF_XDP in native/zero copy mode? tcpdump will not see the packets being sent through an AF_XDP socket in ZC mode. The packet is being pushed directly to the driver from AF_XDP. The xdp program only executes on the RX side hook, there's no TX hooks for XDP today. If you just want to validate your application - you can try using a veth pair on the tx side of your app and either tcpdump on the veth peer (aka not the veth directly attached to your application) or check the ethtool stats for the veth directly attached to your app there will be You can always attach a kprobe to xsk_sendmsg and see how many times it gets invoked.... something like to give you a rough idea of the TX path checkout this link |
@maryamtahhan I am very confused, how the modified message is sent out, in this example(AF_XDP-forwarding). Is there in fuction port_tx_burst? i skim the source af_xdp, the af_xdp use prog from file(xsk_def_xdp_prog.c). There is code look like this Is this send packet to other pc refcnt==0 ? If so, how to trigger the condition? there's no TX hooks for XDP today means i need send the packet by myself, is it right? Thank you very much. |
I'm only making guesses here regarding your setup. If you can send on a highlevel diagram of your setup and where you are AF_XDP programs loaded and where you are trying to tcpdump that would be very helpful. If you are using an XDP prog on the other machine where you are trying to capture the packets I would recommend using xdpdump I believe what the code you reference is saying: if there's nothing using this XDP program (refcount would be 0) then pass all incoming traffic to the kernel... If you want to capture incoming traffic at the XDP hook where an XDP prog is loaded you can use a command like the following:
regarding your question about port_tx_burst --> CNDP had a great explanation of how buffers are added and consumed from the UMEM here, please see the TX flow specifically for what you are trying to understand. The last thing to note is the
After step 3 the zc driver gets triggered from __xsk_sendmsg() |
No - my comment re TX-Hooks was referring to being able to capture outgoing traffic from an application using an AF_XDP socket. You can still send the packet through the xsk, you just won't be able to dump it before it leaves the interface right now... |
@maryamtahhan Thank you very much. I referenced the code xdp-tutorial-master/reflector. https://github.com/xdp-project/xdp-tutorial the main code as following:
xsk_socket_0 eth3 receive the packet from network i do my work in function: process_packet, however, there is no packet sent from eth4. Is it the code wrong? The xdp code need trigger TX_RING, and call function send_msg. but The above code call function send, I'm doubt why it didn't trigger send. |
HI all:
My env is centos 7. core is 5.15.46 (build by myself) gcc 11.2.1 clang 14.0.6 llvm 14.0.6 bpftool is v5.15.46
I do as following:
1: git clone https://github.com/xdp-project/bpf-examples.git
2: cd bpf-examples/AF_XDP-forwarding
3: make
4: run cmd ./xsk_fwd-i eth3 -q 0 -i eth4 -q 0 -c 3
in fact , i modify the code swap_mac_addresses as following, i want to do recv packet from eth3,and then forward the packet to eth4(9.168.1.4) and send the packet to new pc, but i use tcpdump -i eth4 -w 1.cap. there is no packet forward to eth4 . Is it some wrong? or i need change more?
static void swap_dst_info(void * data){
char *dst_ip ="9.168.1.4";
char *new_dst_ip ="9.168.1.5";
}
i use kernal to process arp, i only process tcp protocol.
in fact , i print the info in function port_tx_burst, the src dst ip is what i changed. i add log in af_xdp, there is no event to trigger kernal function xsk_def_prog( xdp prog), ### it means tx queue message don't send. so i think there is need to do something , but i don't know use someone api.
Of course , it can't use tun/tap. It doesn't use af_xdp tx queue
Is there any example i can refer?
Thanks very much. @tohojo
The text was updated successfully, but these errors were encountered: