Skip to content

Commit

Permalink
tcp: Add skb addr and sock addr to arguments of tracepoint tcp_probe.
Browse files Browse the repository at this point in the history
It is useful to expose skb addr and sock addr to user in tracepoint
tcp_probe, so that we can get more information while monitoring
receiving of tcp data, by ebpf or other ways.

For example, we need to identify a packet by seq and end_seq when
calculate transmit latency between layer 2 and layer 4 by ebpf, but which is
not available in tcp_probe, so we can only use kprobe hooking
tcp_rcv_established to get them. But we can use tcp_probe directly if skb
addr and sock addr are available, which is more efficient.

Signed-off-by: fuyuanli <fuyuanli@didiglobal.com>
Reviewed-by: Jason Xing <kerneljasonxing@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
fuyuanli authored and davem330 committed Mar 8, 2024
1 parent 6025b91 commit caabd85
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions include/trace/events/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ TRACE_EVENT(tcp_probe,
__field(__u32, srtt)
__field(__u32, rcv_wnd)
__field(__u64, sock_cookie)
__field(const void *, skbaddr)
__field(const void *, skaddr)
),

TP_fast_assign(
Expand Down Expand Up @@ -286,14 +288,18 @@ TRACE_EVENT(tcp_probe,
__entry->ssthresh = tcp_current_ssthresh(sk);
__entry->srtt = tp->srtt_us >> 3;
__entry->sock_cookie = sock_gen_cookie(sk);

__entry->skbaddr = skb;
__entry->skaddr = sk;
),

TP_printk("family=%s src=%pISpc dest=%pISpc mark=%#x data_len=%d snd_nxt=%#x snd_una=%#x snd_cwnd=%u ssthresh=%u snd_wnd=%u srtt=%u rcv_wnd=%u sock_cookie=%llx",
TP_printk("family=%s src=%pISpc dest=%pISpc mark=%#x data_len=%d snd_nxt=%#x snd_una=%#x snd_cwnd=%u ssthresh=%u snd_wnd=%u srtt=%u rcv_wnd=%u sock_cookie=%llx skbaddr=%p skaddr=%p",
show_family_name(__entry->family),
__entry->saddr, __entry->daddr, __entry->mark,
__entry->data_len, __entry->snd_nxt, __entry->snd_una,
__entry->snd_cwnd, __entry->ssthresh, __entry->snd_wnd,
__entry->srtt, __entry->rcv_wnd, __entry->sock_cookie)
__entry->srtt, __entry->rcv_wnd, __entry->sock_cookie,
__entry->skbaddr, __entry->skaddr)
);

#define TP_STORE_ADDR_PORTS_SKB_V4(__entry, skb) \
Expand Down

0 comments on commit caabd85

Please sign in to comment.