1db8dac20SDavid S. Miller /* 2db8dac20SDavid S. Miller * UDPLITEv6 An implementation of the UDP-Lite protocol over IPv6. 3db8dac20SDavid S. Miller * See also net/ipv4/udplite.c 4db8dac20SDavid S. Miller * 5db8dac20SDavid S. Miller * Authors: Gerrit Renker <gerrit@erg.abdn.ac.uk> 6db8dac20SDavid S. Miller * 7db8dac20SDavid S. Miller * Changes: 8db8dac20SDavid S. Miller * Fixes: 9db8dac20SDavid S. Miller * This program is free software; you can redistribute it and/or 10db8dac20SDavid S. Miller * modify it under the terms of the GNU General Public License 11db8dac20SDavid S. Miller * as published by the Free Software Foundation; either version 12db8dac20SDavid S. Miller * 2 of the License, or (at your option) any later version. 13db8dac20SDavid S. Miller */ 14db8dac20SDavid S. Miller #include "udp_impl.h" 15db8dac20SDavid S. Miller 16db8dac20SDavid S. Miller static int udplitev6_rcv(struct sk_buff *skb) 17db8dac20SDavid S. Miller { 18645ca708SEric Dumazet return __udp6_lib_rcv(skb, &udplite_table, IPPROTO_UDPLITE); 19db8dac20SDavid S. Miller } 20db8dac20SDavid S. Miller 21db8dac20SDavid S. Miller static void udplitev6_err(struct sk_buff *skb, 22db8dac20SDavid S. Miller struct inet6_skb_parm *opt, 23d5fdd6baSBrian Haley u8 type, u8 code, int offset, __be32 info) 24db8dac20SDavid S. Miller { 25645ca708SEric Dumazet __udp6_lib_err(skb, opt, type, code, offset, info, &udplite_table); 26db8dac20SDavid S. Miller } 27db8dac20SDavid S. Miller 2841135cc8SAlexey Dobriyan static const struct inet6_protocol udplitev6_protocol = { 29db8dac20SDavid S. Miller .handler = udplitev6_rcv, 30db8dac20SDavid S. Miller .err_handler = udplitev6_err, 31db8dac20SDavid S. Miller .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, 32db8dac20SDavid S. Miller }; 33db8dac20SDavid S. Miller 34db8dac20SDavid S. Miller struct proto udplitev6_prot = { 35db8dac20SDavid S. Miller .name = "UDPLITEv6", 36db8dac20SDavid S. Miller .owner = THIS_MODULE, 37db8dac20SDavid S. Miller .close = udp_lib_close, 38db8dac20SDavid S. Miller .connect = ip6_datagram_connect, 39db8dac20SDavid S. Miller .disconnect = udp_disconnect, 40db8dac20SDavid S. Miller .ioctl = udp_ioctl, 41db8dac20SDavid S. Miller .init = udplite_sk_init, 42db8dac20SDavid S. Miller .destroy = udpv6_destroy_sock, 43db8dac20SDavid S. Miller .setsockopt = udpv6_setsockopt, 44db8dac20SDavid S. Miller .getsockopt = udpv6_getsockopt, 45db8dac20SDavid S. Miller .sendmsg = udpv6_sendmsg, 46db8dac20SDavid S. Miller .recvmsg = udpv6_recvmsg, 47db8dac20SDavid S. Miller .backlog_rcv = udpv6_queue_rcv_skb, 48db8dac20SDavid S. Miller .hash = udp_lib_hash, 49db8dac20SDavid S. Miller .unhash = udp_lib_unhash, 506ba5a3c5SPavel Emelyanov .get_port = udp_v6_get_port, 51db8dac20SDavid S. Miller .obj_size = sizeof(struct udp6_sock), 52271b72c7SEric Dumazet .slab_flags = SLAB_DESTROY_BY_RCU, 53645ca708SEric Dumazet .h.udp_table = &udplite_table, 54db8dac20SDavid S. Miller #ifdef CONFIG_COMPAT 55db8dac20SDavid S. Miller .compat_setsockopt = compat_udpv6_setsockopt, 56db8dac20SDavid S. Miller .compat_getsockopt = compat_udpv6_getsockopt, 57db8dac20SDavid S. Miller #endif 58db8dac20SDavid S. Miller }; 59db8dac20SDavid S. Miller 60db8dac20SDavid S. Miller static struct inet_protosw udplite6_protosw = { 61db8dac20SDavid S. Miller .type = SOCK_DGRAM, 62db8dac20SDavid S. Miller .protocol = IPPROTO_UDPLITE, 63db8dac20SDavid S. Miller .prot = &udplitev6_prot, 64db8dac20SDavid S. Miller .ops = &inet6_dgram_ops, 65db8dac20SDavid S. Miller .no_check = 0, 66db8dac20SDavid S. Miller .flags = INET_PROTOSW_PERMANENT, 67db8dac20SDavid S. Miller }; 68db8dac20SDavid S. Miller 69db8dac20SDavid S. Miller int __init udplitev6_init(void) 70db8dac20SDavid S. Miller { 71db8dac20SDavid S. Miller int ret; 72db8dac20SDavid S. Miller 73db8dac20SDavid S. Miller ret = inet6_add_protocol(&udplitev6_protocol, IPPROTO_UDPLITE); 74db8dac20SDavid S. Miller if (ret) 75db8dac20SDavid S. Miller goto out; 76db8dac20SDavid S. Miller 77db8dac20SDavid S. Miller ret = inet6_register_protosw(&udplite6_protosw); 78db8dac20SDavid S. Miller if (ret) 79db8dac20SDavid S. Miller goto out_udplitev6_protocol; 80db8dac20SDavid S. Miller out: 81db8dac20SDavid S. Miller return ret; 82db8dac20SDavid S. Miller 83db8dac20SDavid S. Miller out_udplitev6_protocol: 84db8dac20SDavid S. Miller inet6_del_protocol(&udplitev6_protocol, IPPROTO_UDPLITE); 85db8dac20SDavid S. Miller goto out; 86db8dac20SDavid S. Miller } 87db8dac20SDavid S. Miller 88db8dac20SDavid S. Miller void udplitev6_exit(void) 89db8dac20SDavid S. Miller { 90db8dac20SDavid S. Miller inet6_unregister_protosw(&udplite6_protosw); 91db8dac20SDavid S. Miller inet6_del_protocol(&udplitev6_protocol, IPPROTO_UDPLITE); 92db8dac20SDavid S. Miller } 93db8dac20SDavid S. Miller 94db8dac20SDavid S. Miller #ifdef CONFIG_PROC_FS 95db8dac20SDavid S. Miller static struct udp_seq_afinfo udplite6_seq_afinfo = { 96db8dac20SDavid S. Miller .name = "udplite6", 97db8dac20SDavid S. Miller .family = AF_INET6, 98645ca708SEric Dumazet .udp_table = &udplite_table, 994ad96d39SDenis V. Lunev .seq_fops = { 1004ad96d39SDenis V. Lunev .owner = THIS_MODULE, 1014ad96d39SDenis V. Lunev }, 102dda61925SDenis V. Lunev .seq_ops = { 103dda61925SDenis V. Lunev .show = udp6_seq_show, 104dda61925SDenis V. Lunev }, 105db8dac20SDavid S. Miller }; 106db8dac20SDavid S. Miller 1072c8c1e72SAlexey Dobriyan static int __net_init udplite6_proc_init_net(struct net *net) 10884c375afSPavel Emelyanov { 10984c375afSPavel Emelyanov return udp_proc_register(net, &udplite6_seq_afinfo); 11084c375afSPavel Emelyanov } 11184c375afSPavel Emelyanov 1122c8c1e72SAlexey Dobriyan static void __net_exit udplite6_proc_exit_net(struct net *net) 11384c375afSPavel Emelyanov { 11484c375afSPavel Emelyanov udp_proc_unregister(net, &udplite6_seq_afinfo); 11584c375afSPavel Emelyanov } 11684c375afSPavel Emelyanov 11784c375afSPavel Emelyanov static struct pernet_operations udplite6_net_ops = { 11884c375afSPavel Emelyanov .init = udplite6_proc_init_net, 11984c375afSPavel Emelyanov .exit = udplite6_proc_exit_net, 12084c375afSPavel Emelyanov }; 12184c375afSPavel Emelyanov 122db8dac20SDavid S. Miller int __init udplite6_proc_init(void) 123db8dac20SDavid S. Miller { 12484c375afSPavel Emelyanov return register_pernet_subsys(&udplite6_net_ops); 125db8dac20SDavid S. Miller } 126db8dac20SDavid S. Miller 127db8dac20SDavid S. Miller void udplite6_proc_exit(void) 128db8dac20SDavid S. Miller { 12984c375afSPavel Emelyanov unregister_pernet_subsys(&udplite6_net_ops); 130db8dac20SDavid S. Miller } 131db8dac20SDavid S. Miller #endif 132