Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Martin KaFai Lau <kafai@fb.com>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: <netdev@vger.kernel.org>, Qitao Xu <qitao.xu@bytedance.com>,
Cong Wang <cong.wang@bytedance.com>, <bpf@vger.kernel.org>
Subject: Re: [Patch net-next 02/13] ipv4: introduce tracepoint trace_ip_queue_xmit()
Date: Wed, 11 Aug 2021 14:22:57 -0700 [thread overview]
Message-ID: <20210811212257.l3mzdkcwmlbbxd6k@kafai-mbp> (raw)
In-Reply-To: <20210805185750.4522-3-xiyou.wangcong@gmail.com>
On Thu, Aug 05, 2021 at 11:57:39AM -0700, Cong Wang wrote:
> From: Qitao Xu <qitao.xu@bytedance.com>
>
> Tracepoint trace_ip_queue_xmit() is introduced to trace skb
> at the entrance of IP layer on TX side.
>
> Reviewed-by: Cong Wang <cong.wang@bytedance.com>
> Signed-off-by: Qitao Xu <qitao.xu@bytedance.com>
> ---
> include/trace/events/ip.h | 42 +++++++++++++++++++++++++++++++++++++++
> net/ipv4/ip_output.c | 10 +++++++++-
> 2 files changed, 51 insertions(+), 1 deletion(-)
>
> diff --git a/include/trace/events/ip.h b/include/trace/events/ip.h
> index 008f821ebc50..553ae7276732 100644
> --- a/include/trace/events/ip.h
> +++ b/include/trace/events/ip.h
> @@ -41,6 +41,48 @@
> TP_STORE_V4MAPPED(__entry, saddr, daddr)
> #endif
>
> +TRACE_EVENT(ip_queue_xmit,
> +
> + TP_PROTO(const struct sock *sk, const struct sk_buff *skb),
> +
> + TP_ARGS(sk, skb),
> +
> + TP_STRUCT__entry(
> + __field(const void *, skbaddr)
> + __field(const void *, skaddr)
> + __field(__u16, sport)
> + __field(__u16, dport)
> + __array(__u8, saddr, 4)
> + __array(__u8, daddr, 4)
> + __array(__u8, saddr_v6, 16)
> + __array(__u8, daddr_v6, 16)
> + ),
> +
> + TP_fast_assign(
> + struct inet_sock *inet = inet_sk(sk);
> + __be32 *p32;
> +
> + __entry->skbaddr = skb;
> + __entry->skaddr = sk;
> +
> + __entry->sport = ntohs(inet->inet_sport);
> + __entry->dport = ntohs(inet->inet_dport);
> +
> + p32 = (__be32 *) __entry->saddr;
> + *p32 = inet->inet_saddr;
> +
> + p32 = (__be32 *) __entry->daddr;
> + *p32 = inet->inet_daddr;
> +
> + TP_STORE_ADDRS(__entry, inet->inet_saddr, inet->inet_daddr,
> + sk->sk_v6_rcv_saddr, sk->sk_v6_daddr);
> + ),
> +
> + TP_printk("sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c skbaddr=%px",
> + __entry->sport, __entry->dport, __entry->saddr, __entry->daddr,
> + __entry->saddr_v6, __entry->daddr_v6, __entry->skbaddr)
> +);
> +
> #endif /* _TRACE_IP_H */
>
> /* This part must be outside protection */
> diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
> index 6b04a88466b2..dcf94059112e 100644
> --- a/net/ipv4/ip_output.c
> +++ b/net/ipv4/ip_output.c
> @@ -82,6 +82,7 @@
> #include <linux/netfilter_bridge.h>
> #include <linux/netlink.h>
> #include <linux/tcp.h>
> +#include <trace/events/ip.h>
>
> static int
> ip_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
> @@ -536,7 +537,14 @@ EXPORT_SYMBOL(__ip_queue_xmit);
>
> int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl)
> {
> - return __ip_queue_xmit(sk, skb, fl, inet_sk(sk)->tos);
> + int ret;
> +
> + ret = __ip_queue_xmit(sk, skb, fl, inet_sk(sk)->tos);
> + if (!ret)
> + trace_ip_queue_xmit(sk, skb);
Instead of adding tracepoints, the bpf fexit prog can be used here and
the bpf prog will have the sk, skb, and ret available (example in fexit_test.c).
Some tracepoints in this set can also be done with bpf fentry/fexit.
Does bpf fentry/fexit work for your use case?
next prev parent reply other threads:[~2021-08-11 21:23 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-05 18:57 [Patch net-next 00/13] net: add more tracepoints to TCP/IP stack Cong Wang
2021-08-05 18:57 ` [Patch net-next 01/13] net: introduce a new header file include/trace/events/ip.h Cong Wang
2021-08-05 18:57 ` [Patch net-next 02/13] ipv4: introduce tracepoint trace_ip_queue_xmit() Cong Wang
2021-08-06 10:08 ` Eric Dumazet
2021-08-09 20:32 ` Cong Wang
2021-08-11 21:22 ` Martin KaFai Lau [this message]
2021-08-11 22:48 ` Cong Wang
2021-08-11 23:08 ` Martin KaFai Lau
2021-08-12 0:37 ` Cong Wang
2021-08-12 5:46 ` Martin KaFai Lau
2021-08-05 18:57 ` [Patch net-next 03/13] tcp: introduce tracepoint trace_tcp_transmit_skb() Cong Wang
2021-08-05 18:57 ` [Patch net-next 04/13] udp: introduce tracepoint trace_udp_send_skb() Cong Wang
2021-08-05 18:57 ` [Patch net-next 05/13] udp: introduce tracepoint trace_udp_v6_send_skb() Cong Wang
2021-08-05 18:57 ` [Patch net-next 06/13] ipv4: introduce tracepoint trace_ip_rcv() Cong Wang
2021-08-05 18:57 ` [Patch net-next 07/13] ipv6: introduce tracepoint trace_ipv6_rcv() Cong Wang
2021-08-05 18:57 ` [Patch net-next 08/13] ipv4: introduce tracepoint trace_ip_local_deliver_finish() Cong Wang
2021-08-05 18:57 ` [Patch net-next 09/13] udp: introduce tracepoint trace_udp_rcv() Cong Wang
2021-08-05 18:57 ` [Patch net-next 10/13] ipv6: introduce tracepoint trace_udpv6_rcv() Cong Wang
2021-08-05 18:57 ` [Patch net-next 11/13] tcp: introduce tracepoint trace_tcp_v4_rcv() Cong Wang
2021-08-05 18:57 ` [Patch net-next 12/13] ipv6: introduce tracepoint trace_tcp_v6_rcv() Cong Wang
2021-08-05 18:57 ` [Patch net-next 13/13] sock: introduce tracepoint trace_sk_data_ready() Cong Wang
2021-08-06 2:22 ` [Patch net-next 00/13] net: add more tracepoints to TCP/IP stack Cong Wang
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=20210811212257.l3mzdkcwmlbbxd6k@kafai-mbp \
--to=kafai@fb.com \
--cc=bpf@vger.kernel.org \
--cc=cong.wang@bytedance.com \
--cc=netdev@vger.kernel.org \
--cc=qitao.xu@bytedance.com \
--cc=xiyou.wangcong@gmail.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).