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> 15 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 */ 22 DECLARE_EVENT_CLASS(tcp_event_sk_skb, 23 24 TP_PROTO(const struct sock *sk, const struct sk_buff *skb), 25 26 TP_ARGS(sk, skb), 27 28 TP_STRUCT__entry( 29 __field(const void *, skbaddr) 30 __field(const void *, skaddr) 31 __field(int, state) 32 __field(__u16, sport) 33 __field(__u16, dport) 34 __field(__u16, family) 35 __array(__u8, saddr, 4) 36 __array(__u8, daddr, 4) 37 __array(__u8, saddr_v6, 16) 38 __array(__u8, daddr_v6, 16) 39 ), 40 41 TP_fast_assign( 42 const struct inet_sock *inet = inet_sk(sk); 43 __be32 *p32; 44 45 __entry->skbaddr = skb; 46 __entry->skaddr = sk; 47 __entry->state = sk->sk_state; 48 49 __entry->sport = ntohs(inet->inet_sport); 50 __entry->dport = ntohs(inet->inet_dport); 51 __entry->family = sk->sk_family; 52 53 p32 = (__be32 *) __entry->saddr; 54 *p32 = inet->inet_saddr; 55 56 p32 = (__be32 *) __entry->daddr; 57 *p32 = inet->inet_daddr; 58 59 TP_STORE_ADDRS(__entry, inet->inet_saddr, inet->inet_daddr, 60 sk->sk_v6_rcv_saddr, sk->sk_v6_daddr); 61 ), 62 63 TP_printk("skbaddr=%p skaddr=%p family=%s sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c state=%s", 64 __entry->skbaddr, __entry->skaddr, 65 show_family_name(__entry->family), 66 __entry->sport, __entry->dport, __entry->saddr, __entry->daddr, 67 __entry->saddr_v6, __entry->daddr_v6, 68 show_tcp_state_name(__entry->state)) 69 ); 70 71 DEFINE_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); 80 DEFINE_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 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 */ 91 TRACE_EVENT(tcp_send_reset, 92 93 TP_PROTO(const struct sock *sk, 94 const struct sk_buff *skb__nullable, 95 const enum sk_rst_reason reason), 96 97 TP_ARGS(sk, skb__nullable, 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__nullable; 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__nullable) { 122 const struct tcphdr *th = (const struct tcphdr *)skb__nullable->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__nullable, 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))) 137 ); 138 139 #undef FN 140 #undef FNe 141 142 /* 143 * tcp event with arguments sk 144 * 145 * Note: this class requires a valid sk pointer. 146 */ 147 DECLARE_EVENT_CLASS(tcp_event_sk, 148 149 TP_PROTO(struct sock *sk), 150 151 TP_ARGS(sk), 152 153 TP_STRUCT__entry( 154 __field(const void *, skaddr) 155 __field(__u16, sport) 156 __field(__u16, dport) 157 __field(__u16, family) 158 __array(__u8, saddr, 4) 159 __array(__u8, daddr, 4) 160 __array(__u8, saddr_v6, 16) 161 __array(__u8, daddr_v6, 16) 162 __field(__u64, sock_cookie) 163 ), 164 165 TP_fast_assign( 166 struct inet_sock *inet = inet_sk(sk); 167 __be32 *p32; 168 169 __entry->skaddr = sk; 170 171 __entry->sport = ntohs(inet->inet_sport); 172 __entry->dport = ntohs(inet->inet_dport); 173 __entry->family = sk->sk_family; 174 175 p32 = (__be32 *) __entry->saddr; 176 *p32 = inet->inet_saddr; 177 178 p32 = (__be32 *) __entry->daddr; 179 *p32 = inet->inet_daddr; 180 181 TP_STORE_ADDRS(__entry, inet->inet_saddr, inet->inet_daddr, 182 sk->sk_v6_rcv_saddr, sk->sk_v6_daddr); 183 184 __entry->sock_cookie = sock_gen_cookie(sk); 185 ), 186 187 TP_printk("family=%s sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c sock_cookie=%llx", 188 show_family_name(__entry->family), 189 __entry->sport, __entry->dport, 190 __entry->saddr, __entry->daddr, 191 __entry->saddr_v6, __entry->daddr_v6, 192 __entry->sock_cookie) 193 ); 194 195 DEFINE_EVENT(tcp_event_sk, tcp_receive_reset, 196 197 TP_PROTO(struct sock *sk), 198 199 TP_ARGS(sk) 200 ); 201 202 DEFINE_EVENT(tcp_event_sk, tcp_destroy_sock, 203 204 TP_PROTO(struct sock *sk), 205 206 TP_ARGS(sk) 207 ); 208 209 DEFINE_EVENT(tcp_event_sk, tcp_rcv_space_adjust, 210 211 TP_PROTO(struct sock *sk), 212 213 TP_ARGS(sk) 214 ); 215 216 TRACE_EVENT(tcp_retransmit_synack, 217 218 TP_PROTO(const struct sock *sk, const struct request_sock *req), 219 220 TP_ARGS(sk, req), 221 222 TP_STRUCT__entry( 223 __field(const void *, skaddr) 224 __field(const void *, req) 225 __field(__u16, sport) 226 __field(__u16, dport) 227 __field(__u16, family) 228 __array(__u8, saddr, 4) 229 __array(__u8, daddr, 4) 230 __array(__u8, saddr_v6, 16) 231 __array(__u8, daddr_v6, 16) 232 ), 233 234 TP_fast_assign( 235 struct inet_request_sock *ireq = inet_rsk(req); 236 __be32 *p32; 237 238 __entry->skaddr = sk; 239 __entry->req = req; 240 241 __entry->sport = ireq->ir_num; 242 __entry->dport = ntohs(ireq->ir_rmt_port); 243 __entry->family = sk->sk_family; 244 245 p32 = (__be32 *) __entry->saddr; 246 *p32 = ireq->ir_loc_addr; 247 248 p32 = (__be32 *) __entry->daddr; 249 *p32 = ireq->ir_rmt_addr; 250 251 TP_STORE_ADDRS(__entry, ireq->ir_loc_addr, ireq->ir_rmt_addr, 252 ireq->ir_v6_loc_addr, ireq->ir_v6_rmt_addr); 253 ), 254 255 TP_printk("family=%s sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c", 256 show_family_name(__entry->family), 257 __entry->sport, __entry->dport, 258 __entry->saddr, __entry->daddr, 259 __entry->saddr_v6, __entry->daddr_v6) 260 ); 261 262 #include <trace/events/net_probe_common.h> 263 264 TRACE_EVENT(tcp_probe, 265 266 TP_PROTO(struct sock *sk, struct sk_buff *skb), 267 268 TP_ARGS(sk, skb), 269 270 TP_STRUCT__entry( 271 /* sockaddr_in6 is always bigger than sockaddr_in */ 272 __array(__u8, saddr, sizeof(struct sockaddr_in6)) 273 __array(__u8, daddr, sizeof(struct sockaddr_in6)) 274 __field(__u16, sport) 275 __field(__u16, dport) 276 __field(__u16, family) 277 __field(__u32, mark) 278 __field(__u16, data_len) 279 __field(__u32, snd_nxt) 280 __field(__u32, snd_una) 281 __field(__u32, snd_cwnd) 282 __field(__u32, ssthresh) 283 __field(__u32, snd_wnd) 284 __field(__u32, srtt) 285 __field(__u32, rcv_wnd) 286 __field(__u64, sock_cookie) 287 __field(const void *, skbaddr) 288 __field(const void *, skaddr) 289 ), 290 291 TP_fast_assign( 292 const struct tcphdr *th = (const struct tcphdr *)skb->data; 293 const struct inet_sock *inet = inet_sk(sk); 294 const struct tcp_sock *tp = tcp_sk(sk); 295 296 memset(__entry->saddr, 0, sizeof(struct sockaddr_in6)); 297 memset(__entry->daddr, 0, sizeof(struct sockaddr_in6)); 298 299 TP_STORE_ADDR_PORTS(__entry, inet, sk); 300 301 /* For filtering use */ 302 __entry->sport = ntohs(inet->inet_sport); 303 __entry->dport = ntohs(inet->inet_dport); 304 __entry->mark = skb->mark; 305 __entry->family = sk->sk_family; 306 307 __entry->data_len = skb->len - __tcp_hdrlen(th); 308 __entry->snd_nxt = tp->snd_nxt; 309 __entry->snd_una = tp->snd_una; 310 __entry->snd_cwnd = tcp_snd_cwnd(tp); 311 __entry->snd_wnd = tp->snd_wnd; 312 __entry->rcv_wnd = tp->rcv_wnd; 313 __entry->ssthresh = tcp_current_ssthresh(sk); 314 __entry->srtt = tp->srtt_us >> 3; 315 __entry->sock_cookie = sock_gen_cookie(sk); 316 317 __entry->skbaddr = skb; 318 __entry->skaddr = sk; 319 ), 320 321 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", 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 330 /* 331 * tcp event with only skb 332 */ 333 DECLARE_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; 347 __entry->skbaddr = skb; 348 349 memset(__entry->saddr, 0, sizeof(struct sockaddr_in6)); 350 memset(__entry->daddr, 0, sizeof(struct sockaddr_in6)); 351 352 TP_STORE_ADDR_PORTS_SKB(skb, th, __entry->saddr, __entry->daddr); 353 ), 354 355 TP_printk("skbaddr=%p src=%pISpc dest=%pISpc", 356 __entry->skbaddr, __entry->saddr, __entry->daddr) 357 ); 358 359 DEFINE_EVENT(tcp_event_skb, tcp_bad_csum, 360 361 TP_PROTO(const struct sk_buff *skb), 362 363 TP_ARGS(skb) 364 ); 365 366 TRACE_EVENT(tcp_cong_state_set, 367 368 TP_PROTO(struct sock *sk, const u8 ca_state), 369 370 TP_ARGS(sk, ca_state), 371 372 TP_STRUCT__entry( 373 __field(const void *, skaddr) 374 __field(__u16, sport) 375 __field(__u16, dport) 376 __field(__u16, family) 377 __array(__u8, saddr, 4) 378 __array(__u8, daddr, 4) 379 __array(__u8, saddr_v6, 16) 380 __array(__u8, daddr_v6, 16) 381 __field(__u8, cong_state) 382 ), 383 384 TP_fast_assign( 385 struct inet_sock *inet = inet_sk(sk); 386 __be32 *p32; 387 388 __entry->skaddr = sk; 389 390 __entry->sport = ntohs(inet->inet_sport); 391 __entry->dport = ntohs(inet->inet_dport); 392 __entry->family = sk->sk_family; 393 394 p32 = (__be32 *) __entry->saddr; 395 *p32 = inet->inet_saddr; 396 397 p32 = (__be32 *) __entry->daddr; 398 *p32 = inet->inet_daddr; 399 400 TP_STORE_ADDRS(__entry, inet->inet_saddr, inet->inet_daddr, 401 sk->sk_v6_rcv_saddr, sk->sk_v6_daddr); 402 403 __entry->cong_state = ca_state; 404 ), 405 406 TP_printk("family=%s sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c cong_state=%u", 407 show_family_name(__entry->family), 408 __entry->sport, __entry->dport, 409 __entry->saddr, __entry->daddr, 410 __entry->saddr_v6, __entry->daddr_v6, 411 __entry->cong_state) 412 ); 413 414 DECLARE_EVENT_CLASS(tcp_hash_event, 415 416 TP_PROTO(const struct sock *sk, const struct sk_buff *skb), 417 418 TP_ARGS(sk, skb), 419 420 TP_STRUCT__entry( 421 __field(__u64, net_cookie) 422 __field(const void *, skbaddr) 423 __field(const void *, skaddr) 424 __field(int, state) 425 426 /* sockaddr_in6 is always bigger than sockaddr_in */ 427 __array(__u8, saddr, sizeof(struct sockaddr_in6)) 428 __array(__u8, daddr, sizeof(struct sockaddr_in6)) 429 __field(int, l3index) 430 431 __field(__u16, sport) 432 __field(__u16, dport) 433 __field(__u16, family) 434 435 __field(bool, fin) 436 __field(bool, syn) 437 __field(bool, rst) 438 __field(bool, psh) 439 __field(bool, ack) 440 ), 441 442 TP_fast_assign( 443 const struct tcphdr *th = (const struct tcphdr *)skb->data; 444 445 __entry->net_cookie = sock_net(sk)->net_cookie; 446 __entry->skbaddr = skb; 447 __entry->skaddr = sk; 448 __entry->state = sk->sk_state; 449 450 memset(__entry->saddr, 0, sizeof(struct sockaddr_in6)); 451 memset(__entry->daddr, 0, sizeof(struct sockaddr_in6)); 452 TP_STORE_ADDR_PORTS_SKB(skb, th, __entry->saddr, __entry->daddr); 453 __entry->l3index = inet_sdif(skb) ? inet_iif(skb) : 0; 454 455 /* For filtering use */ 456 __entry->sport = ntohs(th->source); 457 __entry->dport = ntohs(th->dest); 458 __entry->family = sk->sk_family; 459 460 __entry->fin = th->fin; 461 __entry->syn = th->syn; 462 __entry->rst = th->rst; 463 __entry->psh = th->psh; 464 __entry->ack = th->ack; 465 ), 466 467 TP_printk("net=%llu state=%s family=%s src=%pISpc dest=%pISpc L3index=%d [%c%c%c%c%c]", 468 __entry->net_cookie, 469 show_tcp_state_name(__entry->state), 470 show_family_name(__entry->family), 471 __entry->saddr, __entry->daddr, 472 __entry->l3index, 473 __entry->fin ? 'F' : ' ', 474 __entry->syn ? 'S' : ' ', 475 __entry->rst ? 'R' : ' ', 476 __entry->psh ? 'P' : ' ', 477 __entry->ack ? '.' : ' ') 478 ); 479 480 DEFINE_EVENT(tcp_hash_event, tcp_hash_bad_header, 481 482 TP_PROTO(const struct sock *sk, const struct sk_buff *skb), 483 TP_ARGS(sk, skb) 484 ); 485 486 DEFINE_EVENT(tcp_hash_event, tcp_hash_md5_required, 487 488 TP_PROTO(const struct sock *sk, const struct sk_buff *skb), 489 TP_ARGS(sk, skb) 490 ); 491 492 DEFINE_EVENT(tcp_hash_event, tcp_hash_md5_unexpected, 493 494 TP_PROTO(const struct sock *sk, const struct sk_buff *skb), 495 TP_ARGS(sk, skb) 496 ); 497 498 DEFINE_EVENT(tcp_hash_event, tcp_hash_md5_mismatch, 499 500 TP_PROTO(const struct sock *sk, const struct sk_buff *skb), 501 TP_ARGS(sk, skb) 502 ); 503 504 DEFINE_EVENT(tcp_hash_event, tcp_hash_ao_required, 505 506 TP_PROTO(const struct sock *sk, const struct sk_buff *skb), 507 TP_ARGS(sk, skb) 508 ); 509 510 DECLARE_EVENT_CLASS(tcp_ao_event, 511 512 TP_PROTO(const struct sock *sk, const struct sk_buff *skb, 513 const __u8 keyid, const __u8 rnext, const __u8 maclen), 514 515 TP_ARGS(sk, skb, keyid, rnext, maclen), 516 517 TP_STRUCT__entry( 518 __field(__u64, net_cookie) 519 __field(const void *, skbaddr) 520 __field(const void *, skaddr) 521 __field(int, state) 522 523 /* sockaddr_in6 is always bigger than sockaddr_in */ 524 __array(__u8, saddr, sizeof(struct sockaddr_in6)) 525 __array(__u8, daddr, sizeof(struct sockaddr_in6)) 526 __field(int, l3index) 527 528 __field(__u16, sport) 529 __field(__u16, dport) 530 __field(__u16, family) 531 532 __field(bool, fin) 533 __field(bool, syn) 534 __field(bool, rst) 535 __field(bool, psh) 536 __field(bool, ack) 537 538 __field(__u8, keyid) 539 __field(__u8, rnext) 540 __field(__u8, maclen) 541 ), 542 543 TP_fast_assign( 544 const struct tcphdr *th = (const struct tcphdr *)skb->data; 545 546 __entry->net_cookie = sock_net(sk)->net_cookie; 547 __entry->skbaddr = skb; 548 __entry->skaddr = sk; 549 __entry->state = sk->sk_state; 550 551 memset(__entry->saddr, 0, sizeof(struct sockaddr_in6)); 552 memset(__entry->daddr, 0, sizeof(struct sockaddr_in6)); 553 TP_STORE_ADDR_PORTS_SKB(skb, th, __entry->saddr, __entry->daddr); 554 __entry->l3index = inet_sdif(skb) ? inet_iif(skb) : 0; 555 556 /* For filtering use */ 557 __entry->sport = ntohs(th->source); 558 __entry->dport = ntohs(th->dest); 559 __entry->family = sk->sk_family; 560 561 __entry->fin = th->fin; 562 __entry->syn = th->syn; 563 __entry->rst = th->rst; 564 __entry->psh = th->psh; 565 __entry->ack = th->ack; 566 567 __entry->keyid = keyid; 568 __entry->rnext = rnext; 569 __entry->maclen = maclen; 570 ), 571 572 TP_printk("net=%llu state=%s family=%s src=%pISpc dest=%pISpc L3index=%d [%c%c%c%c%c] keyid=%u rnext=%u maclen=%u", 573 __entry->net_cookie, 574 show_tcp_state_name(__entry->state), 575 show_family_name(__entry->family), 576 __entry->saddr, __entry->daddr, 577 __entry->l3index, 578 __entry->fin ? 'F' : ' ', 579 __entry->syn ? 'S' : ' ', 580 __entry->rst ? 'R' : ' ', 581 __entry->psh ? 'P' : ' ', 582 __entry->ack ? '.' : ' ', 583 __entry->keyid, __entry->rnext, __entry->maclen) 584 ); 585 586 DEFINE_EVENT(tcp_ao_event, tcp_ao_handshake_failure, 587 TP_PROTO(const struct sock *sk, const struct sk_buff *skb, 588 const __u8 keyid, const __u8 rnext, const __u8 maclen), 589 TP_ARGS(sk, skb, keyid, rnext, maclen) 590 ); 591 592 DEFINE_EVENT(tcp_ao_event, tcp_ao_wrong_maclen, 593 TP_PROTO(const struct sock *sk, const struct sk_buff *skb, 594 const __u8 keyid, const __u8 rnext, const __u8 maclen), 595 TP_ARGS(sk, skb, keyid, rnext, maclen) 596 ); 597 598 DEFINE_EVENT(tcp_ao_event, tcp_ao_mismatch, 599 TP_PROTO(const struct sock *sk, const struct sk_buff *skb, 600 const __u8 keyid, const __u8 rnext, const __u8 maclen), 601 TP_ARGS(sk, skb, keyid, rnext, maclen) 602 ); 603 604 DEFINE_EVENT(tcp_ao_event, tcp_ao_key_not_found, 605 TP_PROTO(const struct sock *sk, const struct sk_buff *skb, 606 const __u8 keyid, const __u8 rnext, const __u8 maclen), 607 TP_ARGS(sk, skb, keyid, rnext, maclen) 608 ); 609 610 DEFINE_EVENT(tcp_ao_event, tcp_ao_rnext_request, 611 TP_PROTO(const struct sock *sk, const struct sk_buff *skb, 612 const __u8 keyid, const __u8 rnext, const __u8 maclen), 613 TP_ARGS(sk, skb, keyid, rnext, maclen) 614 ); 615 616 DECLARE_EVENT_CLASS(tcp_ao_event_sk, 617 618 TP_PROTO(const struct sock *sk, const __u8 keyid, const __u8 rnext), 619 620 TP_ARGS(sk, keyid, rnext), 621 622 TP_STRUCT__entry( 623 __field(__u64, net_cookie) 624 __field(const void *, skaddr) 625 __field(int, state) 626 627 /* sockaddr_in6 is always bigger than sockaddr_in */ 628 __array(__u8, saddr, sizeof(struct sockaddr_in6)) 629 __array(__u8, daddr, sizeof(struct sockaddr_in6)) 630 631 __field(__u16, sport) 632 __field(__u16, dport) 633 __field(__u16, family) 634 635 __field(__u8, keyid) 636 __field(__u8, rnext) 637 ), 638 639 TP_fast_assign( 640 const struct inet_sock *inet = inet_sk(sk); 641 642 __entry->net_cookie = sock_net(sk)->net_cookie; 643 __entry->skaddr = sk; 644 __entry->state = sk->sk_state; 645 646 memset(__entry->saddr, 0, sizeof(struct sockaddr_in6)); 647 memset(__entry->daddr, 0, sizeof(struct sockaddr_in6)); 648 TP_STORE_ADDR_PORTS(__entry, inet, sk); 649 650 /* For filtering use */ 651 __entry->sport = ntohs(inet->inet_sport); 652 __entry->dport = ntohs(inet->inet_dport); 653 __entry->family = sk->sk_family; 654 655 __entry->keyid = keyid; 656 __entry->rnext = rnext; 657 ), 658 659 TP_printk("net=%llu state=%s family=%s src=%pISpc dest=%pISpc keyid=%u rnext=%u", 660 __entry->net_cookie, 661 show_tcp_state_name(__entry->state), 662 show_family_name(__entry->family), 663 __entry->saddr, __entry->daddr, 664 __entry->keyid, __entry->rnext) 665 ); 666 667 DEFINE_EVENT(tcp_ao_event_sk, tcp_ao_synack_no_key, 668 TP_PROTO(const struct sock *sk, const __u8 keyid, const __u8 rnext), 669 TP_ARGS(sk, keyid, rnext) 670 ); 671 672 DECLARE_EVENT_CLASS(tcp_ao_event_sne, 673 674 TP_PROTO(const struct sock *sk, __u32 new_sne), 675 676 TP_ARGS(sk, new_sne), 677 678 TP_STRUCT__entry( 679 __field(__u64, net_cookie) 680 __field(const void *, skaddr) 681 __field(int, state) 682 683 /* sockaddr_in6 is always bigger than sockaddr_in */ 684 __array(__u8, saddr, sizeof(struct sockaddr_in6)) 685 __array(__u8, daddr, sizeof(struct sockaddr_in6)) 686 687 __field(__u16, sport) 688 __field(__u16, dport) 689 __field(__u16, family) 690 691 __field(__u32, new_sne) 692 ), 693 694 TP_fast_assign( 695 const struct inet_sock *inet = inet_sk(sk); 696 697 __entry->net_cookie = sock_net(sk)->net_cookie; 698 __entry->skaddr = sk; 699 __entry->state = sk->sk_state; 700 701 memset(__entry->saddr, 0, sizeof(struct sockaddr_in6)); 702 memset(__entry->daddr, 0, sizeof(struct sockaddr_in6)); 703 TP_STORE_ADDR_PORTS(__entry, inet, sk); 704 705 /* For filtering use */ 706 __entry->sport = ntohs(inet->inet_sport); 707 __entry->dport = ntohs(inet->inet_dport); 708 __entry->family = sk->sk_family; 709 710 __entry->new_sne = new_sne; 711 ), 712 713 TP_printk("net=%llu state=%s family=%s src=%pISpc dest=%pISpc sne=%u", 714 __entry->net_cookie, 715 show_tcp_state_name(__entry->state), 716 show_family_name(__entry->family), 717 __entry->saddr, __entry->daddr, 718 __entry->new_sne) 719 ); 720 721 DEFINE_EVENT(tcp_ao_event_sne, tcp_ao_snd_sne_update, 722 TP_PROTO(const struct sock *sk, __u32 new_sne), 723 TP_ARGS(sk, new_sne) 724 ); 725 726 DEFINE_EVENT(tcp_ao_event_sne, tcp_ao_rcv_sne_update, 727 TP_PROTO(const struct sock *sk, __u32 new_sne), 728 TP_ARGS(sk, new_sne) 729 ); 730 731 #endif /* _TRACE_TCP_H */ 732 733 /* This part must be outside protection */ 734 #include <trace/define_trace.h> 735