ANDROID: vendor_hooks: Add vendor hook to the net
android_vh_ptype_head: To add a debugging chain to ptype list android_vh_kfree_skb To sniff the dropped packet at kernel network Bug: 163716381 Signed-off-by: Bae Soukjin <soukjin.bae@samsung.com> Change-Id: Ide80bf0a129da31a1824d4a33026ac42be327361
This commit is contained in:
parent
cc14895110
commit
d88b2969cf
@ -9,6 +9,7 @@
|
||||
#define CREATE_TRACE_POINTS
|
||||
#include <trace/hooks/vendor_hooks.h>
|
||||
#include <trace/hooks/dtask.h>
|
||||
#include <trace/hooks/net.h>
|
||||
|
||||
/*
|
||||
* Export tracepoints that act as a bare tracehook (ie: have no trace event
|
||||
@ -21,4 +22,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_read_wait_finish);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_write_wait_start);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_write_wait_finish);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sched_show_task);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ptype_head);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_kfree_skb);
|
||||
|
||||
|
27
include/trace/hooks/net.h
Normal file
27
include/trace/hooks/net.h
Normal file
@ -0,0 +1,27 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
|
||||
#undef TRACE_SYSTEM
|
||||
#define TRACE_SYSTEM net
|
||||
#define TRACE_INCLUDE_PATH trace/hooks
|
||||
|
||||
#if !defined(_TRACE_HOOK_NET_VH_H) || defined(TRACE_HEADER_MULTI_READ)
|
||||
#define _TRACE_HOOK_NET_VH_H
|
||||
#include <linux/tracepoint.h>
|
||||
#include <trace/hooks/vendor_hooks.h>
|
||||
|
||||
#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_ANDROID_VENDOR_HOOKS)
|
||||
struct packet_type;
|
||||
struct list_head;
|
||||
struct sk_buff;
|
||||
DECLARE_HOOK(android_vh_ptype_head,
|
||||
TP_PROTO(const struct packet_type *pt, struct list_head *vendor_pt),
|
||||
TP_ARGS(pt, vendor_pt));
|
||||
DECLARE_HOOK(android_vh_kfree_skb,
|
||||
TP_PROTO(struct sk_buff *skb), TP_ARGS(skb));
|
||||
#else
|
||||
#define trace_android_vh_ptype_head(pt, vendor_pt)
|
||||
#define trace_android_vh_kfree_skb(skb)
|
||||
#endif
|
||||
#endif /* _TRACE_HOOK_NET_VH_H */
|
||||
/* This part must be outside protection */
|
||||
#include <trace/define_trace.h>
|
@ -143,6 +143,7 @@
|
||||
#include <linux/net_namespace.h>
|
||||
#include <linux/indirect_call_wrapper.h>
|
||||
#include <net/devlink.h>
|
||||
#include <trace/hooks/net.h>
|
||||
|
||||
#include "net-sysfs.h"
|
||||
|
||||
@ -302,6 +303,12 @@ EXPORT_PER_CPU_SYMBOL(softnet_data);
|
||||
|
||||
static inline struct list_head *ptype_head(const struct packet_type *pt)
|
||||
{
|
||||
struct list_head vendor_pt = { .next = NULL, };
|
||||
|
||||
trace_android_vh_ptype_head(pt, &vendor_pt);
|
||||
if (vendor_pt.next)
|
||||
return vendor_pt.next;
|
||||
|
||||
if (pt->type == htons(ETH_P_ALL))
|
||||
return pt->dev ? &pt->dev->ptype_all : &ptype_all;
|
||||
else
|
||||
|
@ -75,6 +75,7 @@
|
||||
#include <linux/capability.h>
|
||||
#include <linux/user_namespace.h>
|
||||
#include <linux/indirect_call_wrapper.h>
|
||||
#include <trace/hooks/net.h>
|
||||
|
||||
#include "datagram.h"
|
||||
|
||||
@ -693,6 +694,7 @@ void kfree_skb(struct sk_buff *skb)
|
||||
if (!skb_unref(skb))
|
||||
return;
|
||||
|
||||
trace_android_vh_kfree_skb(skb);
|
||||
trace_kfree_skb(skb, __builtin_return_address(0));
|
||||
__kfree_skb(skb);
|
||||
}
|
||||
|
@ -79,6 +79,7 @@
|
||||
#include <trace/events/tcp.h>
|
||||
#include <linux/jump_label_ratelimit.h>
|
||||
#include <net/busy_poll.h>
|
||||
#include <trace/hooks/net.h>
|
||||
|
||||
int sysctl_tcp_max_orphans __read_mostly = NR_FILE;
|
||||
|
||||
@ -4481,6 +4482,7 @@ static bool tcp_ooo_try_coalesce(struct sock *sk,
|
||||
|
||||
static void tcp_drop(struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
trace_android_vh_kfree_skb(skb);
|
||||
sk_drops_add(sk, skb);
|
||||
__kfree_skb(skb);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user