tcp.h (79790b6818e96c58fe2bffee1b418c16e64e7b80) | tcp.h (b533fb9cf4f7c6ca2aa255a5a1fdcde49fff2b24) |
---|---|
1/* SPDX-License-Identifier: GPL-2.0 */ 2#undef TRACE_SYSTEM 3#define TRACE_SYSTEM tcp 4 5#if !defined(_TRACE_TCP_H) || defined(TRACE_HEADER_MULTI_READ) 6#define _TRACE_TCP_H 7 8#include <linux/ipv6.h> 9#include <linux/tcp.h> 10#include <linux/tracepoint.h> 11#include <net/ipv6.h> 12#include <net/tcp.h> 13#include <linux/sock_diag.h> | 1/* SPDX-License-Identifier: GPL-2.0 */ 2#undef TRACE_SYSTEM 3#define TRACE_SYSTEM tcp 4 5#if !defined(_TRACE_TCP_H) || defined(TRACE_HEADER_MULTI_READ) 6#define _TRACE_TCP_H 7 8#include <linux/ipv6.h> 9#include <linux/tcp.h> 10#include <linux/tracepoint.h> 11#include <net/ipv6.h> 12#include <net/tcp.h> 13#include <linux/sock_diag.h> |
14#include <net/rstreason.h> |
|
14 | 15 |
15#define TP_STORE_V4MAPPED(__entry, saddr, daddr) \ 16 do { \ 17 struct in6_addr *pin6; \ 18 \ 19 pin6 = (struct in6_addr *)__entry->saddr_v6; \ 20 ipv6_addr_set_v4mapped(saddr, pin6); \ 21 pin6 = (struct in6_addr *)__entry->daddr_v6; \ 22 ipv6_addr_set_v4mapped(daddr, pin6); \ 23 } while (0) 24 25#if IS_ENABLED(CONFIG_IPV6) 26#define TP_STORE_ADDRS(__entry, saddr, daddr, saddr6, daddr6) \ 27 do { \ 28 if (sk->sk_family == AF_INET6) { \ 29 struct in6_addr *pin6; \ 30 \ 31 pin6 = (struct in6_addr *)__entry->saddr_v6; \ 32 *pin6 = saddr6; \ 33 pin6 = (struct in6_addr *)__entry->daddr_v6; \ 34 *pin6 = daddr6; \ 35 } else { \ 36 TP_STORE_V4MAPPED(__entry, saddr, daddr); \ 37 } \ 38 } while (0) 39#else 40#define TP_STORE_ADDRS(__entry, saddr, daddr, saddr6, daddr6) \ 41 TP_STORE_V4MAPPED(__entry, saddr, daddr) 42#endif 43 | |
44/* 45 * tcp event with arguments sk and skb 46 * 47 * Note: this class requires a valid sk pointer; while skb pointer could 48 * be NULL. 49 */ 50DECLARE_EVENT_CLASS(tcp_event_sk_skb, 51 --- 46 unchanged lines hidden (view full) --- 98 99DEFINE_EVENT(tcp_event_sk_skb, tcp_retransmit_skb, 100 101 TP_PROTO(const struct sock *sk, const struct sk_buff *skb), 102 103 TP_ARGS(sk, skb) 104); 105 | 16/* 17 * tcp event with arguments sk and skb 18 * 19 * Note: this class requires a valid sk pointer; while skb pointer could 20 * be NULL. 21 */ 22DECLARE_EVENT_CLASS(tcp_event_sk_skb, 23 --- 46 unchanged lines hidden (view full) --- 70 71DEFINE_EVENT(tcp_event_sk_skb, tcp_retransmit_skb, 72 73 TP_PROTO(const struct sock *sk, const struct sk_buff *skb), 74 75 TP_ARGS(sk, skb) 76); 77 |
78#undef FN 79#define FN(reason) TRACE_DEFINE_ENUM(SK_RST_REASON_##reason); 80DEFINE_RST_REASON(FN, FN) 81 82#undef FN 83#undef FNe 84#define FN(reason) { SK_RST_REASON_##reason, #reason }, 85#define FNe(reason) { SK_RST_REASON_##reason, #reason } 86 |
|
106/* 107 * skb of trace_tcp_send_reset is the skb that caused RST. In case of 108 * active reset, skb should be NULL 109 */ | 87/* 88 * skb of trace_tcp_send_reset is the skb that caused RST. In case of 89 * active reset, skb should be NULL 90 */ |
110DEFINE_EVENT(tcp_event_sk_skb, tcp_send_reset, | 91TRACE_EVENT(tcp_send_reset, |
111 | 92 |
112 TP_PROTO(const struct sock *sk, const struct sk_buff *skb), | 93 TP_PROTO(const struct sock *sk, 94 const struct sk_buff *skb, 95 const enum sk_rst_reason reason), |
113 | 96 |
114 TP_ARGS(sk, skb) | 97 TP_ARGS(sk, skb, reason), 98 99 TP_STRUCT__entry( 100 __field(const void *, skbaddr) 101 __field(const void *, skaddr) 102 __field(int, state) 103 __field(enum sk_rst_reason, reason) 104 __array(__u8, saddr, sizeof(struct sockaddr_in6)) 105 __array(__u8, daddr, sizeof(struct sockaddr_in6)) 106 ), 107 108 TP_fast_assign( 109 __entry->skbaddr = skb; 110 __entry->skaddr = sk; 111 /* Zero means unknown state. */ 112 __entry->state = sk ? sk->sk_state : 0; 113 114 memset(__entry->saddr, 0, sizeof(struct sockaddr_in6)); 115 memset(__entry->daddr, 0, sizeof(struct sockaddr_in6)); 116 117 if (sk && sk_fullsock(sk)) { 118 const struct inet_sock *inet = inet_sk(sk); 119 120 TP_STORE_ADDR_PORTS(__entry, inet, sk); 121 } else if (skb) { 122 const struct tcphdr *th = (const struct tcphdr *)skb->data; 123 /* 124 * We should reverse the 4-tuple of skb, so later 125 * it can print the right flow direction of rst. 126 */ 127 TP_STORE_ADDR_PORTS_SKB(skb, th, entry->daddr, entry->saddr); 128 } 129 __entry->reason = reason; 130 ), 131 132 TP_printk("skbaddr=%p skaddr=%p src=%pISpc dest=%pISpc state=%s reason=%s", 133 __entry->skbaddr, __entry->skaddr, 134 __entry->saddr, __entry->daddr, 135 __entry->state ? show_tcp_state_name(__entry->state) : "UNKNOWN", 136 __print_symbolic(__entry->reason, DEFINE_RST_REASON(FN, FNe))) |
115); 116 | 137); 138 |
139#undef FN 140#undef FNe 141 |
|
117/* 118 * tcp event with arguments sk 119 * 120 * Note: this class requires a valid sk pointer. 121 */ 122DECLARE_EVENT_CLASS(tcp_event_sk, 123 124 TP_PROTO(struct sock *sk), --- 172 unchanged lines hidden (view full) --- 297 show_family_name(__entry->family), 298 __entry->saddr, __entry->daddr, __entry->mark, 299 __entry->data_len, __entry->snd_nxt, __entry->snd_una, 300 __entry->snd_cwnd, __entry->ssthresh, __entry->snd_wnd, 301 __entry->srtt, __entry->rcv_wnd, __entry->sock_cookie, 302 __entry->skbaddr, __entry->skaddr) 303); 304 | 142/* 143 * tcp event with arguments sk 144 * 145 * Note: this class requires a valid sk pointer. 146 */ 147DECLARE_EVENT_CLASS(tcp_event_sk, 148 149 TP_PROTO(struct sock *sk), --- 172 unchanged lines hidden (view full) --- 322 show_family_name(__entry->family), 323 __entry->saddr, __entry->daddr, __entry->mark, 324 __entry->data_len, __entry->snd_nxt, __entry->snd_una, 325 __entry->snd_cwnd, __entry->ssthresh, __entry->snd_wnd, 326 __entry->srtt, __entry->rcv_wnd, __entry->sock_cookie, 327 __entry->skbaddr, __entry->skaddr) 328); 329 |
305#define TP_STORE_ADDR_PORTS_SKB_V4(__entry, skb) \ 306 do { \ 307 const struct tcphdr *th = (const struct tcphdr *)skb->data; \ 308 struct sockaddr_in *v4 = (void *)__entry->saddr; \ 309 \ 310 v4->sin_family = AF_INET; \ 311 v4->sin_port = th->source; \ 312 v4->sin_addr.s_addr = ip_hdr(skb)->saddr; \ 313 v4 = (void *)__entry->daddr; \ 314 v4->sin_family = AF_INET; \ 315 v4->sin_port = th->dest; \ 316 v4->sin_addr.s_addr = ip_hdr(skb)->daddr; \ 317 } while (0) 318 319#if IS_ENABLED(CONFIG_IPV6) 320 321#define TP_STORE_ADDR_PORTS_SKB(__entry, skb) \ 322 do { \ 323 const struct iphdr *iph = ip_hdr(skb); \ 324 \ 325 if (iph->version == 6) { \ 326 const struct tcphdr *th = (const struct tcphdr *)skb->data; \ 327 struct sockaddr_in6 *v6 = (void *)__entry->saddr; \ 328 \ 329 v6->sin6_family = AF_INET6; \ 330 v6->sin6_port = th->source; \ 331 v6->sin6_addr = ipv6_hdr(skb)->saddr; \ 332 v6 = (void *)__entry->daddr; \ 333 v6->sin6_family = AF_INET6; \ 334 v6->sin6_port = th->dest; \ 335 v6->sin6_addr = ipv6_hdr(skb)->daddr; \ 336 } else \ 337 TP_STORE_ADDR_PORTS_SKB_V4(__entry, skb); \ 338 } while (0) 339 340#else 341 342#define TP_STORE_ADDR_PORTS_SKB(__entry, skb) \ 343 TP_STORE_ADDR_PORTS_SKB_V4(__entry, skb) 344 345#endif 346 | |
347/* 348 * tcp event with only skb 349 */ 350DECLARE_EVENT_CLASS(tcp_event_skb, 351 352 TP_PROTO(const struct sk_buff *skb), 353 354 TP_ARGS(skb), 355 356 TP_STRUCT__entry( 357 __field(const void *, skbaddr) 358 __array(__u8, saddr, sizeof(struct sockaddr_in6)) 359 __array(__u8, daddr, sizeof(struct sockaddr_in6)) 360 ), 361 362 TP_fast_assign( | 330/* 331 * tcp event with only skb 332 */ 333DECLARE_EVENT_CLASS(tcp_event_skb, 334 335 TP_PROTO(const struct sk_buff *skb), 336 337 TP_ARGS(skb), 338 339 TP_STRUCT__entry( 340 __field(const void *, skbaddr) 341 __array(__u8, saddr, sizeof(struct sockaddr_in6)) 342 __array(__u8, daddr, sizeof(struct sockaddr_in6)) 343 ), 344 345 TP_fast_assign( |
346 const struct tcphdr *th = (const struct tcphdr *)skb->data; |
|
363 __entry->skbaddr = skb; 364 365 memset(__entry->saddr, 0, sizeof(struct sockaddr_in6)); 366 memset(__entry->daddr, 0, sizeof(struct sockaddr_in6)); 367 | 347 __entry->skbaddr = skb; 348 349 memset(__entry->saddr, 0, sizeof(struct sockaddr_in6)); 350 memset(__entry->daddr, 0, sizeof(struct sockaddr_in6)); 351 |
368 TP_STORE_ADDR_PORTS_SKB(__entry, skb); | 352 TP_STORE_ADDR_PORTS_SKB(skb, th, __entry->saddr, __entry->daddr); |
369 ), 370 371 TP_printk("skbaddr=%p src=%pISpc dest=%pISpc", 372 __entry->skbaddr, __entry->saddr, __entry->daddr) 373); 374 375DEFINE_EVENT(tcp_event_skb, tcp_bad_csum, 376 --- 57 unchanged lines hidden --- | 353 ), 354 355 TP_printk("skbaddr=%p src=%pISpc dest=%pISpc", 356 __entry->skbaddr, __entry->saddr, __entry->daddr) 357); 358 359DEFINE_EVENT(tcp_event_skb, tcp_bad_csum, 360 --- 57 unchanged lines hidden --- |