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

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
parent 39626e91c7
commit a57c7e9250
8 changed files with 41 additions and 0 deletions
+6
View File
@@ -293,6 +293,12 @@ 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_should_memcg_bypass);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpu_capacity_show);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_init);
+13
View File
@@ -112,6 +112,19 @@ DECLARE_RESTRICTED_HOOK(android_rvh_udpv6_sendmsg,
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);
struct sk_buff;
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));
/* macro versions of hooks are no longer required */
+6
View File
@@ -88,6 +88,8 @@
#include <linux/indirect_call_wrapper.h>
#include <linux/textsearch.h>
#include <trace/hooks/net.h>
#include "dev.h"
#include "netmem_priv.h"
#include "sock_destructor.h"
@@ -432,6 +434,8 @@ struct sk_buff *slab_build_skb(void *data)
data = __slab_build_skb(skb, data, &size);
__finalize_skb_around(skb, data, size);
trace_android_vh_build_skb_around(skb);
return skb;
}
EXPORT_SYMBOL(slab_build_skb);
@@ -449,6 +453,8 @@ static void __build_skb_around(struct sk_buff *skb, void *data,
data = __slab_build_skb(skb, data, &size);
__finalize_skb_around(skb, data, size);
trace_android_vh_build_skb_around(skb);
}
/**
+5
View File
@@ -392,6 +392,9 @@ lookup_protocol:
if (err)
goto out_sk_release;
}
trace_android_rvh_inet_sock_create(sk);
out:
trace_android_vh_inet_create(sk, err);
return err;
@@ -420,6 +423,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);
+2
View File
@@ -881,6 +881,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.
+2
View File
@@ -299,6 +299,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.
*/
+2
View File
@@ -1581,6 +1581,8 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)
spinlock_t *busy = NULL;
int size, rcvbuf;
trace_android_vh_udp_enqueue_schedule_skb(sk, skb);
/* Immediately drop when the receive queue is full.
* Always allow at least one packet.
*/
+5
View File
@@ -70,6 +70,8 @@
#include <linux/mroute6.h>
#include <trace/hooks/net.h>
#include <trace/hooks/net.h>
#include "ip6_offload.h"
MODULE_AUTHOR("Cast of dozens");
@@ -267,6 +269,9 @@ lookup_protocol:
if (err)
goto out_sk_release;
}
trace_android_rvh_inet_sock_create(sk);
out:
trace_android_vh_inet_create(sk, err);
return err;