aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_ipv4.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/tcp_ipv4.c')
-rw-r--r--net/ipv4/tcp_ipv4.c53
1 files changed, 21 insertions, 32 deletions
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 0c4a64355603..70b09ef2463b 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -138,14 +138,6 @@ int tcp_twsk_unique(struct sock *sk, struct sock *sktw, void *twp)
138} 138}
139EXPORT_SYMBOL_GPL(tcp_twsk_unique); 139EXPORT_SYMBOL_GPL(tcp_twsk_unique);
140 140
141static int tcp_repair_connect(struct sock *sk)
142{
143 tcp_connect_init(sk);
144 tcp_finish_connect(sk, NULL);
145
146 return 0;
147}
148
149/* This will initiate an outgoing connection. */ 141/* This will initiate an outgoing connection. */
150int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) 142int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
151{ 143{
@@ -250,10 +242,7 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
250 242
251 inet->inet_id = tp->write_seq ^ jiffies; 243 inet->inet_id = tp->write_seq ^ jiffies;
252 244
253 if (likely(!tp->repair)) 245 err = tcp_connect(sk);
254 err = tcp_connect(sk);
255 else
256 err = tcp_repair_connect(sk);
257 246
258 rt = NULL; 247 rt = NULL;
259 if (err) 248 if (err)
@@ -380,11 +369,10 @@ void tcp_v4_err(struct sk_buff *icmp_skb, u32 info)
380 * We do take care of PMTU discovery (RFC1191) special case : 369 * We do take care of PMTU discovery (RFC1191) special case :
381 * we can receive locally generated ICMP messages while socket is held. 370 * we can receive locally generated ICMP messages while socket is held.
382 */ 371 */
383 if (sock_owned_by_user(sk) && 372 if (sock_owned_by_user(sk)) {
384 type != ICMP_DEST_UNREACH && 373 if (!(type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED))
385 code != ICMP_FRAG_NEEDED) 374 NET_INC_STATS_BH(net, LINUX_MIB_LOCKDROPPEDICMPS);
386 NET_INC_STATS_BH(net, LINUX_MIB_LOCKDROPPEDICMPS); 375 }
387
388 if (sk->sk_state == TCP_CLOSE) 376 if (sk->sk_state == TCP_CLOSE)
389 goto out; 377 goto out;
390 378
@@ -877,10 +865,13 @@ static int tcp_v4_send_synack(struct sock *sk, struct dst_entry *dst,
877} 865}
878 866
879static int tcp_v4_rtx_synack(struct sock *sk, struct request_sock *req, 867static int tcp_v4_rtx_synack(struct sock *sk, struct request_sock *req,
880 struct request_values *rvp) 868 struct request_values *rvp)
881{ 869{
882 TCP_INC_STATS_BH(sock_net(sk), TCP_MIB_RETRANSSEGS); 870 int res = tcp_v4_send_synack(sk, NULL, req, rvp, 0, false);
883 return tcp_v4_send_synack(sk, NULL, req, rvp, 0, false); 871
872 if (!res)
873 TCP_INC_STATS_BH(sock_net(sk), TCP_MIB_RETRANSSEGS);
874 return res;
884} 875}
885 876
886/* 877/*
@@ -1070,7 +1061,7 @@ int tcp_md5_do_del(struct sock *sk, const union tcp_md5_addr *addr, int family)
1070} 1061}
1071EXPORT_SYMBOL(tcp_md5_do_del); 1062EXPORT_SYMBOL(tcp_md5_do_del);
1072 1063
1073void tcp_clear_md5_list(struct sock *sk) 1064static void tcp_clear_md5_list(struct sock *sk)
1074{ 1065{
1075 struct tcp_sock *tp = tcp_sk(sk); 1066 struct tcp_sock *tp = tcp_sk(sk);
1076 struct tcp_md5sig_key *key; 1067 struct tcp_md5sig_key *key;
@@ -1386,7 +1377,8 @@ static int tcp_v4_conn_req_fastopen(struct sock *sk,
1386 struct sock *child; 1377 struct sock *child;
1387 int err; 1378 int err;
1388 1379
1389 req->retrans = 0; 1380 req->num_retrans = 0;
1381 req->num_timeout = 0;
1390 req->sk = NULL; 1382 req->sk = NULL;
1391 1383
1392 child = inet_csk(sk)->icsk_af_ops->syn_recv_sock(sk, skb, req, NULL); 1384 child = inet_csk(sk)->icsk_af_ops->syn_recv_sock(sk, skb, req, NULL);
@@ -1741,7 +1733,7 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1741 1733
1742 tcp_initialize_rcv_mss(newsk); 1734 tcp_initialize_rcv_mss(newsk);
1743 tcp_synack_rtt_meas(newsk, req); 1735 tcp_synack_rtt_meas(newsk, req);
1744 newtp->total_retrans = req->retrans; 1736 newtp->total_retrans = req->num_retrans;
1745 1737
1746#ifdef CONFIG_TCP_MD5SIG 1738#ifdef CONFIG_TCP_MD5SIG
1747 /* Copy over the MD5 key from the original socket */ 1739 /* Copy over the MD5 key from the original socket */
@@ -1774,10 +1766,8 @@ exit:
1774 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_LISTENDROPS); 1766 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_LISTENDROPS);
1775 return NULL; 1767 return NULL;
1776put_and_exit: 1768put_and_exit:
1777 tcp_clear_xmit_timers(newsk); 1769 inet_csk_prepare_forced_close(newsk);
1778 tcp_cleanup_congestion_control(newsk); 1770 tcp_done(newsk);
1779 bh_unlock_sock(newsk);
1780 sock_put(newsk);
1781 goto exit; 1771 goto exit;
1782} 1772}
1783EXPORT_SYMBOL(tcp_v4_syn_recv_sock); 1773EXPORT_SYMBOL(tcp_v4_syn_recv_sock);
@@ -1919,7 +1909,6 @@ EXPORT_SYMBOL(tcp_v4_do_rcv);
1919 1909
1920void tcp_v4_early_demux(struct sk_buff *skb) 1910void tcp_v4_early_demux(struct sk_buff *skb)
1921{ 1911{
1922 struct net *net = dev_net(skb->dev);
1923 const struct iphdr *iph; 1912 const struct iphdr *iph;
1924 const struct tcphdr *th; 1913 const struct tcphdr *th;
1925 struct sock *sk; 1914 struct sock *sk;
@@ -1927,16 +1916,16 @@ void tcp_v4_early_demux(struct sk_buff *skb)
1927 if (skb->pkt_type != PACKET_HOST) 1916 if (skb->pkt_type != PACKET_HOST)
1928 return; 1917 return;
1929 1918
1930 if (!pskb_may_pull(skb, ip_hdrlen(skb) + sizeof(struct tcphdr))) 1919 if (!pskb_may_pull(skb, skb_transport_offset(skb) + sizeof(struct tcphdr)))
1931 return; 1920 return;
1932 1921
1933 iph = ip_hdr(skb); 1922 iph = ip_hdr(skb);
1934 th = (struct tcphdr *) ((char *)iph + ip_hdrlen(skb)); 1923 th = tcp_hdr(skb);
1935 1924
1936 if (th->doff < sizeof(struct tcphdr) / 4) 1925 if (th->doff < sizeof(struct tcphdr) / 4)
1937 return; 1926 return;
1938 1927
1939 sk = __inet_lookup_established(net, &tcp_hashinfo, 1928 sk = __inet_lookup_established(dev_net(skb->dev), &tcp_hashinfo,
1940 iph->saddr, th->source, 1929 iph->saddr, th->source,
1941 iph->daddr, ntohs(th->dest), 1930 iph->daddr, ntohs(th->dest),
1942 skb->skb_iif); 1931 skb->skb_iif);
@@ -2640,7 +2629,7 @@ static void get_openreq4(const struct sock *sk, const struct request_sock *req,
2640 0, 0, /* could print option size, but that is af dependent. */ 2629 0, 0, /* could print option size, but that is af dependent. */
2641 1, /* timers active (only the expire timer) */ 2630 1, /* timers active (only the expire timer) */
2642 jiffies_delta_to_clock_t(delta), 2631 jiffies_delta_to_clock_t(delta),
2643 req->retrans, 2632 req->num_timeout,
2644 from_kuid_munged(seq_user_ns(f), uid), 2633 from_kuid_munged(seq_user_ns(f), uid),
2645 0, /* non standard timer */ 2634 0, /* non standard timer */
2646 0, /* open_requests have no inode */ 2635 0, /* open_requests have no inode */