diff options
author | Arnaldo Carvalho de Melo <acme@mandriva.com> | 2006-03-21 00:23:15 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2006-03-21 00:23:15 -0500 |
commit | 3e0fadc51f2fde01e0e22f481370a9b5f073bfc3 (patch) | |
tree | 0254dd8d495d2e4a2a1a9adb17b7dc10541796d8 /net/dccp/ipv4.c | |
parent | 017487d7d1e905a5bb529f6a2bc8cf8ea14e2307 (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/ipv4.c')
-rw-r--r-- | net/dccp/ipv4.c | 106 |
1 files changed, 6 insertions, 100 deletions
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 3baf4c76a89d..b26a4f8df4dc 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c | |||
@@ -1008,109 +1008,15 @@ struct inet_connection_sock_af_ops dccp_ipv4_af_ops = { | |||
1008 | .sockaddr_len = sizeof(struct sockaddr_in), | 1008 | .sockaddr_len = sizeof(struct sockaddr_in), |
1009 | }; | 1009 | }; |
1010 | 1010 | ||
1011 | int dccp_v4_init_sock(struct sock *sk) | 1011 | static int dccp_v4_init_sock(struct sock *sk) |
1012 | { | 1012 | { |
1013 | struct dccp_sock *dp = dccp_sk(sk); | 1013 | const int err = dccp_init_sock(sk); |
1014 | struct inet_connection_sock *icsk = inet_csk(sk); | ||
1015 | static int dccp_ctl_socket_init = 1; | ||
1016 | |||
1017 | dccp_options_init(&dp->dccps_options); | ||
1018 | do_gettimeofday(&dp->dccps_epoch); | ||
1019 | |||
1020 | /* | ||
1021 | * FIXME: We're hardcoding the CCID, and doing this at this point makes | ||
1022 | * the listening (master) sock get CCID control blocks, which is not | ||
1023 | * necessary, but for now, to not mess with the test userspace apps, | ||
1024 | * lets leave it here, later the real solution is to do this in a | ||
1025 | * setsockopt(CCIDs-I-want/accept). -acme | ||
1026 | */ | ||
1027 | if (likely(!dccp_ctl_socket_init)) { | ||
1028 | int rc = dccp_feat_init(sk); | ||
1029 | |||
1030 | if (rc) | ||
1031 | return rc; | ||
1032 | |||
1033 | if (dp->dccps_options.dccpo_send_ack_vector) { | ||
1034 | dp->dccps_hc_rx_ackvec = dccp_ackvec_alloc(GFP_KERNEL); | ||
1035 | if (dp->dccps_hc_rx_ackvec == NULL) | ||
1036 | return -ENOMEM; | ||
1037 | } | ||
1038 | dp->dccps_hc_rx_ccid = | ||
1039 | ccid_hc_rx_new(dp->dccps_options.dccpo_rx_ccid, | ||
1040 | sk, GFP_KERNEL); | ||
1041 | dp->dccps_hc_tx_ccid = | ||
1042 | ccid_hc_tx_new(dp->dccps_options.dccpo_tx_ccid, | ||
1043 | sk, GFP_KERNEL); | ||
1044 | if (unlikely(dp->dccps_hc_rx_ccid == NULL || | ||
1045 | dp->dccps_hc_tx_ccid == NULL)) { | ||
1046 | ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk); | ||
1047 | ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk); | ||
1048 | if (dp->dccps_options.dccpo_send_ack_vector) { | ||
1049 | dccp_ackvec_free(dp->dccps_hc_rx_ackvec); | ||
1050 | dp->dccps_hc_rx_ackvec = NULL; | ||
1051 | } | ||
1052 | dp->dccps_hc_rx_ccid = dp->dccps_hc_tx_ccid = NULL; | ||
1053 | return -ENOMEM; | ||
1054 | } | ||
1055 | } else { | ||
1056 | /* control socket doesn't need feat nego */ | ||
1057 | INIT_LIST_HEAD(&dp->dccps_options.dccpo_pending); | ||
1058 | INIT_LIST_HEAD(&dp->dccps_options.dccpo_conf); | ||
1059 | dccp_ctl_socket_init = 0; | ||
1060 | } | ||
1061 | |||
1062 | dccp_init_xmit_timers(sk); | ||
1063 | icsk->icsk_rto = DCCP_TIMEOUT_INIT; | ||
1064 | sk->sk_state = DCCP_CLOSED; | ||
1065 | sk->sk_write_space = dccp_write_space; | ||
1066 | icsk->icsk_af_ops = &dccp_ipv4_af_ops; | ||
1067 | icsk->icsk_sync_mss = dccp_sync_mss; | ||
1068 | dp->dccps_mss_cache = 536; | ||
1069 | dp->dccps_role = DCCP_ROLE_UNDEFINED; | ||
1070 | dp->dccps_service = DCCP_SERVICE_INVALID_VALUE; | ||
1071 | dp->dccps_l_ack_ratio = dp->dccps_r_ack_ratio = 1; | ||
1072 | |||
1073 | return 0; | ||
1074 | } | ||
1075 | |||
1076 | EXPORT_SYMBOL_GPL(dccp_v4_init_sock); | ||
1077 | 1014 | ||
1078 | int dccp_v4_destroy_sock(struct sock *sk) | 1015 | if (err == 0) |
1079 | { | 1016 | inet_csk(sk)->icsk_af_ops = &dccp_ipv4_af_ops; |
1080 | struct dccp_sock *dp = dccp_sk(sk); | 1017 | return err; |
1081 | |||
1082 | /* | ||
1083 | * DCCP doesn't use sk_write_queue, just sk_send_head | ||
1084 | * for retransmissions | ||
1085 | */ | ||
1086 | if (sk->sk_send_head != NULL) { | ||
1087 | kfree_skb(sk->sk_send_head); | ||
1088 | sk->sk_send_head = NULL; | ||
1089 | } | ||
1090 | |||
1091 | /* Clean up a referenced DCCP bind bucket. */ | ||
1092 | if (inet_csk(sk)->icsk_bind_hash != NULL) | ||
1093 | inet_put_port(&dccp_hashinfo, sk); | ||
1094 | |||
1095 | kfree(dp->dccps_service_list); | ||
1096 | dp->dccps_service_list = NULL; | ||
1097 | |||
1098 | if (dp->dccps_options.dccpo_send_ack_vector) { | ||
1099 | dccp_ackvec_free(dp->dccps_hc_rx_ackvec); | ||
1100 | dp->dccps_hc_rx_ackvec = NULL; | ||
1101 | } | ||
1102 | ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk); | ||
1103 | ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk); | ||
1104 | dp->dccps_hc_rx_ccid = dp->dccps_hc_tx_ccid = NULL; | ||
1105 | |||
1106 | /* clean up feature negotiation state */ | ||
1107 | dccp_feat_clean(sk); | ||
1108 | |||
1109 | return 0; | ||
1110 | } | 1018 | } |
1111 | 1019 | ||
1112 | EXPORT_SYMBOL_GPL(dccp_v4_destroy_sock); | ||
1113 | |||
1114 | static void dccp_v4_reqsk_destructor(struct request_sock *req) | 1020 | static void dccp_v4_reqsk_destructor(struct request_sock *req) |
1115 | { | 1021 | { |
1116 | kfree(inet_rsk(req)->opt); | 1022 | kfree(inet_rsk(req)->opt); |
@@ -1147,7 +1053,7 @@ struct proto dccp_prot = { | |||
1147 | .accept = inet_csk_accept, | 1053 | .accept = inet_csk_accept, |
1148 | .get_port = dccp_v4_get_port, | 1054 | .get_port = dccp_v4_get_port, |
1149 | .shutdown = dccp_shutdown, | 1055 | .shutdown = dccp_shutdown, |
1150 | .destroy = dccp_v4_destroy_sock, | 1056 | .destroy = dccp_destroy_sock, |
1151 | .orphan_count = &dccp_orphan_count, | 1057 | .orphan_count = &dccp_orphan_count, |
1152 | .max_header = MAX_DCCP_HEADER, | 1058 | .max_header = MAX_DCCP_HEADER, |
1153 | .obj_size = sizeof(struct dccp_sock), | 1059 | .obj_size = sizeof(struct dccp_sock), |