Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Li Zefan | d0b6e04 | 2009-07-13 10:33:21 +0800 | [diff] [blame] | 2 | #undef TRACE_SYSTEM |
| 3 | #define TRACE_SYSTEM skb |
| 4 | |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 5 | #if !defined(_TRACE_SKB_H) || defined(TRACE_HEADER_MULTI_READ) |
| 6 | #define _TRACE_SKB_H |
Neil Horman | 4893d39 | 2009-03-11 09:48:26 +0000 | [diff] [blame] | 7 | |
Josh Stone | 5393f31 | 2009-03-24 09:44:28 +0000 | [diff] [blame] | 8 | #include <linux/skbuff.h> |
Neil Horman | e9b3cc1 | 2009-08-13 05:19:44 +0000 | [diff] [blame] | 9 | #include <linux/netdevice.h> |
Josh Stone | 5393f31 | 2009-03-24 09:44:28 +0000 | [diff] [blame] | 10 | #include <linux/tracepoint.h> |
| 11 | |
Menglong Dong | c504e5c | 2022-01-09 14:36:26 +0800 | [diff] [blame] | 12 | #define TRACE_SKB_DROP_REASON \ |
| 13 | EM(SKB_DROP_REASON_NOT_SPECIFIED, NOT_SPECIFIED) \ |
Menglong Dong | 8512559 | 2022-01-09 14:36:27 +0800 | [diff] [blame] | 14 | EM(SKB_DROP_REASON_NO_SOCKET, NO_SOCKET) \ |
| 15 | EM(SKB_DROP_REASON_PKT_TOO_SMALL, PKT_TOO_SMALL) \ |
| 16 | EM(SKB_DROP_REASON_TCP_CSUM, TCP_CSUM) \ |
Menglong Dong | 364df53 | 2022-01-27 17:13:01 +0800 | [diff] [blame] | 17 | EM(SKB_DROP_REASON_SOCKET_FILTER, SOCKET_FILTER) \ |
Menglong Dong | 1c7fab7 | 2022-01-09 14:36:28 +0800 | [diff] [blame] | 18 | EM(SKB_DROP_REASON_UDP_CSUM, UDP_CSUM) \ |
Menglong Dong | c504e5c | 2022-01-09 14:36:26 +0800 | [diff] [blame] | 19 | EMe(SKB_DROP_REASON_MAX, MAX) |
| 20 | |
| 21 | #undef EM |
| 22 | #undef EMe |
| 23 | |
| 24 | #define EM(a, b) TRACE_DEFINE_ENUM(a); |
| 25 | #define EMe(a, b) TRACE_DEFINE_ENUM(a); |
| 26 | |
| 27 | TRACE_SKB_DROP_REASON |
| 28 | |
| 29 | #undef EM |
| 30 | #undef EMe |
| 31 | #define EM(a, b) { a, #b }, |
| 32 | #define EMe(a, b) { a, #b } |
| 33 | |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 34 | /* |
| 35 | * Tracepoint for free an sk_buff: |
| 36 | */ |
| 37 | TRACE_EVENT(kfree_skb, |
| 38 | |
Menglong Dong | c504e5c | 2022-01-09 14:36:26 +0800 | [diff] [blame] | 39 | TP_PROTO(struct sk_buff *skb, void *location, |
| 40 | enum skb_drop_reason reason), |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 41 | |
Menglong Dong | c504e5c | 2022-01-09 14:36:26 +0800 | [diff] [blame] | 42 | TP_ARGS(skb, location, reason), |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 43 | |
| 44 | TP_STRUCT__entry( |
Menglong Dong | c504e5c | 2022-01-09 14:36:26 +0800 | [diff] [blame] | 45 | __field(void *, skbaddr) |
| 46 | __field(void *, location) |
| 47 | __field(unsigned short, protocol) |
| 48 | __field(enum skb_drop_reason, reason) |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 49 | ), |
| 50 | |
| 51 | TP_fast_assign( |
| 52 | __entry->skbaddr = skb; |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 53 | __entry->location = location; |
David Sharp | ca9da2d | 2010-12-03 16:13:23 -0800 | [diff] [blame] | 54 | __entry->protocol = ntohs(skb->protocol); |
Menglong Dong | c504e5c | 2022-01-09 14:36:26 +0800 | [diff] [blame] | 55 | __entry->reason = reason; |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 56 | ), |
| 57 | |
Menglong Dong | c504e5c | 2022-01-09 14:36:26 +0800 | [diff] [blame] | 58 | TP_printk("skbaddr=%p protocol=%u location=%p reason: %s", |
| 59 | __entry->skbaddr, __entry->protocol, __entry->location, |
| 60 | __print_symbolic(__entry->reason, |
| 61 | TRACE_SKB_DROP_REASON)) |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 62 | ); |
| 63 | |
Koki Sanagi | 07dc22e | 2010-08-23 18:46:12 +0900 | [diff] [blame] | 64 | TRACE_EVENT(consume_skb, |
| 65 | |
| 66 | TP_PROTO(struct sk_buff *skb), |
| 67 | |
| 68 | TP_ARGS(skb), |
| 69 | |
| 70 | TP_STRUCT__entry( |
| 71 | __field( void *, skbaddr ) |
| 72 | ), |
| 73 | |
| 74 | TP_fast_assign( |
| 75 | __entry->skbaddr = skb; |
| 76 | ), |
| 77 | |
| 78 | TP_printk("skbaddr=%p", __entry->skbaddr) |
| 79 | ); |
| 80 | |
Neil Horman | e9b3cc1 | 2009-08-13 05:19:44 +0000 | [diff] [blame] | 81 | TRACE_EVENT(skb_copy_datagram_iovec, |
| 82 | |
| 83 | TP_PROTO(const struct sk_buff *skb, int len), |
| 84 | |
| 85 | TP_ARGS(skb, len), |
| 86 | |
| 87 | TP_STRUCT__entry( |
| 88 | __field( const void *, skbaddr ) |
| 89 | __field( int, len ) |
| 90 | ), |
| 91 | |
| 92 | TP_fast_assign( |
| 93 | __entry->skbaddr = skb; |
| 94 | __entry->len = len; |
| 95 | ), |
| 96 | |
| 97 | TP_printk("skbaddr=%p len=%d", __entry->skbaddr, __entry->len) |
| 98 | ); |
| 99 | |
Steven Rostedt | ea20d92 | 2009-04-10 08:54:16 -0400 | [diff] [blame] | 100 | #endif /* _TRACE_SKB_H */ |
Steven Rostedt | a8d154b | 2009-04-10 09:36:00 -0400 | [diff] [blame] | 101 | |
| 102 | /* This part must be outside protection */ |
| 103 | #include <trace/define_trace.h> |