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 /net/ipv4/tcp_minisocks.c | |
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 'net/ipv4/tcp_minisocks.c')
-rw-r--r-- | net/ipv4/tcp_minisocks.c | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index eea1a17a9ac2..1037401c7cc8 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c | |||
@@ -692,6 +692,8 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req, | |||
692 | struct sock *newsk = sk_alloc(PF_INET, GFP_ATOMIC, sk->sk_prot, 0); | 692 | struct sock *newsk = sk_alloc(PF_INET, GFP_ATOMIC, sk->sk_prot, 0); |
693 | 693 | ||
694 | if(newsk != NULL) { | 694 | if(newsk != NULL) { |
695 | struct inet_request_sock *ireq = inet_rsk(req); | ||
696 | struct tcp_request_sock *treq = tcp_rsk(req); | ||
695 | struct tcp_sock *newtp; | 697 | struct tcp_sock *newtp; |
696 | struct sk_filter *filter; | 698 | struct sk_filter *filter; |
697 | 699 | ||
@@ -703,7 +705,7 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req, | |||
703 | tcp_sk(newsk)->bind_hash = NULL; | 705 | tcp_sk(newsk)->bind_hash = NULL; |
704 | 706 | ||
705 | /* Clone the TCP header template */ | 707 | /* Clone the TCP header template */ |
706 | inet_sk(newsk)->dport = req->rmt_port; | 708 | inet_sk(newsk)->dport = ireq->rmt_port; |
707 | 709 | ||
708 | sock_lock_init(newsk); | 710 | sock_lock_init(newsk); |
709 | bh_lock_sock(newsk); | 711 | bh_lock_sock(newsk); |
@@ -739,14 +741,14 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req, | |||
739 | /* Now setup tcp_sock */ | 741 | /* Now setup tcp_sock */ |
740 | newtp = tcp_sk(newsk); | 742 | newtp = tcp_sk(newsk); |
741 | newtp->pred_flags = 0; | 743 | newtp->pred_flags = 0; |
742 | newtp->rcv_nxt = req->rcv_isn + 1; | 744 | newtp->rcv_nxt = treq->rcv_isn + 1; |
743 | newtp->snd_nxt = req->snt_isn + 1; | 745 | newtp->snd_nxt = treq->snt_isn + 1; |
744 | newtp->snd_una = req->snt_isn + 1; | 746 | newtp->snd_una = treq->snt_isn + 1; |
745 | newtp->snd_sml = req->snt_isn + 1; | 747 | newtp->snd_sml = treq->snt_isn + 1; |
746 | 748 | ||
747 | tcp_prequeue_init(newtp); | 749 | tcp_prequeue_init(newtp); |
748 | 750 | ||
749 | tcp_init_wl(newtp, req->snt_isn, req->rcv_isn); | 751 | tcp_init_wl(newtp, treq->snt_isn, treq->rcv_isn); |
750 | 752 | ||
751 | newtp->retransmits = 0; | 753 | newtp->retransmits = 0; |
752 | newtp->backoff = 0; | 754 | newtp->backoff = 0; |
@@ -775,10 +777,10 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req, | |||
775 | tcp_set_ca_state(newtp, TCP_CA_Open); | 777 | tcp_set_ca_state(newtp, TCP_CA_Open); |
776 | tcp_init_xmit_timers(newsk); | 778 | tcp_init_xmit_timers(newsk); |
777 | skb_queue_head_init(&newtp->out_of_order_queue); | 779 | skb_queue_head_init(&newtp->out_of_order_queue); |
778 | newtp->rcv_wup = req->rcv_isn + 1; | 780 | newtp->rcv_wup = treq->rcv_isn + 1; |
779 | newtp->write_seq = req->snt_isn + 1; | 781 | newtp->write_seq = treq->snt_isn + 1; |
780 | newtp->pushed_seq = newtp->write_seq; | 782 | newtp->pushed_seq = newtp->write_seq; |
781 | newtp->copied_seq = req->rcv_isn + 1; | 783 | newtp->copied_seq = treq->rcv_isn + 1; |
782 | 784 | ||
783 | newtp->rx_opt.saw_tstamp = 0; | 785 | newtp->rx_opt.saw_tstamp = 0; |
784 | 786 | ||
@@ -808,18 +810,18 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req, | |||
808 | newsk->sk_socket = NULL; | 810 | newsk->sk_socket = NULL; |
809 | newsk->sk_sleep = NULL; | 811 | newsk->sk_sleep = NULL; |
810 | 812 | ||
811 | newtp->rx_opt.tstamp_ok = req->tstamp_ok; | 813 | newtp->rx_opt.tstamp_ok = ireq->tstamp_ok; |
812 | if((newtp->rx_opt.sack_ok = req->sack_ok) != 0) { | 814 | if((newtp->rx_opt.sack_ok = ireq->sack_ok) != 0) { |
813 | if (sysctl_tcp_fack) | 815 | if (sysctl_tcp_fack) |
814 | newtp->rx_opt.sack_ok |= 2; | 816 | newtp->rx_opt.sack_ok |= 2; |
815 | } | 817 | } |
816 | newtp->window_clamp = req->window_clamp; | 818 | newtp->window_clamp = req->window_clamp; |
817 | newtp->rcv_ssthresh = req->rcv_wnd; | 819 | newtp->rcv_ssthresh = req->rcv_wnd; |
818 | newtp->rcv_wnd = req->rcv_wnd; | 820 | newtp->rcv_wnd = req->rcv_wnd; |
819 | newtp->rx_opt.wscale_ok = req->wscale_ok; | 821 | newtp->rx_opt.wscale_ok = ireq->wscale_ok; |
820 | if (newtp->rx_opt.wscale_ok) { | 822 | if (newtp->rx_opt.wscale_ok) { |
821 | newtp->rx_opt.snd_wscale = req->snd_wscale; | 823 | newtp->rx_opt.snd_wscale = ireq->snd_wscale; |
822 | newtp->rx_opt.rcv_wscale = req->rcv_wscale; | 824 | newtp->rx_opt.rcv_wscale = ireq->rcv_wscale; |
823 | } else { | 825 | } else { |
824 | newtp->rx_opt.snd_wscale = newtp->rx_opt.rcv_wscale = 0; | 826 | newtp->rx_opt.snd_wscale = newtp->rx_opt.rcv_wscale = 0; |
825 | newtp->window_clamp = min(newtp->window_clamp, 65535U); | 827 | newtp->window_clamp = min(newtp->window_clamp, 65535U); |
@@ -881,7 +883,7 @@ struct sock *tcp_check_req(struct sock *sk,struct sk_buff *skb, | |||
881 | } | 883 | } |
882 | 884 | ||
883 | /* Check for pure retransmitted SYN. */ | 885 | /* Check for pure retransmitted SYN. */ |
884 | if (TCP_SKB_CB(skb)->seq == req->rcv_isn && | 886 | if (TCP_SKB_CB(skb)->seq == tcp_rsk(req)->rcv_isn && |
885 | flg == TCP_FLAG_SYN && | 887 | flg == TCP_FLAG_SYN && |
886 | !paws_reject) { | 888 | !paws_reject) { |
887 | /* | 889 | /* |
@@ -959,7 +961,7 @@ struct sock *tcp_check_req(struct sock *sk,struct sk_buff *skb, | |||
959 | * Invalid ACK: reset will be sent by listening socket | 961 | * Invalid ACK: reset will be sent by listening socket |
960 | */ | 962 | */ |
961 | if ((flg & TCP_FLAG_ACK) && | 963 | if ((flg & TCP_FLAG_ACK) && |
962 | (TCP_SKB_CB(skb)->ack_seq != req->snt_isn+1)) | 964 | (TCP_SKB_CB(skb)->ack_seq != tcp_rsk(req)->snt_isn + 1)) |
963 | return sk; | 965 | return sk; |
964 | 966 | ||
965 | /* Also, it would be not so bad idea to check rcv_tsecr, which | 967 | /* Also, it would be not so bad idea to check rcv_tsecr, which |
@@ -970,7 +972,7 @@ struct sock *tcp_check_req(struct sock *sk,struct sk_buff *skb, | |||
970 | /* RFC793: "first check sequence number". */ | 972 | /* RFC793: "first check sequence number". */ |
971 | 973 | ||
972 | if (paws_reject || !tcp_in_window(TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq, | 974 | if (paws_reject || !tcp_in_window(TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq, |
973 | req->rcv_isn+1, req->rcv_isn+1+req->rcv_wnd)) { | 975 | tcp_rsk(req)->rcv_isn + 1, tcp_rsk(req)->rcv_isn + 1 + req->rcv_wnd)) { |
974 | /* Out of window: send ACK and drop. */ | 976 | /* Out of window: send ACK and drop. */ |
975 | if (!(flg & TCP_FLAG_RST)) | 977 | if (!(flg & TCP_FLAG_RST)) |
976 | req->class->send_ack(skb, req); | 978 | req->class->send_ack(skb, req); |
@@ -981,12 +983,12 @@ struct sock *tcp_check_req(struct sock *sk,struct sk_buff *skb, | |||
981 | 983 | ||
982 | /* In sequence, PAWS is OK. */ | 984 | /* In sequence, PAWS is OK. */ |
983 | 985 | ||
984 | if (tmp_opt.saw_tstamp && !after(TCP_SKB_CB(skb)->seq, req->rcv_isn+1)) | 986 | if (tmp_opt.saw_tstamp && !after(TCP_SKB_CB(skb)->seq, tcp_rsk(req)->rcv_isn + 1)) |
985 | req->ts_recent = tmp_opt.rcv_tsval; | 987 | req->ts_recent = tmp_opt.rcv_tsval; |
986 | 988 | ||
987 | if (TCP_SKB_CB(skb)->seq == req->rcv_isn) { | 989 | if (TCP_SKB_CB(skb)->seq == tcp_rsk(req)->rcv_isn) { |
988 | /* Truncate SYN, it is out of window starting | 990 | /* Truncate SYN, it is out of window starting |
989 | at req->rcv_isn+1. */ | 991 | at tcp_rsk(req)->rcv_isn + 1. */ |
990 | flg &= ~TCP_FLAG_SYN; | 992 | flg &= ~TCP_FLAG_SYN; |
991 | } | 993 | } |
992 | 994 | ||
@@ -1003,8 +1005,8 @@ struct sock *tcp_check_req(struct sock *sk,struct sk_buff *skb, | |||
1003 | return NULL; | 1005 | return NULL; |
1004 | 1006 | ||
1005 | /* If TCP_DEFER_ACCEPT is set, drop bare ACK. */ | 1007 | /* If TCP_DEFER_ACCEPT is set, drop bare ACK. */ |
1006 | if (tp->defer_accept && TCP_SKB_CB(skb)->end_seq == req->rcv_isn+1) { | 1008 | if (tp->defer_accept && TCP_SKB_CB(skb)->end_seq == tcp_rsk(req)->rcv_isn + 1) { |
1007 | req->acked = 1; | 1009 | inet_rsk(req)->acked = 1; |
1008 | return NULL; | 1010 | return NULL; |
1009 | } | 1011 | } |
1010 | 1012 | ||
@@ -1026,7 +1028,7 @@ struct sock *tcp_check_req(struct sock *sk,struct sk_buff *skb, | |||
1026 | 1028 | ||
1027 | listen_overflow: | 1029 | listen_overflow: |
1028 | if (!sysctl_tcp_abort_on_overflow) { | 1030 | if (!sysctl_tcp_abort_on_overflow) { |
1029 | req->acked = 1; | 1031 | inet_rsk(req)->acked = 1; |
1030 | return NULL; | 1032 | return NULL; |
1031 | } | 1033 | } |
1032 | 1034 | ||