diff options
author | Arnaldo Carvalho de Melo <acme@ghostprotocols.net> | 2005-06-19 01:46:52 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-06-19 01:46:52 -0400 |
commit | 2e6599cb899ba4b133f42cbf9d2b1883d2dc583a (patch) | |
tree | b5d4fcca4d2a515fc3d3d20cefaaeebd8dbf661f /include/net/tcp.h | |
parent | 1944972d3bb651474a5021c9da8d0166ae19f1eb (diff) |
[NET] Generalise TCP's struct open_request minisock infrastructure
Kept this first changeset minimal, without changing existing names to
ease peer review.
Basicaly tcp_openreq_alloc now receives the or_calltable, that in turn
has two new members:
->slab, that replaces tcp_openreq_cachep
->obj_size, to inform the size of the openreq descendant for
a specific protocol
The protocol specific fields in struct open_request were moved to a
class hierarchy, with the things that are common to all connection
oriented PF_INET protocols in struct inet_request_sock, the TCP ones
in tcp_request_sock, that is an inet_request_sock, that is an
open_request.
I.e. this uses the same approach used for the struct sock class
hierarchy, with sk_prot indicating if the protocol wants to use the
open_request infrastructure by filling in sk_prot->rsk_prot with an
or_calltable.
Results? Performance is improved and TCP v4 now uses only 64 bytes per
open request minisock, down from 96 without this patch :-)
Next changeset will rename some of the structs, fields and functions
mentioned above, struct or_calltable is way unclear, better name it
struct request_sock_ops, s/struct open_request/struct request_sock/g,
etc.
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/tcp.h')
-rw-r--r-- | include/net/tcp.h | 87 |
1 files changed, 11 insertions, 76 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h index e71f8ba3e101..d438ba566b89 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> |
@@ -613,74 +614,6 @@ extern atomic_t tcp_memory_allocated; | |||
613 | extern atomic_t tcp_sockets_allocated; | 614 | extern atomic_t tcp_sockets_allocated; |
614 | extern int tcp_memory_pressure; | 615 | extern int tcp_memory_pressure; |
615 | 616 | ||
616 | struct open_request; | ||
617 | |||
618 | struct 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 | |||
626 | struct 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) | ||
633 | struct 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 */ | ||
642 | struct 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. */ | ||
673 | extern 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 | |||
678 | static 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) | 617 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
685 | #define TCP_INET_FAMILY(fam) ((fam) == AF_INET) | 618 | #define TCP_INET_FAMILY(fam) ((fam) == AF_INET) |
686 | #else | 619 | #else |
@@ -1832,17 +1765,19 @@ static __inline__ void tcp_openreq_init(struct open_request *req, | |||
1832 | struct tcp_options_received *rx_opt, | 1765 | struct tcp_options_received *rx_opt, |
1833 | struct sk_buff *skb) | 1766 | struct sk_buff *skb) |
1834 | { | 1767 | { |
1768 | struct inet_request_sock *ireq = inet_rsk(req); | ||
1769 | |||
1835 | req->rcv_wnd = 0; /* So that tcp_send_synack() knows! */ | 1770 | req->rcv_wnd = 0; /* So that tcp_send_synack() knows! */ |
1836 | req->rcv_isn = TCP_SKB_CB(skb)->seq; | 1771 | tcp_rsk(req)->rcv_isn = TCP_SKB_CB(skb)->seq; |
1837 | req->mss = rx_opt->mss_clamp; | 1772 | req->mss = rx_opt->mss_clamp; |
1838 | req->ts_recent = rx_opt->saw_tstamp ? rx_opt->rcv_tsval : 0; | 1773 | req->ts_recent = rx_opt->saw_tstamp ? rx_opt->rcv_tsval : 0; |
1839 | req->tstamp_ok = rx_opt->tstamp_ok; | 1774 | ireq->tstamp_ok = rx_opt->tstamp_ok; |
1840 | req->sack_ok = rx_opt->sack_ok; | 1775 | ireq->sack_ok = rx_opt->sack_ok; |
1841 | req->snd_wscale = rx_opt->snd_wscale; | 1776 | ireq->snd_wscale = rx_opt->snd_wscale; |
1842 | req->wscale_ok = rx_opt->wscale_ok; | 1777 | ireq->wscale_ok = rx_opt->wscale_ok; |
1843 | req->acked = 0; | 1778 | ireq->acked = 0; |
1844 | req->ecn_ok = 0; | 1779 | ireq->ecn_ok = 0; |
1845 | req->rmt_port = skb->h.th->source; | 1780 | ireq->rmt_port = skb->h.th->source; |
1846 | } | 1781 | } |
1847 | 1782 | ||
1848 | extern void tcp_enter_memory_pressure(void); | 1783 | extern void tcp_enter_memory_pressure(void); |