aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/proto.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/dccp/proto.c')
-rw-r--r--net/dccp/proto.c132
1 files changed, 5 insertions, 127 deletions
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index abab6c10af9..ef94b0c8a0c 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -23,9 +23,7 @@
23#include <linux/random.h> 23#include <linux/random.h>
24#include <net/checksum.h> 24#include <net/checksum.h>
25 25
26#include <net/inet_common.h>
27#include <net/inet_sock.h> 26#include <net/inet_sock.h>
28#include <net/protocol.h>
29#include <net/sock.h> 27#include <net/sock.h>
30#include <net/xfrm.h> 28#include <net/xfrm.h>
31 29
@@ -55,12 +53,6 @@ struct inet_hashinfo __cacheline_aligned dccp_hashinfo = {
55 53
56EXPORT_SYMBOL_GPL(dccp_hashinfo); 54EXPORT_SYMBOL_GPL(dccp_hashinfo);
57 55
58static struct net_protocol dccp_protocol = {
59 .handler = dccp_v4_rcv,
60 .err_handler = dccp_v4_err,
61 .no_policy = 1,
62};
63
64const char *dccp_packet_name(const int type) 56const char *dccp_packet_name(const int type)
65{ 57{
66 static const char *dccp_packet_names[] = { 58 static const char *dccp_packet_names[] = {
@@ -856,83 +848,6 @@ void dccp_shutdown(struct sock *sk, int how)
856 848
857EXPORT_SYMBOL_GPL(dccp_shutdown); 849EXPORT_SYMBOL_GPL(dccp_shutdown);
858 850
859static const struct proto_ops inet_dccp_ops = {
860 .family = PF_INET,
861 .owner = THIS_MODULE,
862 .release = inet_release,
863 .bind = inet_bind,
864 .connect = inet_stream_connect,
865 .socketpair = sock_no_socketpair,
866 .accept = inet_accept,
867 .getname = inet_getname,
868 /* FIXME: work on tcp_poll to rename it to inet_csk_poll */
869 .poll = dccp_poll,
870 .ioctl = inet_ioctl,
871 /* FIXME: work on inet_listen to rename it to sock_common_listen */
872 .listen = inet_dccp_listen,
873 .shutdown = inet_shutdown,
874 .setsockopt = sock_common_setsockopt,
875 .getsockopt = sock_common_getsockopt,
876 .sendmsg = inet_sendmsg,
877 .recvmsg = sock_common_recvmsg,
878 .mmap = sock_no_mmap,
879 .sendpage = sock_no_sendpage,
880};
881
882extern struct net_proto_family inet_family_ops;
883
884static struct inet_protosw dccp_v4_protosw = {
885 .type = SOCK_DCCP,
886 .protocol = IPPROTO_DCCP,
887 .prot = &dccp_prot,
888 .ops = &inet_dccp_ops,
889 .capability = -1,
890 .no_check = 0,
891 .flags = INET_PROTOSW_ICSK,
892};
893
894/*
895 * This is the global socket data structure used for responding to
896 * the Out-of-the-blue (OOTB) packets. A control sock will be created
897 * for this socket at the initialization time.
898 */
899struct socket *dccp_ctl_socket;
900
901static char dccp_ctl_socket_err_msg[] __initdata =
902 KERN_ERR "DCCP: Failed to create the control socket.\n";
903
904static int __init dccp_ctl_sock_init(void)
905{
906 int rc = sock_create_kern(PF_INET, SOCK_DCCP, IPPROTO_DCCP,
907 &dccp_ctl_socket);
908 if (rc < 0)
909 printk(dccp_ctl_socket_err_msg);
910 else {
911 dccp_ctl_socket->sk->sk_allocation = GFP_ATOMIC;
912 inet_sk(dccp_ctl_socket->sk)->uc_ttl = -1;
913
914 /* Unhash it so that IP input processing does not even
915 * see it, we do not wish this socket to see incoming
916 * packets.
917 */
918 dccp_ctl_socket->sk->sk_prot->unhash(dccp_ctl_socket->sk);
919 }
920
921 return rc;
922}
923
924#ifdef CONFIG_IP_DCCP_UNLOAD_HACK
925void dccp_ctl_sock_exit(void)
926{
927 if (dccp_ctl_socket != NULL) {
928 sock_release(dccp_ctl_socket);
929 dccp_ctl_socket = NULL;
930 }
931}
932
933EXPORT_SYMBOL_GPL(dccp_ctl_sock_exit);
934#endif
935
936static int __init dccp_mib_init(void) 851static int __init dccp_mib_init(void)
937{ 852{
938 int rc = -ENOMEM; 853 int rc = -ENOMEM;
@@ -955,7 +870,7 @@ out_free_one:
955 870
956} 871}
957 872
958static int dccp_mib_exit(void) 873static void dccp_mib_exit(void)
959{ 874{
960 free_percpu(dccp_statistics[0]); 875 free_percpu(dccp_statistics[0]);
961 free_percpu(dccp_statistics[1]); 876 free_percpu(dccp_statistics[1]);
@@ -978,18 +893,14 @@ static int __init dccp_init(void)
978{ 893{
979 unsigned long goal; 894 unsigned long goal;
980 int ehash_order, bhash_order, i; 895 int ehash_order, bhash_order, i;
981 int rc = proto_register(&dccp_prot, 1); 896 int rc = -ENOBUFS;
982 897
983 if (rc)
984 goto out;
985
986 rc = -ENOBUFS;
987 dccp_hashinfo.bind_bucket_cachep = 898 dccp_hashinfo.bind_bucket_cachep =
988 kmem_cache_create("dccp_bind_bucket", 899 kmem_cache_create("dccp_bind_bucket",
989 sizeof(struct inet_bind_bucket), 0, 900 sizeof(struct inet_bind_bucket), 0,
990 SLAB_HWCACHE_ALIGN, NULL, NULL); 901 SLAB_HWCACHE_ALIGN, NULL, NULL);
991 if (!dccp_hashinfo.bind_bucket_cachep) 902 if (!dccp_hashinfo.bind_bucket_cachep)
992 goto out_proto_unregister; 903 goto out;
993 904
994 /* 905 /*
995 * Size and allocate the main established and bind bucket 906 * Size and allocate the main established and bind bucket
@@ -1055,33 +966,18 @@ static int __init dccp_init(void)
1055 if (rc) 966 if (rc)
1056 goto out_free_dccp_bhash; 967 goto out_free_dccp_bhash;
1057 968
1058 rc = -EAGAIN;
1059 if (inet_add_protocol(&dccp_protocol, IPPROTO_DCCP))
1060 goto out_free_dccp_v4_mibs;
1061
1062 inet_register_protosw(&dccp_v4_protosw);
1063
1064 rc = dccp_ackvec_init(); 969 rc = dccp_ackvec_init();
1065 if (rc) 970 if (rc)
1066 goto out_unregister_protosw; 971 goto out_free_dccp_mib;
1067 972
1068 rc = dccp_sysctl_init(); 973 rc = dccp_sysctl_init();
1069 if (rc) 974 if (rc)
1070 goto out_ackvec_exit; 975 goto out_ackvec_exit;
1071
1072 rc = dccp_ctl_sock_init();
1073 if (rc)
1074 goto out_sysctl_exit;
1075out: 976out:
1076 return rc; 977 return rc;
1077out_sysctl_exit:
1078 dccp_sysctl_exit();
1079out_ackvec_exit: 978out_ackvec_exit:
1080 dccp_ackvec_exit(); 979 dccp_ackvec_exit();
1081out_unregister_protosw: 980out_free_dccp_mib:
1082 inet_unregister_protosw(&dccp_v4_protosw);
1083 inet_del_protocol(&dccp_protocol, IPPROTO_DCCP);
1084out_free_dccp_v4_mibs:
1085 dccp_mib_exit(); 981 dccp_mib_exit();
1086out_free_dccp_bhash: 982out_free_dccp_bhash:
1087 free_pages((unsigned long)dccp_hashinfo.bhash, bhash_order); 983 free_pages((unsigned long)dccp_hashinfo.bhash, bhash_order);
@@ -1092,21 +988,11 @@ out_free_dccp_ehash:
1092out_free_bind_bucket_cachep: 988out_free_bind_bucket_cachep:
1093 kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep); 989 kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep);
1094 dccp_hashinfo.bind_bucket_cachep = NULL; 990 dccp_hashinfo.bind_bucket_cachep = NULL;
1095out_proto_unregister:
1096 proto_unregister(&dccp_prot);
1097 goto out; 991 goto out;
1098} 992}
1099 993
1100static const char dccp_del_proto_err_msg[] __exitdata =
1101 KERN_ERR "can't remove dccp net_protocol\n";
1102
1103static void __exit dccp_fini(void) 994static void __exit dccp_fini(void)
1104{ 995{
1105 inet_unregister_protosw(&dccp_v4_protosw);
1106
1107 if (inet_del_protocol(&dccp_protocol, IPPROTO_DCCP) < 0)
1108 printk(dccp_del_proto_err_msg);
1109
1110 dccp_mib_exit(); 996 dccp_mib_exit();
1111 free_pages((unsigned long)dccp_hashinfo.bhash, 997 free_pages((unsigned long)dccp_hashinfo.bhash,
1112 get_order(dccp_hashinfo.bhash_size * 998 get_order(dccp_hashinfo.bhash_size *
@@ -1115,7 +1001,6 @@ static void __exit dccp_fini(void)
1115 get_order(dccp_hashinfo.ehash_size * 1001 get_order(dccp_hashinfo.ehash_size *
1116 sizeof(struct inet_ehash_bucket))); 1002 sizeof(struct inet_ehash_bucket)));
1117 kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep); 1003 kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep);
1118 proto_unregister(&dccp_prot);
1119 dccp_ackvec_exit(); 1004 dccp_ackvec_exit();
1120 dccp_sysctl_exit(); 1005 dccp_sysctl_exit();
1121} 1006}
@@ -1123,13 +1008,6 @@ static void __exit dccp_fini(void)
1123module_init(dccp_init); 1008module_init(dccp_init);
1124module_exit(dccp_fini); 1009module_exit(dccp_fini);
1125 1010
1126/*
1127 * __stringify doesn't likes enums, so use SOCK_DCCP (6) and IPPROTO_DCCP (33)
1128 * values directly, Also cover the case where the protocol is not specified,
1129 * i.e. net-pf-PF_INET-proto-0-type-SOCK_DCCP
1130 */
1131MODULE_ALIAS("net-pf-" __stringify(PF_INET) "-proto-33-type-6");
1132MODULE_ALIAS("net-pf-" __stringify(PF_INET) "-proto-0-type-6");
1133MODULE_LICENSE("GPL"); 1011MODULE_LICENSE("GPL");
1134MODULE_AUTHOR("Arnaldo Carvalho de Melo <acme@conectiva.com.br>"); 1012MODULE_AUTHOR("Arnaldo Carvalho de Melo <acme@conectiva.com.br>");
1135MODULE_DESCRIPTION("DCCP - Datagram Congestion Controlled Protocol"); 1013MODULE_DESCRIPTION("DCCP - Datagram Congestion Controlled Protocol");