diff options
Diffstat (limited to 'include/net/tcp.h')
-rw-r--r-- | include/net/tcp.h | 94 |
1 files changed, 59 insertions, 35 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h index 0cab28cd43a9..f80e74c5ad18 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
@@ -279,6 +279,7 @@ extern int sysctl_tcp_limit_output_bytes; | |||
279 | extern int sysctl_tcp_challenge_ack_limit; | 279 | extern int sysctl_tcp_challenge_ack_limit; |
280 | extern unsigned int sysctl_tcp_notsent_lowat; | 280 | extern unsigned int sysctl_tcp_notsent_lowat; |
281 | extern int sysctl_tcp_min_tso_segs; | 281 | extern int sysctl_tcp_min_tso_segs; |
282 | extern int sysctl_tcp_min_rtt_wlen; | ||
282 | extern int sysctl_tcp_autocorking; | 283 | extern int sysctl_tcp_autocorking; |
283 | extern int sysctl_tcp_invalid_ratelimit; | 284 | extern int sysctl_tcp_invalid_ratelimit; |
284 | extern int sysctl_tcp_pacing_ss_ratio; | 285 | extern int sysctl_tcp_pacing_ss_ratio; |
@@ -365,8 +366,7 @@ void tcp_wfree(struct sk_buff *skb); | |||
365 | void tcp_write_timer_handler(struct sock *sk); | 366 | void tcp_write_timer_handler(struct sock *sk); |
366 | void tcp_delack_timer_handler(struct sock *sk); | 367 | void tcp_delack_timer_handler(struct sock *sk); |
367 | int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg); | 368 | int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg); |
368 | int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb, | 369 | int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb); |
369 | const struct tcphdr *th, unsigned int len); | ||
370 | void tcp_rcv_established(struct sock *sk, struct sk_buff *skb, | 370 | void tcp_rcv_established(struct sock *sk, struct sk_buff *skb, |
371 | const struct tcphdr *th, unsigned int len); | 371 | const struct tcphdr *th, unsigned int len); |
372 | void tcp_rcv_space_adjust(struct sock *sk); | 372 | void tcp_rcv_space_adjust(struct sock *sk); |
@@ -451,19 +451,22 @@ void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb); | |||
451 | void tcp_v4_mtu_reduced(struct sock *sk); | 451 | void tcp_v4_mtu_reduced(struct sock *sk); |
452 | void tcp_req_err(struct sock *sk, u32 seq); | 452 | void tcp_req_err(struct sock *sk, u32 seq); |
453 | int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb); | 453 | int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb); |
454 | struct sock *tcp_create_openreq_child(struct sock *sk, | 454 | struct sock *tcp_create_openreq_child(const struct sock *sk, |
455 | struct request_sock *req, | 455 | struct request_sock *req, |
456 | struct sk_buff *skb); | 456 | struct sk_buff *skb); |
457 | void tcp_ca_openreq_child(struct sock *sk, const struct dst_entry *dst); | 457 | void tcp_ca_openreq_child(struct sock *sk, const struct dst_entry *dst); |
458 | struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb, | 458 | struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb, |
459 | struct request_sock *req, | 459 | struct request_sock *req, |
460 | struct dst_entry *dst); | 460 | struct dst_entry *dst, |
461 | struct request_sock *req_unhash, | ||
462 | bool *own_req); | ||
461 | int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb); | 463 | int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb); |
462 | int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len); | 464 | int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len); |
463 | int tcp_connect(struct sock *sk); | 465 | int tcp_connect(struct sock *sk); |
464 | struct sk_buff *tcp_make_synack(struct sock *sk, struct dst_entry *dst, | 466 | struct sk_buff *tcp_make_synack(const struct sock *sk, struct dst_entry *dst, |
465 | struct request_sock *req, | 467 | struct request_sock *req, |
466 | struct tcp_fastopen_cookie *foc); | 468 | struct tcp_fastopen_cookie *foc, |
469 | bool attach_req); | ||
467 | int tcp_disconnect(struct sock *sk, int flags); | 470 | int tcp_disconnect(struct sock *sk, int flags); |
468 | 471 | ||
469 | void tcp_finish_connect(struct sock *sk, struct sk_buff *skb); | 472 | void tcp_finish_connect(struct sock *sk, struct sk_buff *skb); |
@@ -492,8 +495,9 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb); | |||
492 | 495 | ||
493 | /* syncookies: remember time of last synqueue overflow | 496 | /* syncookies: remember time of last synqueue overflow |
494 | * But do not dirty this field too often (once per second is enough) | 497 | * But do not dirty this field too often (once per second is enough) |
498 | * It is racy as we do not hold a lock, but race is very minor. | ||
495 | */ | 499 | */ |
496 | static inline void tcp_synq_overflow(struct sock *sk) | 500 | static inline void tcp_synq_overflow(const struct sock *sk) |
497 | { | 501 | { |
498 | unsigned long last_overflow = tcp_sk(sk)->rx_opt.ts_recent_stamp; | 502 | unsigned long last_overflow = tcp_sk(sk)->rx_opt.ts_recent_stamp; |
499 | unsigned long now = jiffies; | 503 | unsigned long now = jiffies; |
@@ -520,8 +524,7 @@ static inline u32 tcp_cookie_time(void) | |||
520 | 524 | ||
521 | u32 __cookie_v4_init_sequence(const struct iphdr *iph, const struct tcphdr *th, | 525 | u32 __cookie_v4_init_sequence(const struct iphdr *iph, const struct tcphdr *th, |
522 | u16 *mssp); | 526 | u16 *mssp); |
523 | __u32 cookie_v4_init_sequence(struct sock *sk, const struct sk_buff *skb, | 527 | __u32 cookie_v4_init_sequence(const struct sk_buff *skb, __u16 *mss); |
524 | __u16 *mss); | ||
525 | __u32 cookie_init_timestamp(struct request_sock *req); | 528 | __u32 cookie_init_timestamp(struct request_sock *req); |
526 | bool cookie_timestamp_decode(struct tcp_options_received *opt); | 529 | bool cookie_timestamp_decode(struct tcp_options_received *opt); |
527 | bool cookie_ecn_ok(const struct tcp_options_received *opt, | 530 | bool cookie_ecn_ok(const struct tcp_options_received *opt, |
@@ -534,8 +537,7 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb); | |||
534 | 537 | ||
535 | u32 __cookie_v6_init_sequence(const struct ipv6hdr *iph, | 538 | u32 __cookie_v6_init_sequence(const struct ipv6hdr *iph, |
536 | const struct tcphdr *th, u16 *mssp); | 539 | const struct tcphdr *th, u16 *mssp); |
537 | __u32 cookie_v6_init_sequence(struct sock *sk, const struct sk_buff *skb, | 540 | __u32 cookie_v6_init_sequence(const struct sk_buff *skb, __u16 *mss); |
538 | __u16 *mss); | ||
539 | #endif | 541 | #endif |
540 | /* tcp_output.c */ | 542 | /* tcp_output.c */ |
541 | 543 | ||
@@ -565,7 +567,9 @@ bool tcp_schedule_loss_probe(struct sock *sk); | |||
565 | /* tcp_input.c */ | 567 | /* tcp_input.c */ |
566 | void tcp_resume_early_retransmit(struct sock *sk); | 568 | void tcp_resume_early_retransmit(struct sock *sk); |
567 | void tcp_rearm_rto(struct sock *sk); | 569 | void tcp_rearm_rto(struct sock *sk); |
570 | void tcp_synack_rtt_meas(struct sock *sk, struct request_sock *req); | ||
568 | void tcp_reset(struct sock *sk); | 571 | void tcp_reset(struct sock *sk); |
572 | void tcp_skb_mark_lost_uncond_verify(struct tcp_sock *tp, struct sk_buff *skb); | ||
569 | 573 | ||
570 | /* tcp_timer.c */ | 574 | /* tcp_timer.c */ |
571 | void tcp_init_xmit_timers(struct sock *); | 575 | void tcp_init_xmit_timers(struct sock *); |
@@ -671,6 +675,12 @@ static inline bool tcp_ca_dst_locked(const struct dst_entry *dst) | |||
671 | return dst_metric_locked(dst, RTAX_CC_ALGO); | 675 | return dst_metric_locked(dst, RTAX_CC_ALGO); |
672 | } | 676 | } |
673 | 677 | ||
678 | /* Minimum RTT in usec. ~0 means not available. */ | ||
679 | static inline u32 tcp_min_rtt(const struct tcp_sock *tp) | ||
680 | { | ||
681 | return tp->rtt_min[0].rtt; | ||
682 | } | ||
683 | |||
674 | /* Compute the actual receive window we are currently advertising. | 684 | /* Compute the actual receive window we are currently advertising. |
675 | * Rcv_nxt can be after the window if our peer push more data | 685 | * Rcv_nxt can be after the window if our peer push more data |
676 | * than the offered window. | 686 | * than the offered window. |
@@ -1206,7 +1216,8 @@ static inline int tcp_full_space(const struct sock *sk) | |||
1206 | } | 1216 | } |
1207 | 1217 | ||
1208 | extern void tcp_openreq_init_rwin(struct request_sock *req, | 1218 | extern void tcp_openreq_init_rwin(struct request_sock *req, |
1209 | struct sock *sk, struct dst_entry *dst); | 1219 | const struct sock *sk_listener, |
1220 | const struct dst_entry *dst); | ||
1210 | 1221 | ||
1211 | void tcp_enter_memory_pressure(struct sock *sk); | 1222 | void tcp_enter_memory_pressure(struct sock *sk); |
1212 | 1223 | ||
@@ -1370,16 +1381,16 @@ int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr, | |||
1370 | int family, const u8 *newkey, u8 newkeylen, gfp_t gfp); | 1381 | int family, const u8 *newkey, u8 newkeylen, gfp_t gfp); |
1371 | int tcp_md5_do_del(struct sock *sk, const union tcp_md5_addr *addr, | 1382 | int tcp_md5_do_del(struct sock *sk, const union tcp_md5_addr *addr, |
1372 | int family); | 1383 | int family); |
1373 | struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk, | 1384 | struct tcp_md5sig_key *tcp_v4_md5_lookup(const struct sock *sk, |
1374 | const struct sock *addr_sk); | 1385 | const struct sock *addr_sk); |
1375 | 1386 | ||
1376 | #ifdef CONFIG_TCP_MD5SIG | 1387 | #ifdef CONFIG_TCP_MD5SIG |
1377 | struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk, | 1388 | struct tcp_md5sig_key *tcp_md5_do_lookup(const struct sock *sk, |
1378 | const union tcp_md5_addr *addr, | 1389 | const union tcp_md5_addr *addr, |
1379 | int family); | 1390 | int family); |
1380 | #define tcp_twsk_md5_key(twsk) ((twsk)->tw_md5_key) | 1391 | #define tcp_twsk_md5_key(twsk) ((twsk)->tw_md5_key) |
1381 | #else | 1392 | #else |
1382 | static inline struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk, | 1393 | static inline struct tcp_md5sig_key *tcp_md5_do_lookup(const struct sock *sk, |
1383 | const union tcp_md5_addr *addr, | 1394 | const union tcp_md5_addr *addr, |
1384 | int family) | 1395 | int family) |
1385 | { | 1396 | { |
@@ -1420,10 +1431,10 @@ void tcp_free_fastopen_req(struct tcp_sock *tp); | |||
1420 | 1431 | ||
1421 | extern struct tcp_fastopen_context __rcu *tcp_fastopen_ctx; | 1432 | extern struct tcp_fastopen_context __rcu *tcp_fastopen_ctx; |
1422 | int tcp_fastopen_reset_cipher(void *key, unsigned int len); | 1433 | int tcp_fastopen_reset_cipher(void *key, unsigned int len); |
1423 | bool tcp_try_fastopen(struct sock *sk, struct sk_buff *skb, | 1434 | struct sock *tcp_try_fastopen(struct sock *sk, struct sk_buff *skb, |
1424 | struct request_sock *req, | 1435 | struct request_sock *req, |
1425 | struct tcp_fastopen_cookie *foc, | 1436 | struct tcp_fastopen_cookie *foc, |
1426 | struct dst_entry *dst); | 1437 | struct dst_entry *dst); |
1427 | void tcp_fastopen_init_key_once(bool publish); | 1438 | void tcp_fastopen_init_key_once(bool publish); |
1428 | #define TCP_FASTOPEN_KEY_LENGTH 16 | 1439 | #define TCP_FASTOPEN_KEY_LENGTH 16 |
1429 | 1440 | ||
@@ -1618,7 +1629,6 @@ static inline bool tcp_stream_is_thin(struct tcp_sock *tp) | |||
1618 | /* /proc */ | 1629 | /* /proc */ |
1619 | enum tcp_seq_states { | 1630 | enum tcp_seq_states { |
1620 | TCP_SEQ_STATE_LISTENING, | 1631 | TCP_SEQ_STATE_LISTENING, |
1621 | TCP_SEQ_STATE_OPENREQ, | ||
1622 | TCP_SEQ_STATE_ESTABLISHED, | 1632 | TCP_SEQ_STATE_ESTABLISHED, |
1623 | }; | 1633 | }; |
1624 | 1634 | ||
@@ -1637,7 +1647,6 @@ struct tcp_iter_state { | |||
1637 | enum tcp_seq_states state; | 1647 | enum tcp_seq_states state; |
1638 | struct sock *syn_wait_sk; | 1648 | struct sock *syn_wait_sk; |
1639 | int bucket, offset, sbucket, num; | 1649 | int bucket, offset, sbucket, num; |
1640 | kuid_t uid; | ||
1641 | loff_t last_pos; | 1650 | loff_t last_pos; |
1642 | }; | 1651 | }; |
1643 | 1652 | ||
@@ -1674,7 +1683,7 @@ int tcp4_proc_init(void); | |||
1674 | void tcp4_proc_exit(void); | 1683 | void tcp4_proc_exit(void); |
1675 | #endif | 1684 | #endif |
1676 | 1685 | ||
1677 | int tcp_rtx_synack(struct sock *sk, struct request_sock *req); | 1686 | int tcp_rtx_synack(const struct sock *sk, struct request_sock *req); |
1678 | int tcp_conn_request(struct request_sock_ops *rsk_ops, | 1687 | int tcp_conn_request(struct request_sock_ops *rsk_ops, |
1679 | const struct tcp_request_sock_ops *af_ops, | 1688 | const struct tcp_request_sock_ops *af_ops, |
1680 | struct sock *sk, struct sk_buff *skb); | 1689 | struct sock *sk, struct sk_buff *skb); |
@@ -1682,7 +1691,7 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops, | |||
1682 | /* TCP af-specific functions */ | 1691 | /* TCP af-specific functions */ |
1683 | struct tcp_sock_af_ops { | 1692 | struct tcp_sock_af_ops { |
1684 | #ifdef CONFIG_TCP_MD5SIG | 1693 | #ifdef CONFIG_TCP_MD5SIG |
1685 | struct tcp_md5sig_key *(*md5_lookup) (struct sock *sk, | 1694 | struct tcp_md5sig_key *(*md5_lookup) (const struct sock *sk, |
1686 | const struct sock *addr_sk); | 1695 | const struct sock *addr_sk); |
1687 | int (*calc_md5_hash)(char *location, | 1696 | int (*calc_md5_hash)(char *location, |
1688 | const struct tcp_md5sig_key *md5, | 1697 | const struct tcp_md5sig_key *md5, |
@@ -1697,40 +1706,42 @@ struct tcp_sock_af_ops { | |||
1697 | struct tcp_request_sock_ops { | 1706 | struct tcp_request_sock_ops { |
1698 | u16 mss_clamp; | 1707 | u16 mss_clamp; |
1699 | #ifdef CONFIG_TCP_MD5SIG | 1708 | #ifdef CONFIG_TCP_MD5SIG |
1700 | struct tcp_md5sig_key *(*req_md5_lookup)(struct sock *sk, | 1709 | struct tcp_md5sig_key *(*req_md5_lookup)(const struct sock *sk, |
1701 | const struct sock *addr_sk); | 1710 | const struct sock *addr_sk); |
1702 | int (*calc_md5_hash) (char *location, | 1711 | int (*calc_md5_hash) (char *location, |
1703 | const struct tcp_md5sig_key *md5, | 1712 | const struct tcp_md5sig_key *md5, |
1704 | const struct sock *sk, | 1713 | const struct sock *sk, |
1705 | const struct sk_buff *skb); | 1714 | const struct sk_buff *skb); |
1706 | #endif | 1715 | #endif |
1707 | void (*init_req)(struct request_sock *req, struct sock *sk, | 1716 | void (*init_req)(struct request_sock *req, |
1717 | const struct sock *sk_listener, | ||
1708 | struct sk_buff *skb); | 1718 | struct sk_buff *skb); |
1709 | #ifdef CONFIG_SYN_COOKIES | 1719 | #ifdef CONFIG_SYN_COOKIES |
1710 | __u32 (*cookie_init_seq)(struct sock *sk, const struct sk_buff *skb, | 1720 | __u32 (*cookie_init_seq)(const struct sk_buff *skb, |
1711 | __u16 *mss); | 1721 | __u16 *mss); |
1712 | #endif | 1722 | #endif |
1713 | struct dst_entry *(*route_req)(struct sock *sk, struct flowi *fl, | 1723 | struct dst_entry *(*route_req)(const struct sock *sk, struct flowi *fl, |
1714 | const struct request_sock *req, | 1724 | const struct request_sock *req, |
1715 | bool *strict); | 1725 | bool *strict); |
1716 | __u32 (*init_seq)(const struct sk_buff *skb); | 1726 | __u32 (*init_seq)(const struct sk_buff *skb); |
1717 | int (*send_synack)(struct sock *sk, struct dst_entry *dst, | 1727 | int (*send_synack)(const struct sock *sk, struct dst_entry *dst, |
1718 | struct flowi *fl, struct request_sock *req, | 1728 | struct flowi *fl, struct request_sock *req, |
1719 | u16 queue_mapping, struct tcp_fastopen_cookie *foc); | 1729 | struct tcp_fastopen_cookie *foc, |
1720 | void (*queue_hash_add)(struct sock *sk, struct request_sock *req, | 1730 | bool attach_req); |
1721 | const unsigned long timeout); | ||
1722 | }; | 1731 | }; |
1723 | 1732 | ||
1724 | #ifdef CONFIG_SYN_COOKIES | 1733 | #ifdef CONFIG_SYN_COOKIES |
1725 | static inline __u32 cookie_init_sequence(const struct tcp_request_sock_ops *ops, | 1734 | static inline __u32 cookie_init_sequence(const struct tcp_request_sock_ops *ops, |
1726 | struct sock *sk, struct sk_buff *skb, | 1735 | const struct sock *sk, struct sk_buff *skb, |
1727 | __u16 *mss) | 1736 | __u16 *mss) |
1728 | { | 1737 | { |
1729 | return ops->cookie_init_seq(sk, skb, mss); | 1738 | tcp_synq_overflow(sk); |
1739 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESSENT); | ||
1740 | return ops->cookie_init_seq(skb, mss); | ||
1730 | } | 1741 | } |
1731 | #else | 1742 | #else |
1732 | static inline __u32 cookie_init_sequence(const struct tcp_request_sock_ops *ops, | 1743 | static inline __u32 cookie_init_sequence(const struct tcp_request_sock_ops *ops, |
1733 | struct sock *sk, struct sk_buff *skb, | 1744 | const struct sock *sk, struct sk_buff *skb, |
1734 | __u16 *mss) | 1745 | __u16 *mss) |
1735 | { | 1746 | { |
1736 | return 0; | 1747 | return 0; |
@@ -1742,6 +1753,19 @@ int tcpv4_offload_init(void); | |||
1742 | void tcp_v4_init(void); | 1753 | void tcp_v4_init(void); |
1743 | void tcp_init(void); | 1754 | void tcp_init(void); |
1744 | 1755 | ||
1756 | /* tcp_recovery.c */ | ||
1757 | |||
1758 | /* Flags to enable various loss recovery features. See below */ | ||
1759 | extern int sysctl_tcp_recovery; | ||
1760 | |||
1761 | /* Use TCP RACK to detect (some) tail and retransmit losses */ | ||
1762 | #define TCP_RACK_LOST_RETRANS 0x1 | ||
1763 | |||
1764 | extern int tcp_rack_mark_lost(struct sock *sk); | ||
1765 | |||
1766 | extern void tcp_rack_advance(struct tcp_sock *tp, | ||
1767 | const struct skb_mstamp *xmit_time, u8 sacked); | ||
1768 | |||
1745 | /* | 1769 | /* |
1746 | * Save and compile IPv4 options, return a pointer to it | 1770 | * Save and compile IPv4 options, return a pointer to it |
1747 | */ | 1771 | */ |