diff options
-rw-r--r-- | include/net/inet_connection_sock.h | 4 | ||||
-rw-r--r-- | net/ipv4/inet_connection_sock.c | 25 | ||||
-rw-r--r-- | net/ipv4/tcp_minisocks.c | 18 |
3 files changed, 32 insertions, 15 deletions
diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index 97e002001c1a..a50f4a4b7b4b 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h | |||
@@ -77,6 +77,10 @@ static inline struct inet_connection_sock *inet_csk(const struct sock *sk) | |||
77 | return (struct inet_connection_sock *)sk; | 77 | return (struct inet_connection_sock *)sk; |
78 | } | 78 | } |
79 | 79 | ||
80 | extern struct sock *inet_csk_clone(struct sock *sk, | ||
81 | const struct request_sock *req, | ||
82 | const unsigned int __nocast priority); | ||
83 | |||
80 | enum inet_csk_ack_state_t { | 84 | enum inet_csk_ack_state_t { |
81 | ICSK_ACK_SCHED = 1, | 85 | ICSK_ACK_SCHED = 1, |
82 | ICSK_ACK_TIMER = 2, | 86 | ICSK_ACK_TIMER = 2, |
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index 2712400a8bb8..136ada050b63 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c | |||
@@ -399,3 +399,28 @@ void inet_csk_reqsk_queue_hash_add(struct sock *sk, struct request_sock *req, | |||
399 | } | 399 | } |
400 | 400 | ||
401 | EXPORT_SYMBOL_GPL(inet_csk_reqsk_queue_hash_add); | 401 | EXPORT_SYMBOL_GPL(inet_csk_reqsk_queue_hash_add); |
402 | |||
403 | struct sock *inet_csk_clone(struct sock *sk, const struct request_sock *req, | ||
404 | const unsigned int __nocast priority) | ||
405 | { | ||
406 | struct sock *newsk = sk_clone(sk, priority); | ||
407 | |||
408 | if (newsk != NULL) { | ||
409 | struct inet_connection_sock *newicsk = inet_csk(newsk); | ||
410 | |||
411 | newsk->sk_state = TCP_SYN_RECV; | ||
412 | newicsk->icsk_bind_hash = NULL; | ||
413 | |||
414 | inet_sk(newsk)->dport = inet_rsk(req)->rmt_port; | ||
415 | newsk->sk_write_space = sk_stream_write_space; | ||
416 | |||
417 | newicsk->icsk_retransmits = 0; | ||
418 | newicsk->icsk_backoff = 0; | ||
419 | |||
420 | /* Deinitialize accept_queue to trap illegal accesses. */ | ||
421 | memset(&newicsk->icsk_accept_queue, 0, sizeof(newicsk->icsk_accept_queue)); | ||
422 | } | ||
423 | return newsk; | ||
424 | } | ||
425 | |||
426 | EXPORT_SYMBOL_GPL(inet_csk_clone); | ||
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 56823704eb7d..4cfbe1d1c920 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c | |||
@@ -600,22 +600,14 @@ out: | |||
600 | */ | 600 | */ |
601 | struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req, struct sk_buff *skb) | 601 | struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req, struct sk_buff *skb) |
602 | { | 602 | { |
603 | struct sock *newsk = sk_clone(sk, GFP_ATOMIC); | 603 | struct sock *newsk = inet_csk_clone(sk, req, GFP_ATOMIC); |
604 | 604 | ||
605 | if (newsk != NULL) { | 605 | if (newsk != NULL) { |
606 | struct inet_request_sock *ireq = inet_rsk(req); | 606 | const struct inet_request_sock *ireq = inet_rsk(req); |
607 | struct tcp_request_sock *treq = tcp_rsk(req); | 607 | struct tcp_request_sock *treq = tcp_rsk(req); |
608 | struct inet_sock *newinet = inet_sk(newsk); | 608 | struct inet_connection_sock *newicsk = inet_csk(sk); |
609 | struct inet_connection_sock *newicsk = inet_csk(newsk); | ||
610 | struct tcp_sock *newtp; | 609 | struct tcp_sock *newtp; |
611 | 610 | ||
612 | newsk->sk_state = TCP_SYN_RECV; | ||
613 | newicsk->icsk_bind_hash = NULL; | ||
614 | |||
615 | /* Clone the TCP header template */ | ||
616 | newinet->dport = ireq->rmt_port; | ||
617 | newsk->sk_write_space = sk_stream_write_space; | ||
618 | |||
619 | /* Now setup tcp_sock */ | 611 | /* Now setup tcp_sock */ |
620 | newtp = tcp_sk(newsk); | 612 | newtp = tcp_sk(newsk); |
621 | newtp->pred_flags = 0; | 613 | newtp->pred_flags = 0; |
@@ -626,8 +618,6 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req, | |||
626 | 618 | ||
627 | tcp_init_wl(newtp, treq->snt_isn, treq->rcv_isn); | 619 | tcp_init_wl(newtp, treq->snt_isn, treq->rcv_isn); |
628 | 620 | ||
629 | newicsk->icsk_retransmits = 0; | ||
630 | newicsk->icsk_backoff = 0; | ||
631 | newtp->srtt = 0; | 621 | newtp->srtt = 0; |
632 | newtp->mdev = TCP_TIMEOUT_INIT; | 622 | newtp->mdev = TCP_TIMEOUT_INIT; |
633 | newicsk->icsk_rto = TCP_TIMEOUT_INIT; | 623 | newicsk->icsk_rto = TCP_TIMEOUT_INIT; |
@@ -668,8 +658,6 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req, | |||
668 | newtp->probes_out = 0; | 658 | newtp->probes_out = 0; |
669 | newtp->rx_opt.num_sacks = 0; | 659 | newtp->rx_opt.num_sacks = 0; |
670 | newtp->urg_data = 0; | 660 | newtp->urg_data = 0; |
671 | /* Deinitialize accept_queue to trap illegal accesses. */ | ||
672 | memset(&newicsk->icsk_accept_queue, 0, sizeof(newicsk->icsk_accept_queue)); | ||
673 | 661 | ||
674 | if (sock_flag(newsk, SOCK_KEEPOPEN)) | 662 | if (sock_flag(newsk, SOCK_KEEPOPEN)) |
675 | inet_csk_reset_keepalive_timer(newsk, | 663 | inet_csk_reset_keepalive_timer(newsk, |