0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <linux/export.h>
0012 #include <linux/proc_fs.h>
0013 #include "udp_impl.h"
0014
0015 static int udplitev6_rcv(struct sk_buff *skb)
0016 {
0017 return __udp6_lib_rcv(skb, &udplite_table, IPPROTO_UDPLITE);
0018 }
0019
0020 static int udplitev6_err(struct sk_buff *skb,
0021 struct inet6_skb_parm *opt,
0022 u8 type, u8 code, int offset, __be32 info)
0023 {
0024 return __udp6_lib_err(skb, opt, type, code, offset, info,
0025 &udplite_table);
0026 }
0027
0028 static const struct inet6_protocol udplitev6_protocol = {
0029 .handler = udplitev6_rcv,
0030 .err_handler = udplitev6_err,
0031 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
0032 };
0033
0034 struct proto udplitev6_prot = {
0035 .name = "UDPLITEv6",
0036 .owner = THIS_MODULE,
0037 .close = udp_lib_close,
0038 .connect = ip6_datagram_connect,
0039 .disconnect = udp_disconnect,
0040 .ioctl = udp_ioctl,
0041 .init = udplite_sk_init,
0042 .destroy = udpv6_destroy_sock,
0043 .setsockopt = udpv6_setsockopt,
0044 .getsockopt = udpv6_getsockopt,
0045 .sendmsg = udpv6_sendmsg,
0046 .recvmsg = udpv6_recvmsg,
0047 .hash = udp_lib_hash,
0048 .unhash = udp_lib_unhash,
0049 .rehash = udp_v6_rehash,
0050 .get_port = udp_v6_get_port,
0051
0052 .memory_allocated = &udp_memory_allocated,
0053 .per_cpu_fw_alloc = &udp_memory_per_cpu_fw_alloc,
0054
0055 .sysctl_mem = sysctl_udp_mem,
0056 .obj_size = sizeof(struct udp6_sock),
0057 .h.udp_table = &udplite_table,
0058 };
0059
0060 static struct inet_protosw udplite6_protosw = {
0061 .type = SOCK_DGRAM,
0062 .protocol = IPPROTO_UDPLITE,
0063 .prot = &udplitev6_prot,
0064 .ops = &inet6_dgram_ops,
0065 .flags = INET_PROTOSW_PERMANENT,
0066 };
0067
0068 int __init udplitev6_init(void)
0069 {
0070 int ret;
0071
0072 ret = inet6_add_protocol(&udplitev6_protocol, IPPROTO_UDPLITE);
0073 if (ret)
0074 goto out;
0075
0076 ret = inet6_register_protosw(&udplite6_protosw);
0077 if (ret)
0078 goto out_udplitev6_protocol;
0079 out:
0080 return ret;
0081
0082 out_udplitev6_protocol:
0083 inet6_del_protocol(&udplitev6_protocol, IPPROTO_UDPLITE);
0084 goto out;
0085 }
0086
0087 void udplitev6_exit(void)
0088 {
0089 inet6_unregister_protosw(&udplite6_protosw);
0090 inet6_del_protocol(&udplitev6_protocol, IPPROTO_UDPLITE);
0091 }
0092
0093 #ifdef CONFIG_PROC_FS
0094 static struct udp_seq_afinfo udplite6_seq_afinfo = {
0095 .family = AF_INET6,
0096 .udp_table = &udplite_table,
0097 };
0098
0099 static int __net_init udplite6_proc_init_net(struct net *net)
0100 {
0101 if (!proc_create_net_data("udplite6", 0444, net->proc_net,
0102 &udp6_seq_ops, sizeof(struct udp_iter_state),
0103 &udplite6_seq_afinfo))
0104 return -ENOMEM;
0105 return 0;
0106 }
0107
0108 static void __net_exit udplite6_proc_exit_net(struct net *net)
0109 {
0110 remove_proc_entry("udplite6", net->proc_net);
0111 }
0112
0113 static struct pernet_operations udplite6_net_ops = {
0114 .init = udplite6_proc_init_net,
0115 .exit = udplite6_proc_exit_net,
0116 };
0117
0118 int __init udplite6_proc_init(void)
0119 {
0120 return register_pernet_subsys(&udplite6_net_ops);
0121 }
0122
0123 void udplite6_proc_exit(void)
0124 {
0125 unregister_pernet_subsys(&udplite6_net_ops);
0126 }
0127 #endif