mirror of
https://github.com/openharmony/kernel_common_modules_newip.git
synced 2026-07-19 16:43:31 -04:00
newip内核插桩方式调整 (部分功能转移至kernel_linux_5.10)
Signed-off-by: liangbotong <liangbotong@huawei.com>
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* NewIP Hooks
|
||||
*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
*/
|
||||
#ifdef CONFIG_NEWIP_HOOKS
|
||||
|
||||
#undef TRACE_SYSTEM
|
||||
#define TRACE_SYSTEM nip_hooks /* Header file name */
|
||||
#define TRACE_INCLUDE_PATH trace/hooks /* Header file directory */
|
||||
|
||||
/* Header files prevent duplicate definitions */
|
||||
#if !defined(_TRACE_HOOK_NIP_H) || defined(TRACE_HEADER_MULTI_READ)
|
||||
#define _TRACE_HOOK_NIP_H
|
||||
#include <linux/tracepoint.h>
|
||||
#include <trace/hooks/vendor_hooks.h>
|
||||
|
||||
struct net;
|
||||
struct nip_addr;
|
||||
DECLARE_HOOK(ninet_ehashfn_hook,
|
||||
TP_PROTO(const struct sock *sk, u32 *ret),
|
||||
TP_ARGS(sk, ret)
|
||||
);
|
||||
|
||||
struct net_device;
|
||||
DECLARE_HOOK(ninet_gifconf_hook,
|
||||
TP_PROTO(struct net_device *dev, char __user *buf, int len, int size, int *ret),
|
||||
TP_ARGS(dev, buf, len, size, ret)
|
||||
);
|
||||
#endif /* end of _TRACE_HOOK_NIP_H */
|
||||
|
||||
/* This part must be outside protection */
|
||||
#include <trace/define_trace.h>
|
||||
|
||||
#endif /* end of CONFIG_NEWIP_HOOKS */
|
||||
|
||||
@@ -13,5 +13,3 @@ newip-objs += tcp_nip.o ninet_connection_sock.o ninet_hashtables.o tcp_nip_outpu
|
||||
|
||||
newip-objs += nip_hooks_register.o
|
||||
|
||||
# net/newip/hooks/Makefile
|
||||
obj-$(CONFIG_NEWIP) += hooks/
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
#include <linux/netlink.h>
|
||||
|
||||
#ifdef CONFIG_NEWIP_HOOKS
|
||||
#include <trace/hooks/nip_hooks.h>
|
||||
#include <trace/hooks/inet.h>
|
||||
#include "nip_hooks_register.h"
|
||||
#endif
|
||||
#include "tcp_nip_parameter.h"
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
#
|
||||
|
||||
config NEWIP_HOOKS
|
||||
def_bool NEWIP
|
||||
bool "NEWIP HOOKS"
|
||||
default n
|
||||
depends on VENDOR_HOOKS && NEWIP
|
||||
help
|
||||
Enable NewIP hooks implemented as tracepoints
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
#
|
||||
# Makefile for NewIP Hooks
|
||||
#
|
||||
|
||||
ccflags-y += -I$(src) # needed for trace events
|
||||
|
||||
obj-$(CONFIG_NEWIP_HOOKS) += nip_hooks.o
|
||||
@@ -1,14 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
*
|
||||
* NewIP Hooks
|
||||
*/
|
||||
#define CREATE_TRACE_POINTS
|
||||
#include <trace/hooks/vendor_hooks.h>
|
||||
#include <trace/hooks/nip_hooks.h>
|
||||
|
||||
#ifdef CONFIG_NEWIP_HOOKS
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(ninet_ehashfn_hook);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(ninet_gifconf_hook);
|
||||
#endif
|
||||
@@ -9,17 +9,17 @@
|
||||
|
||||
#include <net/ninet_hashtables.h> /* ninet_ehashfn */
|
||||
#include <net/if_ninet.h>
|
||||
#include <trace/hooks/nip_hooks.h>
|
||||
#include <trace/hooks/inet.h>
|
||||
#include "tcp_nip_parameter.h"
|
||||
|
||||
void ninet_ehashfn_hook(void *data, const struct sock *sk, u32 *ret)
|
||||
void vendor_ninet_ehashfn(void *data, const struct sock *sk, u32 *ret)
|
||||
{
|
||||
*ret = ninet_ehashfn(sock_net(sk), &sk->sk_nip_rcv_saddr,
|
||||
sk->sk_num, &sk->sk_nip_daddr, sk->sk_dport);
|
||||
}
|
||||
|
||||
void ninet_gifconf_hook(void *data, struct net_device *dev,
|
||||
char __user *buf, int len, int size, int *ret)
|
||||
void vendor_ninet_gifconf(void *data, struct net_device *dev,
|
||||
char __user *buf, int len, int size, int *ret)
|
||||
{
|
||||
if (*ret >= 0) {
|
||||
int done = ninet_gifconf(dev, buf + *ret, len - *ret, size);
|
||||
@@ -35,15 +35,15 @@ int ninet_hooks_register(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = register_trace_ninet_ehashfn_hook(&ninet_ehashfn_hook, NULL);
|
||||
ret = register_trace_vendor_ninet_ehashfn(&vendor_ninet_ehashfn, NULL);
|
||||
if (ret) {
|
||||
nip_dbg("failed to register to ninet_ehashfn_hook");
|
||||
nip_dbg("failed to register to vendor_ninet_ehashfn");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = register_trace_ninet_gifconf_hook(&ninet_gifconf_hook, NULL);
|
||||
ret = register_trace_vendor_ninet_gifconf(&vendor_ninet_gifconf, NULL);
|
||||
if (ret) {
|
||||
nip_dbg("failed to register to ninet_gifconf_hook");
|
||||
nip_dbg("failed to register to vendor_ninet_gifconf");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user