netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stanislav Fomichev <sdf@google.com>
To: Kamil Zaripov <zaripov-kamil@avride.ai>
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: Network RX per process per interface statistics
Date: Fri, 24 Mar 2023 13:19:58 -0700	[thread overview]
Message-ID: <ZB4F7l0Nh2ZYwjci@google.com> (raw)
In-Reply-To: <F75020C7-9247-4F15-96CC-C3E6F11C0429@avride.ai>

On 03/24, Kamil Zaripov wrote:
> Hi everyone,

> I trying to make a BPF program that can collect per process per interface  
> statistics of network data consumption. Right now most difficult part for  
> me is RX traffic.

> I have tried to find some point in the sk_buff's way up to network stack  
> where I can extract info both about the network interface which captured  
> package and the process that will consume this data but failed. So I have  
> to listen events in several points and somehow merge collected data.

> The last point I found at which sk_buff still contains information about  
> network device that captured this sk_buff is netif_receive_skb  
> tracepoint. The first point where I can found information about process  
> is protocol's rcv handlers (like tcp_v4_do_rcv). But I have some  
> questions, to finish my program:

> 1. It seems that sk_buff modifies during handling, so how can I "match"  
> sk_buff with same data in netif_receive_skb and in tcp_v4_do_rcv?

By "modifies" - do you mean the payload/headers? You can probably use
the skb pointer address as a unique identifier to connect across different
tracepoints?

> 2. Maybe there is some good point where I can attach listener and where I  
> can extract both process and interface info for each package?

Nothing pops to my mind. But I think that if you store skbaddr=dev from
netif_receive_skb, you should be able to look this up at a later point
where you know skb->process association?

> Regards
> Zaripov Kamil.

  reply	other threads:[~2023-03-24 20:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-24 16:29 Network RX per process per interface statistics Kamil Zaripov
2023-03-24 20:19 ` Stanislav Fomichev [this message]
2023-03-27 14:19   ` Kamil Zaripov
2023-03-27 17:09     ` Stanislav Fomichev

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=ZB4F7l0Nh2ZYwjci@google.com \
    --to=sdf@google.com \
    --cc=bpf@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=zaripov-kamil@avride.ai \
    /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;
as well as URLs for NNTP newsgroup(s).