udplite.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * UDPLITEv6 An implementation of the UDP-Lite protocol over IPv6.
  3. * See also net/ipv4/udplite.c
  4. *
  5. * Authors: Gerrit Renker <gerrit@erg.abdn.ac.uk>
  6. *
  7. * Changes:
  8. * Fixes:
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version
  12. * 2 of the License, or (at your option) any later version.
  13. */
  14. #include <linux/export.h>
  15. #include <linux/proc_fs.h>
  16. #include "udp_impl.h"
  17. static int udplitev6_rcv(struct sk_buff *skb)
  18. {
  19. return __udp6_lib_rcv(skb, &udplite_table, IPPROTO_UDPLITE);
  20. }
  21. static void udplitev6_err(struct sk_buff *skb,
  22. struct inet6_skb_parm *opt,
  23. u8 type, u8 code, int offset, __be32 info)
  24. {
  25. __udp6_lib_err(skb, opt, type, code, offset, info, &udplite_table);
  26. }
  27. static const struct inet6_protocol udplitev6_protocol = {
  28. .handler = udplitev6_rcv,
  29. .err_handler = udplitev6_err,
  30. .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
  31. };
  32. struct proto udplitev6_prot = {
  33. .name = "UDPLITEv6",
  34. .owner = THIS_MODULE,
  35. .close = udp_lib_close,
  36. .connect = ip6_datagram_connect,
  37. .disconnect = udp_disconnect,
  38. .ioctl = udp_ioctl,
  39. .init = udplite_sk_init,
  40. .destroy = udpv6_destroy_sock,
  41. .setsockopt = udpv6_setsockopt,
  42. .getsockopt = udpv6_getsockopt,
  43. .sendmsg = udpv6_sendmsg,
  44. .recvmsg = udpv6_recvmsg,
  45. .hash = udp_lib_hash,
  46. .unhash = udp_lib_unhash,
  47. .get_port = udp_v6_get_port,
  48. .memory_allocated = &udp_memory_allocated,
  49. .sysctl_mem = sysctl_udp_mem,
  50. .obj_size = sizeof(struct udp6_sock),
  51. .h.udp_table = &udplite_table,
  52. #ifdef CONFIG_COMPAT
  53. .compat_setsockopt = compat_udpv6_setsockopt,
  54. .compat_getsockopt = compat_udpv6_getsockopt,
  55. #endif
  56. };
  57. static struct inet_protosw udplite6_protosw = {
  58. .type = SOCK_DGRAM,
  59. .protocol = IPPROTO_UDPLITE,
  60. .prot = &udplitev6_prot,
  61. .ops = &inet6_dgram_ops,
  62. .flags = INET_PROTOSW_PERMANENT,
  63. };
  64. int __init udplitev6_init(void)
  65. {
  66. int ret;
  67. ret = inet6_add_protocol(&udplitev6_protocol, IPPROTO_UDPLITE);
  68. if (ret)
  69. goto out;
  70. ret = inet6_register_protosw(&udplite6_protosw);
  71. if (ret)
  72. goto out_udplitev6_protocol;
  73. out:
  74. return ret;
  75. out_udplitev6_protocol:
  76. inet6_del_protocol(&udplitev6_protocol, IPPROTO_UDPLITE);
  77. goto out;
  78. }
  79. void udplitev6_exit(void)
  80. {
  81. inet6_unregister_protosw(&udplite6_protosw);
  82. inet6_del_protocol(&udplitev6_protocol, IPPROTO_UDPLITE);
  83. }
  84. #ifdef CONFIG_PROC_FS
  85. static struct udp_seq_afinfo udplite6_seq_afinfo = {
  86. .family = AF_INET6,
  87. .udp_table = &udplite_table,
  88. };
  89. static int __net_init udplite6_proc_init_net(struct net *net)
  90. {
  91. if (!proc_create_net_data("udplite6", 0444, net->proc_net,
  92. &udp6_seq_ops, sizeof(struct udp_iter_state),
  93. &udplite6_seq_afinfo))
  94. return -ENOMEM;
  95. return 0;
  96. }
  97. static void __net_exit udplite6_proc_exit_net(struct net *net)
  98. {
  99. remove_proc_entry("udplite6", net->proc_net);
  100. }
  101. static struct pernet_operations udplite6_net_ops = {
  102. .init = udplite6_proc_init_net,
  103. .exit = udplite6_proc_exit_net,
  104. };
  105. int __init udplite6_proc_init(void)
  106. {
  107. return register_pernet_subsys(&udplite6_net_ops);
  108. }
  109. void udplite6_proc_exit(void)
  110. {
  111. unregister_pernet_subsys(&udplite6_net_ops);
  112. }
  113. #endif