Skip to content

Commit caabd85

Browse files
fuyuanlidavem330
authored andcommitted
tcp: Add skb addr and sock addr to arguments of tracepoint tcp_probe.
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 <[email protected]> Reviewed-by: Jason Xing <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6025b91 commit caabd85

File tree

1 file changed

+8
-2
lines changed
  • include/trace/events

1 file changed

+8
-2
lines changed

include/trace/events/tcp.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ TRACE_EVENT(tcp_probe,
259259
__field(__u32, srtt)
260260
__field(__u32, rcv_wnd)
261261
__field(__u64, sock_cookie)
262+
__field(const void *, skbaddr)
263+
__field(const void *, skaddr)
262264
),
263265

264266
TP_fast_assign(
@@ -286,14 +288,18 @@ TRACE_EVENT(tcp_probe,
286288
__entry->ssthresh = tcp_current_ssthresh(sk);
287289
__entry->srtt = tp->srtt_us >> 3;
288290
__entry->sock_cookie = sock_gen_cookie(sk);
291+
292+
__entry->skbaddr = skb;
293+
__entry->skaddr = sk;
289294
),
290295

291-
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",
296+
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",
292297
show_family_name(__entry->family),
293298
__entry->saddr, __entry->daddr, __entry->mark,
294299
__entry->data_len, __entry->snd_nxt, __entry->snd_una,
295300
__entry->snd_cwnd, __entry->ssthresh, __entry->snd_wnd,
296-
__entry->srtt, __entry->rcv_wnd, __entry->sock_cookie)
301+
__entry->srtt, __entry->rcv_wnd, __entry->sock_cookie,
302+
__entry->skbaddr, __entry->skaddr)
297303
);
298304

299305
#define TP_STORE_ADDR_PORTS_SKB_V4(__entry, skb) \

0 commit comments

Comments
 (0)