aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/tcp.c')
-rw-r--r--net/ipv4/tcp.c78
1 files changed, 42 insertions, 36 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 65afeaec15b7..176e11aaea77 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -315,7 +315,6 @@ struct tcp_splice_state {
315 * is strict, actions are advisory and have some latency. 315 * is strict, actions are advisory and have some latency.
316 */ 316 */
317int tcp_memory_pressure __read_mostly; 317int tcp_memory_pressure __read_mostly;
318
319EXPORT_SYMBOL(tcp_memory_pressure); 318EXPORT_SYMBOL(tcp_memory_pressure);
320 319
321void tcp_enter_memory_pressure(struct sock *sk) 320void tcp_enter_memory_pressure(struct sock *sk)
@@ -325,7 +324,6 @@ void tcp_enter_memory_pressure(struct sock *sk)
325 tcp_memory_pressure = 1; 324 tcp_memory_pressure = 1;
326 } 325 }
327} 326}
328
329EXPORT_SYMBOL(tcp_enter_memory_pressure); 327EXPORT_SYMBOL(tcp_enter_memory_pressure);
330 328
331/* Convert seconds to retransmits based on initial and max timeout */ 329/* Convert seconds to retransmits based on initial and max timeout */
@@ -460,6 +458,7 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
460 } 458 }
461 return mask; 459 return mask;
462} 460}
461EXPORT_SYMBOL(tcp_poll);
463 462
464int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg) 463int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg)
465{ 464{
@@ -508,10 +507,11 @@ int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg)
508 507
509 return put_user(answ, (int __user *)arg); 508 return put_user(answ, (int __user *)arg);
510} 509}
510EXPORT_SYMBOL(tcp_ioctl);
511 511
512static inline void tcp_mark_push(struct tcp_sock *tp, struct sk_buff *skb) 512static inline void tcp_mark_push(struct tcp_sock *tp, struct sk_buff *skb)
513{ 513{
514 TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_PSH; 514 TCP_SKB_CB(skb)->flags |= TCPHDR_PSH;
515 tp->pushed_seq = tp->write_seq; 515 tp->pushed_seq = tp->write_seq;
516} 516}
517 517
@@ -527,7 +527,7 @@ static inline void skb_entail(struct sock *sk, struct sk_buff *skb)
527 527
528 skb->csum = 0; 528 skb->csum = 0;
529 tcb->seq = tcb->end_seq = tp->write_seq; 529 tcb->seq = tcb->end_seq = tp->write_seq;
530 tcb->flags = TCPCB_FLAG_ACK; 530 tcb->flags = TCPHDR_ACK;
531 tcb->sacked = 0; 531 tcb->sacked = 0;
532 skb_header_release(skb); 532 skb_header_release(skb);
533 tcp_add_write_queue_tail(sk, skb); 533 tcp_add_write_queue_tail(sk, skb);
@@ -676,6 +676,7 @@ ssize_t tcp_splice_read(struct socket *sock, loff_t *ppos,
676 676
677 return ret; 677 return ret;
678} 678}
679EXPORT_SYMBOL(tcp_splice_read);
679 680
680struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp) 681struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp)
681{ 682{
@@ -816,7 +817,7 @@ new_segment:
816 skb_shinfo(skb)->gso_segs = 0; 817 skb_shinfo(skb)->gso_segs = 0;
817 818
818 if (!copied) 819 if (!copied)
819 TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_PSH; 820 TCP_SKB_CB(skb)->flags &= ~TCPHDR_PSH;
820 821
821 copied += copy; 822 copied += copy;
822 poffset += copy; 823 poffset += copy;
@@ -857,15 +858,15 @@ out_err:
857 return sk_stream_error(sk, flags, err); 858 return sk_stream_error(sk, flags, err);
858} 859}
859 860
860ssize_t tcp_sendpage(struct socket *sock, struct page *page, int offset, 861int tcp_sendpage(struct sock *sk, struct page *page, int offset,
861 size_t size, int flags) 862 size_t size, int flags)
862{ 863{
863 ssize_t res; 864 ssize_t res;
864 struct sock *sk = sock->sk;
865 865
866 if (!(sk->sk_route_caps & NETIF_F_SG) || 866 if (!(sk->sk_route_caps & NETIF_F_SG) ||
867 !(sk->sk_route_caps & NETIF_F_ALL_CSUM)) 867 !(sk->sk_route_caps & NETIF_F_ALL_CSUM))
868 return sock_no_sendpage(sock, page, offset, size, flags); 868 return sock_no_sendpage(sk->sk_socket, page, offset, size,
869 flags);
869 870
870 lock_sock(sk); 871 lock_sock(sk);
871 TCP_CHECK_TIMER(sk); 872 TCP_CHECK_TIMER(sk);
@@ -874,6 +875,7 @@ ssize_t tcp_sendpage(struct socket *sock, struct page *page, int offset,
874 release_sock(sk); 875 release_sock(sk);
875 return res; 876 return res;
876} 877}
878EXPORT_SYMBOL(tcp_sendpage);
877 879
878#define TCP_PAGE(sk) (sk->sk_sndmsg_page) 880#define TCP_PAGE(sk) (sk->sk_sndmsg_page)
879#define TCP_OFF(sk) (sk->sk_sndmsg_off) 881#define TCP_OFF(sk) (sk->sk_sndmsg_off)
@@ -898,10 +900,9 @@ static inline int select_size(struct sock *sk, int sg)
898 return tmp; 900 return tmp;
899} 901}
900 902
901int tcp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, 903int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
902 size_t size) 904 size_t size)
903{ 905{
904 struct sock *sk = sock->sk;
905 struct iovec *iov; 906 struct iovec *iov;
906 struct tcp_sock *tp = tcp_sk(sk); 907 struct tcp_sock *tp = tcp_sk(sk);
907 struct sk_buff *skb; 908 struct sk_buff *skb;
@@ -1062,7 +1063,7 @@ new_segment:
1062 } 1063 }
1063 1064
1064 if (!copied) 1065 if (!copied)
1065 TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_PSH; 1066 TCP_SKB_CB(skb)->flags &= ~TCPHDR_PSH;
1066 1067
1067 tp->write_seq += copy; 1068 tp->write_seq += copy;
1068 TCP_SKB_CB(skb)->end_seq += copy; 1069 TCP_SKB_CB(skb)->end_seq += copy;
@@ -1122,6 +1123,7 @@ out_err:
1122 release_sock(sk); 1123 release_sock(sk);
1123 return err; 1124 return err;
1124} 1125}
1126EXPORT_SYMBOL(tcp_sendmsg);
1125 1127
1126/* 1128/*
1127 * Handle reading urgent data. BSD has very simple semantics for 1129 * Handle reading urgent data. BSD has very simple semantics for
@@ -1381,6 +1383,7 @@ int tcp_read_sock(struct sock *sk, read_descriptor_t *desc,
1381 tcp_cleanup_rbuf(sk, copied); 1383 tcp_cleanup_rbuf(sk, copied);
1382 return copied; 1384 return copied;
1383} 1385}
1386EXPORT_SYMBOL(tcp_read_sock);
1384 1387
1385/* 1388/*
1386 * This routine copies from a sock struct into the user buffer. 1389 * This routine copies from a sock struct into the user buffer.
@@ -1775,6 +1778,7 @@ recv_urg:
1775 err = tcp_recv_urg(sk, msg, len, flags); 1778 err = tcp_recv_urg(sk, msg, len, flags);
1776 goto out; 1779 goto out;
1777} 1780}
1781EXPORT_SYMBOL(tcp_recvmsg);
1778 1782
1779void tcp_set_state(struct sock *sk, int state) 1783void tcp_set_state(struct sock *sk, int state)
1780{ 1784{
@@ -1867,6 +1871,7 @@ void tcp_shutdown(struct sock *sk, int how)
1867 tcp_send_fin(sk); 1871 tcp_send_fin(sk);
1868 } 1872 }
1869} 1873}
1874EXPORT_SYMBOL(tcp_shutdown);
1870 1875
1871void tcp_close(struct sock *sk, long timeout) 1876void tcp_close(struct sock *sk, long timeout)
1872{ 1877{
@@ -1899,6 +1904,10 @@ void tcp_close(struct sock *sk, long timeout)
1899 1904
1900 sk_mem_reclaim(sk); 1905 sk_mem_reclaim(sk);
1901 1906
1907 /* If socket has been already reset (e.g. in tcp_reset()) - kill it. */
1908 if (sk->sk_state == TCP_CLOSE)
1909 goto adjudge_to_death;
1910
1902 /* As outlined in RFC 2525, section 2.17, we send a RST here because 1911 /* As outlined in RFC 2525, section 2.17, we send a RST here because
1903 * data was lost. To witness the awful effects of the old behavior of 1912 * data was lost. To witness the awful effects of the old behavior of
1904 * always doing a FIN, run an older 2.1.x kernel or 2.0.x, start a bulk 1913 * always doing a FIN, run an older 2.1.x kernel or 2.0.x, start a bulk
@@ -2026,6 +2035,7 @@ out:
2026 local_bh_enable(); 2035 local_bh_enable();
2027 sock_put(sk); 2036 sock_put(sk);
2028} 2037}
2038EXPORT_SYMBOL(tcp_close);
2029 2039
2030/* These states need RST on ABORT according to RFC793 */ 2040/* These states need RST on ABORT according to RFC793 */
2031 2041
@@ -2099,6 +2109,7 @@ int tcp_disconnect(struct sock *sk, int flags)
2099 sk->sk_error_report(sk); 2109 sk->sk_error_report(sk);
2100 return err; 2110 return err;
2101} 2111}
2112EXPORT_SYMBOL(tcp_disconnect);
2102 2113
2103/* 2114/*
2104 * Socket option code for TCP. 2115 * Socket option code for TCP.
@@ -2176,6 +2187,8 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
2176 GFP_KERNEL); 2187 GFP_KERNEL);
2177 if (cvp == NULL) 2188 if (cvp == NULL)
2178 return -ENOMEM; 2189 return -ENOMEM;
2190
2191 kref_init(&cvp->kref);
2179 } 2192 }
2180 lock_sock(sk); 2193 lock_sock(sk);
2181 tp->rx_opt.cookie_in_always = 2194 tp->rx_opt.cookie_in_always =
@@ -2190,12 +2203,11 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
2190 */ 2203 */
2191 kref_put(&tp->cookie_values->kref, 2204 kref_put(&tp->cookie_values->kref,
2192 tcp_cookie_values_release); 2205 tcp_cookie_values_release);
2193 kref_init(&cvp->kref);
2194 tp->cookie_values = cvp;
2195 } else { 2206 } else {
2196 cvp = tp->cookie_values; 2207 cvp = tp->cookie_values;
2197 } 2208 }
2198 } 2209 }
2210
2199 if (cvp != NULL) { 2211 if (cvp != NULL) {
2200 cvp->cookie_desired = ctd.tcpct_cookie_desired; 2212 cvp->cookie_desired = ctd.tcpct_cookie_desired;
2201 2213
@@ -2209,6 +2221,8 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
2209 cvp->s_data_desired = ctd.tcpct_s_data_desired; 2221 cvp->s_data_desired = ctd.tcpct_s_data_desired;
2210 cvp->s_data_constant = 0; /* false */ 2222 cvp->s_data_constant = 0; /* false */
2211 } 2223 }
2224
2225 tp->cookie_values = cvp;
2212 } 2226 }
2213 release_sock(sk); 2227 release_sock(sk);
2214 return err; 2228 return err;
@@ -2397,6 +2411,7 @@ int tcp_setsockopt(struct sock *sk, int level, int optname, char __user *optval,
2397 optval, optlen); 2411 optval, optlen);
2398 return do_tcp_setsockopt(sk, level, optname, optval, optlen); 2412 return do_tcp_setsockopt(sk, level, optname, optval, optlen);
2399} 2413}
2414EXPORT_SYMBOL(tcp_setsockopt);
2400 2415
2401#ifdef CONFIG_COMPAT 2416#ifdef CONFIG_COMPAT
2402int compat_tcp_setsockopt(struct sock *sk, int level, int optname, 2417int compat_tcp_setsockopt(struct sock *sk, int level, int optname,
@@ -2407,7 +2422,6 @@ int compat_tcp_setsockopt(struct sock *sk, int level, int optname,
2407 optval, optlen); 2422 optval, optlen);
2408 return do_tcp_setsockopt(sk, level, optname, optval, optlen); 2423 return do_tcp_setsockopt(sk, level, optname, optval, optlen);
2409} 2424}
2410
2411EXPORT_SYMBOL(compat_tcp_setsockopt); 2425EXPORT_SYMBOL(compat_tcp_setsockopt);
2412#endif 2426#endif
2413 2427
@@ -2473,7 +2487,6 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info)
2473 2487
2474 info->tcpi_total_retrans = tp->total_retrans; 2488 info->tcpi_total_retrans = tp->total_retrans;
2475} 2489}
2476
2477EXPORT_SYMBOL_GPL(tcp_get_info); 2490EXPORT_SYMBOL_GPL(tcp_get_info);
2478 2491
2479static int do_tcp_getsockopt(struct sock *sk, int level, 2492static int do_tcp_getsockopt(struct sock *sk, int level,
@@ -2591,6 +2604,12 @@ static int do_tcp_getsockopt(struct sock *sk, int level,
2591 return -EFAULT; 2604 return -EFAULT;
2592 return 0; 2605 return 0;
2593 } 2606 }
2607 case TCP_THIN_LINEAR_TIMEOUTS:
2608 val = tp->thin_lto;
2609 break;
2610 case TCP_THIN_DUPACK:
2611 val = tp->thin_dupack;
2612 break;
2594 default: 2613 default:
2595 return -ENOPROTOOPT; 2614 return -ENOPROTOOPT;
2596 } 2615 }
@@ -2612,6 +2631,7 @@ int tcp_getsockopt(struct sock *sk, int level, int optname, char __user *optval,
2612 optval, optlen); 2631 optval, optlen);
2613 return do_tcp_getsockopt(sk, level, optname, optval, optlen); 2632 return do_tcp_getsockopt(sk, level, optname, optval, optlen);
2614} 2633}
2634EXPORT_SYMBOL(tcp_getsockopt);
2615 2635
2616#ifdef CONFIG_COMPAT 2636#ifdef CONFIG_COMPAT
2617int compat_tcp_getsockopt(struct sock *sk, int level, int optname, 2637int compat_tcp_getsockopt(struct sock *sk, int level, int optname,
@@ -2622,7 +2642,6 @@ int compat_tcp_getsockopt(struct sock *sk, int level, int optname,
2622 optval, optlen); 2642 optval, optlen);
2623 return do_tcp_getsockopt(sk, level, optname, optval, optlen); 2643 return do_tcp_getsockopt(sk, level, optname, optval, optlen);
2624} 2644}
2625
2626EXPORT_SYMBOL(compat_tcp_getsockopt); 2645EXPORT_SYMBOL(compat_tcp_getsockopt);
2627#endif 2646#endif
2628 2647
@@ -2859,7 +2878,6 @@ void tcp_free_md5sig_pool(void)
2859 if (pool) 2878 if (pool)
2860 __tcp_free_md5sig_pool(pool); 2879 __tcp_free_md5sig_pool(pool);
2861} 2880}
2862
2863EXPORT_SYMBOL(tcp_free_md5sig_pool); 2881EXPORT_SYMBOL(tcp_free_md5sig_pool);
2864 2882
2865static struct tcp_md5sig_pool * __percpu * 2883static struct tcp_md5sig_pool * __percpu *
@@ -2935,7 +2953,6 @@ retry:
2935 } 2953 }
2936 return pool; 2954 return pool;
2937} 2955}
2938
2939EXPORT_SYMBOL(tcp_alloc_md5sig_pool); 2956EXPORT_SYMBOL(tcp_alloc_md5sig_pool);
2940 2957
2941 2958
@@ -2959,7 +2976,7 @@ struct tcp_md5sig_pool *tcp_get_md5sig_pool(void)
2959 spin_unlock(&tcp_md5sig_pool_lock); 2976 spin_unlock(&tcp_md5sig_pool_lock);
2960 2977
2961 if (p) 2978 if (p)
2962 return *per_cpu_ptr(p, smp_processor_id()); 2979 return *this_cpu_ptr(p);
2963 2980
2964 local_bh_enable(); 2981 local_bh_enable();
2965 return NULL; 2982 return NULL;
@@ -2987,7 +3004,6 @@ int tcp_md5_hash_header(struct tcp_md5sig_pool *hp,
2987 th->check = old_checksum; 3004 th->check = old_checksum;
2988 return err; 3005 return err;
2989} 3006}
2990
2991EXPORT_SYMBOL(tcp_md5_hash_header); 3007EXPORT_SYMBOL(tcp_md5_hash_header);
2992 3008
2993int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *hp, 3009int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *hp,
@@ -3000,6 +3016,7 @@ int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *hp,
3000 const unsigned head_data_len = skb_headlen(skb) > header_len ? 3016 const unsigned head_data_len = skb_headlen(skb) > header_len ?
3001 skb_headlen(skb) - header_len : 0; 3017 skb_headlen(skb) - header_len : 0;
3002 const struct skb_shared_info *shi = skb_shinfo(skb); 3018 const struct skb_shared_info *shi = skb_shinfo(skb);
3019 struct sk_buff *frag_iter;
3003 3020
3004 sg_init_table(&sg, 1); 3021 sg_init_table(&sg, 1);
3005 3022
@@ -3014,9 +3031,12 @@ int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *hp,
3014 return 1; 3031 return 1;
3015 } 3032 }
3016 3033
3034 skb_walk_frags(skb, frag_iter)
3035 if (tcp_md5_hash_skb_data(hp, frag_iter, 0))
3036 return 1;
3037
3017 return 0; 3038 return 0;
3018} 3039}
3019
3020EXPORT_SYMBOL(tcp_md5_hash_skb_data); 3040EXPORT_SYMBOL(tcp_md5_hash_skb_data);
3021 3041
3022int tcp_md5_hash_key(struct tcp_md5sig_pool *hp, struct tcp_md5sig_key *key) 3042int tcp_md5_hash_key(struct tcp_md5sig_pool *hp, struct tcp_md5sig_key *key)
@@ -3026,7 +3046,6 @@ int tcp_md5_hash_key(struct tcp_md5sig_pool *hp, struct tcp_md5sig_key *key)
3026 sg_init_one(&sg, key->key, key->keylen); 3046 sg_init_one(&sg, key->key, key->keylen);
3027 return crypto_hash_update(&hp->md5_desc, &sg, key->keylen); 3047 return crypto_hash_update(&hp->md5_desc, &sg, key->keylen);
3028} 3048}
3029
3030EXPORT_SYMBOL(tcp_md5_hash_key); 3049EXPORT_SYMBOL(tcp_md5_hash_key);
3031 3050
3032#endif 3051#endif
@@ -3298,16 +3317,3 @@ void __init tcp_init(void)
3298 tcp_secret_retiring = &tcp_secret_two; 3317 tcp_secret_retiring = &tcp_secret_two;
3299 tcp_secret_secondary = &tcp_secret_two; 3318 tcp_secret_secondary = &tcp_secret_two;
3300} 3319}
3301
3302EXPORT_SYMBOL(tcp_close);
3303EXPORT_SYMBOL(tcp_disconnect);
3304EXPORT_SYMBOL(tcp_getsockopt);
3305EXPORT_SYMBOL(tcp_ioctl);
3306EXPORT_SYMBOL(tcp_poll);
3307EXPORT_SYMBOL(tcp_read_sock);
3308EXPORT_SYMBOL(tcp_recvmsg);
3309EXPORT_SYMBOL(tcp_sendmsg);
3310EXPORT_SYMBOL(tcp_splice_read);
3311EXPORT_SYMBOL(tcp_sendpage);
3312EXPORT_SYMBOL(tcp_setsockopt);
3313EXPORT_SYMBOL(tcp_shutdown);