BPF List
 help / color / mirror / Atom feed
From: Rinat Gadelshin <rgadelsh@gmail.com>
To: bpf@vger.kernel.org
Subject: How to read tcp_payload from kprobe/inet_sendmsg
Date: Fri, 27 Sep 2024 14:01:03 +0300	[thread overview]
Message-ID: <3aa5a79c15420a836cb60b6eeb090a11399146f7.camel@gmail.com> (raw)

Hello there!

I'm trying to read DNS queries from kprobe/inet_sendmsg and
kprobe/inet_recvmsg.

I just copy data by

bpf_probe_read(&memory_in_my_map,
               size_from_kprobe_arg,
               msg>msg_iter.iov->iov_base);

It works fine for UDP (I'm checking by `dig @8.8.4.4 google.com`)
Buf for TCP (`dig @8.8.4.4 google.com +tcp`) the payload isn's a valid
DNS request.

I'm using the same method for reading DNS response from
kretprobe/inet_recvmsg (arguments are stored by kprobe/inet_recvmsg).
Receiving DNS responses works well for UDP and TCP.

I've found some related but unanswered topics:
- 
https://www.reddit.com/r/eBPF/comments/15fh3n4/accessing_the_content_of_tcp_packages_in_an_ebpf/

- 
https://stackoverflow.com/questions/76782000/linux-tcp-packet-sniffing-with-ebpf-kprobe-reading-package-content-from-iov-ite

-https://github.com/replicatedhq/exfilter/issues/8

Please, tell me, what I'm doing wrong.


                 reply	other threads:[~2024-09-27 11:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3aa5a79c15420a836cb60b6eeb090a11399146f7.camel@gmail.com \
    --to=rgadelsh@gmail.com \
    --cc=bpf@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox