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
(cherry picked from commit d88b2969cf
)
(cherry picked from commit a8021ba684c584b8a4361d1680f6e466748ab012)
This commit is contained in:
@@ -65,6 +65,7 @@
|
||||
#include <trace/hooks/fips140.h>
|
||||
#include <trace/hooks/remoteproc.h>
|
||||
#include <trace/hooks/shmem_fs.h>
|
||||
#include <trace/hooks/net.h>
|
||||
|
||||
/*
|
||||
* Export tracepoints that act as a bare tracehook (ie: have no trace event
|
||||
@@ -343,3 +344,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_force_compatible_post);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_print_transaction_info);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_setscheduler_uclamp);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rproc_recovery);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ptype_head);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_kfree_skb);
|
||||
|
25
include/trace/hooks/net.h
Normal file
25
include/trace/hooks/net.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/* 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>
|
||||
|
||||
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));
|
||||
|
||||
/* macro versions of hooks are no longer required */
|
||||
|
||||
#endif /* _TRACE_HOOK_NET_VH_H */
|
||||
/* This part must be outside protection */
|
||||
#include <trace/define_trace.h>
|
@@ -146,6 +146,7 @@
|
||||
#include <net/devlink.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
#include <linux/prandom.h>
|
||||
#include <trace/hooks/net.h>
|
||||
|
||||
#include "net-sysfs.h"
|
||||
|
||||
@@ -510,6 +511,12 @@ static inline void netdev_set_addr_lockdep_class(struct net_device *dev)
|
||||
|
||||
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
|
||||
|
@@ -76,6 +76,7 @@
|
||||
#include <linux/capability.h>
|
||||
#include <linux/user_namespace.h>
|
||||
#include <linux/indirect_call_wrapper.h>
|
||||
#include <trace/hooks/net.h>
|
||||
|
||||
#include "datagram.h"
|
||||
|
||||
@@ -701,6 +702,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);
|
||||
}
|
||||
|
@@ -80,6 +80,7 @@
|
||||
#include <linux/jump_label_ratelimit.h>
|
||||
#include <net/busy_poll.h>
|
||||
#include <net/mptcp.h>
|
||||
#include <trace/hooks/net.h>
|
||||
|
||||
int sysctl_tcp_max_orphans __read_mostly = NR_FILE;
|
||||
|
||||
@@ -4618,6 +4619,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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user