netfilter: ipt_SYNPROXY: Pass snet into synproxy_send_tcp
[cascardo/linux.git] / net / ipv4 / tcp_output.c
index 1188e4f..4cd0b50 100644 (file)
@@ -164,6 +164,9 @@ static void tcp_event_data_sent(struct tcp_sock *tp,
        struct inet_connection_sock *icsk = inet_csk(sk);
        const u32 now = tcp_time_stamp;
 
+       if (tcp_packets_in_flight(tp) == 0)
+               tcp_ca_event(sk, CA_EVENT_TX_START);
+
        tp->lsndtime = now;
 
        /* If it is a reply for ato after last received
@@ -940,9 +943,6 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
                                                           &md5);
        tcp_header_size = tcp_options_size + sizeof(struct tcphdr);
 
-       if (tcp_packets_in_flight(tp) == 0)
-               tcp_ca_event(sk, CA_EVENT_TX_START);
-
        /* if no packet is in qdisc/device queue, then allow XPS to select
         * another queue. We can be called from tcp_tsq_handler()
         * which holds one reference to sk_wmem_alloc.
@@ -2165,7 +2165,7 @@ bool tcp_schedule_loss_probe(struct sock *sk)
        /* Don't do any loss probe on a Fast Open connection before 3WHS
         * finishes.
         */
-       if (sk->sk_state == TCP_SYN_RECV)
+       if (tp->fastopen_rsk)
                return false;
 
        /* TLP is only scheduled when next timer event is RTO. */
@@ -2175,7 +2175,7 @@ bool tcp_schedule_loss_probe(struct sock *sk)
        /* Schedule a loss probe in 2*RTT for SACK capable connections
         * in Open state, that are either limited by cwnd or application.
         */
-       if (sysctl_tcp_early_retrans < 3 || !tp->srtt_us || !tp->packets_out ||
+       if (sysctl_tcp_early_retrans < 3 || !tp->packets_out ||
            !tcp_is_sack(tp) || inet_csk(sk)->icsk_ca_state != TCP_CA_Open)
                return false;
 
@@ -2184,9 +2184,10 @@ bool tcp_schedule_loss_probe(struct sock *sk)
                return false;
 
        /* Probe timeout is at least 1.5*rtt + TCP_DELACK_MAX to account
-        * for delayed ack when there's one outstanding packet.
+        * for delayed ack when there's one outstanding packet. If no RTT
+        * sample is available then probe after TCP_TIMEOUT_INIT.
         */
-       timeout = rtt << 1;
+       timeout = rtt << 1 ? : TCP_TIMEOUT_INIT;
        if (tp->packets_out == 1)
                timeout = max_t(u32, timeout,
                                (rtt + (rtt >> 1) + TCP_DELACK_MAX));
@@ -2987,6 +2988,7 @@ struct sk_buff *tcp_make_synack(struct sock *sk, struct dst_entry *dst,
        rcu_read_lock();
        md5 = tcp_rsk(req)->af_specific->req_md5_lookup(sk, req_to_sk(req));
 #endif
+       skb_set_hash(skb, tcp_rsk(req)->txhash, PKT_HASH_TYPE_L4);
        tcp_header_size = tcp_synack_options(sk, req, mss, skb, &opts, md5,
                                             foc) + sizeof(*th);
 
@@ -3505,6 +3507,7 @@ int tcp_rtx_synack(struct sock *sk, struct request_sock *req)
        struct flowi fl;
        int res;
 
+       tcp_rsk(req)->txhash = net_tx_rndhash();
        res = af_ops->send_synack(sk, NULL, &fl, req, 0, NULL);
        if (!res) {
                TCP_INC_STATS_BH(sock_net(sk), TCP_MIB_RETRANSSEGS);