ANDROID: GKI: net: add vendor hooks net qos for gki purpose

Add vendor hooks to support net qos policy feature:

1.android_rvh_tcp_select_window
We want to modify the tcp_select_window return value

2.android_rvh_inet_sock_create; android_rvh_inet_sock_release
We want to add a field when a inet sock is created

3.android_vh_tcp_rtt_estimator
To record the rtt of tcp connections for specified uids

4.android_vh_build_skb_around
To initialize the oem data field in the skb_shared_info structure

Bug: 335081123
Bug: 424394849

Change-Id: Ibb22813c5004464416346d2c4c526d6cc5531fcc
Signed-off-by: jujiang <jyu.jiang@vivo.corp-partner.google.com>
This commit is contained in:
jujiang
2024-04-23 09:55:43 +08:00
committed by Treehugger Robot
parent ba45069401
commit b6fa3795ff
8 changed files with 67 additions and 0 deletions

View File

@@ -93,6 +93,18 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_priority_skip);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_set_priority);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_restore_priority);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_wakeup_ilocked);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_tcp_sendmsg);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_tcp_recvmsg);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_udp_sendmsg);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_udp_recvmsg);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_udpv6_sendmsg);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_udpv6_recvmsg);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_tcp_select_window);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_inet_sock_create);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_inet_sock_release);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tcp_rtt_estimator);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_udp_enqueue_schedule_skb);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_build_skb_around);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_do_send_sig_info);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_killed_process);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mutex_wait_start);

View File

@@ -17,6 +17,8 @@ DECLARE_HOOK(android_vh_ptype_head,
struct nf_conn;
struct sock;
struct net_device;
struct msghdr;
struct sk_buff;
DECLARE_RESTRICTED_HOOK(android_rvh_nf_conn_alloc,
TP_PROTO(struct nf_conn *nf_conn), TP_ARGS(nf_conn), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_nf_conn_free,
@@ -25,6 +27,36 @@ DECLARE_RESTRICTED_HOOK(android_rvh_sk_alloc,
TP_PROTO(struct sock *sock), TP_ARGS(sock), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_sk_free,
TP_PROTO(struct sock *sock), TP_ARGS(sock), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_tcp_sendmsg,
TP_PROTO(struct sock *sk, struct msghdr *msg, size_t len),
TP_ARGS(sk, msg, len), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_tcp_recvmsg,
TP_PROTO(struct sock *sk, struct msghdr *msg, size_t len, int flags, int *addr_len),
TP_ARGS(sk, msg, len, flags, addr_len), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_udp_sendmsg,
TP_PROTO(struct sock *sk, struct msghdr *msg, size_t len),
TP_ARGS(sk, msg, len), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_udp_recvmsg,
TP_PROTO(struct sock *sk, struct msghdr *msg, size_t len, int flags, int *addr_len),
TP_ARGS(sk, msg, len, flags, addr_len), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_udpv6_sendmsg,
TP_PROTO(struct sock *sk, struct msghdr *msg, size_t len),
TP_ARGS(sk, msg, len), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_udpv6_recvmsg,
TP_PROTO(struct sock *sk, struct msghdr *msg, size_t len, int flags, int *addr_len),
TP_ARGS(sk, msg, len, flags, addr_len), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_tcp_select_window,
TP_PROTO(struct sock *sk, u32 *new_win), TP_ARGS(sk, new_win), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_inet_sock_create,
TP_PROTO(struct sock *sk), TP_ARGS(sk), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_inet_sock_release,
TP_PROTO(struct sock *sk), TP_ARGS(sk), 1);
DECLARE_HOOK(android_vh_tcp_rtt_estimator,
TP_PROTO(struct sock *sk, long mrtt_us), TP_ARGS(sk, mrtt_us));
DECLARE_HOOK(android_vh_udp_enqueue_schedule_skb,
TP_PROTO(struct sock *sk, struct sk_buff *skb), TP_ARGS(sk, skb));
DECLARE_HOOK(android_vh_build_skb_around,
TP_PROTO(struct sk_buff *skb), TP_ARGS(skb));
struct poll_table_struct;
typedef struct poll_table_struct poll_table;

View File

@@ -80,6 +80,8 @@
#include <linux/user_namespace.h>
#include <linux/indirect_call_wrapper.h>
#include <trace/hooks/net.h>
#include "dev.h"
#include "sock_destructor.h"
@@ -294,6 +296,7 @@ static void __build_skb_around(struct sk_buff *skb, void *data,
atomic_set(&shinfo->dataref, 1);
skb_set_kcov_handle(skb, kcov_common_handle());
trace_android_vh_build_skb_around(skb);
}
/**

View File

@@ -120,6 +120,7 @@
#include <net/compat.h>
#include <trace/events/sock.h>
#include <trace/hooks/net.h>
/* The inetsw table contains everything that inet_create needs to
* build a new socket.
@@ -386,6 +387,9 @@ lookup_protocol:
if (err)
goto out_sk_release;
}
trace_android_rvh_inet_sock_create(sk);
out:
return err;
out_rcu_unlock:
@@ -413,6 +417,8 @@ int inet_release(struct socket *sock)
if (!sk->sk_kern_sock)
BPF_CGROUP_RUN_PROG_INET_SOCK_RELEASE(sk);
trace_android_rvh_inet_sock_release(sk);
/* Applications forget to leave groups before exiting */
ip_mc_drop_socket(sk);

View File

@@ -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;
@@ -843,6 +844,8 @@ static void tcp_rtt_estimator(struct sock *sk, long mrtt_us)
long m = mrtt_us; /* RTT */
u32 srtt = tp->srtt_us;
trace_android_vh_tcp_rtt_estimator(sk, mrtt_us);
/* The following amusing code comes from Jacobson's
* article in SIGCOMM '88. Note that rtt and mdev
* are scaled versions of rtt and mean deviation.

View File

@@ -46,6 +46,7 @@
#include <linux/static_key.h>
#include <trace/events/tcp.h>
#include <trace/hooks/net.h>
/* Refresh clocks of a TCP socket,
* ensuring monotically increasing values.
@@ -277,6 +278,8 @@ static u16 tcp_select_window(struct sock *sk)
tp->rcv_wnd = new_win;
tp->rcv_wup = tp->rcv_nxt;
trace_android_rvh_tcp_select_window(sk, &new_win);
/* Make sure we do not exceed the maximum possible
* scaled window.
*/

View File

@@ -116,6 +116,7 @@
#if IS_ENABLED(CONFIG_IPV6)
#include <net/ipv6_stubs.h>
#endif
#include <trace/hooks/net.h>
struct udp_table udp_table __read_mostly;
EXPORT_SYMBOL(udp_table);
@@ -1513,6 +1514,8 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)
spinlock_t *busy = NULL;
int size;
trace_android_vh_udp_enqueue_schedule_skb(sk, skb);
/* try to avoid the costly atomic add/sub pair when the receive
* queue is full; always allow at least a packet
*/

View File

@@ -68,6 +68,8 @@
#include <linux/uaccess.h>
#include <linux/mroute6.h>
#include <trace/hooks/net.h>
#include "ip6_offload.h"
MODULE_AUTHOR("Cast of dozens");
@@ -274,6 +276,9 @@ lookup_protocol:
if (err)
goto out_sk_release;
}
trace_android_rvh_inet_sock_create(sk);
out:
return err;
out_rcu_unlock: