aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/proto.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@mandriva.com>2006-03-21 00:23:15 -0500
committerDavid S. Miller <davem@davemloft.net>2006-03-21 00:23:15 -0500
commit3e0fadc51f2fde01e0e22f481370a9b5f073bfc3 (patch)
tree0254dd8d495d2e4a2a1a9adb17b7dc10541796d8 /net/dccp/proto.c
parent017487d7d1e905a5bb529f6a2bc8cf8ea14e2307 (diff)
[DCCP]: Move dccp_v4_{init,destroy}_sock to the core
Removing one more ipv6 uses ipv4 stuff case in dccp land. Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dccp/proto.c')
-rw-r--r--net/dccp/proto.c102
1 files changed, 102 insertions, 0 deletions
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 6403e9306ddb..1c32def26533 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -97,6 +97,108 @@ const char *dccp_state_name(const int state)
97 97
98EXPORT_SYMBOL_GPL(dccp_state_name); 98EXPORT_SYMBOL_GPL(dccp_state_name);
99 99
100int dccp_init_sock(struct sock *sk)
101{
102 struct dccp_sock *dp = dccp_sk(sk);
103 struct inet_connection_sock *icsk = inet_csk(sk);
104 static int dccp_ctl_socket_init = 1;
105
106 dccp_options_init(&dp->dccps_options);
107 do_gettimeofday(&dp->dccps_epoch);
108
109 /*
110 * FIXME: We're hardcoding the CCID, and doing this at this point makes
111 * the listening (master) sock get CCID control blocks, which is not
112 * necessary, but for now, to not mess with the test userspace apps,
113 * lets leave it here, later the real solution is to do this in a
114 * setsockopt(CCIDs-I-want/accept). -acme
115 */
116 if (likely(!dccp_ctl_socket_init)) {
117 int rc = dccp_feat_init(sk);
118
119 if (rc)
120 return rc;
121
122 if (dp->dccps_options.dccpo_send_ack_vector) {
123 dp->dccps_hc_rx_ackvec = dccp_ackvec_alloc(GFP_KERNEL);
124 if (dp->dccps_hc_rx_ackvec == NULL)
125 return -ENOMEM;
126 }
127 dp->dccps_hc_rx_ccid =
128 ccid_hc_rx_new(dp->dccps_options.dccpo_rx_ccid,
129 sk, GFP_KERNEL);
130 dp->dccps_hc_tx_ccid =
131 ccid_hc_tx_new(dp->dccps_options.dccpo_tx_ccid,
132 sk, GFP_KERNEL);
133 if (unlikely(dp->dccps_hc_rx_ccid == NULL ||
134 dp->dccps_hc_tx_ccid == NULL)) {
135 ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk);
136 ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk);
137 if (dp->dccps_options.dccpo_send_ack_vector) {
138 dccp_ackvec_free(dp->dccps_hc_rx_ackvec);
139 dp->dccps_hc_rx_ackvec = NULL;
140 }
141 dp->dccps_hc_rx_ccid = dp->dccps_hc_tx_ccid = NULL;
142 return -ENOMEM;
143 }
144 } else {
145 /* control socket doesn't need feat nego */
146 INIT_LIST_HEAD(&dp->dccps_options.dccpo_pending);
147 INIT_LIST_HEAD(&dp->dccps_options.dccpo_conf);
148 dccp_ctl_socket_init = 0;
149 }
150
151 dccp_init_xmit_timers(sk);
152 icsk->icsk_rto = DCCP_TIMEOUT_INIT;
153 sk->sk_state = DCCP_CLOSED;
154 sk->sk_write_space = dccp_write_space;
155 icsk->icsk_sync_mss = dccp_sync_mss;
156 dp->dccps_mss_cache = 536;
157 dp->dccps_role = DCCP_ROLE_UNDEFINED;
158 dp->dccps_service = DCCP_SERVICE_INVALID_VALUE;
159 dp->dccps_l_ack_ratio = dp->dccps_r_ack_ratio = 1;
160
161 return 0;
162}
163
164EXPORT_SYMBOL_GPL(dccp_init_sock);
165
166int dccp_destroy_sock(struct sock *sk)
167{
168 struct dccp_sock *dp = dccp_sk(sk);
169
170 /*
171 * DCCP doesn't use sk_write_queue, just sk_send_head
172 * for retransmissions
173 */
174 if (sk->sk_send_head != NULL) {
175 kfree_skb(sk->sk_send_head);
176 sk->sk_send_head = NULL;
177 }
178
179 /* Clean up a referenced DCCP bind bucket. */
180 if (inet_csk(sk)->icsk_bind_hash != NULL)
181 inet_put_port(&dccp_hashinfo, sk);
182
183 kfree(dp->dccps_service_list);
184 dp->dccps_service_list = NULL;
185
186 if (dp->dccps_options.dccpo_send_ack_vector) {
187 dccp_ackvec_free(dp->dccps_hc_rx_ackvec);
188 dp->dccps_hc_rx_ackvec = NULL;
189 }
190 ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk);
191 ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk);
192 dp->dccps_hc_rx_ccid = dp->dccps_hc_tx_ccid = NULL;
193
194 /* clean up feature negotiation state */
195 dccp_feat_clean(sk);
196
197 return 0;
198}
199
200EXPORT_SYMBOL_GPL(dccp_destroy_sock);
201
100static inline int dccp_listen_start(struct sock *sk) 202static inline int dccp_listen_start(struct sock *sk)
101{ 203{
102 struct dccp_sock *dp = dccp_sk(sk); 204 struct dccp_sock *dp = dccp_sk(sk);