All of lore.kernel.org
 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: Mon, 27 Mar 2023 10:09:50 -0700	[thread overview]
Message-ID: <ZCHN3sbx2Cr0r0hM@google.com> (raw)
In-Reply-To: <C8C3B8DB-1CF1-4C51-91A1-6D4C6FEFD6D1@avride.ai>

On 03/27, Kamil Zaripov wrote:
> > 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?

> No, I mean when situations when same package through its way to the  
> network stack change sk_buff pointer. For example, after skb_clone()  
> call. I have made some test and found out (empirically) that pointer to  
> the skb->head a much better tracking ID. However, I am not sure that  
> there is no other corner cases when skb->head also can change.

Yeah, those are tricky :-(

> > 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?

> Yes, I have already implemented and make some test of this approach: I’m  
> listening at netif_receive_skb tracepoint to create skb_head->netif map  
> and then listening for __kfree_skb calls to create pid->skb_head map.  
> However, this approach have some weaknesses:
> - Part of packages of TCP protocol packages (ACK, for example) are  
> handled by the kernel, so I account this packages as kernel activity. But  
> almost every TCP ACK package have some  associated socket, which, in  
> turn, have associated process.
> - I am not sure that all package consumes call __kfree_skb at the end.  
> Maybe there is some other miscounting in this place.

> Maybe there is some other approaches to map packages to processes?

I'm not super familiar with those tracing hooks. Maybe you need to
handle consume_skb as well?

If I were to solve something like this, I'd probably look at cgroup/ingress
hooks. Those are guaranteed to run for every incoming packet into cgroup's
sockets. (at least removes that kfree_skb vs consume_skb issue).

But it doesn't solve your problem with the clones...

      reply	other threads:[~2023-03-27 17:10 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
2023-03-27 14:19   ` Kamil Zaripov
2023-03-27 17:09     ` Stanislav Fomichev [this message]

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=ZCHN3sbx2Cr0r0hM@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.