diff options
author | Arnaldo Carvalho de Melo <acme@mandriva.com> | 2006-03-21 01:01:03 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2006-03-21 01:01:03 -0500 |
commit | c4d9390941aee136fd35bb38eb1d6de4e3b1487d (patch) | |
tree | fcaf0032ba5971145b5f527b8635cd7aa3a39d8c /net/dccp | |
parent | 72478873571d869906f7a250b09e12fa5b65e321 (diff) |
[ICSK]: Introduce inet_csk_ctl_sock_create
Consolidating open coded sequences in tcp and dccp, v4 and v6.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dccp')
-rw-r--r-- | net/dccp/ipv4.c | 26 | ||||
-rw-r--r-- | net/dccp/ipv6.c | 27 |
2 files changed, 5 insertions, 48 deletions
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index f53bce590ade..7098f1055f4a 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c | |||
@@ -1099,29 +1099,6 @@ static struct inet_protosw dccp_v4_protosw = { | |||
1099 | .flags = INET_PROTOSW_ICSK, | 1099 | .flags = INET_PROTOSW_ICSK, |
1100 | }; | 1100 | }; |
1101 | 1101 | ||
1102 | static char dccp_v4_ctl_socket_err_msg[] __initdata = | ||
1103 | KERN_ERR "DCCP: Failed to create the control socket.\n"; | ||
1104 | |||
1105 | static int __init dccp_v4_ctl_sock_init(void) | ||
1106 | { | ||
1107 | int rc = sock_create_kern(PF_INET, SOCK_DCCP, IPPROTO_DCCP, | ||
1108 | &dccp_v4_ctl_socket); | ||
1109 | if (rc < 0) | ||
1110 | printk(dccp_v4_ctl_socket_err_msg); | ||
1111 | else { | ||
1112 | dccp_v4_ctl_socket->sk->sk_allocation = GFP_ATOMIC; | ||
1113 | inet_sk(dccp_v4_ctl_socket->sk)->uc_ttl = -1; | ||
1114 | |||
1115 | /* Unhash it so that IP input processing does not even | ||
1116 | * see it, we do not wish this socket to see incoming | ||
1117 | * packets. | ||
1118 | */ | ||
1119 | dccp_v4_ctl_socket->sk->sk_prot->unhash(dccp_v4_ctl_socket->sk); | ||
1120 | } | ||
1121 | |||
1122 | return rc; | ||
1123 | } | ||
1124 | |||
1125 | static int __init dccp_v4_init(void) | 1102 | static int __init dccp_v4_init(void) |
1126 | { | 1103 | { |
1127 | int err = proto_register(&dccp_v4_prot, 1); | 1104 | int err = proto_register(&dccp_v4_prot, 1); |
@@ -1135,7 +1112,8 @@ static int __init dccp_v4_init(void) | |||
1135 | 1112 | ||
1136 | inet_register_protosw(&dccp_v4_protosw); | 1113 | inet_register_protosw(&dccp_v4_protosw); |
1137 | 1114 | ||
1138 | err = dccp_v4_ctl_sock_init(); | 1115 | err = inet_csk_ctl_sock_create(&dccp_v4_ctl_socket, PF_INET, |
1116 | SOCK_DCCP, IPPROTO_DCCP); | ||
1139 | if (err) | 1117 | if (err) |
1140 | goto out_unregister_protosw; | 1118 | goto out_unregister_protosw; |
1141 | out: | 1119 | out: |
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index 3c9f0836404f..6bd9979334a2 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c | |||
@@ -1229,29 +1229,6 @@ static struct inet_protosw dccp_v6_protosw = { | |||
1229 | .flags = INET_PROTOSW_ICSK, | 1229 | .flags = INET_PROTOSW_ICSK, |
1230 | }; | 1230 | }; |
1231 | 1231 | ||
1232 | static char dccp_v6_ctl_socket_err_msg[] __initdata = | ||
1233 | KERN_ERR "DCCP: Failed to create the control socket.\n"; | ||
1234 | |||
1235 | static int __init dccp_v6_ctl_sock_init(void) | ||
1236 | { | ||
1237 | int rc = sock_create_kern(PF_INET6, SOCK_DCCP, IPPROTO_DCCP, | ||
1238 | &dccp_v6_ctl_socket); | ||
1239 | if (rc < 0) | ||
1240 | printk(dccp_v6_ctl_socket_err_msg); | ||
1241 | else { | ||
1242 | dccp_v6_ctl_socket->sk->sk_allocation = GFP_ATOMIC; | ||
1243 | inet_sk(dccp_v6_ctl_socket->sk)->uc_ttl = -1; | ||
1244 | |||
1245 | /* Unhash it so that IP input processing does not even | ||
1246 | * see it, we do not wish this socket to see incoming | ||
1247 | * packets. | ||
1248 | */ | ||
1249 | dccp_v6_ctl_socket->sk->sk_prot->unhash(dccp_v6_ctl_socket->sk); | ||
1250 | } | ||
1251 | |||
1252 | return rc; | ||
1253 | } | ||
1254 | |||
1255 | static int __init dccp_v6_init(void) | 1232 | static int __init dccp_v6_init(void) |
1256 | { | 1233 | { |
1257 | int err = proto_register(&dccp_v6_prot, 1); | 1234 | int err = proto_register(&dccp_v6_prot, 1); |
@@ -1265,7 +1242,9 @@ static int __init dccp_v6_init(void) | |||
1265 | 1242 | ||
1266 | inet6_register_protosw(&dccp_v6_protosw); | 1243 | inet6_register_protosw(&dccp_v6_protosw); |
1267 | 1244 | ||
1268 | if (dccp_v6_ctl_sock_init() != 0) | 1245 | err = inet_csk_ctl_sock_create(&dccp_v6_ctl_socket, PF_INET6, |
1246 | SOCK_DCCP, IPPROTO_DCCP); | ||
1247 | if (err != 0) | ||
1269 | goto out_unregister_protosw; | 1248 | goto out_unregister_protosw; |
1270 | out: | 1249 | out: |
1271 | return err; | 1250 | return err; |