diff options
author | Arnaldo Carvalho de Melo <acme@ghostprotocols.net> | 2005-08-09 23:09:59 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2005-08-29 18:42:26 -0400 |
commit | c676270bcd25015b978722ec0352c330dcc87883 (patch) | |
tree | 098cc52c71d68465e7ee5fbae462d58126b68885 /net/ipv4/inet_timewait_sock.c | |
parent | e48c414ee61f4ac8d5cff2973e66a7cbc8a93aa5 (diff) |
[INET_TWSK]: Introduce inet_twsk_alloc
With the parts of tcp_time_wait that are not TCP specific, tcp_time_wait uses
it and so will dccp_time_wait.
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/inet_timewait_sock.c')
-rw-r--r-- | net/ipv4/inet_timewait_sock.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c index d38d160faeb7..ceb577c74237 100644 --- a/net/ipv4/inet_timewait_sock.c +++ b/net/ipv4/inet_timewait_sock.c | |||
@@ -81,3 +81,31 @@ void __inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk, | |||
81 | 81 | ||
82 | write_unlock(&ehead->lock); | 82 | write_unlock(&ehead->lock); |
83 | } | 83 | } |
84 | |||
85 | struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, const int state) | ||
86 | { | ||
87 | struct inet_timewait_sock *tw = kmem_cache_alloc(sk->sk_prot_creator->twsk_slab, | ||
88 | SLAB_ATOMIC); | ||
89 | if (tw != NULL) { | ||
90 | const struct inet_sock *inet = inet_sk(sk); | ||
91 | |||
92 | /* Give us an identity. */ | ||
93 | tw->tw_daddr = inet->daddr; | ||
94 | tw->tw_rcv_saddr = inet->rcv_saddr; | ||
95 | tw->tw_bound_dev_if = sk->sk_bound_dev_if; | ||
96 | tw->tw_num = inet->num; | ||
97 | tw->tw_state = TCP_TIME_WAIT; | ||
98 | tw->tw_substate = state; | ||
99 | tw->tw_sport = inet->sport; | ||
100 | tw->tw_dport = inet->dport; | ||
101 | tw->tw_family = sk->sk_family; | ||
102 | tw->tw_reuse = sk->sk_reuse; | ||
103 | tw->tw_hashent = sk->sk_hashent; | ||
104 | tw->tw_ipv6only = 0; | ||
105 | tw->tw_prot = sk->sk_prot_creator; | ||
106 | atomic_set(&tw->tw_refcnt, 1); | ||
107 | inet_twsk_dead_node_init(tw); | ||
108 | } | ||
109 | |||
110 | return tw; | ||
111 | } | ||