Commit | Line | Data |
---|---|---|
ba4e58ec GR |
1 | /* |
2 | * UDPLITE An implementation of the UDP-Lite protocol (RFC 3828). | |
3 | * | |
ba4e58ec GR |
4 | * Authors: Gerrit Renker <gerrit@erg.abdn.ac.uk> |
5 | * | |
6 | * Changes: | |
7 | * Fixes: | |
8 | * This program is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU General Public License | |
10 | * as published by the Free Software Foundation; either version | |
11 | * 2 of the License, or (at your option) any later version. | |
12 | */ | |
13 | #include "udp_impl.h" | |
ba4e58ec GR |
14 | |
15 | struct hlist_head udplite_hash[UDP_HTABLE_SIZE]; | |
ba4e58ec | 16 | |
f5b99bcd | 17 | static int udplite_rcv(struct sk_buff *skb) |
ba4e58ec | 18 | { |
759e5d00 | 19 | return __udp4_lib_rcv(skb, udplite_hash, IPPROTO_UDPLITE); |
ba4e58ec GR |
20 | } |
21 | ||
f5b99bcd | 22 | static void udplite_err(struct sk_buff *skb, u32 info) |
ba4e58ec | 23 | { |
fc80be87 | 24 | __udp4_lib_err(skb, info, udplite_hash); |
ba4e58ec GR |
25 | } |
26 | ||
27 | static struct net_protocol udplite_protocol = { | |
28 | .handler = udplite_rcv, | |
29 | .err_handler = udplite_err, | |
30 | .no_policy = 1, | |
92f1fecb | 31 | .netns_ok = 1, |
ba4e58ec GR |
32 | }; |
33 | ||
34 | struct proto udplite_prot = { | |
35 | .name = "UDP-Lite", | |
36 | .owner = THIS_MODULE, | |
37 | .close = udp_lib_close, | |
38 | .connect = ip4_datagram_connect, | |
39 | .disconnect = udp_disconnect, | |
40 | .ioctl = udp_ioctl, | |
41 | .init = udplite_sk_init, | |
42 | .destroy = udp_destroy_sock, | |
43 | .setsockopt = udp_setsockopt, | |
44 | .getsockopt = udp_getsockopt, | |
45 | .sendmsg = udp_sendmsg, | |
46 | .recvmsg = udp_recvmsg, | |
47 | .sendpage = udp_sendpage, | |
48 | .backlog_rcv = udp_queue_rcv_skb, | |
49 | .hash = udp_lib_hash, | |
50 | .unhash = udp_lib_unhash, | |
6ba5a3c5 | 51 | .get_port = udp_v4_get_port, |
ba4e58ec | 52 | .obj_size = sizeof(struct udp_sock), |
6ba5a3c5 | 53 | .h.udp_hash = udplite_hash, |
ba4e58ec GR |
54 | #ifdef CONFIG_COMPAT |
55 | .compat_setsockopt = compat_udp_setsockopt, | |
56 | .compat_getsockopt = compat_udp_getsockopt, | |
57 | #endif | |
58 | }; | |
59 | ||
60 | static struct inet_protosw udplite4_protosw = { | |
61 | .type = SOCK_DGRAM, | |
62 | .protocol = IPPROTO_UDPLITE, | |
63 | .prot = &udplite_prot, | |
64 | .ops = &inet_dgram_ops, | |
65 | .capability = -1, | |
66 | .no_check = 0, /* must checksum (RFC 3828) */ | |
67 | .flags = INET_PROTOSW_PERMANENT, | |
68 | }; | |
69 | ||
70 | #ifdef CONFIG_PROC_FS | |
ba4e58ec | 71 | static struct udp_seq_afinfo udplite4_seq_afinfo = { |
ba4e58ec GR |
72 | .name = "udplite", |
73 | .family = AF_INET, | |
74 | .hashtable = udplite_hash, | |
4ad96d39 DL |
75 | .seq_fops = { |
76 | .owner = THIS_MODULE, | |
77 | }, | |
dda61925 DL |
78 | .seq_ops = { |
79 | .show = udp4_seq_show, | |
80 | }, | |
ba4e58ec | 81 | }; |
ff2bac6a | 82 | |
84c375af PE |
83 | static int udplite4_proc_init_net(struct net *net) |
84 | { | |
85 | return udp_proc_register(net, &udplite4_seq_afinfo); | |
86 | } | |
87 | ||
88 | static void udplite4_proc_exit_net(struct net *net) | |
89 | { | |
90 | udp_proc_unregister(net, &udplite4_seq_afinfo); | |
91 | } | |
92 | ||
93 | static struct pernet_operations udplite4_net_ops = { | |
94 | .init = udplite4_proc_init_net, | |
95 | .exit = udplite4_proc_exit_net, | |
96 | }; | |
97 | ||
ff2bac6a PE |
98 | static __init int udplite4_proc_init(void) |
99 | { | |
84c375af | 100 | return register_pernet_subsys(&udplite4_net_ops); |
ff2bac6a PE |
101 | } |
102 | #else | |
103 | static inline int udplite4_proc_init(void) | |
104 | { | |
105 | return 0; | |
106 | } | |
ba4e58ec GR |
107 | #endif |
108 | ||
109 | void __init udplite4_register(void) | |
110 | { | |
111 | if (proto_register(&udplite_prot, 1)) | |
112 | goto out_register_err; | |
113 | ||
114 | if (inet_add_protocol(&udplite_protocol, IPPROTO_UDPLITE) < 0) | |
115 | goto out_unregister_proto; | |
116 | ||
117 | inet_register_protosw(&udplite4_protosw); | |
118 | ||
ff2bac6a | 119 | if (udplite4_proc_init()) |
0dc47877 | 120 | printk(KERN_ERR "%s: Cannot register /proc!\n", __func__); |
ba4e58ec GR |
121 | return; |
122 | ||
123 | out_unregister_proto: | |
124 | proto_unregister(&udplite_prot); | |
125 | out_register_err: | |
0dc47877 | 126 | printk(KERN_CRIT "%s: Cannot add UDP-Lite protocol.\n", __func__); |
ba4e58ec GR |
127 | } |
128 | ||
129 | EXPORT_SYMBOL(udplite_hash); | |
130 | EXPORT_SYMBOL(udplite_prot); |