blob: 5738b97710676237ef2def3e149c4b82b7eebd66 [file] [log] [blame]
Tom Herbert23461552014-09-17 12:25:56 -07001#include <linux/module.h>
2#include <linux/errno.h>
3#include <linux/socket.h>
4#include <linux/skbuff.h>
5#include <linux/ip.h>
6#include <linux/udp.h>
7#include <linux/types.h>
8#include <linux/kernel.h>
9#include <net/genetlink.h>
Tom Herbert37dd0242014-10-03 15:48:09 -070010#include <net/gue.h>
Tom Herbert23461552014-09-17 12:25:56 -070011#include <net/ip.h>
Tom Herbertafe93322014-09-17 12:25:57 -070012#include <net/protocol.h>
Tom Herbert23461552014-09-17 12:25:56 -070013#include <net/udp.h>
14#include <net/udp_tunnel.h>
15#include <net/xfrm.h>
16#include <uapi/linux/fou.h>
17#include <uapi/linux/genetlink.h>
18
Tom Herbert23461552014-09-17 12:25:56 -070019struct fou {
20 struct socket *sock;
21 u8 protocol;
Tom Herbertfe881ef2015-02-10 16:30:33 -080022 u8 flags;
WANG Cong4cbcdf22015-04-10 12:00:28 -070023 __be16 port;
WANG Cong7a6c8c32015-04-10 12:00:30 -070024 u16 type;
Tom Herbert23461552014-09-17 12:25:56 -070025 struct list_head list;
Hannes Frederic Sowa3036fac2015-12-15 21:01:53 +010026 struct rcu_head rcu;
Tom Herbert23461552014-09-17 12:25:56 -070027};
28
Tom Herbertfe881ef2015-02-10 16:30:33 -080029#define FOU_F_REMCSUM_NOPARTIAL BIT(0)
30
Tom Herbert23461552014-09-17 12:25:56 -070031struct fou_cfg {
Tom Herbert37dd0242014-10-03 15:48:09 -070032 u16 type;
Tom Herbert23461552014-09-17 12:25:56 -070033 u8 protocol;
Tom Herbertfe881ef2015-02-10 16:30:33 -080034 u8 flags;
Tom Herbert23461552014-09-17 12:25:56 -070035 struct udp_port_cfg udp_config;
36};
37
WANG Cong02d793c2015-04-10 12:00:29 -070038static unsigned int fou_net_id;
39
40struct fou_net {
41 struct list_head fou_list;
42 struct mutex fou_lock;
43};
44
Tom Herbert23461552014-09-17 12:25:56 -070045static inline struct fou *fou_from_sock(struct sock *sk)
46{
47 return sk->sk_user_data;
48}
49
Jesse Grossa09a4c82016-03-19 09:32:02 -070050static int fou_recv_pull(struct sk_buff *skb, size_t len)
Tom Herbert23461552014-09-17 12:25:56 -070051{
52 struct iphdr *iph = ip_hdr(skb);
53
54 /* Remove 'len' bytes from the packet (UDP header and
Tom Herbert5024c332014-11-04 09:06:53 -080055 * FOU header if present).
Tom Herbert23461552014-09-17 12:25:56 -070056 */
57 iph->tot_len = htons(ntohs(iph->tot_len) - len);
58 __skb_pull(skb, len);
59 skb_postpull_rcsum(skb, udp_hdr(skb), len);
60 skb_reset_transport_header(skb);
Jesse Grossa09a4c82016-03-19 09:32:02 -070061 return iptunnel_pull_offloads(skb);
Tom Herbert23461552014-09-17 12:25:56 -070062}
63
64static int fou_udp_recv(struct sock *sk, struct sk_buff *skb)
65{
66 struct fou *fou = fou_from_sock(sk);
67
68 if (!fou)
69 return 1;
70
Jesse Grossa09a4c82016-03-19 09:32:02 -070071 if (fou_recv_pull(skb, sizeof(struct udphdr)))
72 goto drop;
Tom Herbert5024c332014-11-04 09:06:53 -080073
74 return -fou->protocol;
Jesse Grossa09a4c82016-03-19 09:32:02 -070075
76drop:
77 kfree_skb(skb);
78 return 0;
Tom Herbert5024c332014-11-04 09:06:53 -080079}
80
Tom Herberta8d31c12014-11-04 09:06:57 -080081static struct guehdr *gue_remcsum(struct sk_buff *skb, struct guehdr *guehdr,
Tom Herbertfe881ef2015-02-10 16:30:33 -080082 void *data, size_t hdrlen, u8 ipproto,
83 bool nopartial)
Tom Herberta8d31c12014-11-04 09:06:57 -080084{
85 __be16 *pd = data;
Tom Herbert4fd671d2014-11-25 11:21:20 -080086 size_t start = ntohs(pd[0]);
87 size_t offset = ntohs(pd[1]);
Tom Herbertb7fe10e2015-08-19 17:07:32 -070088 size_t plen = sizeof(struct udphdr) + hdrlen +
89 max_t(size_t, offset + sizeof(u16), start);
90
91 if (skb->remcsum_offload)
92 return guehdr;
Tom Herberta8d31c12014-11-04 09:06:57 -080093
Tom Herberta8d31c12014-11-04 09:06:57 -080094 if (!pskb_may_pull(skb, plen))
95 return NULL;
96 guehdr = (struct guehdr *)&udp_hdr(skb)[1];
97
Tom Herbertfe881ef2015-02-10 16:30:33 -080098 skb_remcsum_process(skb, (void *)guehdr + hdrlen,
99 start, offset, nopartial);
Tom Herberta8d31c12014-11-04 09:06:57 -0800100
101 return guehdr;
102}
103
Tom Herbert5024c332014-11-04 09:06:53 -0800104static int gue_control_message(struct sk_buff *skb, struct guehdr *guehdr)
105{
106 /* No support yet */
107 kfree_skb(skb);
108 return 0;
Tom Herbert23461552014-09-17 12:25:56 -0700109}
110
Tom Herbert37dd0242014-10-03 15:48:09 -0700111static int gue_udp_recv(struct sock *sk, struct sk_buff *skb)
112{
113 struct fou *fou = fou_from_sock(sk);
Tom Herbert5024c332014-11-04 09:06:53 -0800114 size_t len, optlen, hdrlen;
Tom Herbert37dd0242014-10-03 15:48:09 -0700115 struct guehdr *guehdr;
Tom Herbert5024c332014-11-04 09:06:53 -0800116 void *data;
Tom Herberta8d31c12014-11-04 09:06:57 -0800117 u16 doffset = 0;
Tom Herbert37dd0242014-10-03 15:48:09 -0700118
119 if (!fou)
120 return 1;
121
122 len = sizeof(struct udphdr) + sizeof(struct guehdr);
123 if (!pskb_may_pull(skb, len))
124 goto drop;
125
Tom Herbert5024c332014-11-04 09:06:53 -0800126 guehdr = (struct guehdr *)&udp_hdr(skb)[1];
Tom Herbert37dd0242014-10-03 15:48:09 -0700127
Tom Herbert5024c332014-11-04 09:06:53 -0800128 optlen = guehdr->hlen << 2;
129 len += optlen;
130
Tom Herbert37dd0242014-10-03 15:48:09 -0700131 if (!pskb_may_pull(skb, len))
132 goto drop;
133
Tom Herbert5024c332014-11-04 09:06:53 -0800134 /* guehdr may change after pull */
135 guehdr = (struct guehdr *)&udp_hdr(skb)[1];
Li RongQingd8f00d22014-10-17 16:53:47 +0800136
Tom Herbert5024c332014-11-04 09:06:53 -0800137 hdrlen = sizeof(struct guehdr) + optlen;
138
139 if (guehdr->version != 0 || validate_gue_flags(guehdr, optlen))
Tom Herbert37dd0242014-10-03 15:48:09 -0700140 goto drop;
141
Tom Herberta8d31c12014-11-04 09:06:57 -0800142 hdrlen = sizeof(struct guehdr) + optlen;
143
144 ip_hdr(skb)->tot_len = htons(ntohs(ip_hdr(skb)->tot_len) - len);
145
Tom Herberta8d31c12014-11-04 09:06:57 -0800146 /* Pull csum through the guehdr now . This can be used if
147 * there is a remote checksum offload.
148 */
149 skb_postpull_rcsum(skb, udp_hdr(skb), len);
Tom Herbert5024c332014-11-04 09:06:53 -0800150
151 data = &guehdr[1];
152
153 if (guehdr->flags & GUE_FLAG_PRIV) {
Tom Herberta8d31c12014-11-04 09:06:57 -0800154 __be32 flags = *(__be32 *)(data + doffset);
Tom Herbert5024c332014-11-04 09:06:53 -0800155
Tom Herberta8d31c12014-11-04 09:06:57 -0800156 doffset += GUE_LEN_PRIV;
157
158 if (flags & GUE_PFLAG_REMCSUM) {
159 guehdr = gue_remcsum(skb, guehdr, data + doffset,
Tom Herbertfe881ef2015-02-10 16:30:33 -0800160 hdrlen, guehdr->proto_ctype,
161 !!(fou->flags &
162 FOU_F_REMCSUM_NOPARTIAL));
Tom Herberta8d31c12014-11-04 09:06:57 -0800163 if (!guehdr)
164 goto drop;
165
166 data = &guehdr[1];
167
168 doffset += GUE_PLEN_REMCSUM;
169 }
Tom Herbert37dd0242014-10-03 15:48:09 -0700170 }
171
Tom Herbert5024c332014-11-04 09:06:53 -0800172 if (unlikely(guehdr->control))
173 return gue_control_message(skb, guehdr);
174
Tom Herbert4fd671d2014-11-25 11:21:20 -0800175 __skb_pull(skb, sizeof(struct udphdr) + hdrlen);
Tom Herberta8d31c12014-11-04 09:06:57 -0800176 skb_reset_transport_header(skb);
177
Jesse Grossa09a4c82016-03-19 09:32:02 -0700178 if (iptunnel_pull_offloads(skb))
179 goto drop;
180
Tom Herbert5024c332014-11-04 09:06:53 -0800181 return -guehdr->proto_ctype;
182
Tom Herbert37dd0242014-10-03 15:48:09 -0700183drop:
184 kfree_skb(skb);
185 return 0;
186}
187
Tom Herbertd92283e2016-04-05 08:22:54 -0700188static struct sk_buff **fou_gro_receive(struct sock *sk,
189 struct sk_buff **head,
190 struct sk_buff *skb)
Tom Herbertafe93322014-09-17 12:25:57 -0700191{
192 const struct net_offload *ops;
193 struct sk_buff **pp = NULL;
Tom Herbertd92283e2016-04-05 08:22:54 -0700194 u8 proto = fou_from_sock(sk)->protocol;
Tom Herbertefc98d02014-10-03 15:48:08 -0700195 const struct net_offload **offloads;
Tom Herbertafe93322014-09-17 12:25:57 -0700196
Alexander Duyckc3483382016-03-29 14:55:22 -0700197 /* We can clear the encap_mark for FOU as we are essentially doing
198 * one of two possible things. We are either adding an L4 tunnel
199 * header to the outer L3 tunnel header, or we are are simply
200 * treating the GRE tunnel header as though it is a UDP protocol
201 * specific header such as VXLAN or GENEVE.
202 */
203 NAPI_GRO_CB(skb)->encap_mark = 0;
204
Tom Herbertafe93322014-09-17 12:25:57 -0700205 rcu_read_lock();
Tom Herbertefc98d02014-10-03 15:48:08 -0700206 offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
Tom Herbertafe93322014-09-17 12:25:57 -0700207 ops = rcu_dereference(offloads[proto]);
208 if (!ops || !ops->callbacks.gro_receive)
209 goto out_unlock;
210
211 pp = ops->callbacks.gro_receive(head, skb);
212
213out_unlock:
214 rcu_read_unlock();
215
216 return pp;
217}
218
Tom Herbertd92283e2016-04-05 08:22:54 -0700219static int fou_gro_complete(struct sock *sk, struct sk_buff *skb,
220 int nhoff)
Tom Herbertafe93322014-09-17 12:25:57 -0700221{
222 const struct net_offload *ops;
Tom Herbertd92283e2016-04-05 08:22:54 -0700223 u8 proto = fou_from_sock(sk)->protocol;
Tom Herbertafe93322014-09-17 12:25:57 -0700224 int err = -ENOSYS;
Tom Herbertefc98d02014-10-03 15:48:08 -0700225 const struct net_offload **offloads;
Tom Herbertafe93322014-09-17 12:25:57 -0700226
Jesse Grosscfdf1e12014-11-10 11:45:13 -0800227 udp_tunnel_gro_complete(skb, nhoff);
228
Tom Herbertafe93322014-09-17 12:25:57 -0700229 rcu_read_lock();
Tom Herbertefc98d02014-10-03 15:48:08 -0700230 offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
Tom Herbertafe93322014-09-17 12:25:57 -0700231 ops = rcu_dereference(offloads[proto]);
232 if (WARN_ON(!ops || !ops->callbacks.gro_complete))
233 goto out_unlock;
234
235 err = ops->callbacks.gro_complete(skb, nhoff);
236
237out_unlock:
238 rcu_read_unlock();
239
240 return err;
241}
242
Tom Herberta8d31c12014-11-04 09:06:57 -0800243static struct guehdr *gue_gro_remcsum(struct sk_buff *skb, unsigned int off,
244 struct guehdr *guehdr, void *data,
Tom Herbertb7fe10e2015-08-19 17:07:32 -0700245 size_t hdrlen, struct gro_remcsum *grc,
246 bool nopartial)
Tom Herberta8d31c12014-11-04 09:06:57 -0800247{
248 __be16 *pd = data;
Tom Herbert4fd671d2014-11-25 11:21:20 -0800249 size_t start = ntohs(pd[0]);
250 size_t offset = ntohs(pd[1]);
Tom Herberta8d31c12014-11-04 09:06:57 -0800251
252 if (skb->remcsum_offload)
Tom Herbertb7fe10e2015-08-19 17:07:32 -0700253 return guehdr;
Tom Herberta8d31c12014-11-04 09:06:57 -0800254
Tom Herbert4fd671d2014-11-25 11:21:20 -0800255 if (!NAPI_GRO_CB(skb)->csum_valid)
Tom Herberta8d31c12014-11-04 09:06:57 -0800256 return NULL;
257
Tom Herbertb7fe10e2015-08-19 17:07:32 -0700258 guehdr = skb_gro_remcsum_process(skb, (void *)guehdr, off, hdrlen,
259 start, offset, grc, nopartial);
Tom Herberta8d31c12014-11-04 09:06:57 -0800260
261 skb->remcsum_offload = 1;
262
263 return guehdr;
264}
265
Tom Herbertd92283e2016-04-05 08:22:54 -0700266static struct sk_buff **gue_gro_receive(struct sock *sk,
267 struct sk_buff **head,
268 struct sk_buff *skb)
Tom Herbert37dd0242014-10-03 15:48:09 -0700269{
270 const struct net_offload **offloads;
271 const struct net_offload *ops;
272 struct sk_buff **pp = NULL;
273 struct sk_buff *p;
Tom Herbert37dd0242014-10-03 15:48:09 -0700274 struct guehdr *guehdr;
Tom Herbert5024c332014-11-04 09:06:53 -0800275 size_t len, optlen, hdrlen, off;
276 void *data;
Tom Herberta8d31c12014-11-04 09:06:57 -0800277 u16 doffset = 0;
Tom Herbert37dd0242014-10-03 15:48:09 -0700278 int flush = 1;
Tom Herbertd92283e2016-04-05 08:22:54 -0700279 struct fou *fou = fou_from_sock(sk);
Tom Herbert26c4f7d2015-02-10 16:30:27 -0800280 struct gro_remcsum grc;
281
282 skb_gro_remcsum_init(&grc);
Tom Herbert37dd0242014-10-03 15:48:09 -0700283
284 off = skb_gro_offset(skb);
Tom Herbert5024c332014-11-04 09:06:53 -0800285 len = off + sizeof(*guehdr);
286
Tom Herbert37dd0242014-10-03 15:48:09 -0700287 guehdr = skb_gro_header_fast(skb, off);
Tom Herbert5024c332014-11-04 09:06:53 -0800288 if (skb_gro_header_hard(skb, len)) {
289 guehdr = skb_gro_header_slow(skb, len, off);
Tom Herbert37dd0242014-10-03 15:48:09 -0700290 if (unlikely(!guehdr))
291 goto out;
292 }
293
Tom Herbert5024c332014-11-04 09:06:53 -0800294 optlen = guehdr->hlen << 2;
295 len += optlen;
Tom Herbert37dd0242014-10-03 15:48:09 -0700296
Tom Herbert5024c332014-11-04 09:06:53 -0800297 if (skb_gro_header_hard(skb, len)) {
298 guehdr = skb_gro_header_slow(skb, len, off);
Tom Herbert37dd0242014-10-03 15:48:09 -0700299 if (unlikely(!guehdr))
Tom Herbert5024c332014-11-04 09:06:53 -0800300 goto out;
301 }
302
303 if (unlikely(guehdr->control) || guehdr->version != 0 ||
304 validate_gue_flags(guehdr, optlen))
305 goto out;
306
307 hdrlen = sizeof(*guehdr) + optlen;
308
Tom Herberta8d31c12014-11-04 09:06:57 -0800309 /* Adjust NAPI_GRO_CB(skb)->csum to account for guehdr,
310 * this is needed if there is a remote checkcsum offload.
311 */
Tom Herbert5024c332014-11-04 09:06:53 -0800312 skb_gro_postpull_rcsum(skb, guehdr, hdrlen);
313
314 data = &guehdr[1];
315
316 if (guehdr->flags & GUE_FLAG_PRIV) {
Tom Herberta8d31c12014-11-04 09:06:57 -0800317 __be32 flags = *(__be32 *)(data + doffset);
Tom Herbert5024c332014-11-04 09:06:53 -0800318
Tom Herberta8d31c12014-11-04 09:06:57 -0800319 doffset += GUE_LEN_PRIV;
320
321 if (flags & GUE_PFLAG_REMCSUM) {
322 guehdr = gue_gro_remcsum(skb, off, guehdr,
Tom Herbertb7fe10e2015-08-19 17:07:32 -0700323 data + doffset, hdrlen, &grc,
Tom Herbertfe881ef2015-02-10 16:30:33 -0800324 !!(fou->flags &
325 FOU_F_REMCSUM_NOPARTIAL));
Tom Herbertb7fe10e2015-08-19 17:07:32 -0700326
Tom Herberta8d31c12014-11-04 09:06:57 -0800327 if (!guehdr)
328 goto out;
329
330 data = &guehdr[1];
331
332 doffset += GUE_PLEN_REMCSUM;
333 }
Tom Herbert37dd0242014-10-03 15:48:09 -0700334 }
335
Tom Herberta8d31c12014-11-04 09:06:57 -0800336 skb_gro_pull(skb, hdrlen);
337
Tom Herbert37dd0242014-10-03 15:48:09 -0700338 for (p = *head; p; p = p->next) {
339 const struct guehdr *guehdr2;
340
341 if (!NAPI_GRO_CB(p)->same_flow)
342 continue;
343
344 guehdr2 = (struct guehdr *)(p->data + off);
345
346 /* Compare base GUE header to be equal (covers
Tom Herbert5024c332014-11-04 09:06:53 -0800347 * hlen, version, proto_ctype, and flags.
Tom Herbert37dd0242014-10-03 15:48:09 -0700348 */
349 if (guehdr->word != guehdr2->word) {
350 NAPI_GRO_CB(p)->same_flow = 0;
351 continue;
352 }
353
354 /* Compare optional fields are the same. */
355 if (guehdr->hlen && memcmp(&guehdr[1], &guehdr2[1],
356 guehdr->hlen << 2)) {
357 NAPI_GRO_CB(p)->same_flow = 0;
358 continue;
359 }
360 }
361
Alexander Duyckc3483382016-03-29 14:55:22 -0700362 /* We can clear the encap_mark for GUE as we are essentially doing
363 * one of two possible things. We are either adding an L4 tunnel
364 * header to the outer L3 tunnel header, or we are are simply
365 * treating the GRE tunnel header as though it is a UDP protocol
366 * specific header such as VXLAN or GENEVE.
367 */
368 NAPI_GRO_CB(skb)->encap_mark = 0;
369
Tom Herbert5024c332014-11-04 09:06:53 -0800370 rcu_read_lock();
371 offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
372 ops = rcu_dereference(offloads[guehdr->proto_ctype]);
Tom Herbert27013662015-08-19 17:07:34 -0700373 if (WARN_ON_ONCE(!ops || !ops->callbacks.gro_receive))
Tom Herbert5024c332014-11-04 09:06:53 -0800374 goto out_unlock;
Tom Herbert37dd0242014-10-03 15:48:09 -0700375
376 pp = ops->callbacks.gro_receive(head, skb);
Alexander Duyckc194cf92016-03-09 09:24:23 -0800377 flush = 0;
Tom Herbert37dd0242014-10-03 15:48:09 -0700378
379out_unlock:
380 rcu_read_unlock();
381out:
382 NAPI_GRO_CB(skb)->flush |= flush;
Tom Herbert26c4f7d2015-02-10 16:30:27 -0800383 skb_gro_remcsum_cleanup(skb, &grc);
Tom Herbert37dd0242014-10-03 15:48:09 -0700384
385 return pp;
386}
387
Tom Herbertd92283e2016-04-05 08:22:54 -0700388static int gue_gro_complete(struct sock *sk, struct sk_buff *skb, int nhoff)
Tom Herbert37dd0242014-10-03 15:48:09 -0700389{
390 const struct net_offload **offloads;
391 struct guehdr *guehdr = (struct guehdr *)(skb->data + nhoff);
392 const struct net_offload *ops;
393 unsigned int guehlen;
394 u8 proto;
395 int err = -ENOENT;
396
Tom Herbert5024c332014-11-04 09:06:53 -0800397 proto = guehdr->proto_ctype;
Tom Herbert37dd0242014-10-03 15:48:09 -0700398
399 guehlen = sizeof(*guehdr) + (guehdr->hlen << 2);
400
401 rcu_read_lock();
402 offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
403 ops = rcu_dereference(offloads[proto]);
404 if (WARN_ON(!ops || !ops->callbacks.gro_complete))
405 goto out_unlock;
406
407 err = ops->callbacks.gro_complete(skb, nhoff + guehlen);
408
409out_unlock:
410 rcu_read_unlock();
411 return err;
412}
413
WANG Cong02d793c2015-04-10 12:00:29 -0700414static int fou_add_to_port_list(struct net *net, struct fou *fou)
Tom Herbert23461552014-09-17 12:25:56 -0700415{
WANG Cong02d793c2015-04-10 12:00:29 -0700416 struct fou_net *fn = net_generic(net, fou_net_id);
Tom Herbert23461552014-09-17 12:25:56 -0700417 struct fou *fout;
418
WANG Cong02d793c2015-04-10 12:00:29 -0700419 mutex_lock(&fn->fou_lock);
420 list_for_each_entry(fout, &fn->fou_list, list) {
Tom Herbert23461552014-09-17 12:25:56 -0700421 if (fou->port == fout->port) {
WANG Cong02d793c2015-04-10 12:00:29 -0700422 mutex_unlock(&fn->fou_lock);
Tom Herbert23461552014-09-17 12:25:56 -0700423 return -EALREADY;
424 }
425 }
426
WANG Cong02d793c2015-04-10 12:00:29 -0700427 list_add(&fou->list, &fn->fou_list);
428 mutex_unlock(&fn->fou_lock);
Tom Herbert23461552014-09-17 12:25:56 -0700429
430 return 0;
431}
432
433static void fou_release(struct fou *fou)
434{
435 struct socket *sock = fou->sock;
Tom Herbert23461552014-09-17 12:25:56 -0700436
Tom Herbert23461552014-09-17 12:25:56 -0700437 list_del(&fou->list);
WANG Cong02d793c2015-04-10 12:00:29 -0700438 udp_tunnel_sock_release(sock);
Tom Herbert23461552014-09-17 12:25:56 -0700439
Hannes Frederic Sowa3036fac2015-12-15 21:01:53 +0100440 kfree_rcu(fou, rcu);
Tom Herbert23461552014-09-17 12:25:56 -0700441}
442
Tom Herbert37dd0242014-10-03 15:48:09 -0700443static int fou_encap_init(struct sock *sk, struct fou *fou, struct fou_cfg *cfg)
444{
445 udp_sk(sk)->encap_rcv = fou_udp_recv;
Tom Herbertd92283e2016-04-05 08:22:54 -0700446 udp_sk(sk)->gro_receive = fou_gro_receive;
447 udp_sk(sk)->gro_complete = fou_gro_complete;
448 fou_from_sock(sk)->protocol = cfg->protocol;
Tom Herbert37dd0242014-10-03 15:48:09 -0700449
450 return 0;
451}
452
453static int gue_encap_init(struct sock *sk, struct fou *fou, struct fou_cfg *cfg)
454{
455 udp_sk(sk)->encap_rcv = gue_udp_recv;
Tom Herbertd92283e2016-04-05 08:22:54 -0700456 udp_sk(sk)->gro_receive = gue_gro_receive;
457 udp_sk(sk)->gro_complete = gue_gro_complete;
Tom Herbert37dd0242014-10-03 15:48:09 -0700458
459 return 0;
460}
461
Tom Herbert23461552014-09-17 12:25:56 -0700462static int fou_create(struct net *net, struct fou_cfg *cfg,
463 struct socket **sockp)
464{
Tom Herbert23461552014-09-17 12:25:56 -0700465 struct socket *sock = NULL;
WANG Cong02d793c2015-04-10 12:00:29 -0700466 struct fou *fou = NULL;
Tom Herbert23461552014-09-17 12:25:56 -0700467 struct sock *sk;
WANG Cong02d793c2015-04-10 12:00:29 -0700468 int err;
Tom Herbert23461552014-09-17 12:25:56 -0700469
470 /* Open UDP socket */
471 err = udp_sock_create(net, &cfg->udp_config, &sock);
472 if (err < 0)
473 goto error;
474
475 /* Allocate FOU port structure */
476 fou = kzalloc(sizeof(*fou), GFP_KERNEL);
477 if (!fou) {
478 err = -ENOMEM;
479 goto error;
480 }
481
482 sk = sock->sk;
483
Tom Herbertfe881ef2015-02-10 16:30:33 -0800484 fou->flags = cfg->flags;
Tom Herbert37dd0242014-10-03 15:48:09 -0700485 fou->port = cfg->udp_config.local_udp_port;
486
487 /* Initial for fou type */
488 switch (cfg->type) {
489 case FOU_ENCAP_DIRECT:
490 err = fou_encap_init(sk, fou, cfg);
491 if (err)
492 goto error;
493 break;
494 case FOU_ENCAP_GUE:
495 err = gue_encap_init(sk, fou, cfg);
496 if (err)
497 goto error;
498 break;
499 default:
500 err = -EINVAL;
501 goto error;
502 }
Tom Herbert23461552014-09-17 12:25:56 -0700503
WANG Cong7a6c8c32015-04-10 12:00:30 -0700504 fou->type = cfg->type;
505
Tom Herbert23461552014-09-17 12:25:56 -0700506 udp_sk(sk)->encap_type = 1;
507 udp_encap_enable();
508
509 sk->sk_user_data = fou;
510 fou->sock = sock;
511
Tom Herbert224d0192015-01-05 13:56:14 -0800512 inet_inc_convert_csum(sk);
Tom Herbert23461552014-09-17 12:25:56 -0700513
514 sk->sk_allocation = GFP_ATOMIC;
515
WANG Cong02d793c2015-04-10 12:00:29 -0700516 err = fou_add_to_port_list(net, fou);
Tom Herbert23461552014-09-17 12:25:56 -0700517 if (err)
518 goto error;
519
520 if (sockp)
521 *sockp = sock;
522
523 return 0;
524
525error:
526 kfree(fou);
527 if (sock)
WANG Cong02d793c2015-04-10 12:00:29 -0700528 udp_tunnel_sock_release(sock);
Tom Herbert23461552014-09-17 12:25:56 -0700529
530 return err;
531}
532
533static int fou_destroy(struct net *net, struct fou_cfg *cfg)
534{
WANG Cong02d793c2015-04-10 12:00:29 -0700535 struct fou_net *fn = net_generic(net, fou_net_id);
WANG Cong4cbcdf22015-04-10 12:00:28 -0700536 __be16 port = cfg->udp_config.local_udp_port;
Tom Herbert23461552014-09-17 12:25:56 -0700537 int err = -EINVAL;
WANG Cong02d793c2015-04-10 12:00:29 -0700538 struct fou *fou;
Tom Herbert23461552014-09-17 12:25:56 -0700539
WANG Cong02d793c2015-04-10 12:00:29 -0700540 mutex_lock(&fn->fou_lock);
541 list_for_each_entry(fou, &fn->fou_list, list) {
Tom Herbert23461552014-09-17 12:25:56 -0700542 if (fou->port == port) {
Tom Herbert23461552014-09-17 12:25:56 -0700543 fou_release(fou);
544 err = 0;
545 break;
546 }
547 }
WANG Cong02d793c2015-04-10 12:00:29 -0700548 mutex_unlock(&fn->fou_lock);
Tom Herbert23461552014-09-17 12:25:56 -0700549
550 return err;
551}
552
553static struct genl_family fou_nl_family = {
554 .id = GENL_ID_GENERATE,
555 .hdrsize = 0,
556 .name = FOU_GENL_NAME,
557 .version = FOU_GENL_VERSION,
558 .maxattr = FOU_ATTR_MAX,
559 .netnsok = true,
560};
561
562static struct nla_policy fou_nl_policy[FOU_ATTR_MAX + 1] = {
563 [FOU_ATTR_PORT] = { .type = NLA_U16, },
564 [FOU_ATTR_AF] = { .type = NLA_U8, },
565 [FOU_ATTR_IPPROTO] = { .type = NLA_U8, },
Tom Herbert37dd0242014-10-03 15:48:09 -0700566 [FOU_ATTR_TYPE] = { .type = NLA_U8, },
Tom Herbertfe881ef2015-02-10 16:30:33 -0800567 [FOU_ATTR_REMCSUM_NOPARTIAL] = { .type = NLA_FLAG, },
Tom Herbert23461552014-09-17 12:25:56 -0700568};
569
570static int parse_nl_config(struct genl_info *info,
571 struct fou_cfg *cfg)
572{
573 memset(cfg, 0, sizeof(*cfg));
574
575 cfg->udp_config.family = AF_INET;
576
577 if (info->attrs[FOU_ATTR_AF]) {
578 u8 family = nla_get_u8(info->attrs[FOU_ATTR_AF]);
579
Jiri Bencb9b66952015-08-28 20:48:21 +0200580 if (family != AF_INET)
Tom Herbert23461552014-09-17 12:25:56 -0700581 return -EINVAL;
582
583 cfg->udp_config.family = family;
584 }
585
586 if (info->attrs[FOU_ATTR_PORT]) {
WANG Cong4cbcdf22015-04-10 12:00:28 -0700587 __be16 port = nla_get_be16(info->attrs[FOU_ATTR_PORT]);
Tom Herbert23461552014-09-17 12:25:56 -0700588
589 cfg->udp_config.local_udp_port = port;
590 }
591
592 if (info->attrs[FOU_ATTR_IPPROTO])
593 cfg->protocol = nla_get_u8(info->attrs[FOU_ATTR_IPPROTO]);
594
Tom Herbert37dd0242014-10-03 15:48:09 -0700595 if (info->attrs[FOU_ATTR_TYPE])
596 cfg->type = nla_get_u8(info->attrs[FOU_ATTR_TYPE]);
597
Tom Herbertfe881ef2015-02-10 16:30:33 -0800598 if (info->attrs[FOU_ATTR_REMCSUM_NOPARTIAL])
599 cfg->flags |= FOU_F_REMCSUM_NOPARTIAL;
600
Tom Herbert23461552014-09-17 12:25:56 -0700601 return 0;
602}
603
604static int fou_nl_cmd_add_port(struct sk_buff *skb, struct genl_info *info)
605{
WANG Cong02d793c2015-04-10 12:00:29 -0700606 struct net *net = genl_info_net(info);
Tom Herbert23461552014-09-17 12:25:56 -0700607 struct fou_cfg cfg;
608 int err;
609
610 err = parse_nl_config(info, &cfg);
611 if (err)
612 return err;
613
WANG Cong02d793c2015-04-10 12:00:29 -0700614 return fou_create(net, &cfg, NULL);
Tom Herbert23461552014-09-17 12:25:56 -0700615}
616
617static int fou_nl_cmd_rm_port(struct sk_buff *skb, struct genl_info *info)
618{
WANG Cong02d793c2015-04-10 12:00:29 -0700619 struct net *net = genl_info_net(info);
Tom Herbert23461552014-09-17 12:25:56 -0700620 struct fou_cfg cfg;
WANG Cong67270632015-04-10 12:00:27 -0700621 int err;
Tom Herbert23461552014-09-17 12:25:56 -0700622
WANG Cong67270632015-04-10 12:00:27 -0700623 err = parse_nl_config(info, &cfg);
624 if (err)
625 return err;
Tom Herbert23461552014-09-17 12:25:56 -0700626
WANG Cong02d793c2015-04-10 12:00:29 -0700627 return fou_destroy(net, &cfg);
Tom Herbert23461552014-09-17 12:25:56 -0700628}
629
WANG Cong7a6c8c32015-04-10 12:00:30 -0700630static int fou_fill_info(struct fou *fou, struct sk_buff *msg)
631{
632 if (nla_put_u8(msg, FOU_ATTR_AF, fou->sock->sk->sk_family) ||
633 nla_put_be16(msg, FOU_ATTR_PORT, fou->port) ||
634 nla_put_u8(msg, FOU_ATTR_IPPROTO, fou->protocol) ||
635 nla_put_u8(msg, FOU_ATTR_TYPE, fou->type))
636 return -1;
637
638 if (fou->flags & FOU_F_REMCSUM_NOPARTIAL)
639 if (nla_put_flag(msg, FOU_ATTR_REMCSUM_NOPARTIAL))
640 return -1;
641 return 0;
642}
643
644static int fou_dump_info(struct fou *fou, u32 portid, u32 seq,
645 u32 flags, struct sk_buff *skb, u8 cmd)
646{
647 void *hdr;
648
649 hdr = genlmsg_put(skb, portid, seq, &fou_nl_family, flags, cmd);
650 if (!hdr)
651 return -ENOMEM;
652
653 if (fou_fill_info(fou, skb) < 0)
654 goto nla_put_failure;
655
656 genlmsg_end(skb, hdr);
657 return 0;
658
659nla_put_failure:
660 genlmsg_cancel(skb, hdr);
661 return -EMSGSIZE;
662}
663
664static int fou_nl_cmd_get_port(struct sk_buff *skb, struct genl_info *info)
665{
666 struct net *net = genl_info_net(info);
667 struct fou_net *fn = net_generic(net, fou_net_id);
668 struct sk_buff *msg;
669 struct fou_cfg cfg;
670 struct fou *fout;
671 __be16 port;
672 int ret;
673
674 ret = parse_nl_config(info, &cfg);
675 if (ret)
676 return ret;
677 port = cfg.udp_config.local_udp_port;
678 if (port == 0)
679 return -EINVAL;
680
681 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
682 if (!msg)
683 return -ENOMEM;
684
685 ret = -ESRCH;
686 mutex_lock(&fn->fou_lock);
687 list_for_each_entry(fout, &fn->fou_list, list) {
688 if (port == fout->port) {
689 ret = fou_dump_info(fout, info->snd_portid,
690 info->snd_seq, 0, msg,
691 info->genlhdr->cmd);
692 break;
693 }
694 }
695 mutex_unlock(&fn->fou_lock);
696 if (ret < 0)
697 goto out_free;
698
699 return genlmsg_reply(msg, info);
700
701out_free:
702 nlmsg_free(msg);
703 return ret;
704}
705
706static int fou_nl_dump(struct sk_buff *skb, struct netlink_callback *cb)
707{
708 struct net *net = sock_net(skb->sk);
709 struct fou_net *fn = net_generic(net, fou_net_id);
710 struct fou *fout;
711 int idx = 0, ret;
712
713 mutex_lock(&fn->fou_lock);
714 list_for_each_entry(fout, &fn->fou_list, list) {
715 if (idx++ < cb->args[0])
716 continue;
717 ret = fou_dump_info(fout, NETLINK_CB(cb->skb).portid,
718 cb->nlh->nlmsg_seq, NLM_F_MULTI,
719 skb, FOU_CMD_GET);
720 if (ret)
WANG Cong540207a2015-04-15 11:48:49 -0700721 break;
WANG Cong7a6c8c32015-04-10 12:00:30 -0700722 }
723 mutex_unlock(&fn->fou_lock);
724
WANG Cong7a6c8c32015-04-10 12:00:30 -0700725 cb->args[0] = idx;
726 return skb->len;
727}
728
Tom Herbert23461552014-09-17 12:25:56 -0700729static const struct genl_ops fou_nl_ops[] = {
730 {
731 .cmd = FOU_CMD_ADD,
732 .doit = fou_nl_cmd_add_port,
733 .policy = fou_nl_policy,
734 .flags = GENL_ADMIN_PERM,
735 },
736 {
737 .cmd = FOU_CMD_DEL,
738 .doit = fou_nl_cmd_rm_port,
739 .policy = fou_nl_policy,
740 .flags = GENL_ADMIN_PERM,
741 },
WANG Cong7a6c8c32015-04-10 12:00:30 -0700742 {
743 .cmd = FOU_CMD_GET,
744 .doit = fou_nl_cmd_get_port,
745 .dumpit = fou_nl_dump,
746 .policy = fou_nl_policy,
747 },
Tom Herbert23461552014-09-17 12:25:56 -0700748};
749
Tom Herberta8c5f902014-11-12 11:54:09 -0800750size_t fou_encap_hlen(struct ip_tunnel_encap *e)
751{
752 return sizeof(struct udphdr);
753}
754EXPORT_SYMBOL(fou_encap_hlen);
755
756size_t gue_encap_hlen(struct ip_tunnel_encap *e)
757{
758 size_t len;
759 bool need_priv = false;
760
761 len = sizeof(struct udphdr) + sizeof(struct guehdr);
762
763 if (e->flags & TUNNEL_ENCAP_FLAG_REMCSUM) {
764 len += GUE_PLEN_REMCSUM;
765 need_priv = true;
766 }
767
768 len += need_priv ? GUE_LEN_PRIV : 0;
769
770 return len;
771}
772EXPORT_SYMBOL(gue_encap_hlen);
773
Tom Herbert63487ba2014-11-04 09:06:51 -0800774static void fou_build_udp(struct sk_buff *skb, struct ip_tunnel_encap *e,
775 struct flowi4 *fl4, u8 *protocol, __be16 sport)
776{
777 struct udphdr *uh;
778
779 skb_push(skb, sizeof(struct udphdr));
780 skb_reset_transport_header(skb);
781
782 uh = udp_hdr(skb);
783
784 uh->dest = e->dport;
785 uh->source = sport;
786 uh->len = htons(skb->len);
Tom Herbert63487ba2014-11-04 09:06:51 -0800787 udp_set_csum(!(e->flags & TUNNEL_ENCAP_FLAG_CSUM), skb,
788 fl4->saddr, fl4->daddr, skb->len);
789
790 *protocol = IPPROTO_UDP;
791}
792
793int fou_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,
794 u8 *protocol, struct flowi4 *fl4)
795{
Edward Cree06f62292016-02-11 21:00:16 +0000796 int type = e->flags & TUNNEL_ENCAP_FLAG_CSUM ? SKB_GSO_UDP_TUNNEL_CSUM :
797 SKB_GSO_UDP_TUNNEL;
Tom Herbert63487ba2014-11-04 09:06:51 -0800798 __be16 sport;
799
Edward Cree6fa79662016-02-11 21:02:31 +0000800 skb = iptunnel_handle_offloads(skb, type);
Tom Herbert63487ba2014-11-04 09:06:51 -0800801
802 if (IS_ERR(skb))
803 return PTR_ERR(skb);
804
805 sport = e->sport ? : udp_flow_src_port(dev_net(skb->dev),
806 skb, 0, 0, false);
807 fou_build_udp(skb, e, fl4, protocol, sport);
808
809 return 0;
810}
811EXPORT_SYMBOL(fou_build_header);
812
813int gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,
814 u8 *protocol, struct flowi4 *fl4)
815{
Edward Cree06f62292016-02-11 21:00:16 +0000816 int type = e->flags & TUNNEL_ENCAP_FLAG_CSUM ? SKB_GSO_UDP_TUNNEL_CSUM :
817 SKB_GSO_UDP_TUNNEL;
Tom Herbert63487ba2014-11-04 09:06:51 -0800818 struct guehdr *guehdr;
Tom Herbertb17f7092014-11-04 09:06:56 -0800819 size_t hdrlen, optlen = 0;
Tom Herbert63487ba2014-11-04 09:06:51 -0800820 __be16 sport;
Tom Herbert5024c332014-11-04 09:06:53 -0800821 void *data;
822 bool need_priv = false;
823
Tom Herbertb17f7092014-11-04 09:06:56 -0800824 if ((e->flags & TUNNEL_ENCAP_FLAG_REMCSUM) &&
825 skb->ip_summed == CHECKSUM_PARTIAL) {
Tom Herbertb17f7092014-11-04 09:06:56 -0800826 optlen += GUE_PLEN_REMCSUM;
827 type |= SKB_GSO_TUNNEL_REMCSUM;
828 need_priv = true;
829 }
830
Tom Herbert5024c332014-11-04 09:06:53 -0800831 optlen += need_priv ? GUE_LEN_PRIV : 0;
Tom Herbert63487ba2014-11-04 09:06:51 -0800832
Edward Cree6fa79662016-02-11 21:02:31 +0000833 skb = iptunnel_handle_offloads(skb, type);
Tom Herbert63487ba2014-11-04 09:06:51 -0800834
835 if (IS_ERR(skb))
836 return PTR_ERR(skb);
837
838 /* Get source port (based on flow hash) before skb_push */
839 sport = e->sport ? : udp_flow_src_port(dev_net(skb->dev),
840 skb, 0, 0, false);
841
Tom Herbertb17f7092014-11-04 09:06:56 -0800842 hdrlen = sizeof(struct guehdr) + optlen;
843
844 skb_push(skb, hdrlen);
Tom Herbert63487ba2014-11-04 09:06:51 -0800845
846 guehdr = (struct guehdr *)skb->data;
847
Tom Herbert5024c332014-11-04 09:06:53 -0800848 guehdr->control = 0;
Tom Herbert63487ba2014-11-04 09:06:51 -0800849 guehdr->version = 0;
Tom Herbert5024c332014-11-04 09:06:53 -0800850 guehdr->hlen = optlen >> 2;
Tom Herbert63487ba2014-11-04 09:06:51 -0800851 guehdr->flags = 0;
Tom Herbert5024c332014-11-04 09:06:53 -0800852 guehdr->proto_ctype = *protocol;
853
854 data = &guehdr[1];
855
856 if (need_priv) {
857 __be32 *flags = data;
858
859 guehdr->flags |= GUE_FLAG_PRIV;
860 *flags = 0;
861 data += GUE_LEN_PRIV;
862
Tom Herbertb17f7092014-11-04 09:06:56 -0800863 if (type & SKB_GSO_TUNNEL_REMCSUM) {
864 u16 csum_start = skb_checksum_start_offset(skb);
865 __be16 *pd = data;
866
867 if (csum_start < hdrlen)
868 return -EINVAL;
869
870 csum_start -= hdrlen;
871 pd[0] = htons(csum_start);
872 pd[1] = htons(csum_start + skb->csum_offset);
873
874 if (!skb_is_gso(skb)) {
875 skb->ip_summed = CHECKSUM_NONE;
876 skb->encapsulation = 0;
877 }
878
879 *flags |= GUE_PFLAG_REMCSUM;
880 data += GUE_PLEN_REMCSUM;
881 }
882
Tom Herbert5024c332014-11-04 09:06:53 -0800883 }
Tom Herbert63487ba2014-11-04 09:06:51 -0800884
885 fou_build_udp(skb, e, fl4, protocol, sport);
886
887 return 0;
888}
889EXPORT_SYMBOL(gue_build_header);
890
Tom Herberta8c5f902014-11-12 11:54:09 -0800891#ifdef CONFIG_NET_FOU_IP_TUNNELS
892
Andi Kleen5eeb2922015-04-08 06:04:31 -0700893static const struct ip_tunnel_encap_ops fou_iptun_ops = {
Tom Herberta8c5f902014-11-12 11:54:09 -0800894 .encap_hlen = fou_encap_hlen,
895 .build_header = fou_build_header,
896};
897
Andi Kleen5eeb2922015-04-08 06:04:31 -0700898static const struct ip_tunnel_encap_ops gue_iptun_ops = {
Tom Herberta8c5f902014-11-12 11:54:09 -0800899 .encap_hlen = gue_encap_hlen,
900 .build_header = gue_build_header,
901};
902
903static int ip_tunnel_encap_add_fou_ops(void)
904{
905 int ret;
906
907 ret = ip_tunnel_encap_add_ops(&fou_iptun_ops, TUNNEL_ENCAP_FOU);
908 if (ret < 0) {
909 pr_err("can't add fou ops\n");
910 return ret;
911 }
912
913 ret = ip_tunnel_encap_add_ops(&gue_iptun_ops, TUNNEL_ENCAP_GUE);
914 if (ret < 0) {
915 pr_err("can't add gue ops\n");
916 ip_tunnel_encap_del_ops(&fou_iptun_ops, TUNNEL_ENCAP_FOU);
917 return ret;
918 }
919
920 return 0;
921}
922
923static void ip_tunnel_encap_del_fou_ops(void)
924{
925 ip_tunnel_encap_del_ops(&fou_iptun_ops, TUNNEL_ENCAP_FOU);
926 ip_tunnel_encap_del_ops(&gue_iptun_ops, TUNNEL_ENCAP_GUE);
927}
928
929#else
930
931static int ip_tunnel_encap_add_fou_ops(void)
932{
933 return 0;
934}
935
Thomas Graf882288c2014-11-13 12:48:21 +0100936static void ip_tunnel_encap_del_fou_ops(void)
Tom Herberta8c5f902014-11-12 11:54:09 -0800937{
938}
939
940#endif
941
WANG Cong02d793c2015-04-10 12:00:29 -0700942static __net_init int fou_init_net(struct net *net)
943{
944 struct fou_net *fn = net_generic(net, fou_net_id);
945
946 INIT_LIST_HEAD(&fn->fou_list);
947 mutex_init(&fn->fou_lock);
948 return 0;
949}
950
951static __net_exit void fou_exit_net(struct net *net)
952{
953 struct fou_net *fn = net_generic(net, fou_net_id);
954 struct fou *fou, *next;
955
956 /* Close all the FOU sockets */
957 mutex_lock(&fn->fou_lock);
958 list_for_each_entry_safe(fou, next, &fn->fou_list, list)
959 fou_release(fou);
960 mutex_unlock(&fn->fou_lock);
961}
962
963static struct pernet_operations fou_net_ops = {
964 .init = fou_init_net,
965 .exit = fou_exit_net,
966 .id = &fou_net_id,
967 .size = sizeof(struct fou_net),
968};
969
Tom Herbert23461552014-09-17 12:25:56 -0700970static int __init fou_init(void)
971{
972 int ret;
973
WANG Cong02d793c2015-04-10 12:00:29 -0700974 ret = register_pernet_device(&fou_net_ops);
975 if (ret)
Tom Herberta8c5f902014-11-12 11:54:09 -0800976 goto exit;
977
WANG Cong02d793c2015-04-10 12:00:29 -0700978 ret = genl_register_family_with_ops(&fou_nl_family,
979 fou_nl_ops);
Tom Herberta8c5f902014-11-12 11:54:09 -0800980 if (ret < 0)
WANG Cong02d793c2015-04-10 12:00:29 -0700981 goto unregister;
Tom Herberta8c5f902014-11-12 11:54:09 -0800982
WANG Cong02d793c2015-04-10 12:00:29 -0700983 ret = ip_tunnel_encap_add_fou_ops();
984 if (ret == 0)
985 return 0;
986
987 genl_unregister_family(&fou_nl_family);
988unregister:
989 unregister_pernet_device(&fou_net_ops);
Tom Herberta8c5f902014-11-12 11:54:09 -0800990exit:
Tom Herbert23461552014-09-17 12:25:56 -0700991 return ret;
992}
993
994static void __exit fou_fini(void)
995{
Tom Herberta8c5f902014-11-12 11:54:09 -0800996 ip_tunnel_encap_del_fou_ops();
Tom Herbert23461552014-09-17 12:25:56 -0700997 genl_unregister_family(&fou_nl_family);
WANG Cong02d793c2015-04-10 12:00:29 -0700998 unregister_pernet_device(&fou_net_ops);
Tom Herbert23461552014-09-17 12:25:56 -0700999}
1000
1001module_init(fou_init);
1002module_exit(fou_fini);
1003MODULE_AUTHOR("Tom Herbert <therbert@google.com>");
1004MODULE_LICENSE("GPL");