diff options
Diffstat (limited to 'include/net/tcp.h')
-rw-r--r-- | include/net/tcp.h | 190 |
1 files changed, 143 insertions, 47 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h index 5c472f255b77..a385797f160a 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
@@ -220,6 +220,7 @@ extern int sysctl_tcp_app_win; | |||
220 | extern int sysctl_tcp_adv_win_scale; | 220 | extern int sysctl_tcp_adv_win_scale; |
221 | extern int sysctl_tcp_tw_reuse; | 221 | extern int sysctl_tcp_tw_reuse; |
222 | extern int sysctl_tcp_frto; | 222 | extern int sysctl_tcp_frto; |
223 | extern int sysctl_tcp_frto_response; | ||
223 | extern int sysctl_tcp_low_latency; | 224 | extern int sysctl_tcp_low_latency; |
224 | extern int sysctl_tcp_dma_copybreak; | 225 | extern int sysctl_tcp_dma_copybreak; |
225 | extern int sysctl_tcp_nometrics_save; | 226 | extern int sysctl_tcp_nometrics_save; |
@@ -230,6 +231,7 @@ extern int sysctl_tcp_mtu_probing; | |||
230 | extern int sysctl_tcp_base_mss; | 231 | extern int sysctl_tcp_base_mss; |
231 | extern int sysctl_tcp_workaround_signed_windows; | 232 | extern int sysctl_tcp_workaround_signed_windows; |
232 | extern int sysctl_tcp_slow_start_after_idle; | 233 | extern int sysctl_tcp_slow_start_after_idle; |
234 | extern int sysctl_tcp_max_ssthresh; | ||
233 | 235 | ||
234 | extern atomic_t tcp_memory_allocated; | 236 | extern atomic_t tcp_memory_allocated; |
235 | extern atomic_t tcp_sockets_allocated; | 237 | extern atomic_t tcp_sockets_allocated; |
@@ -341,6 +343,7 @@ extern struct sock * tcp_check_req(struct sock *sk,struct sk_buff *skb, | |||
341 | extern int tcp_child_process(struct sock *parent, | 343 | extern int tcp_child_process(struct sock *parent, |
342 | struct sock *child, | 344 | struct sock *child, |
343 | struct sk_buff *skb); | 345 | struct sk_buff *skb); |
346 | extern int tcp_use_frto(struct sock *sk); | ||
344 | extern void tcp_enter_frto(struct sock *sk); | 347 | extern void tcp_enter_frto(struct sock *sk); |
345 | extern void tcp_enter_loss(struct sock *sk, int how); | 348 | extern void tcp_enter_loss(struct sock *sk, int how); |
346 | extern void tcp_clear_retrans(struct tcp_sock *tp); | 349 | extern void tcp_clear_retrans(struct tcp_sock *tp); |
@@ -417,9 +420,9 @@ extern __u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb, | |||
417 | 420 | ||
418 | /* tcp_output.c */ | 421 | /* tcp_output.c */ |
419 | 422 | ||
420 | extern void __tcp_push_pending_frames(struct sock *sk, struct tcp_sock *tp, | 423 | extern void __tcp_push_pending_frames(struct sock *sk, unsigned int cur_mss, |
421 | unsigned int cur_mss, int nonagle); | 424 | int nonagle); |
422 | extern int tcp_may_send_now(struct sock *sk, struct tcp_sock *tp); | 425 | extern int tcp_may_send_now(struct sock *sk); |
423 | extern int tcp_retransmit_skb(struct sock *, struct sk_buff *); | 426 | extern int tcp_retransmit_skb(struct sock *, struct sk_buff *); |
424 | extern void tcp_xmit_retransmit_queue(struct sock *); | 427 | extern void tcp_xmit_retransmit_queue(struct sock *); |
425 | extern void tcp_simple_retransmit(struct sock *); | 428 | extern void tcp_simple_retransmit(struct sock *); |
@@ -476,8 +479,10 @@ static inline void tcp_fast_path_on(struct tcp_sock *tp) | |||
476 | __tcp_fast_path_on(tp, tp->snd_wnd >> tp->rx_opt.snd_wscale); | 479 | __tcp_fast_path_on(tp, tp->snd_wnd >> tp->rx_opt.snd_wscale); |
477 | } | 480 | } |
478 | 481 | ||
479 | static inline void tcp_fast_path_check(struct sock *sk, struct tcp_sock *tp) | 482 | static inline void tcp_fast_path_check(struct sock *sk) |
480 | { | 483 | { |
484 | struct tcp_sock *tp = tcp_sk(sk); | ||
485 | |||
481 | if (skb_queue_empty(&tp->out_of_order_queue) && | 486 | if (skb_queue_empty(&tp->out_of_order_queue) && |
482 | tp->rcv_wnd && | 487 | tp->rcv_wnd && |
483 | atomic_read(&sk->sk_rmem_alloc) < sk->sk_rcvbuf && | 488 | atomic_read(&sk->sk_rmem_alloc) < sk->sk_rcvbuf && |
@@ -588,10 +593,10 @@ static inline void tcp_dec_pcount_approx(__u32 *count, | |||
588 | } | 593 | } |
589 | } | 594 | } |
590 | 595 | ||
591 | static inline void tcp_packets_out_inc(struct sock *sk, | 596 | static inline void tcp_packets_out_inc(struct sock *sk, |
592 | struct tcp_sock *tp, | ||
593 | const struct sk_buff *skb) | 597 | const struct sk_buff *skb) |
594 | { | 598 | { |
599 | struct tcp_sock *tp = tcp_sk(sk); | ||
595 | int orig = tp->packets_out; | 600 | int orig = tp->packets_out; |
596 | 601 | ||
597 | tp->packets_out += tcp_skb_pcount(skb); | 602 | tp->packets_out += tcp_skb_pcount(skb); |
@@ -624,9 +629,12 @@ enum tcp_ca_event { | |||
624 | #define TCP_CA_MAX 128 | 629 | #define TCP_CA_MAX 128 |
625 | #define TCP_CA_BUF_MAX (TCP_CA_NAME_MAX*TCP_CA_MAX) | 630 | #define TCP_CA_BUF_MAX (TCP_CA_NAME_MAX*TCP_CA_MAX) |
626 | 631 | ||
632 | #define TCP_CONG_NON_RESTRICTED 0x1 | ||
633 | #define TCP_CONG_RTT_STAMP 0x2 | ||
634 | |||
627 | struct tcp_congestion_ops { | 635 | struct tcp_congestion_ops { |
628 | struct list_head list; | 636 | struct list_head list; |
629 | int non_restricted; | 637 | unsigned long flags; |
630 | 638 | ||
631 | /* initialize private data (optional) */ | 639 | /* initialize private data (optional) */ |
632 | void (*init)(struct sock *sk); | 640 | void (*init)(struct sock *sk); |
@@ -640,8 +648,6 @@ struct tcp_congestion_ops { | |||
640 | /* do new cwnd calculation (required) */ | 648 | /* do new cwnd calculation (required) */ |
641 | void (*cong_avoid)(struct sock *sk, u32 ack, | 649 | void (*cong_avoid)(struct sock *sk, u32 ack, |
642 | u32 rtt, u32 in_flight, int good_ack); | 650 | u32 rtt, u32 in_flight, int good_ack); |
643 | /* round trip time sample per acked packet (optional) */ | ||
644 | void (*rtt_sample)(struct sock *sk, u32 usrtt); | ||
645 | /* call before changing ca_state (optional) */ | 651 | /* call before changing ca_state (optional) */ |
646 | void (*set_state)(struct sock *sk, u8 new_state); | 652 | void (*set_state)(struct sock *sk, u8 new_state); |
647 | /* call when cwnd event occurs (optional) */ | 653 | /* call when cwnd event occurs (optional) */ |
@@ -649,7 +655,7 @@ struct tcp_congestion_ops { | |||
649 | /* new value of cwnd after loss (optional) */ | 655 | /* new value of cwnd after loss (optional) */ |
650 | u32 (*undo_cwnd)(struct sock *sk); | 656 | u32 (*undo_cwnd)(struct sock *sk); |
651 | /* hook for packet ack accounting (optional) */ | 657 | /* hook for packet ack accounting (optional) */ |
652 | void (*pkts_acked)(struct sock *sk, u32 num_acked); | 658 | void (*pkts_acked)(struct sock *sk, u32 num_acked, ktime_t last); |
653 | /* get info for inet_diag (optional) */ | 659 | /* get info for inet_diag (optional) */ |
654 | void (*get_info)(struct sock *sk, u32 ext, struct sk_buff *skb); | 660 | void (*get_info)(struct sock *sk, u32 ext, struct sk_buff *skb); |
655 | 661 | ||
@@ -736,7 +742,7 @@ static inline void tcp_sync_left_out(struct tcp_sock *tp) | |||
736 | tp->left_out = tp->sacked_out + tp->lost_out; | 742 | tp->left_out = tp->sacked_out + tp->lost_out; |
737 | } | 743 | } |
738 | 744 | ||
739 | extern void tcp_enter_cwr(struct sock *sk); | 745 | extern void tcp_enter_cwr(struct sock *sk, const int set_ssthresh); |
740 | extern __u32 tcp_init_cwnd(struct tcp_sock *tp, struct dst_entry *dst); | 746 | extern __u32 tcp_init_cwnd(struct tcp_sock *tp, struct dst_entry *dst); |
741 | 747 | ||
742 | /* Slow start with delack produces 3 packets of burst, so that | 748 | /* Slow start with delack produces 3 packets of burst, so that |
@@ -775,18 +781,21 @@ static inline void tcp_minshall_update(struct tcp_sock *tp, int mss, | |||
775 | tp->snd_sml = TCP_SKB_CB(skb)->end_seq; | 781 | tp->snd_sml = TCP_SKB_CB(skb)->end_seq; |
776 | } | 782 | } |
777 | 783 | ||
778 | static inline void tcp_check_probe_timer(struct sock *sk, struct tcp_sock *tp) | 784 | static inline void tcp_check_probe_timer(struct sock *sk) |
779 | { | 785 | { |
786 | struct tcp_sock *tp = tcp_sk(sk); | ||
780 | const struct inet_connection_sock *icsk = inet_csk(sk); | 787 | const struct inet_connection_sock *icsk = inet_csk(sk); |
788 | |||
781 | if (!tp->packets_out && !icsk->icsk_pending) | 789 | if (!tp->packets_out && !icsk->icsk_pending) |
782 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_PROBE0, | 790 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_PROBE0, |
783 | icsk->icsk_rto, TCP_RTO_MAX); | 791 | icsk->icsk_rto, TCP_RTO_MAX); |
784 | } | 792 | } |
785 | 793 | ||
786 | static inline void tcp_push_pending_frames(struct sock *sk, | 794 | static inline void tcp_push_pending_frames(struct sock *sk) |
787 | struct tcp_sock *tp) | ||
788 | { | 795 | { |
789 | __tcp_push_pending_frames(sk, tp, tcp_current_mss(sk, 1), tp->nonagle); | 796 | struct tcp_sock *tp = tcp_sk(sk); |
797 | |||
798 | __tcp_push_pending_frames(sk, tcp_current_mss(sk, 1), tp->nonagle); | ||
790 | } | 799 | } |
791 | 800 | ||
792 | static inline void tcp_init_wl(struct tcp_sock *tp, u32 ack, u32 seq) | 801 | static inline void tcp_init_wl(struct tcp_sock *tp, u32 ack, u32 seq) |
@@ -815,7 +824,7 @@ static inline __sum16 __tcp_checksum_complete(struct sk_buff *skb) | |||
815 | 824 | ||
816 | static inline int tcp_checksum_complete(struct sk_buff *skb) | 825 | static inline int tcp_checksum_complete(struct sk_buff *skb) |
817 | { | 826 | { |
818 | return skb->ip_summed != CHECKSUM_UNNECESSARY && | 827 | return !skb_csum_unnecessary(skb) && |
819 | __tcp_checksum_complete(skb); | 828 | __tcp_checksum_complete(skb); |
820 | } | 829 | } |
821 | 830 | ||
@@ -918,21 +927,7 @@ static inline void tcp_set_state(struct sock *sk, int state) | |||
918 | #endif | 927 | #endif |
919 | } | 928 | } |
920 | 929 | ||
921 | static inline void tcp_done(struct sock *sk) | 930 | extern void tcp_done(struct sock *sk); |
922 | { | ||
923 | if(sk->sk_state == TCP_SYN_SENT || sk->sk_state == TCP_SYN_RECV) | ||
924 | TCP_INC_STATS_BH(TCP_MIB_ATTEMPTFAILS); | ||
925 | |||
926 | tcp_set_state(sk, TCP_CLOSE); | ||
927 | tcp_clear_xmit_timers(sk); | ||
928 | |||
929 | sk->sk_shutdown = SHUTDOWN_MASK; | ||
930 | |||
931 | if (!sock_flag(sk, SOCK_DEAD)) | ||
932 | sk->sk_state_change(sk); | ||
933 | else | ||
934 | inet_csk_destroy_sock(sk); | ||
935 | } | ||
936 | 931 | ||
937 | static inline void tcp_sack_reset(struct tcp_options_received *rx_opt) | 932 | static inline void tcp_sack_reset(struct tcp_options_received *rx_opt) |
938 | { | 933 | { |
@@ -981,7 +976,7 @@ static inline void tcp_openreq_init(struct request_sock *req, | |||
981 | ireq->wscale_ok = rx_opt->wscale_ok; | 976 | ireq->wscale_ok = rx_opt->wscale_ok; |
982 | ireq->acked = 0; | 977 | ireq->acked = 0; |
983 | ireq->ecn_ok = 0; | 978 | ireq->ecn_ok = 0; |
984 | ireq->rmt_port = skb->h.th->source; | 979 | ireq->rmt_port = tcp_hdr(skb)->source; |
985 | } | 980 | } |
986 | 981 | ||
987 | extern void tcp_enter_memory_pressure(void); | 982 | extern void tcp_enter_memory_pressure(void); |
@@ -1011,7 +1006,7 @@ static inline int tcp_paws_check(const struct tcp_options_received *rx_opt, int | |||
1011 | { | 1006 | { |
1012 | if ((s32)(rx_opt->rcv_tsval - rx_opt->ts_recent) >= 0) | 1007 | if ((s32)(rx_opt->rcv_tsval - rx_opt->ts_recent) >= 0) |
1013 | return 0; | 1008 | return 0; |
1014 | if (xtime.tv_sec >= rx_opt->ts_recent_stamp + TCP_PAWS_24DAYS) | 1009 | if (get_seconds() >= rx_opt->ts_recent_stamp + TCP_PAWS_24DAYS) |
1015 | return 0; | 1010 | return 0; |
1016 | 1011 | ||
1017 | /* RST segments are not recommended to carry timestamp, | 1012 | /* RST segments are not recommended to carry timestamp, |
@@ -1026,26 +1021,13 @@ static inline int tcp_paws_check(const struct tcp_options_received *rx_opt, int | |||
1026 | 1021 | ||
1027 | However, we can relax time bounds for RST segments to MSL. | 1022 | However, we can relax time bounds for RST segments to MSL. |
1028 | */ | 1023 | */ |
1029 | if (rst && xtime.tv_sec >= rx_opt->ts_recent_stamp + TCP_PAWS_MSL) | 1024 | if (rst && get_seconds() >= rx_opt->ts_recent_stamp + TCP_PAWS_MSL) |
1030 | return 0; | 1025 | return 0; |
1031 | return 1; | 1026 | return 1; |
1032 | } | 1027 | } |
1033 | 1028 | ||
1034 | #define TCP_CHECK_TIMER(sk) do { } while (0) | 1029 | #define TCP_CHECK_TIMER(sk) do { } while (0) |
1035 | 1030 | ||
1036 | static inline int tcp_use_frto(const struct sock *sk) | ||
1037 | { | ||
1038 | const struct tcp_sock *tp = tcp_sk(sk); | ||
1039 | |||
1040 | /* F-RTO must be activated in sysctl and there must be some | ||
1041 | * unsent new data, and the advertised window should allow | ||
1042 | * sending it. | ||
1043 | */ | ||
1044 | return (sysctl_tcp_frto && sk->sk_send_head && | ||
1045 | !after(TCP_SKB_CB(sk->sk_send_head)->end_seq, | ||
1046 | tp->snd_una + tp->snd_wnd)); | ||
1047 | } | ||
1048 | |||
1049 | static inline void tcp_mib_init(void) | 1031 | static inline void tcp_mib_init(void) |
1050 | { | 1032 | { |
1051 | /* See RFC 2012 */ | 1033 | /* See RFC 2012 */ |
@@ -1172,6 +1154,120 @@ static inline void tcp_put_md5sig_pool(void) | |||
1172 | put_cpu(); | 1154 | put_cpu(); |
1173 | } | 1155 | } |
1174 | 1156 | ||
1157 | /* write queue abstraction */ | ||
1158 | static inline void tcp_write_queue_purge(struct sock *sk) | ||
1159 | { | ||
1160 | struct sk_buff *skb; | ||
1161 | |||
1162 | while ((skb = __skb_dequeue(&sk->sk_write_queue)) != NULL) | ||
1163 | sk_stream_free_skb(sk, skb); | ||
1164 | sk_stream_mem_reclaim(sk); | ||
1165 | } | ||
1166 | |||
1167 | static inline struct sk_buff *tcp_write_queue_head(struct sock *sk) | ||
1168 | { | ||
1169 | struct sk_buff *skb = sk->sk_write_queue.next; | ||
1170 | if (skb == (struct sk_buff *) &sk->sk_write_queue) | ||
1171 | return NULL; | ||
1172 | return skb; | ||
1173 | } | ||
1174 | |||
1175 | static inline struct sk_buff *tcp_write_queue_tail(struct sock *sk) | ||
1176 | { | ||
1177 | struct sk_buff *skb = sk->sk_write_queue.prev; | ||
1178 | if (skb == (struct sk_buff *) &sk->sk_write_queue) | ||
1179 | return NULL; | ||
1180 | return skb; | ||
1181 | } | ||
1182 | |||
1183 | static inline struct sk_buff *tcp_write_queue_next(struct sock *sk, struct sk_buff *skb) | ||
1184 | { | ||
1185 | return skb->next; | ||
1186 | } | ||
1187 | |||
1188 | #define tcp_for_write_queue(skb, sk) \ | ||
1189 | for (skb = (sk)->sk_write_queue.next; \ | ||
1190 | (skb != (struct sk_buff *)&(sk)->sk_write_queue); \ | ||
1191 | skb = skb->next) | ||
1192 | |||
1193 | #define tcp_for_write_queue_from(skb, sk) \ | ||
1194 | for (; (skb != (struct sk_buff *)&(sk)->sk_write_queue);\ | ||
1195 | skb = skb->next) | ||
1196 | |||
1197 | static inline struct sk_buff *tcp_send_head(struct sock *sk) | ||
1198 | { | ||
1199 | return sk->sk_send_head; | ||
1200 | } | ||
1201 | |||
1202 | static inline void tcp_advance_send_head(struct sock *sk, struct sk_buff *skb) | ||
1203 | { | ||
1204 | sk->sk_send_head = skb->next; | ||
1205 | if (sk->sk_send_head == (struct sk_buff *)&sk->sk_write_queue) | ||
1206 | sk->sk_send_head = NULL; | ||
1207 | } | ||
1208 | |||
1209 | static inline void tcp_check_send_head(struct sock *sk, struct sk_buff *skb_unlinked) | ||
1210 | { | ||
1211 | if (sk->sk_send_head == skb_unlinked) | ||
1212 | sk->sk_send_head = NULL; | ||
1213 | } | ||
1214 | |||
1215 | static inline void tcp_init_send_head(struct sock *sk) | ||
1216 | { | ||
1217 | sk->sk_send_head = NULL; | ||
1218 | } | ||
1219 | |||
1220 | static inline void __tcp_add_write_queue_tail(struct sock *sk, struct sk_buff *skb) | ||
1221 | { | ||
1222 | __skb_queue_tail(&sk->sk_write_queue, skb); | ||
1223 | } | ||
1224 | |||
1225 | static inline void tcp_add_write_queue_tail(struct sock *sk, struct sk_buff *skb) | ||
1226 | { | ||
1227 | __tcp_add_write_queue_tail(sk, skb); | ||
1228 | |||
1229 | /* Queue it, remembering where we must start sending. */ | ||
1230 | if (sk->sk_send_head == NULL) | ||
1231 | sk->sk_send_head = skb; | ||
1232 | } | ||
1233 | |||
1234 | static inline void __tcp_add_write_queue_head(struct sock *sk, struct sk_buff *skb) | ||
1235 | { | ||
1236 | __skb_queue_head(&sk->sk_write_queue, skb); | ||
1237 | } | ||
1238 | |||
1239 | /* Insert buff after skb on the write queue of sk. */ | ||
1240 | static inline void tcp_insert_write_queue_after(struct sk_buff *skb, | ||
1241 | struct sk_buff *buff, | ||
1242 | struct sock *sk) | ||
1243 | { | ||
1244 | __skb_append(skb, buff, &sk->sk_write_queue); | ||
1245 | } | ||
1246 | |||
1247 | /* Insert skb between prev and next on the write queue of sk. */ | ||
1248 | static inline void tcp_insert_write_queue_before(struct sk_buff *new, | ||
1249 | struct sk_buff *skb, | ||
1250 | struct sock *sk) | ||
1251 | { | ||
1252 | __skb_insert(new, skb->prev, skb, &sk->sk_write_queue); | ||
1253 | } | ||
1254 | |||
1255 | static inline void tcp_unlink_write_queue(struct sk_buff *skb, struct sock *sk) | ||
1256 | { | ||
1257 | __skb_unlink(skb, &sk->sk_write_queue); | ||
1258 | } | ||
1259 | |||
1260 | static inline int tcp_skb_is_last(const struct sock *sk, | ||
1261 | const struct sk_buff *skb) | ||
1262 | { | ||
1263 | return skb->next == (struct sk_buff *)&sk->sk_write_queue; | ||
1264 | } | ||
1265 | |||
1266 | static inline int tcp_write_queue_empty(struct sock *sk) | ||
1267 | { | ||
1268 | return skb_queue_empty(&sk->sk_write_queue); | ||
1269 | } | ||
1270 | |||
1175 | /* /proc */ | 1271 | /* /proc */ |
1176 | enum tcp_seq_states { | 1272 | enum tcp_seq_states { |
1177 | TCP_SEQ_STATE_LISTENING, | 1273 | TCP_SEQ_STATE_LISTENING, |