aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/tcp.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/tcp.h')
-rw-r--r--include/net/tcp.h160
1 files changed, 32 insertions, 128 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h
index e71f8ba3e101..f730935b824a 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -31,6 +31,7 @@
31#include <linux/cache.h> 31#include <linux/cache.h>
32#include <linux/percpu.h> 32#include <linux/percpu.h>
33#include <net/checksum.h> 33#include <net/checksum.h>
34#include <net/request_sock.h>
34#include <net/sock.h> 35#include <net/sock.h>
35#include <net/snmp.h> 36#include <net/snmp.h>
36#include <net/ip.h> 37#include <net/ip.h>
@@ -563,7 +564,6 @@ static __inline__ int tcp_sk_listen_hashfn(struct sock *sk)
563#define TCP_NAGLE_PUSH 4 /* Cork is overriden for already queued data */ 564#define TCP_NAGLE_PUSH 4 /* Cork is overriden for already queued data */
564 565
565/* sysctl variables for tcp */ 566/* sysctl variables for tcp */
566extern int sysctl_max_syn_backlog;
567extern int sysctl_tcp_timestamps; 567extern int sysctl_tcp_timestamps;
568extern int sysctl_tcp_window_scaling; 568extern int sysctl_tcp_window_scaling;
569extern int sysctl_tcp_sack; 569extern int sysctl_tcp_sack;
@@ -613,74 +613,6 @@ extern atomic_t tcp_memory_allocated;
613extern atomic_t tcp_sockets_allocated; 613extern atomic_t tcp_sockets_allocated;
614extern int tcp_memory_pressure; 614extern int tcp_memory_pressure;
615 615
616struct open_request;
617
618struct or_calltable {
619 int family;
620 int (*rtx_syn_ack) (struct sock *sk, struct open_request *req, struct dst_entry*);
621 void (*send_ack) (struct sk_buff *skb, struct open_request *req);
622 void (*destructor) (struct open_request *req);
623 void (*send_reset) (struct sk_buff *skb);
624};
625
626struct tcp_v4_open_req {
627 __u32 loc_addr;
628 __u32 rmt_addr;
629 struct ip_options *opt;
630};
631
632#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
633struct tcp_v6_open_req {
634 struct in6_addr loc_addr;
635 struct in6_addr rmt_addr;
636 struct sk_buff *pktopts;
637 int iif;
638};
639#endif
640
641/* this structure is too big */
642struct open_request {
643 struct open_request *dl_next; /* Must be first member! */
644 __u32 rcv_isn;
645 __u32 snt_isn;
646 __u16 rmt_port;
647 __u16 mss;
648 __u8 retrans;
649 __u8 __pad;
650 __u16 snd_wscale : 4,
651 rcv_wscale : 4,
652 tstamp_ok : 1,
653 sack_ok : 1,
654 wscale_ok : 1,
655 ecn_ok : 1,
656 acked : 1;
657 /* The following two fields can be easily recomputed I think -AK */
658 __u32 window_clamp; /* window clamp at creation time */
659 __u32 rcv_wnd; /* rcv_wnd offered first time */
660 __u32 ts_recent;
661 unsigned long expires;
662 struct or_calltable *class;
663 struct sock *sk;
664 union {
665 struct tcp_v4_open_req v4_req;
666#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
667 struct tcp_v6_open_req v6_req;
668#endif
669 } af;
670};
671
672/* SLAB cache for open requests. */
673extern kmem_cache_t *tcp_openreq_cachep;
674
675#define tcp_openreq_alloc() kmem_cache_alloc(tcp_openreq_cachep, SLAB_ATOMIC)
676#define tcp_openreq_fastfree(req) kmem_cache_free(tcp_openreq_cachep, req)
677
678static inline void tcp_openreq_free(struct open_request *req)
679{
680 req->class->destructor(req);
681 tcp_openreq_fastfree(req);
682}
683
684#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 616#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
685#define TCP_INET_FAMILY(fam) ((fam) == AF_INET) 617#define TCP_INET_FAMILY(fam) ((fam) == AF_INET)
686#else 618#else
@@ -708,7 +640,7 @@ struct tcp_func {
708 640
709 struct sock * (*syn_recv_sock) (struct sock *sk, 641 struct sock * (*syn_recv_sock) (struct sock *sk,
710 struct sk_buff *skb, 642 struct sk_buff *skb,
711 struct open_request *req, 643 struct request_sock *req,
712 struct dst_entry *dst); 644 struct dst_entry *dst);
713 645
714 int (*remember_stamp) (struct sock *sk); 646 int (*remember_stamp) (struct sock *sk);
@@ -852,8 +784,8 @@ extern enum tcp_tw_status tcp_timewait_state_process(struct tcp_tw_bucket *tw,
852 unsigned len); 784 unsigned len);
853 785
854extern struct sock * tcp_check_req(struct sock *sk,struct sk_buff *skb, 786extern struct sock * tcp_check_req(struct sock *sk,struct sk_buff *skb,
855 struct open_request *req, 787 struct request_sock *req,
856 struct open_request **prev); 788 struct request_sock **prev);
857extern int tcp_child_process(struct sock *parent, 789extern int tcp_child_process(struct sock *parent,
858 struct sock *child, 790 struct sock *child,
859 struct sk_buff *skb); 791 struct sk_buff *skb);
@@ -903,12 +835,12 @@ extern int tcp_v4_conn_request(struct sock *sk,
903 struct sk_buff *skb); 835 struct sk_buff *skb);
904 836
905extern struct sock * tcp_create_openreq_child(struct sock *sk, 837extern struct sock * tcp_create_openreq_child(struct sock *sk,
906 struct open_request *req, 838 struct request_sock *req,
907 struct sk_buff *skb); 839 struct sk_buff *skb);
908 840
909extern struct sock * tcp_v4_syn_recv_sock(struct sock *sk, 841extern struct sock * tcp_v4_syn_recv_sock(struct sock *sk,
910 struct sk_buff *skb, 842 struct sk_buff *skb,
911 struct open_request *req, 843 struct request_sock *req,
912 struct dst_entry *dst); 844 struct dst_entry *dst);
913 845
914extern int tcp_v4_do_rcv(struct sock *sk, 846extern int tcp_v4_do_rcv(struct sock *sk,
@@ -922,7 +854,7 @@ extern int tcp_connect(struct sock *sk);
922 854
923extern struct sk_buff * tcp_make_synack(struct sock *sk, 855extern struct sk_buff * tcp_make_synack(struct sock *sk,
924 struct dst_entry *dst, 856 struct dst_entry *dst,
925 struct open_request *req); 857 struct request_sock *req);
926 858
927extern int tcp_disconnect(struct sock *sk, int flags); 859extern int tcp_disconnect(struct sock *sk, int flags);
928 860
@@ -1750,99 +1682,71 @@ static inline int tcp_full_space(const struct sock *sk)
1750 return tcp_win_from_space(sk->sk_rcvbuf); 1682 return tcp_win_from_space(sk->sk_rcvbuf);
1751} 1683}
1752 1684
1753static inline void tcp_acceptq_queue(struct sock *sk, struct open_request *req, 1685static inline void tcp_acceptq_queue(struct sock *sk, struct request_sock *req,
1754 struct sock *child) 1686 struct sock *child)
1755{ 1687{
1756 struct tcp_sock *tp = tcp_sk(sk); 1688 reqsk_queue_add(&tcp_sk(sk)->accept_queue, req, sk, child);
1757
1758 req->sk = child;
1759 sk_acceptq_added(sk);
1760
1761 if (!tp->accept_queue_tail) {
1762 tp->accept_queue = req;
1763 } else {
1764 tp->accept_queue_tail->dl_next = req;
1765 }
1766 tp->accept_queue_tail = req;
1767 req->dl_next = NULL;
1768} 1689}
1769 1690
1770struct tcp_listen_opt
1771{
1772 u8 max_qlen_log; /* log_2 of maximal queued SYNs */
1773 int qlen;
1774 int qlen_young;
1775 int clock_hand;
1776 u32 hash_rnd;
1777 struct open_request *syn_table[TCP_SYNQ_HSIZE];
1778};
1779
1780static inline void 1691static inline void
1781tcp_synq_removed(struct sock *sk, struct open_request *req) 1692tcp_synq_removed(struct sock *sk, struct request_sock *req)
1782{ 1693{
1783 struct tcp_listen_opt *lopt = tcp_sk(sk)->listen_opt; 1694 if (reqsk_queue_removed(&tcp_sk(sk)->accept_queue, req) == 0)
1784
1785 if (--lopt->qlen == 0)
1786 tcp_delete_keepalive_timer(sk); 1695 tcp_delete_keepalive_timer(sk);
1787 if (req->retrans == 0)
1788 lopt->qlen_young--;
1789} 1696}
1790 1697
1791static inline void tcp_synq_added(struct sock *sk) 1698static inline void tcp_synq_added(struct sock *sk)
1792{ 1699{
1793 struct tcp_listen_opt *lopt = tcp_sk(sk)->listen_opt; 1700 if (reqsk_queue_added(&tcp_sk(sk)->accept_queue) == 0)
1794
1795 if (lopt->qlen++ == 0)
1796 tcp_reset_keepalive_timer(sk, TCP_TIMEOUT_INIT); 1701 tcp_reset_keepalive_timer(sk, TCP_TIMEOUT_INIT);
1797 lopt->qlen_young++;
1798} 1702}
1799 1703
1800static inline int tcp_synq_len(struct sock *sk) 1704static inline int tcp_synq_len(struct sock *sk)
1801{ 1705{
1802 return tcp_sk(sk)->listen_opt->qlen; 1706 return reqsk_queue_len(&tcp_sk(sk)->accept_queue);
1803} 1707}
1804 1708
1805static inline int tcp_synq_young(struct sock *sk) 1709static inline int tcp_synq_young(struct sock *sk)
1806{ 1710{
1807 return tcp_sk(sk)->listen_opt->qlen_young; 1711 return reqsk_queue_len_young(&tcp_sk(sk)->accept_queue);
1808} 1712}
1809 1713
1810static inline int tcp_synq_is_full(struct sock *sk) 1714static inline int tcp_synq_is_full(struct sock *sk)
1811{ 1715{
1812 return tcp_synq_len(sk) >> tcp_sk(sk)->listen_opt->max_qlen_log; 1716 return reqsk_queue_is_full(&tcp_sk(sk)->accept_queue);
1813} 1717}
1814 1718
1815static inline void tcp_synq_unlink(struct tcp_sock *tp, struct open_request *req, 1719static inline void tcp_synq_unlink(struct tcp_sock *tp, struct request_sock *req,
1816 struct open_request **prev) 1720 struct request_sock **prev)
1817{ 1721{
1818 write_lock(&tp->syn_wait_lock); 1722 reqsk_queue_unlink(&tp->accept_queue, req, prev);
1819 *prev = req->dl_next;
1820 write_unlock(&tp->syn_wait_lock);
1821} 1723}
1822 1724
1823static inline void tcp_synq_drop(struct sock *sk, struct open_request *req, 1725static inline void tcp_synq_drop(struct sock *sk, struct request_sock *req,
1824 struct open_request **prev) 1726 struct request_sock **prev)
1825{ 1727{
1826 tcp_synq_unlink(tcp_sk(sk), req, prev); 1728 tcp_synq_unlink(tcp_sk(sk), req, prev);
1827 tcp_synq_removed(sk, req); 1729 tcp_synq_removed(sk, req);
1828 tcp_openreq_free(req); 1730 reqsk_free(req);
1829} 1731}
1830 1732
1831static __inline__ void tcp_openreq_init(struct open_request *req, 1733static __inline__ void tcp_openreq_init(struct request_sock *req,
1832 struct tcp_options_received *rx_opt, 1734 struct tcp_options_received *rx_opt,
1833 struct sk_buff *skb) 1735 struct sk_buff *skb)
1834{ 1736{
1737 struct inet_request_sock *ireq = inet_rsk(req);
1738
1835 req->rcv_wnd = 0; /* So that tcp_send_synack() knows! */ 1739 req->rcv_wnd = 0; /* So that tcp_send_synack() knows! */
1836 req->rcv_isn = TCP_SKB_CB(skb)->seq; 1740 tcp_rsk(req)->rcv_isn = TCP_SKB_CB(skb)->seq;
1837 req->mss = rx_opt->mss_clamp; 1741 req->mss = rx_opt->mss_clamp;
1838 req->ts_recent = rx_opt->saw_tstamp ? rx_opt->rcv_tsval : 0; 1742 req->ts_recent = rx_opt->saw_tstamp ? rx_opt->rcv_tsval : 0;
1839 req->tstamp_ok = rx_opt->tstamp_ok; 1743 ireq->tstamp_ok = rx_opt->tstamp_ok;
1840 req->sack_ok = rx_opt->sack_ok; 1744 ireq->sack_ok = rx_opt->sack_ok;
1841 req->snd_wscale = rx_opt->snd_wscale; 1745 ireq->snd_wscale = rx_opt->snd_wscale;
1842 req->wscale_ok = rx_opt->wscale_ok; 1746 ireq->wscale_ok = rx_opt->wscale_ok;
1843 req->acked = 0; 1747 ireq->acked = 0;
1844 req->ecn_ok = 0; 1748 ireq->ecn_ok = 0;
1845 req->rmt_port = skb->h.th->source; 1749 ireq->rmt_port = skb->h.th->source;
1846} 1750}
1847 1751
1848extern void tcp_enter_memory_pressure(void); 1752extern void tcp_enter_memory_pressure(void);