From: Eric Dumazet <eric.dumazet@gmail.com>
To: Yafang Shao <laoar.shao@gmail.com>, daniel@iogearbox.net, ast@kernel.org
Cc: yhs@fb.com, brakmo@fb.com, edumazet@google.com,
davem@davemloft.net, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, shaoyafang@didiglobal.com
Subject: Re: [bpf-next 2/2] bpf: add BPF_SOCK_OPS_STATS_CB for tcp_stats()
Date: Tue, 12 Feb 2019 07:11:20 -0800 [thread overview]
Message-ID: <e5fabb00-4fad-183a-5c2d-e22ed58006c7@gmail.com> (raw)
In-Reply-To: <1549971097-12627-3-git-send-email-laoar.shao@gmail.com>
On 02/12/2019 03:31 AM, Yafang Shao wrote:
> Introuce this new op BPF_SOCK_OPS_STATS_CB for tcp_stats() such that it
> can be traced via BPF on a per socket basis.
> There's one argument in BPF_SOCK_OPS_STATS_CB, which is Linux MIB index
> LINUX_MIB_* to indicate the TCP event.
> All these Linux MIBs are defined in include/uapi/linux/snmp.h.
>
> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
> ---
> include/uapi/linux/bpf.h | 5 +++++
> net/ipv4/tcp_input.c | 1 +
> 2 files changed, 6 insertions(+)
>
> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> index 1777fa0..0314ddd 100644
> --- a/include/uapi/linux/bpf.h
> +++ b/include/uapi/linux/bpf.h
> @@ -2894,6 +2894,11 @@ enum {
> BPF_SOCK_OPS_TCP_LISTEN_CB, /* Called on listen(2), right after
> * socket transition to LISTEN state.
> */
> + BPF_SOCK_OPS_STATS_CB, /*
> + * Called on tcp_stats().
> + * Arg1: Linux MIB index
> + * LINUX_MIB_*
> + */
> };
>
> /* List of TCP states. There is a build check in net/ipv4/tcp.c to detect
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index 88deb1f..4acf458 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -3557,6 +3557,7 @@ static u32 tcp_newly_delivered(struct sock *sk, u32 prior_delivered, int flag)
> static void tcp_stats(struct sock *sk, int mib_idx)
> {
> NET_INC_STATS(sock_net(sk), mib_idx);
> + tcp_call_bpf(sk, BPF_SOCK_OPS_STATS_CB, 1, &mib_idx);
> }
>
> /* This routine deals with incoming acks, but not outgoing ones. */
>
If the plan is to add to all NET_INC_STATS() calls in TCP an additional tcp_call_bpf()
I will say no.
So far, tcp_call_bpf() has not been used in fast path.
next prev parent reply other threads:[~2019-02-12 15:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-12 11:31 [bpf-next 0/2] cleanup SOCK_DEBUG() and introduce BPF_SOCK_OPS_STATS_CB Yafang Shao
2019-02-12 11:31 ` [bpf-next 1/2] tcp: replace SOCK_DEBUG() with tcp_stats() Yafang Shao
2019-02-12 15:07 ` Eric Dumazet
2019-02-13 2:07 ` Yafang Shao
2019-02-13 2:15 ` Eric Dumazet
2019-02-13 2:46 ` Yafang Shao
2019-02-13 2:49 ` Alexei Starovoitov
2019-02-13 3:04 ` Yafang Shao
2019-02-12 11:31 ` [bpf-next 2/2] bpf: add BPF_SOCK_OPS_STATS_CB for tcp_stats() Yafang Shao
2019-02-12 15:11 ` Eric Dumazet [this message]
2019-02-13 2:10 ` Yafang Shao
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=e5fabb00-4fad-183a-5c2d-e22ed58006c7@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=ast@kernel.org \
--cc=brakmo@fb.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=laoar.shao@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=shaoyafang@didiglobal.com \
--cc=yhs@fb.com \
/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).