tree b87d6b9a610f015889b0b1f91b8669adfb600763
parent 3f421baa4720b708022f8bcc52a61e5cd6f10bf8
author Arnaldo Carvalho de Melo <[EMAIL PROTECTED]> Wed, 10 Aug 2005 10:11:24 
-0700
committer David S. Miller <[EMAIL PROTECTED]> Tue, 30 Aug 2005 05:49:20 -0700

[ICSK]: Introduce inet_csk_clone

Signed-off-by: Arnaldo Carvalho de Melo <[EMAIL PROTECTED]>
Signed-off-by: David S. Miller <[EMAIL PROTECTED]>

 include/net/inet_connection_sock.h |    4 ++++
 net/ipv4/inet_connection_sock.c    |   25 +++++++++++++++++++++++++
 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
--- a/include/net/inet_connection_sock.h
+++ b/include/net/inet_connection_sock.h
@@ -77,6 +77,10 @@ static inline struct inet_connection_soc
        return (struct inet_connection_sock *)sk;
 }
 
+extern struct sock *inet_csk_clone(struct sock *sk,
+                                  const struct request_sock *req,
+                                  const unsigned int __nocast priority);
+
 enum inet_csk_ack_state_t {
        ICSK_ACK_SCHED  = 1,
        ICSK_ACK_TIMER  = 2,
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
--- 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(struc
 }
 
 EXPORT_SYMBOL_GPL(inet_csk_reqsk_queue_hash_add);
+
+struct sock *inet_csk_clone(struct sock *sk, const struct request_sock *req,
+                           const unsigned int __nocast priority)
+{
+       struct sock *newsk = sk_clone(sk, priority);
+
+       if (newsk != NULL) {
+               struct inet_connection_sock *newicsk = inet_csk(newsk);
+
+               newsk->sk_state = TCP_SYN_RECV;
+               newicsk->icsk_bind_hash = NULL;
+
+               inet_sk(newsk)->dport = inet_rsk(req)->rmt_port;
+               newsk->sk_write_space = sk_stream_write_space;
+
+               newicsk->icsk_retransmits = 0;
+               newicsk->icsk_backoff = 0;
+
+               /* Deinitialize accept_queue to trap illegal accesses. */
+               memset(&newicsk->icsk_accept_queue, 0, 
sizeof(newicsk->icsk_accept_queue));
+       }
+       return newsk;
+}
+
+EXPORT_SYMBOL_GPL(inet_csk_clone);
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -600,22 +600,14 @@ out:
  */
 struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock 
*req, struct sk_buff *skb)
 {
-       struct sock *newsk = sk_clone(sk, GFP_ATOMIC);
+       struct sock *newsk = inet_csk_clone(sk, req, GFP_ATOMIC);
 
        if (newsk != NULL) {
-               struct inet_request_sock *ireq = inet_rsk(req);
+               const struct inet_request_sock *ireq = inet_rsk(req);
                struct tcp_request_sock *treq = tcp_rsk(req);
-               struct inet_sock *newinet = inet_sk(newsk);
-               struct inet_connection_sock *newicsk = inet_csk(newsk);
+               struct inet_connection_sock *newicsk = inet_csk(sk);
                struct tcp_sock *newtp;
 
-               newsk->sk_state = TCP_SYN_RECV;
-               newicsk->icsk_bind_hash = NULL;
-
-               /* Clone the TCP header template */
-               newinet->dport = ireq->rmt_port;
-               newsk->sk_write_space = sk_stream_write_space;
-
                /* Now setup tcp_sock */
                newtp = tcp_sk(newsk);
                newtp->pred_flags = 0;
@@ -626,8 +618,6 @@ struct sock *tcp_create_openreq_child(st
 
                tcp_init_wl(newtp, treq->snt_isn, treq->rcv_isn);
 
-               newicsk->icsk_retransmits = 0;
-               newicsk->icsk_backoff = 0;
                newtp->srtt = 0;
                newtp->mdev = TCP_TIMEOUT_INIT;
                newicsk->icsk_rto = TCP_TIMEOUT_INIT;
@@ -668,8 +658,6 @@ struct sock *tcp_create_openreq_child(st
                newtp->probes_out = 0;
                newtp->rx_opt.num_sacks = 0;
                newtp->urg_data = 0;
-               /* Deinitialize accept_queue to trap illegal accesses. */
-               memset(&newicsk->icsk_accept_queue, 0, 
sizeof(newicsk->icsk_accept_queue));
 
                if (sock_flag(newsk, SOCK_KEEPOPEN))
                        inet_csk_reset_keepalive_timer(newsk,
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to