diff options
author | Arnaldo Carvalho de Melo <acme@mandriva.com> | 2005-12-14 02:26:10 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-01-03 16:10:58 -0500 |
commit | d83d8461f902c672bc1bd8fbc6a94e19f092da97 (patch) | |
tree | 0534c553ab92baa2eb9dbb5bba64f2c4540b1e89 /net/dccp | |
parent | 22712813620fa8e682dbfb253a60ca0131da1e07 (diff) |
[IP_SOCKGLUE]: Remove most of the tcp specific calls
As DCCP needs to be called in the same spots.
Now we have a member in inet_sock (is_icsk), set at sock creation time from
struct inet_protosw->flags (if INET_PROTOSW_ICSK is set, like for TCP and
DCCP) to see if a struct sock instance is a inet_connection_sock for places
like the ones in ip_sockglue.c (v4 and v6) where we previously were looking if
sk_type was SOCK_STREAM, that is insufficient because we now use the same code
for DCCP, that has sk_type SOCK_DCCP.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dccp')
-rw-r--r-- | net/dccp/diag.c | 2 | ||||
-rw-r--r-- | net/dccp/input.c | 2 | ||||
-rw-r--r-- | net/dccp/ipv4.c | 12 | ||||
-rw-r--r-- | net/dccp/ipv6.c | 26 | ||||
-rw-r--r-- | net/dccp/output.c | 7 | ||||
-rw-r--r-- | net/dccp/proto.c | 2 |
6 files changed, 28 insertions, 23 deletions
diff --git a/net/dccp/diag.c b/net/dccp/diag.c index f675d8e642d3..3f78c00e3822 100644 --- a/net/dccp/diag.c +++ b/net/dccp/diag.c | |||
@@ -28,7 +28,7 @@ static void dccp_get_info(struct sock *sk, struct tcp_info *info) | |||
28 | info->tcpi_retransmits = icsk->icsk_retransmits; | 28 | info->tcpi_retransmits = icsk->icsk_retransmits; |
29 | info->tcpi_probes = icsk->icsk_probes_out; | 29 | info->tcpi_probes = icsk->icsk_probes_out; |
30 | info->tcpi_backoff = icsk->icsk_backoff; | 30 | info->tcpi_backoff = icsk->icsk_backoff; |
31 | info->tcpi_pmtu = dp->dccps_pmtu_cookie; | 31 | info->tcpi_pmtu = icsk->icsk_pmtu_cookie; |
32 | 32 | ||
33 | if (dp->dccps_options.dccpo_send_ack_vector) | 33 | if (dp->dccps_options.dccpo_send_ack_vector) |
34 | info->tcpi_options |= TCPI_OPT_SACK; | 34 | info->tcpi_options |= TCPI_OPT_SACK; |
diff --git a/net/dccp/input.c b/net/dccp/input.c index 9a724ff2a622..55e921bdd131 100644 --- a/net/dccp/input.c +++ b/net/dccp/input.c | |||
@@ -311,7 +311,7 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk, | |||
311 | goto out_invalid_packet; | 311 | goto out_invalid_packet; |
312 | } | 312 | } |
313 | 313 | ||
314 | dccp_sync_mss(sk, dp->dccps_pmtu_cookie); | 314 | dccp_sync_mss(sk, icsk->icsk_pmtu_cookie); |
315 | 315 | ||
316 | /* | 316 | /* |
317 | * Step 10: Process REQUEST state (second part) | 317 | * Step 10: Process REQUEST state (second part) |
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 671fbf3b2379..c363051a7f16 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c | |||
@@ -104,9 +104,9 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
104 | inet->dport = usin->sin_port; | 104 | inet->dport = usin->sin_port; |
105 | inet->daddr = daddr; | 105 | inet->daddr = daddr; |
106 | 106 | ||
107 | dp->dccps_ext_header_len = 0; | 107 | inet_csk(sk)->icsk_ext_hdr_len = 0; |
108 | if (inet->opt != NULL) | 108 | if (inet->opt != NULL) |
109 | dp->dccps_ext_header_len = inet->opt->optlen; | 109 | inet_csk(sk)->icsk_ext_hdr_len = inet->opt->optlen; |
110 | /* | 110 | /* |
111 | * Socket identity is still unknown (sport may be zero). | 111 | * Socket identity is still unknown (sport may be zero). |
112 | * However we set state to DCCP_REQUESTING and not releasing socket | 112 | * However we set state to DCCP_REQUESTING and not releasing socket |
@@ -191,7 +191,7 @@ static inline void dccp_do_pmtu_discovery(struct sock *sk, | |||
191 | mtu = dst_mtu(dst); | 191 | mtu = dst_mtu(dst); |
192 | 192 | ||
193 | if (inet->pmtudisc != IP_PMTUDISC_DONT && | 193 | if (inet->pmtudisc != IP_PMTUDISC_DONT && |
194 | dp->dccps_pmtu_cookie > mtu) { | 194 | inet_csk(sk)->icsk_pmtu_cookie > mtu) { |
195 | dccp_sync_mss(sk, mtu); | 195 | dccp_sync_mss(sk, mtu); |
196 | 196 | ||
197 | /* | 197 | /* |
@@ -1051,6 +1051,7 @@ struct inet_connection_sock_af_ops dccp_ipv4_af_ops = { | |||
1051 | int dccp_v4_init_sock(struct sock *sk) | 1051 | int dccp_v4_init_sock(struct sock *sk) |
1052 | { | 1052 | { |
1053 | struct dccp_sock *dp = dccp_sk(sk); | 1053 | struct dccp_sock *dp = dccp_sk(sk); |
1054 | struct inet_connection_sock *icsk = inet_csk(sk); | ||
1054 | static int dccp_ctl_socket_init = 1; | 1055 | static int dccp_ctl_socket_init = 1; |
1055 | 1056 | ||
1056 | dccp_options_init(&dp->dccps_options); | 1057 | dccp_options_init(&dp->dccps_options); |
@@ -1090,10 +1091,11 @@ int dccp_v4_init_sock(struct sock *sk) | |||
1090 | dccp_ctl_socket_init = 0; | 1091 | dccp_ctl_socket_init = 0; |
1091 | 1092 | ||
1092 | dccp_init_xmit_timers(sk); | 1093 | dccp_init_xmit_timers(sk); |
1093 | inet_csk(sk)->icsk_rto = DCCP_TIMEOUT_INIT; | 1094 | icsk->icsk_rto = DCCP_TIMEOUT_INIT; |
1094 | sk->sk_state = DCCP_CLOSED; | 1095 | sk->sk_state = DCCP_CLOSED; |
1095 | sk->sk_write_space = dccp_write_space; | 1096 | sk->sk_write_space = dccp_write_space; |
1096 | inet_csk(sk)->icsk_af_ops = &dccp_ipv4_af_ops; | 1097 | icsk->icsk_af_ops = &dccp_ipv4_af_ops; |
1098 | icsk->icsk_sync_mss = dccp_sync_mss; | ||
1097 | dp->dccps_mss_cache = 536; | 1099 | dp->dccps_mss_cache = 536; |
1098 | dp->dccps_role = DCCP_ROLE_UNDEFINED; | 1100 | dp->dccps_role = DCCP_ROLE_UNDEFINED; |
1099 | dp->dccps_service = DCCP_SERVICE_INVALID_VALUE; | 1101 | dp->dccps_service = DCCP_SERVICE_INVALID_VALUE; |
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index 71bf04eb21e1..599b0be21515 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c | |||
@@ -88,6 +88,7 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, | |||
88 | int addr_len) | 88 | int addr_len) |
89 | { | 89 | { |
90 | struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr; | 90 | struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr; |
91 | struct inet_connection_sock *icsk = inet_csk(sk); | ||
91 | struct inet_sock *inet = inet_sk(sk); | 92 | struct inet_sock *inet = inet_sk(sk); |
92 | struct ipv6_pinfo *np = inet6_sk(sk); | 93 | struct ipv6_pinfo *np = inet6_sk(sk); |
93 | struct dccp_sock *dp = dccp_sk(sk); | 94 | struct dccp_sock *dp = dccp_sk(sk); |
@@ -158,7 +159,7 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, | |||
158 | */ | 159 | */ |
159 | 160 | ||
160 | if (addr_type == IPV6_ADDR_MAPPED) { | 161 | if (addr_type == IPV6_ADDR_MAPPED) { |
161 | u32 exthdrlen = dp->dccps_ext_header_len; | 162 | u32 exthdrlen = icsk->icsk_ext_hdr_len; |
162 | struct sockaddr_in sin; | 163 | struct sockaddr_in sin; |
163 | 164 | ||
164 | SOCK_DEBUG(sk, "connect: ipv4 mapped\n"); | 165 | SOCK_DEBUG(sk, "connect: ipv4 mapped\n"); |
@@ -170,14 +171,14 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, | |||
170 | sin.sin_port = usin->sin6_port; | 171 | sin.sin_port = usin->sin6_port; |
171 | sin.sin_addr.s_addr = usin->sin6_addr.s6_addr32[3]; | 172 | sin.sin_addr.s_addr = usin->sin6_addr.s6_addr32[3]; |
172 | 173 | ||
173 | inet_csk(sk)->icsk_af_ops = &dccp_ipv6_mapped; | 174 | icsk->icsk_af_ops = &dccp_ipv6_mapped; |
174 | sk->sk_backlog_rcv = dccp_v4_do_rcv; | 175 | sk->sk_backlog_rcv = dccp_v4_do_rcv; |
175 | 176 | ||
176 | err = dccp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin)); | 177 | err = dccp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin)); |
177 | 178 | ||
178 | if (err) { | 179 | if (err) { |
179 | dp->dccps_ext_header_len = exthdrlen; | 180 | icsk->icsk_ext_hdr_len = exthdrlen; |
180 | inet_csk(sk)->icsk_af_ops = &dccp_ipv6_af_ops; | 181 | icsk->icsk_af_ops = &dccp_ipv6_af_ops; |
181 | sk->sk_backlog_rcv = dccp_v6_do_rcv; | 182 | sk->sk_backlog_rcv = dccp_v6_do_rcv; |
182 | goto failure; | 183 | goto failure; |
183 | } else { | 184 | } else { |
@@ -227,9 +228,10 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, | |||
227 | 228 | ||
228 | ip6_dst_store(sk, dst, NULL); | 229 | ip6_dst_store(sk, dst, NULL); |
229 | 230 | ||
230 | dp->dccps_ext_header_len = 0; | 231 | icsk->icsk_ext_hdr_len = 0; |
231 | if (np->opt) | 232 | if (np->opt) |
232 | dp->dccps_ext_header_len = np->opt->opt_flen + np->opt->opt_nflen; | 233 | icsk->icsk_ext_hdr_len = (np->opt->opt_flen + |
234 | np->opt->opt_nflen); | ||
233 | 235 | ||
234 | inet->dport = usin->sin6_port; | 236 | inet->dport = usin->sin6_port; |
235 | 237 | ||
@@ -292,7 +294,6 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | |||
292 | np = inet6_sk(sk); | 294 | np = inet6_sk(sk); |
293 | 295 | ||
294 | if (type == ICMPV6_PKT_TOOBIG) { | 296 | if (type == ICMPV6_PKT_TOOBIG) { |
295 | struct dccp_sock *dp = dccp_sk(sk); | ||
296 | struct dst_entry *dst = NULL; | 297 | struct dst_entry *dst = NULL; |
297 | 298 | ||
298 | if (sock_owned_by_user(sk)) | 299 | if (sock_owned_by_user(sk)) |
@@ -332,7 +333,7 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | |||
332 | } else | 333 | } else |
333 | dst_hold(dst); | 334 | dst_hold(dst); |
334 | 335 | ||
335 | if (dp->dccps_pmtu_cookie > dst_mtu(dst)) { | 336 | if (inet_csk(sk)->icsk_pmtu_cookie > dst_mtu(dst)) { |
336 | dccp_sync_mss(sk, dst_mtu(dst)); | 337 | dccp_sync_mss(sk, dst_mtu(dst)); |
337 | } /* else let the usual retransmit timer handle it */ | 338 | } /* else let the usual retransmit timer handle it */ |
338 | dst_release(dst); | 339 | dst_release(dst); |
@@ -808,7 +809,7 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk, | |||
808 | worked with IPv6 icsk.icsk_af_ops. | 809 | worked with IPv6 icsk.icsk_af_ops. |
809 | Sync it now. | 810 | Sync it now. |
810 | */ | 811 | */ |
811 | dccp_sync_mss(newsk, newdp->dccps_pmtu_cookie); | 812 | dccp_sync_mss(newsk, inet_csk(newsk)->icsk_pmtu_cookie); |
812 | 813 | ||
813 | return newsk; | 814 | return newsk; |
814 | } | 815 | } |
@@ -916,10 +917,10 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk, | |||
916 | sock_kfree_s(sk, opt, opt->tot_len); | 917 | sock_kfree_s(sk, opt, opt->tot_len); |
917 | } | 918 | } |
918 | 919 | ||
919 | newdp->dccps_ext_header_len = 0; | 920 | inet_csk(newsk)->icsk_ext_hdr_len = 0; |
920 | if (newnp->opt) | 921 | if (newnp->opt) |
921 | newdp->dccps_ext_header_len = newnp->opt->opt_nflen + | 922 | inet_csk(newsk)->icsk_ext_hdr_len = (newnp->opt->opt_nflen + |
922 | newnp->opt->opt_flen; | 923 | newnp->opt->opt_flen); |
923 | 924 | ||
924 | dccp_sync_mss(newsk, dst_mtu(dst)); | 925 | dccp_sync_mss(newsk, dst_mtu(dst)); |
925 | 926 | ||
@@ -1230,6 +1231,7 @@ static struct inet_protosw dccp_v6_protosw = { | |||
1230 | .prot = &dccp_v6_prot, | 1231 | .prot = &dccp_v6_prot, |
1231 | .ops = &inet6_dccp_ops, | 1232 | .ops = &inet6_dccp_ops, |
1232 | .capability = -1, | 1233 | .capability = -1, |
1234 | .flags = INET_PROTOSW_ICSK, | ||
1233 | }; | 1235 | }; |
1234 | 1236 | ||
1235 | static int __init dccp_v6_init(void) | 1237 | static int __init dccp_v6_init(void) |
diff --git a/net/dccp/output.c b/net/dccp/output.c index c40f7f8a328b..95a3c2c6a3ce 100644 --- a/net/dccp/output.c +++ b/net/dccp/output.c | |||
@@ -134,12 +134,13 @@ static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb) | |||
134 | 134 | ||
135 | unsigned int dccp_sync_mss(struct sock *sk, u32 pmtu) | 135 | unsigned int dccp_sync_mss(struct sock *sk, u32 pmtu) |
136 | { | 136 | { |
137 | struct inet_connection_sock *icsk = inet_csk(sk); | ||
137 | struct dccp_sock *dp = dccp_sk(sk); | 138 | struct dccp_sock *dp = dccp_sk(sk); |
138 | int mss_now = (pmtu - inet_csk(sk)->icsk_af_ops->net_header_len - | 139 | int mss_now = (pmtu - icsk->icsk_af_ops->net_header_len - |
139 | sizeof(struct dccp_hdr) - sizeof(struct dccp_hdr_ext)); | 140 | sizeof(struct dccp_hdr) - sizeof(struct dccp_hdr_ext)); |
140 | 141 | ||
141 | /* Now subtract optional transport overhead */ | 142 | /* Now subtract optional transport overhead */ |
142 | mss_now -= dp->dccps_ext_header_len; | 143 | mss_now -= icsk->icsk_ext_hdr_len; |
143 | 144 | ||
144 | /* | 145 | /* |
145 | * FIXME: this should come from the CCID infrastructure, where, say, | 146 | * FIXME: this should come from the CCID infrastructure, where, say, |
@@ -152,7 +153,7 @@ unsigned int dccp_sync_mss(struct sock *sk, u32 pmtu) | |||
152 | mss_now -= ((5 + 6 + 10 + 6 + 6 + 6 + 3) / 4) * 4; | 153 | mss_now -= ((5 + 6 + 10 + 6 + 6 + 6 + 3) / 4) * 4; |
153 | 154 | ||
154 | /* And store cached results */ | 155 | /* And store cached results */ |
155 | dp->dccps_pmtu_cookie = pmtu; | 156 | icsk->icsk_pmtu_cookie = pmtu; |
156 | dp->dccps_mss_cache = mss_now; | 157 | dp->dccps_mss_cache = mss_now; |
157 | 158 | ||
158 | return mss_now; | 159 | return mss_now; |
diff --git a/net/dccp/proto.c b/net/dccp/proto.c index 51dfacd22a6e..40a4c6899051 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c | |||
@@ -712,7 +712,7 @@ static struct inet_protosw dccp_v4_protosw = { | |||
712 | .ops = &inet_dccp_ops, | 712 | .ops = &inet_dccp_ops, |
713 | .capability = -1, | 713 | .capability = -1, |
714 | .no_check = 0, | 714 | .no_check = 0, |
715 | .flags = 0, | 715 | .flags = INET_PROTOSW_ICSK, |
716 | }; | 716 | }; |
717 | 717 | ||
718 | /* | 718 | /* |