Score:0

Tap interface injected packet not received at user appllication

cx flag

I have written an application using AF_XDP sockets, currently all packets are received on the interface are received by the Af_XDP application. The application filters packet of specific port number all other packet are reinjected into linux network stack using a tap interface. I have other application running on the system. I am pushing the packets back in with tap, but finding that nothing gets delivered to the other applications. The tcpdump shows that packet are received at the tap interface. I am assuming the packet received at the tap interface will be handled by the network stack via which they will be received by other applications and after processing and they will go out from real interface. But that is not happening.

Gour DEV avatar
cx flag
https://www.gabriel.urdhr.fr/2021/05/08/tuntap/ Found this link which explain how the tun/tap device works. The problem with my setup is that i did not assigned any ip address to my tap device. The kernel after processing the packet is sending them back to the tap device. Since the tap device does not have an ip address thus the packets were getting dropped by the kernel.
Gour DEV avatar
cx flag
Is there a way for the setup to work without giving an ip address to TAP device and only use it as a mechanism to inject packet into kernel.
Gour DEV avatar
cx flag
The problem is that kernel is not sending packet to any interface after processing it.
A.B avatar
cl flag
A.B
if rp_filter=1 (try `sysctl -ar \\.rp_filter`) chances are the kernel will drop the packets too.
Gour DEV avatar
cx flag
I disabled the rp_filter on all interfaces but i did not worked
Gour DEV avatar
cx flag
After injecting the packet into the kernel the packet reply did not came.
A.B avatar
cl flag
A.B
That's a whole new problem: if your routes aren't adequate there will be no reply at all or where you expect it.
Gour DEV avatar
cx flag
The main interface on which the AF_XDP is listening has the ip address 192.168.2.2/24. The problem is that the AF_XDP application is picking up all the packet(single queue nic). So i want to send the packet which are not mean for the application back to kernel for that i used the TAP device i did no allocated any ip address to TAP device i thought once the packet is received at the TAP device i will be injected into the kernel like it was received form wire. An after the kernl processes the packet it will go throught the main interface. Please correct my understanding of TAP interface.
Score:0
cx flag

The problem with my case was that after receiving packet from AF_XDP socket I was writting it to TAP interface assuming that the packet will be injected into the kernel. But in my case the kernel was dropping the packet since the MAC address of packet is not same as the MAC address of TAP interface.

There were two solution to this problem. One to modify to packet eth_dst to broadcast address or set the TAP interface in promiscious mode. Things worked fine after that.

Also the rp_filter also needs to disabled otherwise packet will dropped at IP layer.

  1. disable rp_filter
  2. Check MAC address is same as TAP interface or Broadcast or use TUN interface or you can use TAP interface in promiscious mode.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.