forked from Minki/linux
ec43908dd5
It is annoying to add new skb drop reasons to 'enum skb_drop_reason' and TRACE_SKB_DROP_REASON in trace/event/skb.h, and it's easy to forget to add the new reasons we added to TRACE_SKB_DROP_REASON. TRACE_SKB_DROP_REASON is used to convert drop reason of type number to string. For now, the string we passed to user space is exactly the same as the name in 'enum skb_drop_reason' with a 'SKB_DROP_REASON_' prefix. Therefore, we can use 'auto-generation' to generate these drop reasons to string at build time. The new source 'dropreason_str.c' will be auto generated during build time, which contains the string array 'const char * const drop_reasons[]'. Signed-off-by: Menglong Dong <imagedong@tencent.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
81 lines
1.5 KiB
C
81 lines
1.5 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#undef TRACE_SYSTEM
|
|
#define TRACE_SYSTEM skb
|
|
|
|
#if !defined(_TRACE_SKB_H) || defined(TRACE_HEADER_MULTI_READ)
|
|
#define _TRACE_SKB_H
|
|
|
|
#include <linux/skbuff.h>
|
|
#include <linux/netdevice.h>
|
|
#include <linux/tracepoint.h>
|
|
|
|
/*
|
|
* Tracepoint for free an sk_buff:
|
|
*/
|
|
TRACE_EVENT(kfree_skb,
|
|
|
|
TP_PROTO(struct sk_buff *skb, void *location,
|
|
enum skb_drop_reason reason),
|
|
|
|
TP_ARGS(skb, location, reason),
|
|
|
|
TP_STRUCT__entry(
|
|
__field(void *, skbaddr)
|
|
__field(void *, location)
|
|
__field(unsigned short, protocol)
|
|
__field(enum skb_drop_reason, reason)
|
|
),
|
|
|
|
TP_fast_assign(
|
|
__entry->skbaddr = skb;
|
|
__entry->location = location;
|
|
__entry->protocol = ntohs(skb->protocol);
|
|
__entry->reason = reason;
|
|
),
|
|
|
|
TP_printk("skbaddr=%p protocol=%u location=%p reason: %s",
|
|
__entry->skbaddr, __entry->protocol, __entry->location,
|
|
drop_reasons[__entry->reason])
|
|
);
|
|
|
|
TRACE_EVENT(consume_skb,
|
|
|
|
TP_PROTO(struct sk_buff *skb),
|
|
|
|
TP_ARGS(skb),
|
|
|
|
TP_STRUCT__entry(
|
|
__field( void *, skbaddr )
|
|
),
|
|
|
|
TP_fast_assign(
|
|
__entry->skbaddr = skb;
|
|
),
|
|
|
|
TP_printk("skbaddr=%p", __entry->skbaddr)
|
|
);
|
|
|
|
TRACE_EVENT(skb_copy_datagram_iovec,
|
|
|
|
TP_PROTO(const struct sk_buff *skb, int len),
|
|
|
|
TP_ARGS(skb, len),
|
|
|
|
TP_STRUCT__entry(
|
|
__field( const void *, skbaddr )
|
|
__field( int, len )
|
|
),
|
|
|
|
TP_fast_assign(
|
|
__entry->skbaddr = skb;
|
|
__entry->len = len;
|
|
),
|
|
|
|
TP_printk("skbaddr=%p len=%d", __entry->skbaddr, __entry->len)
|
|
);
|
|
|
|
#endif /* _TRACE_SKB_H */
|
|
|
|
/* This part must be outside protection */
|
|
#include <trace/define_trace.h>
|