diff options
author | David S. Miller <davem@davemloft.net> | 2011-05-08 18:28:03 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-05-08 18:28:03 -0400 |
commit | 0e734419923bd8e599858f8fc196c7804bb85564 (patch) | |
tree | 5e8dfaeb84c610a1c4086ed88c26b73e4ba87197 /net | |
parent | 77357a95522ba645bbfd65253b34317c824103f9 (diff) |
ipv4: Use inet_csk_route_child_sock() in DCCP and TCP.
Operation order is now transposed, we first create the child
socket then we try to hook up the route.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/dccp/ipv4.c | 19 | ||||
-rw-r--r-- | net/ipv4/tcp_ipv4.c | 18 |
2 files changed, 20 insertions, 17 deletions
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 4ac1a728083a..46b15e9e9b57 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c | |||
@@ -396,15 +396,10 @@ struct sock *dccp_v4_request_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
396 | if (sk_acceptq_is_full(sk)) | 396 | if (sk_acceptq_is_full(sk)) |
397 | goto exit_overflow; | 397 | goto exit_overflow; |
398 | 398 | ||
399 | if (dst == NULL && (dst = inet_csk_route_req(sk, req)) == NULL) | ||
400 | goto exit; | ||
401 | |||
402 | newsk = dccp_create_openreq_child(sk, req, skb); | 399 | newsk = dccp_create_openreq_child(sk, req, skb); |
403 | if (newsk == NULL) | 400 | if (newsk == NULL) |
404 | goto exit_nonewsk; | 401 | goto exit_nonewsk; |
405 | 402 | ||
406 | sk_setup_caps(newsk, dst); | ||
407 | |||
408 | newinet = inet_sk(newsk); | 403 | newinet = inet_sk(newsk); |
409 | ireq = inet_rsk(req); | 404 | ireq = inet_rsk(req); |
410 | newinet->inet_daddr = ireq->rmt_addr; | 405 | newinet->inet_daddr = ireq->rmt_addr; |
@@ -416,12 +411,15 @@ struct sock *dccp_v4_request_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
416 | newinet->mc_ttl = ip_hdr(skb)->ttl; | 411 | newinet->mc_ttl = ip_hdr(skb)->ttl; |
417 | newinet->inet_id = jiffies; | 412 | newinet->inet_id = jiffies; |
418 | 413 | ||
414 | if (dst == NULL && (dst = inet_csk_route_child_sock(sk, newsk, req)) == NULL) | ||
415 | goto put_and_exit; | ||
416 | |||
417 | sk_setup_caps(newsk, dst); | ||
418 | |||
419 | dccp_sync_mss(newsk, dst_mtu(dst)); | 419 | dccp_sync_mss(newsk, dst_mtu(dst)); |
420 | 420 | ||
421 | if (__inet_inherit_port(sk, newsk) < 0) { | 421 | if (__inet_inherit_port(sk, newsk) < 0) |
422 | sock_put(newsk); | 422 | goto put_and_exit; |
423 | goto exit; | ||
424 | } | ||
425 | __inet_hash_nolisten(newsk, NULL); | 423 | __inet_hash_nolisten(newsk, NULL); |
426 | 424 | ||
427 | return newsk; | 425 | return newsk; |
@@ -433,6 +431,9 @@ exit_nonewsk: | |||
433 | exit: | 431 | exit: |
434 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_LISTENDROPS); | 432 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_LISTENDROPS); |
435 | return NULL; | 433 | return NULL; |
434 | put_and_exit: | ||
435 | sock_put(newsk); | ||
436 | goto exit; | ||
436 | } | 437 | } |
437 | 438 | ||
438 | EXPORT_SYMBOL_GPL(dccp_v4_request_recv_sock); | 439 | EXPORT_SYMBOL_GPL(dccp_v4_request_recv_sock); |
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index a71217156856..374de3c98d5e 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
@@ -1421,15 +1421,11 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
1421 | if (sk_acceptq_is_full(sk)) | 1421 | if (sk_acceptq_is_full(sk)) |
1422 | goto exit_overflow; | 1422 | goto exit_overflow; |
1423 | 1423 | ||
1424 | if (!dst && (dst = inet_csk_route_req(sk, req)) == NULL) | ||
1425 | goto exit; | ||
1426 | |||
1427 | newsk = tcp_create_openreq_child(sk, req, skb); | 1424 | newsk = tcp_create_openreq_child(sk, req, skb); |
1428 | if (!newsk) | 1425 | if (!newsk) |
1429 | goto exit_nonewsk; | 1426 | goto exit_nonewsk; |
1430 | 1427 | ||
1431 | newsk->sk_gso_type = SKB_GSO_TCPV4; | 1428 | newsk->sk_gso_type = SKB_GSO_TCPV4; |
1432 | sk_setup_caps(newsk, dst); | ||
1433 | 1429 | ||
1434 | newtp = tcp_sk(newsk); | 1430 | newtp = tcp_sk(newsk); |
1435 | newinet = inet_sk(newsk); | 1431 | newinet = inet_sk(newsk); |
@@ -1447,6 +1443,11 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
1447 | inet_csk(newsk)->icsk_ext_hdr_len = inet_opt->opt.optlen; | 1443 | inet_csk(newsk)->icsk_ext_hdr_len = inet_opt->opt.optlen; |
1448 | newinet->inet_id = newtp->write_seq ^ jiffies; | 1444 | newinet->inet_id = newtp->write_seq ^ jiffies; |
1449 | 1445 | ||
1446 | if (!dst && (dst = inet_csk_route_child_sock(sk, newsk, req)) == NULL) | ||
1447 | goto put_and_exit; | ||
1448 | |||
1449 | sk_setup_caps(newsk, dst); | ||
1450 | |||
1450 | tcp_mtup_init(newsk); | 1451 | tcp_mtup_init(newsk); |
1451 | tcp_sync_mss(newsk, dst_mtu(dst)); | 1452 | tcp_sync_mss(newsk, dst_mtu(dst)); |
1452 | newtp->advmss = dst_metric_advmss(dst); | 1453 | newtp->advmss = dst_metric_advmss(dst); |
@@ -1474,10 +1475,8 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
1474 | } | 1475 | } |
1475 | #endif | 1476 | #endif |
1476 | 1477 | ||
1477 | if (__inet_inherit_port(sk, newsk) < 0) { | 1478 | if (__inet_inherit_port(sk, newsk) < 0) |
1478 | sock_put(newsk); | 1479 | goto put_and_exit; |
1479 | goto exit; | ||
1480 | } | ||
1481 | __inet_hash_nolisten(newsk, NULL); | 1480 | __inet_hash_nolisten(newsk, NULL); |
1482 | 1481 | ||
1483 | return newsk; | 1482 | return newsk; |
@@ -1489,6 +1488,9 @@ exit_nonewsk: | |||
1489 | exit: | 1488 | exit: |
1490 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_LISTENDROPS); | 1489 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_LISTENDROPS); |
1491 | return NULL; | 1490 | return NULL; |
1491 | put_and_exit: | ||
1492 | sock_put(newsk); | ||
1493 | goto exit; | ||
1492 | } | 1494 | } |
1493 | EXPORT_SYMBOL(tcp_v4_syn_recv_sock); | 1495 | EXPORT_SYMBOL(tcp_v4_syn_recv_sock); |
1494 | 1496 | ||