net/sched: tunnel_key: Allow to set tos and ttl for tc based ip tunnels
[sfrench/cifs-2.6.git] / net / sched / act_tunnel_key.c
1 /*
2  * Copyright (c) 2016, Amir Vadai <amir@vadai.me>
3  * Copyright (c) 2016, Mellanox Technologies. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  */
10
11 #include <linux/module.h>
12 #include <linux/init.h>
13 #include <linux/kernel.h>
14 #include <linux/skbuff.h>
15 #include <linux/rtnetlink.h>
16 #include <net/geneve.h>
17 #include <net/netlink.h>
18 #include <net/pkt_sched.h>
19 #include <net/dst.h>
20
21 #include <linux/tc_act/tc_tunnel_key.h>
22 #include <net/tc_act/tc_tunnel_key.h>
23
24 static unsigned int tunnel_key_net_id;
25 static struct tc_action_ops act_tunnel_key_ops;
26
27 static int tunnel_key_act(struct sk_buff *skb, const struct tc_action *a,
28                           struct tcf_result *res)
29 {
30         struct tcf_tunnel_key *t = to_tunnel_key(a);
31         struct tcf_tunnel_key_params *params;
32         int action;
33
34         rcu_read_lock();
35
36         params = rcu_dereference(t->params);
37
38         tcf_lastuse_update(&t->tcf_tm);
39         bstats_cpu_update(this_cpu_ptr(t->common.cpu_bstats), skb);
40         action = params->action;
41
42         switch (params->tcft_action) {
43         case TCA_TUNNEL_KEY_ACT_RELEASE:
44                 skb_dst_drop(skb);
45                 break;
46         case TCA_TUNNEL_KEY_ACT_SET:
47                 skb_dst_drop(skb);
48                 skb_dst_set(skb, dst_clone(&params->tcft_enc_metadata->dst));
49                 break;
50         default:
51                 WARN_ONCE(1, "Bad tunnel_key action %d.\n",
52                           params->tcft_action);
53                 break;
54         }
55
56         rcu_read_unlock();
57
58         return action;
59 }
60
61 static const struct nla_policy
62 enc_opts_policy[TCA_TUNNEL_KEY_ENC_OPTS_MAX + 1] = {
63         [TCA_TUNNEL_KEY_ENC_OPTS_GENEVE]        = { .type = NLA_NESTED },
64 };
65
66 static const struct nla_policy
67 geneve_opt_policy[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_MAX + 1] = {
68         [TCA_TUNNEL_KEY_ENC_OPT_GENEVE_CLASS]      = { .type = NLA_U16 },
69         [TCA_TUNNEL_KEY_ENC_OPT_GENEVE_TYPE]       = { .type = NLA_U8 },
70         [TCA_TUNNEL_KEY_ENC_OPT_GENEVE_DATA]       = { .type = NLA_BINARY,
71                                                        .len = 128 },
72 };
73
74 static int
75 tunnel_key_copy_geneve_opt(const struct nlattr *nla, void *dst, int dst_len,
76                            struct netlink_ext_ack *extack)
77 {
78         struct nlattr *tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_MAX + 1];
79         int err, data_len, opt_len;
80         u8 *data;
81
82         err = nla_parse_nested(tb, TCA_TUNNEL_KEY_ENC_OPT_GENEVE_MAX,
83                                nla, geneve_opt_policy, extack);
84         if (err < 0)
85                 return err;
86
87         if (!tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_CLASS] ||
88             !tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_TYPE] ||
89             !tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_DATA]) {
90                 NL_SET_ERR_MSG(extack, "Missing tunnel key geneve option class, type or data");
91                 return -EINVAL;
92         }
93
94         data = nla_data(tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_DATA]);
95         data_len = nla_len(tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_DATA]);
96         if (data_len < 4) {
97                 NL_SET_ERR_MSG(extack, "Tunnel key geneve option data is less than 4 bytes long");
98                 return -ERANGE;
99         }
100         if (data_len % 4) {
101                 NL_SET_ERR_MSG(extack, "Tunnel key geneve option data is not a multiple of 4 bytes long");
102                 return -ERANGE;
103         }
104
105         opt_len = sizeof(struct geneve_opt) + data_len;
106         if (dst) {
107                 struct geneve_opt *opt = dst;
108
109                 WARN_ON(dst_len < opt_len);
110
111                 opt->opt_class =
112                         nla_get_be16(tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_CLASS]);
113                 opt->type = nla_get_u8(tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_TYPE]);
114                 opt->length = data_len / 4; /* length is in units of 4 bytes */
115                 opt->r1 = 0;
116                 opt->r2 = 0;
117                 opt->r3 = 0;
118
119                 memcpy(opt + 1, data, data_len);
120         }
121
122         return opt_len;
123 }
124
125 static int tunnel_key_copy_opts(const struct nlattr *nla, u8 *dst,
126                                 int dst_len, struct netlink_ext_ack *extack)
127 {
128         int err, rem, opt_len, len = nla_len(nla), opts_len = 0;
129         const struct nlattr *attr, *head = nla_data(nla);
130
131         err = nla_validate(head, len, TCA_TUNNEL_KEY_ENC_OPTS_MAX,
132                            enc_opts_policy, extack);
133         if (err)
134                 return err;
135
136         nla_for_each_attr(attr, head, len, rem) {
137                 switch (nla_type(attr)) {
138                 case TCA_TUNNEL_KEY_ENC_OPTS_GENEVE:
139                         opt_len = tunnel_key_copy_geneve_opt(attr, dst,
140                                                              dst_len, extack);
141                         if (opt_len < 0)
142                                 return opt_len;
143                         opts_len += opt_len;
144                         if (dst) {
145                                 dst_len -= opt_len;
146                                 dst += opt_len;
147                         }
148                         break;
149                 }
150         }
151
152         if (!opts_len) {
153                 NL_SET_ERR_MSG(extack, "Empty list of tunnel options");
154                 return -EINVAL;
155         }
156
157         if (rem > 0) {
158                 NL_SET_ERR_MSG(extack, "Trailing data after parsing tunnel key options attributes");
159                 return -EINVAL;
160         }
161
162         return opts_len;
163 }
164
165 static int tunnel_key_get_opts_len(struct nlattr *nla,
166                                    struct netlink_ext_ack *extack)
167 {
168         return tunnel_key_copy_opts(nla, NULL, 0, extack);
169 }
170
171 static int tunnel_key_opts_set(struct nlattr *nla, struct ip_tunnel_info *info,
172                                int opts_len, struct netlink_ext_ack *extack)
173 {
174         info->options_len = opts_len;
175         switch (nla_type(nla_data(nla))) {
176         case TCA_TUNNEL_KEY_ENC_OPTS_GENEVE:
177 #if IS_ENABLED(CONFIG_INET)
178                 info->key.tun_flags |= TUNNEL_GENEVE_OPT;
179                 return tunnel_key_copy_opts(nla, ip_tunnel_info_opts(info),
180                                             opts_len, extack);
181 #else
182                 return -EAFNOSUPPORT;
183 #endif
184         default:
185                 NL_SET_ERR_MSG(extack, "Cannot set tunnel options for unknown tunnel type");
186                 return -EINVAL;
187         }
188 }
189
190 static const struct nla_policy tunnel_key_policy[TCA_TUNNEL_KEY_MAX + 1] = {
191         [TCA_TUNNEL_KEY_PARMS]      = { .len = sizeof(struct tc_tunnel_key) },
192         [TCA_TUNNEL_KEY_ENC_IPV4_SRC] = { .type = NLA_U32 },
193         [TCA_TUNNEL_KEY_ENC_IPV4_DST] = { .type = NLA_U32 },
194         [TCA_TUNNEL_KEY_ENC_IPV6_SRC] = { .len = sizeof(struct in6_addr) },
195         [TCA_TUNNEL_KEY_ENC_IPV6_DST] = { .len = sizeof(struct in6_addr) },
196         [TCA_TUNNEL_KEY_ENC_KEY_ID]   = { .type = NLA_U32 },
197         [TCA_TUNNEL_KEY_ENC_DST_PORT] = {.type = NLA_U16},
198         [TCA_TUNNEL_KEY_NO_CSUM]      = { .type = NLA_U8 },
199         [TCA_TUNNEL_KEY_ENC_OPTS]     = { .type = NLA_NESTED },
200         [TCA_TUNNEL_KEY_ENC_TOS]      = { .type = NLA_U8 },
201         [TCA_TUNNEL_KEY_ENC_TTL]      = { .type = NLA_U8 },
202 };
203
204 static int tunnel_key_init(struct net *net, struct nlattr *nla,
205                            struct nlattr *est, struct tc_action **a,
206                            int ovr, int bind, bool rtnl_held,
207                            struct netlink_ext_ack *extack)
208 {
209         struct tc_action_net *tn = net_generic(net, tunnel_key_net_id);
210         struct nlattr *tb[TCA_TUNNEL_KEY_MAX + 1];
211         struct tcf_tunnel_key_params *params_old;
212         struct tcf_tunnel_key_params *params_new;
213         struct metadata_dst *metadata = NULL;
214         struct tc_tunnel_key *parm;
215         struct tcf_tunnel_key *t;
216         bool exists = false;
217         __be16 dst_port = 0;
218         int opts_len = 0;
219         __be64 key_id;
220         __be16 flags;
221         u8 tos, ttl;
222         int ret = 0;
223         int err;
224
225         if (!nla) {
226                 NL_SET_ERR_MSG(extack, "Tunnel requires attributes to be passed");
227                 return -EINVAL;
228         }
229
230         err = nla_parse_nested(tb, TCA_TUNNEL_KEY_MAX, nla, tunnel_key_policy,
231                                extack);
232         if (err < 0) {
233                 NL_SET_ERR_MSG(extack, "Failed to parse nested tunnel key attributes");
234                 return err;
235         }
236
237         if (!tb[TCA_TUNNEL_KEY_PARMS]) {
238                 NL_SET_ERR_MSG(extack, "Missing tunnel key parameters");
239                 return -EINVAL;
240         }
241
242         parm = nla_data(tb[TCA_TUNNEL_KEY_PARMS]);
243         err = tcf_idr_check_alloc(tn, &parm->index, a, bind);
244         if (err < 0)
245                 return err;
246         exists = err;
247         if (exists && bind)
248                 return 0;
249
250         switch (parm->t_action) {
251         case TCA_TUNNEL_KEY_ACT_RELEASE:
252                 break;
253         case TCA_TUNNEL_KEY_ACT_SET:
254                 if (!tb[TCA_TUNNEL_KEY_ENC_KEY_ID]) {
255                         NL_SET_ERR_MSG(extack, "Missing tunnel key id");
256                         ret = -EINVAL;
257                         goto err_out;
258                 }
259
260                 key_id = key32_to_tunnel_id(nla_get_be32(tb[TCA_TUNNEL_KEY_ENC_KEY_ID]));
261
262                 flags = TUNNEL_KEY | TUNNEL_CSUM;
263                 if (tb[TCA_TUNNEL_KEY_NO_CSUM] &&
264                     nla_get_u8(tb[TCA_TUNNEL_KEY_NO_CSUM]))
265                         flags &= ~TUNNEL_CSUM;
266
267                 if (tb[TCA_TUNNEL_KEY_ENC_DST_PORT])
268                         dst_port = nla_get_be16(tb[TCA_TUNNEL_KEY_ENC_DST_PORT]);
269
270                 if (tb[TCA_TUNNEL_KEY_ENC_OPTS]) {
271                         opts_len = tunnel_key_get_opts_len(tb[TCA_TUNNEL_KEY_ENC_OPTS],
272                                                            extack);
273                         if (opts_len < 0) {
274                                 ret = opts_len;
275                                 goto err_out;
276                         }
277                 }
278
279                 tos = 0;
280                 if (tb[TCA_TUNNEL_KEY_ENC_TOS])
281                         tos = nla_get_u8(tb[TCA_TUNNEL_KEY_ENC_TOS]);
282                 ttl = 0;
283                 if (tb[TCA_TUNNEL_KEY_ENC_TTL])
284                         ttl = nla_get_u8(tb[TCA_TUNNEL_KEY_ENC_TTL]);
285
286                 if (tb[TCA_TUNNEL_KEY_ENC_IPV4_SRC] &&
287                     tb[TCA_TUNNEL_KEY_ENC_IPV4_DST]) {
288                         __be32 saddr;
289                         __be32 daddr;
290
291                         saddr = nla_get_in_addr(tb[TCA_TUNNEL_KEY_ENC_IPV4_SRC]);
292                         daddr = nla_get_in_addr(tb[TCA_TUNNEL_KEY_ENC_IPV4_DST]);
293
294                         metadata = __ip_tun_set_dst(saddr, daddr, tos, ttl,
295                                                     dst_port, flags,
296                                                     key_id, opts_len);
297                 } else if (tb[TCA_TUNNEL_KEY_ENC_IPV6_SRC] &&
298                            tb[TCA_TUNNEL_KEY_ENC_IPV6_DST]) {
299                         struct in6_addr saddr;
300                         struct in6_addr daddr;
301
302                         saddr = nla_get_in6_addr(tb[TCA_TUNNEL_KEY_ENC_IPV6_SRC]);
303                         daddr = nla_get_in6_addr(tb[TCA_TUNNEL_KEY_ENC_IPV6_DST]);
304
305                         metadata = __ipv6_tun_set_dst(&saddr, &daddr, tos, ttl, dst_port,
306                                                       0, flags,
307                                                       key_id, 0);
308                 } else {
309                         NL_SET_ERR_MSG(extack, "Missing either ipv4 or ipv6 src and dst");
310                         ret = -EINVAL;
311                         goto err_out;
312                 }
313
314                 if (!metadata) {
315                         NL_SET_ERR_MSG(extack, "Cannot allocate tunnel metadata dst");
316                         ret = -ENOMEM;
317                         goto err_out;
318                 }
319
320                 if (opts_len) {
321                         ret = tunnel_key_opts_set(tb[TCA_TUNNEL_KEY_ENC_OPTS],
322                                                   &metadata->u.tun_info,
323                                                   opts_len, extack);
324                         if (ret < 0)
325                                 goto err_out;
326                 }
327
328                 metadata->u.tun_info.mode |= IP_TUNNEL_INFO_TX;
329                 break;
330         default:
331                 NL_SET_ERR_MSG(extack, "Unknown tunnel key action");
332                 ret = -EINVAL;
333                 goto err_out;
334         }
335
336         if (!exists) {
337                 ret = tcf_idr_create(tn, parm->index, est, a,
338                                      &act_tunnel_key_ops, bind, true);
339                 if (ret) {
340                         NL_SET_ERR_MSG(extack, "Cannot create TC IDR");
341                         goto err_out;
342                 }
343
344                 ret = ACT_P_CREATED;
345         } else if (!ovr) {
346                 tcf_idr_release(*a, bind);
347                 NL_SET_ERR_MSG(extack, "TC IDR already exists");
348                 return -EEXIST;
349         }
350
351         t = to_tunnel_key(*a);
352
353         ASSERT_RTNL();
354         params_new = kzalloc(sizeof(*params_new), GFP_KERNEL);
355         if (unlikely(!params_new)) {
356                 tcf_idr_release(*a, bind);
357                 NL_SET_ERR_MSG(extack, "Cannot allocate tunnel key parameters");
358                 return -ENOMEM;
359         }
360
361         params_old = rtnl_dereference(t->params);
362
363         params_new->action = parm->action;
364         params_new->tcft_action = parm->t_action;
365         params_new->tcft_enc_metadata = metadata;
366
367         rcu_assign_pointer(t->params, params_new);
368
369         if (params_old)
370                 kfree_rcu(params_old, rcu);
371
372         if (ret == ACT_P_CREATED)
373                 tcf_idr_insert(tn, *a);
374
375         return ret;
376
377 err_out:
378         if (exists)
379                 tcf_idr_release(*a, bind);
380         else
381                 tcf_idr_cleanup(tn, parm->index);
382         return ret;
383 }
384
385 static void tunnel_key_release(struct tc_action *a)
386 {
387         struct tcf_tunnel_key *t = to_tunnel_key(a);
388         struct tcf_tunnel_key_params *params;
389
390         params = rcu_dereference_protected(t->params, 1);
391         if (params) {
392                 if (params->tcft_action == TCA_TUNNEL_KEY_ACT_SET)
393                         dst_release(&params->tcft_enc_metadata->dst);
394
395                 kfree_rcu(params, rcu);
396         }
397 }
398
399 static int tunnel_key_geneve_opts_dump(struct sk_buff *skb,
400                                        const struct ip_tunnel_info *info)
401 {
402         int len = info->options_len;
403         u8 *src = (u8 *)(info + 1);
404         struct nlattr *start;
405
406         start = nla_nest_start(skb, TCA_TUNNEL_KEY_ENC_OPTS_GENEVE);
407         if (!start)
408                 return -EMSGSIZE;
409
410         while (len > 0) {
411                 struct geneve_opt *opt = (struct geneve_opt *)src;
412
413                 if (nla_put_be16(skb, TCA_TUNNEL_KEY_ENC_OPT_GENEVE_CLASS,
414                                  opt->opt_class) ||
415                     nla_put_u8(skb, TCA_TUNNEL_KEY_ENC_OPT_GENEVE_TYPE,
416                                opt->type) ||
417                     nla_put(skb, TCA_TUNNEL_KEY_ENC_OPT_GENEVE_DATA,
418                             opt->length * 4, opt + 1))
419                         return -EMSGSIZE;
420
421                 len -= sizeof(struct geneve_opt) + opt->length * 4;
422                 src += sizeof(struct geneve_opt) + opt->length * 4;
423         }
424
425         nla_nest_end(skb, start);
426         return 0;
427 }
428
429 static int tunnel_key_opts_dump(struct sk_buff *skb,
430                                 const struct ip_tunnel_info *info)
431 {
432         struct nlattr *start;
433         int err;
434
435         if (!info->options_len)
436                 return 0;
437
438         start = nla_nest_start(skb, TCA_TUNNEL_KEY_ENC_OPTS);
439         if (!start)
440                 return -EMSGSIZE;
441
442         if (info->key.tun_flags & TUNNEL_GENEVE_OPT) {
443                 err = tunnel_key_geneve_opts_dump(skb, info);
444                 if (err)
445                         return err;
446         } else {
447                 return -EINVAL;
448         }
449
450         nla_nest_end(skb, start);
451         return 0;
452 }
453
454 static int tunnel_key_dump_addresses(struct sk_buff *skb,
455                                      const struct ip_tunnel_info *info)
456 {
457         unsigned short family = ip_tunnel_info_af(info);
458
459         if (family == AF_INET) {
460                 __be32 saddr = info->key.u.ipv4.src;
461                 __be32 daddr = info->key.u.ipv4.dst;
462
463                 if (!nla_put_in_addr(skb, TCA_TUNNEL_KEY_ENC_IPV4_SRC, saddr) &&
464                     !nla_put_in_addr(skb, TCA_TUNNEL_KEY_ENC_IPV4_DST, daddr))
465                         return 0;
466         }
467
468         if (family == AF_INET6) {
469                 const struct in6_addr *saddr6 = &info->key.u.ipv6.src;
470                 const struct in6_addr *daddr6 = &info->key.u.ipv6.dst;
471
472                 if (!nla_put_in6_addr(skb,
473                                       TCA_TUNNEL_KEY_ENC_IPV6_SRC, saddr6) &&
474                     !nla_put_in6_addr(skb,
475                                       TCA_TUNNEL_KEY_ENC_IPV6_DST, daddr6))
476                         return 0;
477         }
478
479         return -EINVAL;
480 }
481
482 static int tunnel_key_dump(struct sk_buff *skb, struct tc_action *a,
483                            int bind, int ref)
484 {
485         unsigned char *b = skb_tail_pointer(skb);
486         struct tcf_tunnel_key *t = to_tunnel_key(a);
487         struct tcf_tunnel_key_params *params;
488         struct tc_tunnel_key opt = {
489                 .index    = t->tcf_index,
490                 .refcnt   = refcount_read(&t->tcf_refcnt) - ref,
491                 .bindcnt  = atomic_read(&t->tcf_bindcnt) - bind,
492         };
493         struct tcf_t tm;
494
495         params = rtnl_dereference(t->params);
496
497         opt.t_action = params->tcft_action;
498         opt.action = params->action;
499
500         if (nla_put(skb, TCA_TUNNEL_KEY_PARMS, sizeof(opt), &opt))
501                 goto nla_put_failure;
502
503         if (params->tcft_action == TCA_TUNNEL_KEY_ACT_SET) {
504                 struct ip_tunnel_info *info =
505                         &params->tcft_enc_metadata->u.tun_info;
506                 struct ip_tunnel_key *key = &info->key;
507                 __be32 key_id = tunnel_id_to_key32(key->tun_id);
508
509                 if (nla_put_be32(skb, TCA_TUNNEL_KEY_ENC_KEY_ID, key_id) ||
510                     tunnel_key_dump_addresses(skb,
511                                               &params->tcft_enc_metadata->u.tun_info) ||
512                     nla_put_be16(skb, TCA_TUNNEL_KEY_ENC_DST_PORT, key->tp_dst) ||
513                     nla_put_u8(skb, TCA_TUNNEL_KEY_NO_CSUM,
514                                !(key->tun_flags & TUNNEL_CSUM)) ||
515                     tunnel_key_opts_dump(skb, info))
516                         goto nla_put_failure;
517
518                 if (key->tos && nla_put_u8(skb, TCA_TUNNEL_KEY_ENC_TOS, key->tos))
519                         goto nla_put_failure;
520
521                 if (key->ttl && nla_put_u8(skb, TCA_TUNNEL_KEY_ENC_TTL, key->ttl))
522                         goto nla_put_failure;
523         }
524
525         tcf_tm_dump(&tm, &t->tcf_tm);
526         if (nla_put_64bit(skb, TCA_TUNNEL_KEY_TM, sizeof(tm),
527                           &tm, TCA_TUNNEL_KEY_PAD))
528                 goto nla_put_failure;
529
530         return skb->len;
531
532 nla_put_failure:
533         nlmsg_trim(skb, b);
534         return -1;
535 }
536
537 static int tunnel_key_walker(struct net *net, struct sk_buff *skb,
538                              struct netlink_callback *cb, int type,
539                              const struct tc_action_ops *ops,
540                              struct netlink_ext_ack *extack)
541 {
542         struct tc_action_net *tn = net_generic(net, tunnel_key_net_id);
543
544         return tcf_generic_walker(tn, skb, cb, type, ops, extack);
545 }
546
547 static int tunnel_key_search(struct net *net, struct tc_action **a, u32 index,
548                              struct netlink_ext_ack *extack)
549 {
550         struct tc_action_net *tn = net_generic(net, tunnel_key_net_id);
551
552         return tcf_idr_search(tn, a, index);
553 }
554
555 static int tunnel_key_delete(struct net *net, u32 index)
556 {
557         struct tc_action_net *tn = net_generic(net, tunnel_key_net_id);
558
559         return tcf_idr_delete_index(tn, index);
560 }
561
562 static struct tc_action_ops act_tunnel_key_ops = {
563         .kind           =       "tunnel_key",
564         .type           =       TCA_ACT_TUNNEL_KEY,
565         .owner          =       THIS_MODULE,
566         .act            =       tunnel_key_act,
567         .dump           =       tunnel_key_dump,
568         .init           =       tunnel_key_init,
569         .cleanup        =       tunnel_key_release,
570         .walk           =       tunnel_key_walker,
571         .lookup         =       tunnel_key_search,
572         .delete         =       tunnel_key_delete,
573         .size           =       sizeof(struct tcf_tunnel_key),
574 };
575
576 static __net_init int tunnel_key_init_net(struct net *net)
577 {
578         struct tc_action_net *tn = net_generic(net, tunnel_key_net_id);
579
580         return tc_action_net_init(tn, &act_tunnel_key_ops);
581 }
582
583 static void __net_exit tunnel_key_exit_net(struct list_head *net_list)
584 {
585         tc_action_net_exit(net_list, tunnel_key_net_id);
586 }
587
588 static struct pernet_operations tunnel_key_net_ops = {
589         .init = tunnel_key_init_net,
590         .exit_batch = tunnel_key_exit_net,
591         .id   = &tunnel_key_net_id,
592         .size = sizeof(struct tc_action_net),
593 };
594
595 static int __init tunnel_key_init_module(void)
596 {
597         return tcf_register_action(&act_tunnel_key_ops, &tunnel_key_net_ops);
598 }
599
600 static void __exit tunnel_key_cleanup_module(void)
601 {
602         tcf_unregister_action(&act_tunnel_key_ops, &tunnel_key_net_ops);
603 }
604
605 module_init(tunnel_key_init_module);
606 module_exit(tunnel_key_cleanup_module);
607
608 MODULE_AUTHOR("Amir Vadai <amir@vadai.me>");
609 MODULE_DESCRIPTION("ip tunnel manipulation actions");
610 MODULE_LICENSE("GPL v2");