diff --git a/src/linux/net/newip/nip_input.c b/src/linux/net/newip/nip_input.c index 5ea944392cf80e1c678c5ec93d00f09fb9a6d1b3..64a5e90495edd684f8c90844fe2400a3c6585725 100644 --- a/src/linux/net/newip/nip_input.c +++ b/src/linux/net/newip/nip_input.c @@ -44,7 +44,7 @@ static int _nip_update_recv_skb_len(struct sk_buff *skb, static int nip_rcv_finish(struct sk_buff *skb) { struct net *net = dev_net(skb->dev); - void (*edemux)(struct sk_buff *skb); + void (*edemux)(struct sk_buff *skb) = NULL; /* set /proc/sys/net/ipv4/ip_early_demux to change sysctl_ip_early_demux, * which is used by ipv4, ipv6 and newip diff --git a/src/linux/net/newip/nip_output.c b/src/linux/net/newip/nip_output.c index 6c5642a61850c220342b1de9327dd1f5a0ae11f9..3ede2a062510125a9c9c8a9131b84f1fc9048ae1 100644 --- a/src/linux/net/newip/nip_output.c +++ b/src/linux/net/newip/nip_output.c @@ -312,8 +312,7 @@ static int nip_dst_lookup_tail(struct net *net, const struct sock *sk, rt = (struct nip_rt_info *)*dst; if (*dst == &net->newip.nip_broadcast_entry->dst) { - if (!&fln->saddr) - fln->saddr = fln->daddr; + fln->saddr = fln->daddr; err = 0; } else { err = nip_route_get_saddr(net, rt, &fln->daddr, &fln->saddr); diff --git a/src/linux/net/newip/tcp_nip.c b/src/linux/net/newip/tcp_nip.c index 7c6a02610d801185f2fb21e6b72908736bafd835..ce19f60f7e575225018d2c6e3ec6fd373f46b38d 100644 --- a/src/linux/net/newip/tcp_nip.c +++ b/src/linux/net/newip/tcp_nip.c @@ -1108,7 +1108,7 @@ int tcp_nip_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonbloc int copied = 0; u32 *seq; unsigned long used; - int err; + int err = 0; int target; long timeo; size_t len_tmp = len; @@ -1381,25 +1381,35 @@ static int tcp_nip_rcv(struct sk_buff *skb) int ret; int dif = skb->skb_iif; - if (skb->pkt_type != PACKET_HOST) + if (skb->pkt_type != PACKET_HOST) { + DEBUG("%s unknown pkt-type(%u), drop skb.", __func__, skb->pkt_type); goto discard_it; + } - if (!nip_get_tcp_input_checksum(skb)) + if (!nip_get_tcp_input_checksum(skb)) { + DEBUG("%s checksum fail, drop skb.", __func__); goto discard_it; + } th = (const struct tcphdr *)skb->data; - if (unlikely(th->doff < sizeof(struct tcphdr) / TCP_NUM_4)) - goto bad_packet; + if (unlikely(th->doff < sizeof(struct tcphdr) / TCP_NUM_4)) { + DEBUG("%s non-four byte alignment, drop skb.", __func__); + goto discard_it; + } sk = __ninet_lookup_skb(&tcp_hashinfo, skb, __tcp_hdrlen(th), - th->source, th->dest, dif, - &refcounted); - if (!sk) + th->source, th->dest, dif, &refcounted); + if (!sk) { + DEBUG("%s: can`t find related sock for skb, will disconnect.", __func__); goto no_tcp_socket; + } - if (sk->sk_state == TCP_TIME_WAIT) - goto do_time_wait; + if (sk->sk_state == TCP_TIME_WAIT) { + /* Handles the SK portion of the interrupt state */ + DEBUG("%s sk_state is TCP_TIME_WAIT, drop skb.", __func__); + goto discard_it; + } if (sk->sk_state == TCP_NEW_SYN_RECV) { struct request_sock *req = inet_reqsk(sk); struct sock *nsk; @@ -1420,11 +1430,12 @@ static int tcp_nip_rcv(struct sk_buff *skb) nsk = tcp_nip_check_req(sk, skb, req); } if (!nsk || nsk == sk) { - DEBUG("%s skb info error and create newsk failure!!!", __func__); + DEBUG("%s skb info error and create newsk failure, drop skb.", __func__); reqsk_put(req); goto discard_and_relse; } if (tcp_nip_child_process(sk, nsk, skb)) { + DEBUG("%s child process fail, drop skb.", __func__); goto discard_and_relse; } else { sock_put(sk); @@ -1434,8 +1445,10 @@ static int tcp_nip_rcv(struct sk_buff *skb) tcp_nip_fill_cb(skb, th); - if (tcp_filter(sk, skb)) + if (tcp_filter(sk, skb)) { + DEBUG("%s tcp filter fail, drop skb.", __func__); goto discard_and_relse; + } th = (const struct tcphdr *)skb->data; skb->dev = NULL; @@ -1453,8 +1466,10 @@ static int tcp_nip_rcv(struct sk_buff *skb) } else { DEBUG("%s: sock locked by user! put packet into backlog", __func__); - if (tcp_nip_add_backlog(sk, skb)) + if (tcp_nip_add_backlog(sk, skb)) { + DEBUG("%s add backlog fail, drop skb.", __func__); goto discard_and_relse; + } } bh_unlock_sock(sk); @@ -1465,14 +1480,9 @@ put_and_return: return ret ? -1 : 0; no_tcp_socket: - /* Checksum checked, send reset back */ tcp_nip_send_reset(NULL, skb); - DEBUG("%s: cannot find related tcp sock for skb", __func__); - goto discard_it; -bad_packet: goto discard_it; discard_it: - DEBUG("%s: drop tcp newip skb and release it", __func__); kfree_skb(skb); return 0; @@ -1481,9 +1491,6 @@ discard_and_relse: if (refcounted) sock_put(sk); goto discard_it; -/* Handles the SK portion of the interrupt state */ -do_time_wait: - goto discard_it; } static void tcp_nip_early_demux(struct sk_buff *skb) diff --git a/src/linux/net/newip/tcp_nip_input.c b/src/linux/net/newip/tcp_nip_input.c index a01dcf1e425758fde8baf00298c45761a7fbe68e..7b2a3c893245d33552763c9818c42838632ec6a1 100644 --- a/src/linux/net/newip/tcp_nip_input.c +++ b/src/linux/net/newip/tcp_nip_input.c @@ -429,7 +429,7 @@ static int tcp_nip_clean_rtx_queue(struct sock *sk, ktime_t *skb_snd_tstamp) while ((skb = tcp_write_queue_head(sk)) && skb != tcp_nip_send_head(sk)) { struct tcp_skb_cb *scb = TCP_SKB_CB(skb); - u32 acked_pcount; + u32 acked_pcount = 0; if (after(scb->end_seq, tp->snd_una)) { if (tcp_skb_pcount(skb) == 1 || !after(tp->snd_una, scb->seq)) @@ -827,7 +827,7 @@ int _tcp_nip_conn_request(struct request_sock_ops *rsk_ops, /* The best way to do this is to prink the value of user_mss and see if it is 0 */ tmp_opt.user_mss = tp->rx_opt.user_mss; /* Parsing of TCP options in SKB */ - tcp_nip_parse_options(skb, &tmp_opt, 0, false); + tcp_nip_parse_options(skb, &tmp_opt, 0, NULL); /* Tstamp_ok indicates the TIMESTAMP seen on the received SYN packet */ tmp_opt.tstamp_ok = tmp_opt.saw_tstamp; diff --git a/src/linux/net/newip/tcp_nip_output.c b/src/linux/net/newip/tcp_nip_output.c index 15d64bb089906c71183a08d710babfd9a67cbaba..80a69ba065cc43515b9a8cb4132c29e13622024d 100644 --- a/src/linux/net/newip/tcp_nip_output.c +++ b/src/linux/net/newip/tcp_nip_output.c @@ -166,19 +166,18 @@ u32 __nip_tcp_select_window(struct sock *sk) /* Don't do rounding if we are using window scaling, since the * scaled window will not line up with the MSS boundary anyway. + * tp->rx_opt.rcv_wscale is always true */ - if (tp->rx_opt.rcv_wscale) { - window = free_space; + window = free_space; - /* Advertise enough space so that it won't get scaled away. - * Import case: prevent zero window announcement if - * 1< mss. - */ - window = ALIGN(window, (1 << tp->rx_opt.rcv_wscale)); - DEBUG("%s wscale(%u) win change [%u to %u], [allowed|free]space=[%u, %u], mss=%u", - __func__, tp->rx_opt.rcv_wscale, free_space, window, - allowed_space, free_space, mss); - } + /* Advertise enough space so that it won't get scaled away. + * Import case: prevent zero window announcement if + * 1< mss. + */ + window = ALIGN(window, (1 << tp->rx_opt.rcv_wscale)); + DEBUG("%s wscale(%u) win change [%u to %u], [allowed|free]space=[%u, %u], mss=%u", + __func__, tp->rx_opt.rcv_wscale, free_space, window, + allowed_space, free_space, mss); return window; } diff --git a/src/linux/net/newip/tcp_nip_parameter.c b/src/linux/net/newip/tcp_nip_parameter.c index dcd42eb13ce8809d676132cfed584a51d09cbfd0..1badd91f3745d4dca480d172f0ff049bd50278de 100644 --- a/src/linux/net/newip/tcp_nip_parameter.c +++ b/src/linux/net/newip/tcp_nip_parameter.c @@ -136,6 +136,12 @@ module_param_named(nip_keepalive_time, g_nip_keepalive_time, int, 0644); int g_nip_keepalive_intvl = 25; module_param_named(nip_keepalive_intvl, g_nip_keepalive_intvl, int, 0644); +/*********************************************************************************************/ +/* probe parameters */ +/*********************************************************************************************/ +int g_nip_probe_max = 2000; +module_param_named(nip_probe_max, g_nip_probe_max, int, 0644); + /*********************************************************************************************/ /* window mode parameters */ /*********************************************************************************************/ diff --git a/src/linux/net/newip/tcp_nip_parameter.h b/src/linux/net/newip/tcp_nip_parameter.h index 9d830beaa75730b4b6320d7aa765b19f3552906f..6630f6d77e11569691d9dfef386e0dfffef29ed6 100644 --- a/src/linux/net/newip/tcp_nip_parameter.h +++ b/src/linux/net/newip/tcp_nip_parameter.h @@ -76,6 +76,11 @@ extern int g_nip_keepalive_intvl; extern bool g_nip_tcp_snd_win_enable; extern bool g_nip_tcp_rcv_win_enable; +/*********************************************************************************************/ +/* probe parameters */ +/*********************************************************************************************/ +extern int g_nip_probe_max; + /*********************************************************************************************/ /* nip debug parameters */ /*********************************************************************************************/ @@ -92,7 +97,7 @@ do { \ /* Debugging of packet retransmission after ACK */ extern int g_ack_retrans_debug; - #define RETRANS_DBG(fmt, ...) \ +#define RETRANS_DBG(fmt, ...) \ do { \ if (g_ack_retrans_debug) \ pr_crit(fmt, ##__VA_ARGS__); \ diff --git a/src/linux/net/newip/tcp_nip_timer.c b/src/linux/net/newip/tcp_nip_timer.c index 07aeec22d7273c85426474f6702cc069ffa28a58..aa7f1ca27ec3945decc9f21757c5c7895b1a66bd 100644 --- a/src/linux/net/newip/tcp_nip_timer.c +++ b/src/linux/net/newip/tcp_nip_timer.c @@ -181,7 +181,6 @@ void tcp_nip_retransmit_timer(struct sock *sk) inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, icsk->icsk_rto, TCP_RTO_MAX); } -#define NIP_MAX_PROBES 2000 void tcp_nip_probe_timer(struct sock *sk) { struct inet_connection_sock *icsk = inet_csk(sk); @@ -198,11 +197,8 @@ void tcp_nip_probe_timer(struct sock *sk) return; } -#ifdef NIP_MAX_PROBES - max_probes = NIP_MAX_PROBES; // 2000 - fix session auto close -#else - max_probes = sock_net(sk)->ipv4.sysctl_tcp_retries2; -#endif + /* default: sock_net(sk)->ipv4.sysctl_tcp_retries2 */ + max_probes = g_nip_probe_max; /* fix session auto close */ if (sock_flag(sk, SOCK_DEAD)) { const bool alive = inet_csk_rto_backoff(icsk, TCP_RTO_MAX) < TCP_RTO_MAX; @@ -224,6 +220,8 @@ abort: icsk_backoff = icsk->icsk_backoff; __func__, icsk_probes_out, icsk_backoff, max_probes); tcp_nip_write_err(sk); } else { + icsk_backoff = icsk->icsk_backoff; + icsk_probes_out = icsk->icsk_probes_out; DEBUG("%s will send probe0, icsk_probes_out=%u, icsk_backoff=%u, max_probes=%u", __func__, icsk_probes_out, icsk_backoff, max_probes); /* Only send another probe if we didn't close things up. */