diff options
author | Arnaldo Carvalho de Melo <acme@mandriva.com> | 2005-12-14 02:16:16 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-01-03 16:10:40 -0500 |
commit | 57cca05af1e20fdc65b55be52c042c234f86c866 (patch) | |
tree | 43b18dca01340861e7ad392c0c2ce398a1c878fd /net/dccp | |
parent | af05dc9394feb193d221bc9d4c6db768facb4b40 (diff) |
[DCCP]: Introduce dccp_ipv4_af_ops
And make the core DCCP code AF agnostic, just like TCP, now its time
to work on net/dccp/ipv6.c, we are close to the end!
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/input.c | 5 | ||||
-rw-r--r-- | net/dccp/ipv4.c | 23 | ||||
-rw-r--r-- | net/dccp/minisocks.c | 2 | ||||
-rw-r--r-- | net/dccp/output.c | 14 | ||||
-rw-r--r-- | net/dccp/proto.c | 9 |
5 files changed, 39 insertions, 14 deletions
diff --git a/net/dccp/input.c b/net/dccp/input.c index 3454d5941900..c81488fa293e 100644 --- a/net/dccp/input.c +++ b/net/dccp/input.c | |||
@@ -329,7 +329,7 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk, | |||
329 | dccp_set_state(sk, DCCP_PARTOPEN); | 329 | dccp_set_state(sk, DCCP_PARTOPEN); |
330 | 330 | ||
331 | /* Make sure socket is routed, for correct metrics. */ | 331 | /* Make sure socket is routed, for correct metrics. */ |
332 | inet_sk_rebuild_header(sk); | 332 | icsk->icsk_af_ops->rebuild_header(sk); |
333 | 333 | ||
334 | if (!sock_flag(sk, SOCK_DEAD)) { | 334 | if (!sock_flag(sk, SOCK_DEAD)) { |
335 | sk->sk_state_change(sk); | 335 | sk->sk_state_change(sk); |
@@ -444,7 +444,8 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb, | |||
444 | */ | 444 | */ |
445 | if (sk->sk_state == DCCP_LISTEN) { | 445 | if (sk->sk_state == DCCP_LISTEN) { |
446 | if (dh->dccph_type == DCCP_PKT_REQUEST) { | 446 | if (dh->dccph_type == DCCP_PKT_REQUEST) { |
447 | if (dccp_v4_conn_request(sk, skb) < 0) | 447 | if (inet_csk(sk)->icsk_af_ops->conn_request(sk, |
448 | skb) < 0) | ||
448 | return 1; | 449 | return 1; |
449 | 450 | ||
450 | /* FIXME: do congestion control initialization */ | 451 | /* FIXME: do congestion control initialization */ |
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 1ac3e30ae791..0ce7d0fe5ee7 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c | |||
@@ -607,6 +607,15 @@ out: | |||
607 | sock_put(sk); | 607 | sock_put(sk); |
608 | } | 608 | } |
609 | 609 | ||
610 | /* This routine computes an IPv4 DCCP checksum. */ | ||
611 | static void dccp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb) | ||
612 | { | ||
613 | const struct inet_sock *inet = inet_sk(sk); | ||
614 | struct dccp_hdr *dh = dccp_hdr(skb); | ||
615 | |||
616 | dh->dccph_checksum = dccp_v4_checksum(skb, inet->saddr, inet->daddr); | ||
617 | } | ||
618 | |||
610 | int dccp_v4_send_reset(struct sock *sk, enum dccp_reset_codes code) | 619 | int dccp_v4_send_reset(struct sock *sk, enum dccp_reset_codes code) |
611 | { | 620 | { |
612 | struct sk_buff *skb; | 621 | struct sk_buff *skb; |
@@ -1195,6 +1204,19 @@ do_time_wait: | |||
1195 | goto no_dccp_socket; | 1204 | goto no_dccp_socket; |
1196 | } | 1205 | } |
1197 | 1206 | ||
1207 | struct inet_connection_sock_af_ops dccp_ipv4_af_ops = { | ||
1208 | .queue_xmit = ip_queue_xmit, | ||
1209 | .send_check = dccp_v4_send_check, | ||
1210 | .rebuild_header = inet_sk_rebuild_header, | ||
1211 | .conn_request = dccp_v4_conn_request, | ||
1212 | .syn_recv_sock = dccp_v4_request_recv_sock, | ||
1213 | .net_header_len = sizeof(struct iphdr), | ||
1214 | .setsockopt = ip_setsockopt, | ||
1215 | .getsockopt = ip_getsockopt, | ||
1216 | .addr2sockaddr = inet_csk_addr2sockaddr, | ||
1217 | .sockaddr_len = sizeof(struct sockaddr_in), | ||
1218 | }; | ||
1219 | |||
1198 | static int dccp_v4_init_sock(struct sock *sk) | 1220 | static int dccp_v4_init_sock(struct sock *sk) |
1199 | { | 1221 | { |
1200 | struct dccp_sock *dp = dccp_sk(sk); | 1222 | struct dccp_sock *dp = dccp_sk(sk); |
@@ -1240,6 +1262,7 @@ static int dccp_v4_init_sock(struct sock *sk) | |||
1240 | inet_csk(sk)->icsk_rto = DCCP_TIMEOUT_INIT; | 1262 | inet_csk(sk)->icsk_rto = DCCP_TIMEOUT_INIT; |
1241 | sk->sk_state = DCCP_CLOSED; | 1263 | sk->sk_state = DCCP_CLOSED; |
1242 | sk->sk_write_space = dccp_write_space; | 1264 | sk->sk_write_space = dccp_write_space; |
1265 | inet_csk(sk)->icsk_af_ops = &dccp_ipv4_af_ops; | ||
1243 | dp->dccps_mss_cache = 536; | 1266 | dp->dccps_mss_cache = 536; |
1244 | dp->dccps_role = DCCP_ROLE_UNDEFINED; | 1267 | dp->dccps_role = DCCP_ROLE_UNDEFINED; |
1245 | dp->dccps_service = DCCP_SERVICE_INVALID_VALUE; | 1268 | dp->dccps_service = DCCP_SERVICE_INVALID_VALUE; |
diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c index 1393461898bb..c7ff80cf53a0 100644 --- a/net/dccp/minisocks.c +++ b/net/dccp/minisocks.c | |||
@@ -214,7 +214,7 @@ struct sock *dccp_check_req(struct sock *sk, struct sk_buff *skb, | |||
214 | goto drop; | 214 | goto drop; |
215 | } | 215 | } |
216 | 216 | ||
217 | child = dccp_v4_request_recv_sock(sk, skb, req, NULL); | 217 | child = inet_csk(sk)->icsk_af_ops->syn_recv_sock(sk, skb, req, NULL); |
218 | if (child == NULL) | 218 | if (child == NULL) |
219 | goto listen_overflow; | 219 | goto listen_overflow; |
220 | 220 | ||
diff --git a/net/dccp/output.c b/net/dccp/output.c index 74ff87025878..f35880503bb8 100644 --- a/net/dccp/output.c +++ b/net/dccp/output.c | |||
@@ -43,6 +43,7 @@ static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb) | |||
43 | { | 43 | { |
44 | if (likely(skb != NULL)) { | 44 | if (likely(skb != NULL)) { |
45 | const struct inet_sock *inet = inet_sk(sk); | 45 | const struct inet_sock *inet = inet_sk(sk); |
46 | const struct inet_connection_sock *icsk = inet_csk(sk); | ||
46 | struct dccp_sock *dp = dccp_sk(sk); | 47 | struct dccp_sock *dp = dccp_sk(sk); |
47 | struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb); | 48 | struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb); |
48 | struct dccp_hdr *dh; | 49 | struct dccp_hdr *dh; |
@@ -108,8 +109,7 @@ static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb) | |||
108 | break; | 109 | break; |
109 | } | 110 | } |
110 | 111 | ||
111 | dh->dccph_checksum = dccp_v4_checksum(skb, inet->saddr, | 112 | icsk->icsk_af_ops->send_check(sk, skb->len, skb); |
112 | inet->daddr); | ||
113 | 113 | ||
114 | if (set_ack) | 114 | if (set_ack) |
115 | dccp_event_ack_sent(sk); | 115 | dccp_event_ack_sent(sk); |
@@ -117,7 +117,7 @@ static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb) | |||
117 | DCCP_INC_STATS(DCCP_MIB_OUTSEGS); | 117 | DCCP_INC_STATS(DCCP_MIB_OUTSEGS); |
118 | 118 | ||
119 | memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt)); | 119 | memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt)); |
120 | err = ip_queue_xmit(skb, 0); | 120 | err = icsk->icsk_af_ops->queue_xmit(skb, 0); |
121 | if (err <= 0) | 121 | if (err <= 0) |
122 | return err; | 122 | return err; |
123 | 123 | ||
@@ -135,16 +135,14 @@ static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb) | |||
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 dccp_sock *dp = dccp_sk(sk); | 137 | struct dccp_sock *dp = dccp_sk(sk); |
138 | int mss_now; | ||
139 | |||
140 | /* | 138 | /* |
141 | * FIXME: we really should be using the af_specific thing to support | 139 | * FIXME: we really should be using the af_specific thing to support |
142 | * IPv6. | 140 | * IPv6. |
143 | * mss_now = pmtu - tp->af_specific->net_header_len - | 141 | * mss_now = pmtu - tp->af_specific->net_header_len - |
144 | * sizeof(struct dccp_hdr) - sizeof(struct dccp_hdr_ext); | 142 | * sizeof(struct dccp_hdr) - sizeof(struct dccp_hdr_ext); |
145 | */ | 143 | */ |
146 | mss_now = pmtu - sizeof(struct iphdr) - sizeof(struct dccp_hdr) - | 144 | int mss_now = (pmtu - inet_csk(sk)->icsk_af_ops->net_header_len - |
147 | sizeof(struct dccp_hdr_ext); | 145 | sizeof(struct dccp_hdr) - sizeof(struct dccp_hdr_ext)); |
148 | 146 | ||
149 | /* Now subtract optional transport overhead */ | 147 | /* Now subtract optional transport overhead */ |
150 | mss_now -= dp->dccps_ext_header_len; | 148 | mss_now -= dp->dccps_ext_header_len; |
@@ -266,7 +264,7 @@ int dccp_write_xmit(struct sock *sk, struct sk_buff *skb, long *timeo) | |||
266 | 264 | ||
267 | int dccp_retransmit_skb(struct sock *sk, struct sk_buff *skb) | 265 | int dccp_retransmit_skb(struct sock *sk, struct sk_buff *skb) |
268 | { | 266 | { |
269 | if (inet_sk_rebuild_header(sk) != 0) | 267 | if (inet_csk(sk)->icsk_af_ops->rebuild_header(sk) != 0) |
270 | return -EHOSTUNREACH; /* Routing failure or similar. */ | 268 | return -EHOSTUNREACH; /* Routing failure or similar. */ |
271 | 269 | ||
272 | return dccp_transmit_skb(sk, (skb_cloned(skb) ? | 270 | return dccp_transmit_skb(sk, (skb_cloned(skb) ? |
diff --git a/net/dccp/proto.c b/net/dccp/proto.c index 8a6b2a9e4581..7b30c12147c2 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c | |||
@@ -254,7 +254,9 @@ int dccp_setsockopt(struct sock *sk, int level, int optname, | |||
254 | int val; | 254 | int val; |
255 | 255 | ||
256 | if (level != SOL_DCCP) | 256 | if (level != SOL_DCCP) |
257 | return ip_setsockopt(sk, level, optname, optval, optlen); | 257 | return inet_csk(sk)->icsk_af_ops->setsockopt(sk, level, |
258 | optname, optval, | ||
259 | optlen); | ||
258 | 260 | ||
259 | if (optlen < sizeof(int)) | 261 | if (optlen < sizeof(int)) |
260 | return -EINVAL; | 262 | return -EINVAL; |
@@ -320,8 +322,9 @@ int dccp_getsockopt(struct sock *sk, int level, int optname, | |||
320 | int val, len; | 322 | int val, len; |
321 | 323 | ||
322 | if (level != SOL_DCCP) | 324 | if (level != SOL_DCCP) |
323 | return ip_getsockopt(sk, level, optname, optval, optlen); | 325 | return inet_csk(sk)->icsk_af_ops->getsockopt(sk, level, |
324 | 326 | optname, optval, | |
327 | optlen); | ||
325 | if (get_user(len, optlen)) | 328 | if (get_user(len, optlen)) |
326 | return -EFAULT; | 329 | return -EFAULT; |
327 | 330 | ||