Topics

sockmap redirect doesn't work all the time

forrest0579@...
 

Hi all,

Recently I've been testing with ebpf sockmap. I know that after setting the sock fd in sockmap, the data send to this socket can redirect to another socket that register in the sockmap. 

I rewrite an example based on https://github.com/dippynark/bpf-sockmap and find something unexpected. In my example, my program(an LB instance with sockmap support to redirect data from client to the backend real server) will accept a connection from client and build a new connection to real server. Than set both the two sock fds to sockmap and the verdict program will redirect packet from one socket to another.
I find that some packets are not handled by sockmap if the packet arrived before I set sock fd. So I have to read the packets from my program and send it out to the real server.

In my expectation, I think that after set sockfd to sockmap, all packets should be handled by parser/verdict ebpf functions and should not read any data from userspace, even if the packet received before the sock fd. But it seems I'm wrong...

If the description above is as expected, in what scenario I could use the sockmap since it doesn't make sure all packet handled by ebpf redirect.
Or if I am wrong, or using the sockmap in the wrong way/scenario, please point this out

Thanks,

Forrest Chen

Ferenc Fejes
 

Hi!

Are you sure about the problem? Try to log (with bpf_printk for example) the incoming packets in the BPF program to check if the really missing. I also encountered your problem in my experiments, but then it turned out the packets dropped because of insufficient receiver memory on the peer socket. I recommend you to try it with small messages (like 10kbyte, so you can count all the packets if the arriving properly, based on the BPF parser log). 

Thanks,
Ferenc