mirror of
https://github.com/openharmony/kernel_common_modules_newip.git
synced 2026-07-19 16:43:31 -04:00
tcp sock结构体newip相关定义挪到tcp_nip_sock和tcp_request_sock中
Signed-off-by: yangyanjun <yangyanjun@huawei.com>
This commit is contained in:
@@ -54,8 +54,24 @@ struct ninet_skb_parm {
|
||||
};
|
||||
#pragma pack()
|
||||
|
||||
struct tcp_nip_common {
|
||||
u32 ack_retrans_num;
|
||||
u32 ack_retrans_seq;
|
||||
u32 nip_ssthresh;
|
||||
u32 nip_ssthresh_reset;
|
||||
bool nip_keepalive_enable;
|
||||
u32 idle_ka_probes_out;
|
||||
u32 nip_keepalive_out;
|
||||
u32 last_rcv_nxt;
|
||||
u32 dup_ack_cnt;
|
||||
u32 keepalive_time_bak;
|
||||
u32 keepalive_probes_bak;
|
||||
u32 keepalive_intvl_bak;
|
||||
};
|
||||
|
||||
struct tcp_nip_request_sock {
|
||||
struct tcp_request_sock tcp_nip_rsk_tcp;
|
||||
struct tcp_nip_common common;
|
||||
};
|
||||
|
||||
struct nip_udp_sock {
|
||||
@@ -64,6 +80,7 @@ struct nip_udp_sock {
|
||||
|
||||
struct tcp_nip_sock {
|
||||
struct tcp_sock tcp;
|
||||
struct tcp_nip_common common;
|
||||
};
|
||||
|
||||
#endif /* _NIP_H */
|
||||
|
||||
@@ -159,6 +159,16 @@ static inline bool tcp_nip_write_queue_empty(struct sock *sk)
|
||||
return skb_queue_empty(&sk->sk_write_queue);
|
||||
}
|
||||
|
||||
static inline struct tcp_nip_sock *tcp_nip_sk(const struct sock *sk)
|
||||
{
|
||||
return (struct tcp_nip_sock *)sk;
|
||||
}
|
||||
|
||||
static inline struct tcp_nip_request_sock *tcp_nip_rsk(const struct request_sock *req)
|
||||
{
|
||||
return (struct tcp_nip_request_sock *)req;
|
||||
}
|
||||
|
||||
/* connect */
|
||||
int __tcp_nip_connect(struct sock *sk);
|
||||
int _tcp_nip_conn_request(struct request_sock_ops *rsk_ops,
|
||||
|
||||
@@ -531,6 +531,7 @@ static struct sock *tcp_nip_syn_recv_sock(const struct sock *sk, struct sk_buff
|
||||
struct request_sock *req_unhash,
|
||||
bool *own_req)
|
||||
{
|
||||
struct tcp_nip_request_sock *niptreq = tcp_nip_rsk(req);
|
||||
struct inet_request_sock *ireq = inet_rsk(req);
|
||||
bool found_dup_sk = false;
|
||||
struct tcp_nip_sock *newtcpnipsk;
|
||||
@@ -557,6 +558,7 @@ static struct sock *tcp_nip_syn_recv_sock(const struct sock *sk, struct sk_buff
|
||||
ninet_sk_rx_dst_set(newsk, skb);
|
||||
|
||||
newtcpnipsk = (struct tcp_nip_sock *)newsk;
|
||||
newtcpnipsk->common = niptreq->common;
|
||||
|
||||
newtp = tcp_sk(newsk);
|
||||
newinet = inet_sk(newsk);
|
||||
@@ -689,17 +691,18 @@ void tcp_nip_keepalive_enable(struct sock *sk)
|
||||
#if IS_ENABLED(CONFIG_NEWIP_FAST_KEEPALIVE)
|
||||
int ret;
|
||||
struct tcp_sock *tp = tcp_sk(sk);
|
||||
struct tcp_nip_common *ntp = &tcp_nip_sk(sk)->common;
|
||||
struct sk_buff *skb = tcp_nip_send_head(sk);
|
||||
|
||||
if (!skb)
|
||||
return;
|
||||
|
||||
if (tp->nip_keepalive_enable) {
|
||||
if (ntp->nip_keepalive_enable) {
|
||||
/* If keepalive set by setsockopt, backup para and change para to nip para */
|
||||
if (tp->keepalive_time > HZ) {
|
||||
tp->keepalive_time_bak = tp->keepalive_time;
|
||||
tp->keepalive_probes_bak = tp->keepalive_probes;
|
||||
tp->keepalive_intvl_bak = tp->keepalive_intvl;
|
||||
ntp->keepalive_time_bak = tp->keepalive_time;
|
||||
ntp->keepalive_probes_bak = tp->keepalive_probes;
|
||||
ntp->keepalive_intvl_bak = tp->keepalive_intvl;
|
||||
|
||||
DEBUG("%s HZ=%u, change time/probes/intvl [%u, %u, %u] to [%u, %u, %u]",
|
||||
__func__, HZ, tp->keepalive_time, tp->keepalive_probes,
|
||||
@@ -716,9 +719,9 @@ void tcp_nip_keepalive_enable(struct sock *sk)
|
||||
|
||||
/* If keepalive set by setsockopt, backup para */
|
||||
if (sock_flag(sk, SOCK_KEEPOPEN)) {
|
||||
tp->keepalive_time_bak = tp->keepalive_time;
|
||||
tp->keepalive_probes_bak = tp->keepalive_probes;
|
||||
tp->keepalive_intvl_bak = tp->keepalive_intvl;
|
||||
ntp->keepalive_time_bak = tp->keepalive_time;
|
||||
ntp->keepalive_probes_bak = tp->keepalive_probes;
|
||||
ntp->keepalive_intvl_bak = tp->keepalive_intvl;
|
||||
DEBUG("%s HZ=%u, backup normal time/probes/intvl [%u, %u, %u]", __func__,
|
||||
HZ, tp->keepalive_time, tp->keepalive_probes, tp->keepalive_intvl);
|
||||
}
|
||||
@@ -736,7 +739,7 @@ void tcp_nip_keepalive_enable(struct sock *sk)
|
||||
DEBUG("%s ok, HZ=%u, time/probes/intvl [%u, %u, %u]",
|
||||
__func__, HZ, tp->keepalive_time, tp->keepalive_probes,
|
||||
tp->keepalive_intvl);
|
||||
tp->nip_keepalive_enable = true;
|
||||
ntp->nip_keepalive_enable = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -744,35 +747,36 @@ void tcp_nip_keepalive_disable(struct sock *sk)
|
||||
{
|
||||
#if IS_ENABLED(CONFIG_NEWIP_FAST_KEEPALIVE)
|
||||
struct tcp_sock *tp = tcp_sk(sk);
|
||||
struct tcp_nip_common *ntp = &tcp_nip_sk(sk)->common;
|
||||
|
||||
if (!tp->nip_keepalive_enable)
|
||||
if (!ntp->nip_keepalive_enable)
|
||||
return;
|
||||
|
||||
if (!sock_flag(sk, SOCK_KEEPOPEN)) {
|
||||
tp->nip_keepalive_enable = false;
|
||||
ntp->nip_keepalive_enable = false;
|
||||
DEBUG("%s ok, HZ=%u, normal ka has disable.", __func__, HZ);
|
||||
return;
|
||||
}
|
||||
|
||||
if (tp->idle_ka_probes_out < g_nip_idle_ka_probes_out)
|
||||
if (ntp->idle_ka_probes_out < g_nip_idle_ka_probes_out)
|
||||
return;
|
||||
|
||||
/* newip keepalive change to normal keepalive */
|
||||
if (tp->keepalive_time_bak) {
|
||||
if (ntp->keepalive_time_bak) {
|
||||
DEBUG("%s HZ=%u, change normal time/probes/intvl [%u, %u, %u] to [%u, %u, %u].",
|
||||
__func__, HZ, tp->keepalive_time, tp->keepalive_probes,
|
||||
tp->keepalive_intvl, tp->keepalive_time_bak, tp->keepalive_probes_bak,
|
||||
tp->keepalive_intvl_bak);
|
||||
tp->keepalive_time = tp->keepalive_time_bak;
|
||||
tp->keepalive_probes = tp->keepalive_probes_bak;
|
||||
tp->keepalive_intvl = tp->keepalive_intvl_bak;
|
||||
tp->keepalive_intvl, ntp->keepalive_time_bak, ntp->keepalive_probes_bak,
|
||||
ntp->keepalive_intvl_bak);
|
||||
tp->keepalive_time = ntp->keepalive_time_bak;
|
||||
tp->keepalive_probes = ntp->keepalive_probes_bak;
|
||||
tp->keepalive_intvl = ntp->keepalive_intvl_bak;
|
||||
inet_csk_reset_keepalive_timer(sk, tp->keepalive_time);
|
||||
return;
|
||||
}
|
||||
|
||||
tp->keepalive_time_bak = 0;
|
||||
tp->keepalive_probes_bak = 0;
|
||||
tp->keepalive_intvl_bak = 0;
|
||||
ntp->keepalive_time_bak = 0;
|
||||
ntp->keepalive_probes_bak = 0;
|
||||
ntp->keepalive_intvl_bak = 0;
|
||||
|
||||
/* enable keepalive (SO_KEEPALIVE) */
|
||||
if (sk->sk_prot->keepalive)
|
||||
@@ -780,34 +784,29 @@ void tcp_nip_keepalive_disable(struct sock *sk)
|
||||
sock_valbool_flag(sk, SOCK_KEEPOPEN, 0);
|
||||
|
||||
DEBUG("%s ok, HZ=%u, idle_ka_probes_out=%u", __func__, HZ, g_nip_idle_ka_probes_out);
|
||||
tp->nip_keepalive_enable = false;
|
||||
ntp->nip_keepalive_enable = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void tcp_nip_rtt_init(struct sock *sk)
|
||||
static void _tcp_sock_priv_init(struct sock *sk)
|
||||
{
|
||||
struct tcp_sock *tp = tcp_sk(sk);
|
||||
struct tcp_nip_common *ntp = &tcp_nip_sk(sk)->common;
|
||||
|
||||
memset(ntp, 0, sizeof(*ntp));
|
||||
ntp->nip_ssthresh = g_nip_ssthresh_default;
|
||||
tp->sacked_out = 0;
|
||||
tp->rcv_tstamp = 0;
|
||||
tp->selective_acks[0].start_seq = 0;
|
||||
tp->selective_acks[0].end_seq = 0;
|
||||
tp->ack_retrans_seq = 0;
|
||||
tp->ack_retrans_num = 0;
|
||||
tp->nip_ssthresh = g_nip_ssthresh_default;
|
||||
tp->nip_ssthresh_reset = 0;
|
||||
tp->last_rcv_nxt = 0;
|
||||
tp->dup_ack_cnt = 0;
|
||||
|
||||
tp->nip_keepalive_enable = false;
|
||||
tp->nip_keepalive_out = 0;
|
||||
tp->idle_ka_probes_out = 0;
|
||||
tp->keepalive_time = 0;
|
||||
tp->keepalive_probes = 0;
|
||||
tp->keepalive_intvl = 0;
|
||||
tp->keepalive_time_bak = 0;
|
||||
tp->keepalive_probes_bak = 0;
|
||||
tp->keepalive_intvl_bak = 0;
|
||||
}
|
||||
|
||||
static void tcp_sock_priv_init(struct sock *sk)
|
||||
{
|
||||
_tcp_sock_priv_init(sk);
|
||||
}
|
||||
|
||||
/* Function
|
||||
@@ -822,6 +821,8 @@ static int tcp_nip_init_sock(struct sock *sk)
|
||||
struct inet_connection_sock *icsk = inet_csk(sk);
|
||||
struct tcp_sock *tp = tcp_sk(sk);
|
||||
|
||||
tcp_sock_priv_init(sk);
|
||||
|
||||
tp->out_of_order_queue = RB_ROOT;
|
||||
tcp_nip_init_xmit_timers(sk);
|
||||
INIT_LIST_HEAD(&tp->tsq_node);
|
||||
@@ -838,8 +839,6 @@ static int tcp_nip_init_sock(struct sock *sk)
|
||||
tp->snd_cwnd_clamp = ~0;
|
||||
tp->mss_cache = TCP_MSS_DEFAULT;
|
||||
|
||||
tcp_nip_rtt_init(sk);
|
||||
|
||||
tp->reordering = sock_net(sk)->ipv4.sysctl_tcp_reordering;
|
||||
tp->tsoffset = 0;
|
||||
sk->sk_state = TCP_CLOSE;
|
||||
@@ -1594,7 +1593,7 @@ int tcp_nip_disconnect(struct sock *sk, int flags)
|
||||
__skb_queue_purge(&sk->sk_receive_queue);
|
||||
tcp_write_queue_purge(sk);
|
||||
|
||||
tcp_nip_rtt_init(sk);
|
||||
_tcp_sock_priv_init(sk);
|
||||
|
||||
inet->inet_dport = 0;
|
||||
sk->sk_shutdown = 0;
|
||||
|
||||
@@ -359,6 +359,7 @@ void tcp_nip_send_delayed_ack(struct sock *sk)
|
||||
static void __tcp_nip_ack_snd_check(struct sock *sk, int ofo_possible)
|
||||
{
|
||||
struct tcp_sock *tp = tcp_sk(sk);
|
||||
struct tcp_nip_common *ntp = &tcp_nip_sk(sk)->common;
|
||||
|
||||
inet_csk(sk)->icsk_ack.rcv_mss = tcp_nip_current_mss(sk); // TCP_BASE_MSS
|
||||
|
||||
@@ -368,15 +369,15 @@ static void __tcp_nip_ack_snd_check(struct sock *sk, int ofo_possible)
|
||||
/* We have out of order data. */
|
||||
(ofo_possible && tp->nip_out_of_order_queue)) {
|
||||
if (ofo_possible && tp->nip_out_of_order_queue) {
|
||||
if (tp->rcv_nxt == tp->last_rcv_nxt) {
|
||||
tp->dup_ack_cnt++;
|
||||
if (tp->rcv_nxt == ntp->last_rcv_nxt) {
|
||||
ntp->dup_ack_cnt++;
|
||||
} else {
|
||||
tp->dup_ack_cnt = 0;
|
||||
tp->last_rcv_nxt = tp->rcv_nxt;
|
||||
ntp->dup_ack_cnt = 0;
|
||||
ntp->last_rcv_nxt = tp->rcv_nxt;
|
||||
}
|
||||
if (tp->dup_ack_cnt < g_dup_ack_snd_max)
|
||||
if (ntp->dup_ack_cnt < g_dup_ack_snd_max)
|
||||
tcp_nip_send_ack(sk);
|
||||
else if (tp->dup_ack_cnt % g_dup_ack_snd_max == 0)
|
||||
else if (ntp->dup_ack_cnt % g_dup_ack_snd_max == 0)
|
||||
tcp_nip_send_ack(sk);
|
||||
} else {
|
||||
tcp_nip_send_ack(sk);
|
||||
@@ -568,6 +569,15 @@ void tcp_nip_parse_options(const struct sk_buff *skb,
|
||||
}
|
||||
}
|
||||
|
||||
static void tcp_nip_common_init(struct request_sock *req)
|
||||
{
|
||||
struct tcp_nip_request_sock *niptreq = tcp_nip_rsk(req);
|
||||
struct tcp_nip_common *ntp = &niptreq->common;
|
||||
|
||||
memset(ntp, 0, sizeof(*ntp));
|
||||
ntp->nip_ssthresh = g_nip_ssthresh_default;
|
||||
}
|
||||
|
||||
/* Function
|
||||
* Initializes the connection request block information based
|
||||
* on the options and sequence number in the received SYN segment
|
||||
@@ -583,6 +593,8 @@ static void tcp_nip_openreq_init(struct request_sock *req,
|
||||
{
|
||||
struct inet_request_sock *ireq = inet_rsk(req);
|
||||
|
||||
tcp_nip_common_init(req);
|
||||
|
||||
req->rsk_rcv_wnd = 0;
|
||||
tcp_rsk(req)->rcv_isn = TCP_SKB_CB(skb)->seq;
|
||||
tcp_rsk(req)->rcv_nxt = TCP_SKB_CB(skb)->seq + 1;
|
||||
@@ -937,6 +949,7 @@ static void tcp_nip_ack_retrans(struct sock *sk, u32 ack, int ack_type, u32 retr
|
||||
{
|
||||
int skb_index = 0;
|
||||
struct tcp_sock *tp = tcp_sk(sk);
|
||||
struct tcp_nip_common *ntp = &tcp_nip_sk(sk)->common;
|
||||
struct sk_buff *skb, *tmp;
|
||||
const char *ack_str[ACK_DEF] = {"dup", "nor"};
|
||||
int index = ack_type == DUP_ACK ? DUP_ACK : NOR_ACK;
|
||||
@@ -944,40 +957,40 @@ static void tcp_nip_ack_retrans(struct sock *sk, u32 ack, int ack_type, u32 retr
|
||||
skb_queue_walk_safe(&sk->sk_write_queue, skb, tmp) {
|
||||
if (skb == tcp_nip_send_head(sk)) {
|
||||
SSTHRESH_DBG("%s %s ack retrans(%u) end, ack=%u, seq=%u~%u, pkt_out=%u",
|
||||
__func__, ack_str[index], tp->ack_retrans_num, ack,
|
||||
__func__, ack_str[index], ntp->ack_retrans_num, ack,
|
||||
tp->selective_acks[0].start_seq,
|
||||
tp->selective_acks[0].end_seq, tp->packets_out);
|
||||
tp->selective_acks[0].start_seq = 0;
|
||||
tp->selective_acks[0].end_seq = 0;
|
||||
tp->ack_retrans_seq = 0;
|
||||
tp->ack_retrans_num = 0;
|
||||
ntp->ack_retrans_seq = 0;
|
||||
ntp->ack_retrans_num = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (TCP_SKB_CB(skb)->seq > tp->selective_acks[0].end_seq) {
|
||||
SSTHRESH_DBG("%s %s ack retrans(%u) finish, ack=%u, seq=%u~%u, pkt_out=%u",
|
||||
__func__, ack_str[index], tp->ack_retrans_num, ack,
|
||||
__func__, ack_str[index], ntp->ack_retrans_num, ack,
|
||||
tp->selective_acks[0].start_seq,
|
||||
tp->selective_acks[0].end_seq, tp->packets_out);
|
||||
|
||||
tp->selective_acks[0].start_seq = 0;
|
||||
tp->selective_acks[0].end_seq = 0;
|
||||
tp->ack_retrans_seq = 0;
|
||||
tp->ack_retrans_num = 0;
|
||||
ntp->ack_retrans_seq = 0;
|
||||
ntp->ack_retrans_num = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (TCP_SKB_CB(skb)->seq != tp->ack_retrans_seq)
|
||||
if (TCP_SKB_CB(skb)->seq != ntp->ack_retrans_seq)
|
||||
continue;
|
||||
|
||||
if (skb_index < retrans_num) {
|
||||
tcp_nip_retransmit_skb(sk, skb, 1);
|
||||
skb_index++;
|
||||
tp->ack_retrans_num++;
|
||||
tp->ack_retrans_seq = TCP_SKB_CB(skb)->end_seq;
|
||||
ntp->ack_retrans_num++;
|
||||
ntp->ack_retrans_seq = TCP_SKB_CB(skb)->end_seq;
|
||||
} else {
|
||||
RETRANS_DBG("%s %s ack retrans(%u) no end, ack=%u, seq=%u~%u, pkt_out=%u",
|
||||
__func__, ack_str[index], tp->ack_retrans_num, ack,
|
||||
__func__, ack_str[index], ntp->ack_retrans_num, ack,
|
||||
tp->selective_acks[0].start_seq,
|
||||
tp->selective_acks[0].end_seq, tp->packets_out);
|
||||
break;
|
||||
@@ -993,6 +1006,7 @@ static void tcp_nip_dup_ack_retrans(struct sock *sk, const struct sk_buff *skb,
|
||||
{
|
||||
if (tcp_write_queue_head(sk)) {
|
||||
struct tcp_sock *tp = tcp_sk(sk);
|
||||
struct tcp_nip_common *ntp = &tcp_nip_sk(sk)->common;
|
||||
|
||||
tp->sacked_out++;
|
||||
if (tp->sacked_out == DUP_ACK_RETRANS_START_NUM) {
|
||||
@@ -1002,23 +1016,23 @@ static void tcp_nip_dup_ack_retrans(struct sock *sk, const struct sk_buff *skb,
|
||||
int mss = tcp_nip_current_mss(sk);
|
||||
struct tcphdr *th = (struct tcphdr *)skb->data;
|
||||
u16 discard_num = htons(th->urg_ptr);
|
||||
u32 last_nip_ssthresh = tp->nip_ssthresh;
|
||||
u32 last_nip_ssthresh = ntp->nip_ssthresh;
|
||||
|
||||
if (tp->selective_acks[0].end_seq)
|
||||
SSTHRESH_DBG("%s last retans(%u) not end, seq=%u~%u, pkt_out=%u",
|
||||
__func__, tp->ack_retrans_num,
|
||||
__func__, ntp->ack_retrans_num,
|
||||
tp->selective_acks[0].start_seq,
|
||||
tp->selective_acks[0].end_seq,
|
||||
tp->packets_out);
|
||||
|
||||
tp->selective_acks[0].start_seq = ack;
|
||||
tp->selective_acks[0].end_seq = ack + discard_num * mss;
|
||||
tp->ack_retrans_seq = ack;
|
||||
tp->ack_retrans_num = 0;
|
||||
ntp->ack_retrans_seq = ack;
|
||||
ntp->ack_retrans_num = 0;
|
||||
|
||||
tp->nip_ssthresh = g_ssthresh_low;
|
||||
ntp->nip_ssthresh = g_ssthresh_low;
|
||||
SSTHRESH_DBG("%s new dup ack, win %u to %u, discard_num=%u, seq=%u~%u",
|
||||
__func__, last_nip_ssthresh, tp->nip_ssthresh, discard_num,
|
||||
__func__, last_nip_ssthresh, ntp->nip_ssthresh, discard_num,
|
||||
tp->selective_acks[0].start_seq,
|
||||
tp->selective_acks[0].end_seq);
|
||||
|
||||
@@ -1030,17 +1044,18 @@ static void tcp_nip_dup_ack_retrans(struct sock *sk, const struct sk_buff *skb,
|
||||
static void tcp_nip_nor_ack_retrans(struct sock *sk, u32 ack, u32 retrans_num)
|
||||
{
|
||||
struct tcp_sock *tp = tcp_sk(sk);
|
||||
struct tcp_nip_common *ntp = &tcp_nip_sk(sk)->common;
|
||||
|
||||
if (tp->selective_acks[0].end_seq != 0) {
|
||||
if (ack >= tp->selective_acks[0].end_seq) {
|
||||
SSTHRESH_DBG("%s nor ack retrans(%u) resume, seq=%u~%u, pkt_out=%u, ack=%u",
|
||||
__func__, tp->ack_retrans_num,
|
||||
__func__, ntp->ack_retrans_num,
|
||||
tp->selective_acks[0].start_seq,
|
||||
tp->selective_acks[0].end_seq, tp->packets_out, ack);
|
||||
tp->selective_acks[0].start_seq = 0;
|
||||
tp->selective_acks[0].end_seq = 0;
|
||||
tp->ack_retrans_seq = 0;
|
||||
tp->ack_retrans_num = 0;
|
||||
ntp->ack_retrans_seq = 0;
|
||||
ntp->ack_retrans_num = 0;
|
||||
|
||||
tp->sacked_out = 0;
|
||||
return;
|
||||
@@ -1056,15 +1071,16 @@ static void tcp_nip_ack_calc_ssthresh(struct sock *sk, u32 ack, int icsk_rto_las
|
||||
ktime_t skb_snd_tstamp)
|
||||
{
|
||||
struct tcp_sock *tp = tcp_sk(sk);
|
||||
struct tcp_nip_common *ntp = &tcp_nip_sk(sk)->common;
|
||||
struct inet_connection_sock *icsk = inet_csk(sk);
|
||||
int ack_reset = ack / g_nip_ssthresh_reset;
|
||||
u32 nip_ssthresh;
|
||||
|
||||
if (tp->nip_ssthresh_reset != ack_reset) {
|
||||
if (ntp->nip_ssthresh_reset != ack_reset) {
|
||||
SSTHRESH_DBG("%s ack reset win %u to %u, ack=%u",
|
||||
__func__, tp->nip_ssthresh, g_ssthresh_low, ack);
|
||||
tp->nip_ssthresh_reset = ack_reset;
|
||||
tp->nip_ssthresh = g_ssthresh_low;
|
||||
__func__, ntp->nip_ssthresh, g_ssthresh_low, ack);
|
||||
ntp->nip_ssthresh_reset = ack_reset;
|
||||
ntp->nip_ssthresh = g_ssthresh_low;
|
||||
} else {
|
||||
if (skb_snd_tstamp) {
|
||||
u32 rtt_tstamp = tp->rcv_tstamp - skb_snd_tstamp;
|
||||
@@ -1072,22 +1088,22 @@ static void tcp_nip_ack_calc_ssthresh(struct sock *sk, u32 ack, int icsk_rto_las
|
||||
if (rtt_tstamp >= g_rtt_tstamp_rto_up) {
|
||||
SSTHRESH_DBG("%s rtt %u >= %u, win %u to %u, rto %u to %u, ack=%u",
|
||||
__func__, rtt_tstamp, g_rtt_tstamp_rto_up,
|
||||
tp->nip_ssthresh, g_ssthresh_low_min,
|
||||
ntp->nip_ssthresh, g_ssthresh_low_min,
|
||||
icsk_rto_last, icsk->icsk_rto, ack);
|
||||
|
||||
tp->nip_ssthresh = g_ssthresh_low_min;
|
||||
ntp->nip_ssthresh = g_ssthresh_low_min;
|
||||
} else if (rtt_tstamp >= g_rtt_tstamp_high) {
|
||||
SSTHRESH_DBG("%s rtt %u >= %u, win %u to %u, ack=%u",
|
||||
__func__, rtt_tstamp, g_rtt_tstamp_high,
|
||||
tp->nip_ssthresh, g_ssthresh_low, ack);
|
||||
ntp->nip_ssthresh, g_ssthresh_low, ack);
|
||||
|
||||
tp->nip_ssthresh = g_ssthresh_low;
|
||||
ntp->nip_ssthresh = g_ssthresh_low;
|
||||
} else if (rtt_tstamp >= g_rtt_tstamp_mid_high) {
|
||||
SSTHRESH_DBG("%s rtt %u >= %u, win %u to %u, ack=%u",
|
||||
__func__, rtt_tstamp, g_rtt_tstamp_mid_high,
|
||||
tp->nip_ssthresh, g_ssthresh_mid_low, ack);
|
||||
ntp->nip_ssthresh, g_ssthresh_mid_low, ack);
|
||||
|
||||
tp->nip_ssthresh = g_ssthresh_mid_low;
|
||||
ntp->nip_ssthresh = g_ssthresh_mid_low;
|
||||
} else if (rtt_tstamp >= g_rtt_tstamp_mid_low) {
|
||||
u32 rtt_tstamp_scale = g_rtt_tstamp_mid_high - rtt_tstamp;
|
||||
int half_mid_high = g_ssthresh_mid_high / 2;
|
||||
@@ -1095,25 +1111,25 @@ static void tcp_nip_ack_calc_ssthresh(struct sock *sk, u32 ack, int icsk_rto_las
|
||||
nip_ssthresh = half_mid_high + rtt_tstamp_scale * half_mid_high /
|
||||
(g_rtt_tstamp_mid_high - g_rtt_tstamp_mid_low);
|
||||
|
||||
tp->nip_ssthresh = tp->nip_ssthresh > g_ssthresh_mid_high ?
|
||||
half_mid_high : tp->nip_ssthresh;
|
||||
nip_ssthresh = (tp->nip_ssthresh * g_ssthresh_high_step +
|
||||
nip_ssthresh) / (g_ssthresh_high_step + 1);
|
||||
ntp->nip_ssthresh = ntp->nip_ssthresh > g_ssthresh_mid_high ?
|
||||
half_mid_high : ntp->nip_ssthresh;
|
||||
nip_ssthresh = (ntp->nip_ssthresh * g_ssthresh_high_step +
|
||||
nip_ssthresh) / (g_ssthresh_high_step + 1);
|
||||
|
||||
SSTHRESH_DBG("%s rtt %u >= %u, win %u to %u, ack=%u",
|
||||
__func__, rtt_tstamp, g_rtt_tstamp_mid_low,
|
||||
tp->nip_ssthresh, nip_ssthresh, ack);
|
||||
ntp->nip_ssthresh, nip_ssthresh, ack);
|
||||
|
||||
tp->nip_ssthresh = nip_ssthresh;
|
||||
ntp->nip_ssthresh = nip_ssthresh;
|
||||
} else if (rtt_tstamp != 0) {
|
||||
nip_ssthresh = (tp->nip_ssthresh * g_ssthresh_high_step +
|
||||
g_ssthresh_high) / (g_ssthresh_high_step + 1);
|
||||
nip_ssthresh = (ntp->nip_ssthresh * g_ssthresh_high_step +
|
||||
g_ssthresh_high) / (g_ssthresh_high_step + 1);
|
||||
|
||||
SSTHRESH_DBG("%s rtt %u < %u, win %u to %u, ack=%u",
|
||||
__func__, rtt_tstamp, g_rtt_tstamp_mid_low,
|
||||
tp->nip_ssthresh, nip_ssthresh, ack);
|
||||
ntp->nip_ssthresh, nip_ssthresh, ack);
|
||||
|
||||
tp->nip_ssthresh = nip_ssthresh;
|
||||
ntp->nip_ssthresh = nip_ssthresh;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1122,6 +1138,7 @@ static void tcp_nip_ack_calc_ssthresh(struct sock *sk, u32 ack, int icsk_rto_las
|
||||
static int tcp_nip_ack(struct sock *sk, const struct sk_buff *skb, int flag)
|
||||
{
|
||||
struct tcp_sock *tp = tcp_sk(sk);
|
||||
struct tcp_nip_common *ntp = &tcp_nip_sk(sk)->common;
|
||||
struct inet_connection_sock *icsk = inet_csk(sk);
|
||||
u32 prior_snd_una = tp->snd_una;
|
||||
u32 ack_seq = TCP_SKB_CB(skb)->seq;
|
||||
@@ -1137,7 +1154,7 @@ static int tcp_nip_ack(struct sock *sk, const struct sk_buff *skb, int flag)
|
||||
|
||||
flag |= tcp_nip_ack_update_window(sk, skb, ack, ack_seq);
|
||||
icsk->icsk_probes_out = 0; // probe0 cnt
|
||||
tp->nip_keepalive_out = 0; // keepalive cnt
|
||||
ntp->nip_keepalive_out = 0; // keepalive cnt
|
||||
tp->rcv_tstamp = tcp_jiffies32;
|
||||
|
||||
/* maybe zero window probe */
|
||||
|
||||
@@ -129,6 +129,7 @@ u32 __nip_tcp_select_window(struct sock *sk)
|
||||
{
|
||||
struct inet_connection_sock *icsk = inet_csk(sk);
|
||||
struct tcp_sock *tp = tcp_sk(sk);
|
||||
struct tcp_nip_common *ntp = &tcp_nip_sk(sk)->common;
|
||||
int mss = tcp_nip_current_mss(sk); /* TCP_BASE_MSS */
|
||||
int allowed_space = tcp_full_space(sk);
|
||||
int full_space = min_t(int, tp->window_clamp, allowed_space); /* Total receive cache */
|
||||
@@ -155,7 +156,8 @@ u32 __nip_tcp_select_window(struct sock *sk)
|
||||
|
||||
if (g_nip_tcp_rcv_win_enable) {
|
||||
if (g_ssthresh_enable == 1)
|
||||
free_space = free_space > tp->nip_ssthresh ? tp->nip_ssthresh : free_space;
|
||||
free_space = free_space > ntp->nip_ssthresh ?
|
||||
ntp->nip_ssthresh : free_space;
|
||||
else
|
||||
free_space = free_space > tp->rcv_ssthresh ? tp->rcv_ssthresh : free_space;
|
||||
} else {
|
||||
@@ -1042,15 +1044,16 @@ static bool tcp_nip_write_xmit(struct sock *sk, unsigned int mss_now, int nonagl
|
||||
int push_one, gfp_t gfp)
|
||||
{
|
||||
struct tcp_sock *tp = tcp_sk(sk);
|
||||
struct tcp_nip_common *ntp = &tcp_nip_sk(sk)->common;
|
||||
struct sk_buff *skb;
|
||||
u32 snd_num = g_nip_tcp_snd_win_enable ? (tp->nip_ssthresh / mss_now) : 0xFFFFFFFF;
|
||||
u32 last_nip_ssthresh = tp->nip_ssthresh;
|
||||
u32 snd_num = g_nip_tcp_snd_win_enable ? (ntp->nip_ssthresh / mss_now) : 0xFFFFFFFF;
|
||||
u32 last_nip_ssthresh = ntp->nip_ssthresh;
|
||||
bool snd_wnd_ready;
|
||||
static const char * const str[] = {"can`t send pkt because no window",
|
||||
"have window to send pkt"};
|
||||
|
||||
tcp_nip_keepalive_enable(sk);
|
||||
tp->idle_ka_probes_out = 0;
|
||||
ntp->idle_ka_probes_out = 0;
|
||||
|
||||
tcp_mstamp_refresh(tp);
|
||||
|
||||
@@ -1058,11 +1061,11 @@ static bool tcp_nip_write_xmit(struct sock *sk, unsigned int mss_now, int nonagl
|
||||
u32 tstamp = tcp_jiffies32 - tp->rcv_tstamp;
|
||||
|
||||
if (tstamp >= g_ack_to_nxt_snd_tstamp) {
|
||||
tp->nip_ssthresh = g_ssthresh_low_min;
|
||||
snd_num = tp->nip_ssthresh / mss_now;
|
||||
ntp->nip_ssthresh = g_ssthresh_low_min;
|
||||
snd_num = ntp->nip_ssthresh / mss_now;
|
||||
SSTHRESH_DBG("%s new snd tstamp %u >= %u, ssthresh %u to %u, snd_num=%u",
|
||||
__func__, tstamp, g_ack_to_nxt_snd_tstamp,
|
||||
last_nip_ssthresh, tp->nip_ssthresh, snd_num);
|
||||
last_nip_ssthresh, ntp->nip_ssthresh, snd_num);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -137,6 +137,7 @@ static int tcp_nip_write_timeout(struct sock *sk)
|
||||
void tcp_nip_retransmit_timer(struct sock *sk)
|
||||
{
|
||||
struct tcp_sock *tp = tcp_sk(sk);
|
||||
struct tcp_nip_common *ntp = &tcp_nip_sk(sk)->common;
|
||||
struct inet_connection_sock *icsk = inet_csk(sk);
|
||||
struct sk_buff *skb = tcp_write_queue_head(sk);
|
||||
struct tcp_skb_cb *scb = TCP_SKB_CB(skb);
|
||||
@@ -161,7 +162,8 @@ void tcp_nip_retransmit_timer(struct sock *sk)
|
||||
TCP_RTO_MAX);
|
||||
|
||||
SSTHRESH_DBG("%s seq %u retransmit fail, win=%u, rto=%u, pkt_out=%u",
|
||||
__func__, scb->seq, tp->nip_ssthresh, icsk->icsk_rto, tp->packets_out);
|
||||
__func__, scb->seq, ntp->nip_ssthresh,
|
||||
icsk->icsk_rto, tp->packets_out);
|
||||
return;
|
||||
}
|
||||
icsk->icsk_backoff++;
|
||||
@@ -171,10 +173,10 @@ void tcp_nip_retransmit_timer(struct sock *sk)
|
||||
icsk->icsk_rto = min(icsk->icsk_rto << 1, TCP_RTO_MAX);
|
||||
|
||||
SSTHRESH_DBG("%s seq %u, reset win %u to %u, rto %u to %u, pkt_out=%u",
|
||||
__func__, scb->seq, tp->nip_ssthresh, g_ssthresh_low,
|
||||
__func__, scb->seq, ntp->nip_ssthresh, g_ssthresh_low,
|
||||
icsk_rto_last, icsk->icsk_rto, tp->packets_out);
|
||||
|
||||
tp->nip_ssthresh = g_ssthresh_low;
|
||||
ntp->nip_ssthresh = g_ssthresh_low;
|
||||
|
||||
inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, icsk->icsk_rto, TCP_RTO_MAX);
|
||||
}
|
||||
@@ -280,6 +282,7 @@ static bool tcp_nip_keepalive_is_timeout(struct sock *sk, u32 elapsed)
|
||||
{
|
||||
struct inet_connection_sock *icsk = inet_csk(sk);
|
||||
struct tcp_sock *tp = tcp_sk(sk);
|
||||
struct tcp_nip_common *ntp = &tcp_nip_sk(sk)->common;
|
||||
u32 keepalive_time = keepalive_time_when(tp);
|
||||
bool is_timeout = false;
|
||||
|
||||
@@ -290,11 +293,11 @@ static bool tcp_nip_keepalive_is_timeout(struct sock *sk, u32 elapsed)
|
||||
*/
|
||||
if ((icsk->icsk_user_timeout != 0 &&
|
||||
elapsed >= msecs_to_jiffies(icsk->icsk_user_timeout) &&
|
||||
tp->nip_keepalive_out > 0) ||
|
||||
ntp->nip_keepalive_out > 0) ||
|
||||
(icsk->icsk_user_timeout == 0 &&
|
||||
tp->nip_keepalive_out >= keepalive_probes(tp))) {
|
||||
ntp->nip_keepalive_out >= keepalive_probes(tp))) {
|
||||
DEBUG("%s normal keepalive timeout, keepalive_out=%u.",
|
||||
__func__, tp->nip_keepalive_out);
|
||||
__func__, ntp->nip_keepalive_out);
|
||||
tcp_nip_write_err(sk);
|
||||
is_timeout = true;
|
||||
}
|
||||
@@ -307,6 +310,7 @@ static void tcp_nip_keepalive_timer(struct timer_list *t)
|
||||
{
|
||||
struct sock *sk = from_timer(sk, t, sk_timer);
|
||||
struct tcp_sock *tp = tcp_sk(sk);
|
||||
struct tcp_nip_common *ntp = &tcp_nip_sk(sk)->common;
|
||||
u32 elapsed;
|
||||
|
||||
/* Only process if socket is not in use. */
|
||||
@@ -348,8 +352,8 @@ static void tcp_nip_keepalive_timer(struct timer_list *t)
|
||||
goto out;
|
||||
|
||||
if (tcp_nip_write_wakeup(sk, LINUX_MIB_TCPKEEPALIVE) <= 0) {
|
||||
tp->nip_keepalive_out++;
|
||||
tp->idle_ka_probes_out++;
|
||||
ntp->nip_keepalive_out++;
|
||||
ntp->idle_ka_probes_out++;
|
||||
elapsed = keepalive_intvl_when(tp);
|
||||
} else {
|
||||
/* If keepalive was lost due to local congestion,
|
||||
|
||||
Reference in New Issue
Block a user