Open kloud1989 opened 4 years ago
Your code works fine for me. What exactly is the problem you're having?
On an unrelated note, putting your perf_buffer_poll
call at the end of your program will cause it to drop events if you run it for long enough. You want to poll the perf buffer in your while loop so you can consume events.
Your code works fine for me. What exactly is the problem you're having?
The problem is that, as in the sample result, the last two events in the table are IPV6 events. However, the saddr, daddr and the follow-up fields can't be resolved properly. Since the code works fine for you, I have to believe the problem is related to kernel versions or OS versions. What's the platform you are running on?
On an unrelated note, putting your
perf_buffer_poll
call at the end of your program will cause it to drop events if you run it for long enough. You want to poll the perf buffer in your while loop so you can consume events.
Ahh, you're right! I've tried this before, with a very old kernel, and it didn't work well when I stopped the tool by Ctrl+C. Now as I tried with kernel v5.4, it works fine!
I'm on Arch Linux 5.7.2, latest bcc from master. FWIW have you had a look at https://github.com/iovisor/bcc/blob/master/tools/tcptracer.py which seems to be quite similar to what you are trying to do here?
I referenced to this _tcptracer.py when writing my tool. Modifications are required to trace every send/recv events. I can't tell what I'm doing wrong.
I'm writing a tool to record every TCP event. However, I can only resolve IPV4 events properly, IPV6 events can't be resolved properly. Here is a sample result:![image](https://user-images.githubusercontent.com/12099844/84860530-c506c580-b0a1-11ea-9aac-2d1d548e4050.png)
Here is my tool implementation. Anything wrong? I can record IPV6 events correctly if record upon tcp_sendmsg/tcp_recvmsg entries without BPF_TABLE applied. However, to record the end time of the event, I have to use the return kprobe too, thus BPF_TABLE is used.
I'm running this tool on Chromium OS, kernel V5.4.
tcptrans.c:
tcptrans.py: