ANDROID: GKI: Add hooks for TCP parameter management.
These hooks allow vendor modules to perform more operations on tcp sockets, thereby ensure efficient transmission of application data. 'trace_android_vh_tcp_fastsyn', 'trace_android_vh_tcp_state_change', 'trace_android_vh_tcp_select_window', 'trace_android_vh_tcp_update_rtt' and 'trace_android_vh_tcp_sock_error' are invoked during different state transitions of a TCP connection. The vendor module will record certain parameter information and adopt different strategies based on the TCP state to ensure the smooth transmission of application data packets. Bug: 354619847 Change-Id: Ia900227adb89592eb81b575f8fcd8f356cd00f7b Signed-off-by: jiangxinpei <huangdezhi@hihonor.com> (cherry picked from commit e8020c62826dea209e70c5b47326592d56dcc254)
This commit is contained in:
committed by
Treehugger Robot
parent
0e47a7391b
commit
51fe955bf6
@@ -243,6 +243,11 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_flush_wq_wait_start);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_flush_wq_wait_finish);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_flush_work_wait_start);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_flush_work_wait_finish);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tcp_sock_error);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tcp_fastsyn);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tcp_state_change);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tcp_select_window);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tcp_update_rtt);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sk_alloc);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sk_free);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_enable_thermal_genl_check);
|
||||
|
||||
@@ -8,6 +8,16 @@
|
||||
#define _TRACE_HOOK_NET_VH_H
|
||||
#include <trace/hooks/vendor_hooks.h>
|
||||
|
||||
#ifndef TCP_STATE_CHANGE_REASON_H
|
||||
#define TCP_STATE_CHANGE_REASON_H
|
||||
enum tcp_state_change_reason {
|
||||
TCP_STATE_CHANGE_REASON_NORMAL,
|
||||
TCP_STATE_CHANGE_REASON_SYN_RST,
|
||||
TCP_STATE_CHANGE_REASON_SYN_TIMEOUT,
|
||||
TCP_STATE_CHANGE_REASON_RETRANSMIT
|
||||
};
|
||||
#endif
|
||||
|
||||
struct packet_type;
|
||||
struct list_head;
|
||||
DECLARE_HOOK(android_vh_ptype_head,
|
||||
@@ -46,6 +56,17 @@ DECLARE_HOOK(android_vh_udp_unicast_rcv_skb,
|
||||
DECLARE_HOOK(android_vh_udp6_unicast_rcv_skb,
|
||||
TP_PROTO(struct sk_buff *skb, struct sock *sk),
|
||||
TP_ARGS(skb, sk));
|
||||
DECLARE_HOOK(android_vh_tcp_sock_error,
|
||||
TP_PROTO(struct sock *sk), TP_ARGS(sk));
|
||||
DECLARE_HOOK(android_vh_tcp_fastsyn,
|
||||
TP_PROTO(struct sock *sk), TP_ARGS(sk));
|
||||
DECLARE_HOOK(android_vh_tcp_select_window,
|
||||
TP_PROTO(struct sock *sk, uint32_t *win), TP_ARGS(sk, win));
|
||||
DECLARE_HOOK(android_vh_tcp_state_change,
|
||||
TP_PROTO(struct sock *sk, enum tcp_state_change_reason reason, int state),
|
||||
TP_ARGS(sk, reason, state));
|
||||
DECLARE_HOOK(android_vh_tcp_update_rtt,
|
||||
TP_PROTO(struct sock *sk, long rtt), TP_ARGS(sk, rtt));
|
||||
DECLARE_HOOK(android_vh_sk_alloc,
|
||||
TP_PROTO(struct sock *sk), TP_ARGS(sk));
|
||||
DECLARE_HOOK(android_vh_sk_free,
|
||||
|
||||
@@ -284,6 +284,7 @@
|
||||
#include <net/hotdata.h>
|
||||
#include <trace/events/tcp.h>
|
||||
#include <net/rps.h>
|
||||
#include <trace/hooks/net.h>
|
||||
|
||||
#include "../core/devmem.h"
|
||||
|
||||
@@ -2869,6 +2870,8 @@ void tcp_set_state(struct sock *sk, int state)
|
||||
{
|
||||
int oldstate = sk->sk_state;
|
||||
|
||||
trace_android_vh_tcp_state_change(sk, TCP_STATE_CHANGE_REASON_NORMAL, state);
|
||||
|
||||
/* We defined a new enum for TCP states that are exported in BPF
|
||||
* so as not force the internal TCP states to be frozen. The
|
||||
* following checks will detect if an internal state value ever
|
||||
|
||||
@@ -3222,6 +3222,8 @@ static bool tcp_ack_update_rtt(struct sock *sk, const int flag,
|
||||
if (seq_rtt_us < 0)
|
||||
return false;
|
||||
|
||||
trace_android_vh_tcp_update_rtt(sk, seq_rtt_us);
|
||||
|
||||
/* ca_rtt_us >= 0 is counting on the invariant that ca_rtt_us is
|
||||
* always taken together with ACK, SACK, or TS-opts. Any negative
|
||||
* values will be skipped with the seq_rtt_us < 0 check above.
|
||||
@@ -4622,6 +4624,8 @@ void tcp_fin(struct sock *sk)
|
||||
tcp_sack_reset(&tp->rx_opt);
|
||||
|
||||
if (!sock_flag(sk, SOCK_DEAD)) {
|
||||
trace_android_vh_tcp_sock_error(sk);
|
||||
|
||||
sk->sk_state_change(sk);
|
||||
|
||||
/* Do not send POLL_HUP for half duplex close. */
|
||||
@@ -6483,6 +6487,8 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,
|
||||
|
||||
if (th->rst) {
|
||||
tcp_reset(sk, skb);
|
||||
|
||||
trace_android_vh_tcp_state_change(sk, TCP_STATE_CHANGE_REASON_SYN_RST, 0);
|
||||
consume:
|
||||
__kfree_skb(skb);
|
||||
return 0;
|
||||
|
||||
@@ -274,6 +274,9 @@ static u16 tcp_select_window(struct sock *sk)
|
||||
|
||||
cur_win = tcp_receive_window(tp);
|
||||
new_win = __tcp_select_window(sk);
|
||||
|
||||
trace_android_vh_tcp_select_window(sk, &new_win);
|
||||
|
||||
if (new_win < cur_win) {
|
||||
/* Danger Will Robinson!
|
||||
* Don't update rcv_wup/rcv_wnd here or else
|
||||
|
||||
@@ -293,10 +293,15 @@ static int tcp_write_timeout(struct sock *sk)
|
||||
|
||||
if (expired) {
|
||||
/* Has it gone just too far? */
|
||||
|
||||
trace_android_vh_tcp_state_change(sk, TCP_STATE_CHANGE_REASON_SYN_TIMEOUT, 0);
|
||||
|
||||
tcp_write_err(sk);
|
||||
return 1;
|
||||
}
|
||||
|
||||
trace_android_vh_tcp_state_change(sk, TCP_STATE_CHANGE_REASON_RETRANSMIT, 0);
|
||||
|
||||
if (sk_rethink_txhash(sk)) {
|
||||
tp->timeout_rehash++;
|
||||
__NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPTIMEOUTREHASH);
|
||||
@@ -667,6 +672,8 @@ out_reset_timer:
|
||||
*/
|
||||
icsk->icsk_backoff++;
|
||||
icsk->icsk_rto = min(icsk->icsk_rto << 1, TCP_RTO_MAX);
|
||||
|
||||
trace_android_vh_tcp_fastsyn(sk);
|
||||
}
|
||||
inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS,
|
||||
tcp_clamp_rto_to_user_timeout(sk), TCP_RTO_MAX);
|
||||
|
||||
Reference in New Issue
Block a user