blob: 536c4bc31be60c35d0881fd3380aaebb42ab2d69 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Amir Vadaid0f6dd82016-09-08 16:23:48 +03002/*
3 * Copyright (c) 2016, Amir Vadai <amir@vadai.me>
4 * Copyright (c) 2016, Mellanox Technologies. All rights reserved.
Amir Vadaid0f6dd82016-09-08 16:23:48 +03005 */
6
7#include <linux/module.h>
8#include <linux/init.h>
9#include <linux/kernel.h>
10#include <linux/skbuff.h>
11#include <linux/rtnetlink.h>
Simon Horman0ed52692018-06-26 21:39:37 -070012#include <net/geneve.h>
Xin Longfca3f912019-11-21 18:03:26 +080013#include <net/vxlan.h>
Xin Longe20d4ff2019-11-21 18:03:27 +080014#include <net/erspan.h>
Amir Vadaid0f6dd82016-09-08 16:23:48 +030015#include <net/netlink.h>
16#include <net/pkt_sched.h>
17#include <net/dst.h>
Davide Carattie5fdaba2019-03-20 15:00:13 +010018#include <net/pkt_cls.h>
Amir Vadaid0f6dd82016-09-08 16:23:48 +030019
20#include <linux/tc_act/tc_tunnel_key.h>
21#include <net/tc_act/tc_tunnel_key.h>
22
Alexey Dobriyanc7d03a02016-11-17 04:58:21 +030023static unsigned int tunnel_key_net_id;
Amir Vadaid0f6dd82016-09-08 16:23:48 +030024static struct tc_action_ops act_tunnel_key_ops;
25
26static int tunnel_key_act(struct sk_buff *skb, const struct tc_action *a,
27 struct tcf_result *res)
28{
29 struct tcf_tunnel_key *t = to_tunnel_key(a);
30 struct tcf_tunnel_key_params *params;
31 int action;
32
Paolo Abeni7fd4b282018-07-30 14:30:43 +020033 params = rcu_dereference_bh(t->params);
Amir Vadaid0f6dd82016-09-08 16:23:48 +030034
35 tcf_lastuse_update(&t->tcf_tm);
Vlad Buslov5e1ad952019-10-30 16:09:01 +020036 tcf_action_update_bstats(&t->common, skb);
Davide Caratti38230a32018-07-06 21:01:06 +020037 action = READ_ONCE(t->tcf_action);
Amir Vadaid0f6dd82016-09-08 16:23:48 +030038
39 switch (params->tcft_action) {
40 case TCA_TUNNEL_KEY_ACT_RELEASE:
41 skb_dst_drop(skb);
42 break;
43 case TCA_TUNNEL_KEY_ACT_SET:
44 skb_dst_drop(skb);
45 skb_dst_set(skb, dst_clone(&params->tcft_enc_metadata->dst));
46 break;
47 default:
48 WARN_ONCE(1, "Bad tunnel_key action %d.\n",
49 params->tcft_action);
50 break;
51 }
52
Amir Vadaid0f6dd82016-09-08 16:23:48 +030053 return action;
54}
55
Simon Horman0ed52692018-06-26 21:39:37 -070056static const struct nla_policy
57enc_opts_policy[TCA_TUNNEL_KEY_ENC_OPTS_MAX + 1] = {
Xin Longfca3f912019-11-21 18:03:26 +080058 [TCA_TUNNEL_KEY_ENC_OPTS_UNSPEC] = {
59 .strict_start_type = TCA_TUNNEL_KEY_ENC_OPTS_VXLAN },
Simon Horman0ed52692018-06-26 21:39:37 -070060 [TCA_TUNNEL_KEY_ENC_OPTS_GENEVE] = { .type = NLA_NESTED },
Xin Longfca3f912019-11-21 18:03:26 +080061 [TCA_TUNNEL_KEY_ENC_OPTS_VXLAN] = { .type = NLA_NESTED },
Xin Longe20d4ff2019-11-21 18:03:27 +080062 [TCA_TUNNEL_KEY_ENC_OPTS_ERSPAN] = { .type = NLA_NESTED },
Simon Horman0ed52692018-06-26 21:39:37 -070063};
64
65static const struct nla_policy
66geneve_opt_policy[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_MAX + 1] = {
67 [TCA_TUNNEL_KEY_ENC_OPT_GENEVE_CLASS] = { .type = NLA_U16 },
68 [TCA_TUNNEL_KEY_ENC_OPT_GENEVE_TYPE] = { .type = NLA_U8 },
69 [TCA_TUNNEL_KEY_ENC_OPT_GENEVE_DATA] = { .type = NLA_BINARY,
70 .len = 128 },
71};
72
Xin Longfca3f912019-11-21 18:03:26 +080073static const struct nla_policy
74vxlan_opt_policy[TCA_TUNNEL_KEY_ENC_OPT_VXLAN_MAX + 1] = {
75 [TCA_TUNNEL_KEY_ENC_OPT_VXLAN_GBP] = { .type = NLA_U32 },
76};
77
Xin Longe20d4ff2019-11-21 18:03:27 +080078static const struct nla_policy
79erspan_opt_policy[TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_MAX + 1] = {
80 [TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_VER] = { .type = NLA_U8 },
81 [TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_INDEX] = { .type = NLA_U32 },
82 [TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_DIR] = { .type = NLA_U8 },
83 [TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_HWID] = { .type = NLA_U8 },
84};
85
Simon Horman0ed52692018-06-26 21:39:37 -070086static int
87tunnel_key_copy_geneve_opt(const struct nlattr *nla, void *dst, int dst_len,
88 struct netlink_ext_ack *extack)
89{
90 struct nlattr *tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_MAX + 1];
91 int err, data_len, opt_len;
92 u8 *data;
93
Johannes Berg8cb08172019-04-26 14:07:28 +020094 err = nla_parse_nested_deprecated(tb,
95 TCA_TUNNEL_KEY_ENC_OPT_GENEVE_MAX,
96 nla, geneve_opt_policy, extack);
Simon Horman0ed52692018-06-26 21:39:37 -070097 if (err < 0)
98 return err;
99
100 if (!tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_CLASS] ||
101 !tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_TYPE] ||
102 !tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_DATA]) {
103 NL_SET_ERR_MSG(extack, "Missing tunnel key geneve option class, type or data");
104 return -EINVAL;
105 }
106
107 data = nla_data(tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_DATA]);
108 data_len = nla_len(tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_DATA]);
109 if (data_len < 4) {
110 NL_SET_ERR_MSG(extack, "Tunnel key geneve option data is less than 4 bytes long");
111 return -ERANGE;
112 }
113 if (data_len % 4) {
114 NL_SET_ERR_MSG(extack, "Tunnel key geneve option data is not a multiple of 4 bytes long");
115 return -ERANGE;
116 }
117
118 opt_len = sizeof(struct geneve_opt) + data_len;
119 if (dst) {
120 struct geneve_opt *opt = dst;
121
122 WARN_ON(dst_len < opt_len);
123
124 opt->opt_class =
125 nla_get_be16(tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_CLASS]);
126 opt->type = nla_get_u8(tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_TYPE]);
127 opt->length = data_len / 4; /* length is in units of 4 bytes */
128 opt->r1 = 0;
129 opt->r2 = 0;
130 opt->r3 = 0;
131
132 memcpy(opt + 1, data, data_len);
133 }
134
135 return opt_len;
136}
137
Xin Longfca3f912019-11-21 18:03:26 +0800138static int
139tunnel_key_copy_vxlan_opt(const struct nlattr *nla, void *dst, int dst_len,
140 struct netlink_ext_ack *extack)
141{
142 struct nlattr *tb[TCA_TUNNEL_KEY_ENC_OPT_VXLAN_MAX + 1];
143 int err;
144
145 err = nla_parse_nested(tb, TCA_TUNNEL_KEY_ENC_OPT_VXLAN_MAX, nla,
146 vxlan_opt_policy, extack);
147 if (err < 0)
148 return err;
149
150 if (!tb[TCA_TUNNEL_KEY_ENC_OPT_VXLAN_GBP]) {
151 NL_SET_ERR_MSG(extack, "Missing tunnel key vxlan option gbp");
152 return -EINVAL;
153 }
154
155 if (dst) {
156 struct vxlan_metadata *md = dst;
157
158 md->gbp = nla_get_u32(tb[TCA_TUNNEL_KEY_ENC_OPT_VXLAN_GBP]);
159 }
160
161 return sizeof(struct vxlan_metadata);
162}
163
Xin Longe20d4ff2019-11-21 18:03:27 +0800164static int
165tunnel_key_copy_erspan_opt(const struct nlattr *nla, void *dst, int dst_len,
166 struct netlink_ext_ack *extack)
167{
168 struct nlattr *tb[TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_MAX + 1];
169 int err;
170 u8 ver;
171
172 err = nla_parse_nested(tb, TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_MAX, nla,
173 erspan_opt_policy, extack);
174 if (err < 0)
175 return err;
176
177 if (!tb[TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_VER]) {
178 NL_SET_ERR_MSG(extack, "Missing tunnel key erspan option ver");
179 return -EINVAL;
180 }
181
182 ver = nla_get_u8(tb[TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_VER]);
183 if (ver == 1) {
184 if (!tb[TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_INDEX]) {
185 NL_SET_ERR_MSG(extack, "Missing tunnel key erspan option index");
186 return -EINVAL;
187 }
188 } else if (ver == 2) {
189 if (!tb[TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_DIR] ||
190 !tb[TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_HWID]) {
191 NL_SET_ERR_MSG(extack, "Missing tunnel key erspan option dir or hwid");
192 return -EINVAL;
193 }
194 } else {
195 NL_SET_ERR_MSG(extack, "Tunnel key erspan option ver is incorrect");
196 return -EINVAL;
197 }
198
199 if (dst) {
200 struct erspan_metadata *md = dst;
201
202 md->version = ver;
203 if (ver == 1) {
204 nla = tb[TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_INDEX];
205 md->u.index = nla_get_be32(nla);
206 } else {
207 nla = tb[TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_DIR];
208 md->u.md2.dir = nla_get_u8(nla);
209 nla = tb[TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_HWID];
210 set_hwid(&md->u.md2, nla_get_u8(nla));
211 }
212 }
213
214 return sizeof(struct erspan_metadata);
215}
216
Simon Horman0ed52692018-06-26 21:39:37 -0700217static int tunnel_key_copy_opts(const struct nlattr *nla, u8 *dst,
218 int dst_len, struct netlink_ext_ack *extack)
219{
Xin Longfca3f912019-11-21 18:03:26 +0800220 int err, rem, opt_len, len = nla_len(nla), opts_len = 0, type = 0;
Simon Horman0ed52692018-06-26 21:39:37 -0700221 const struct nlattr *attr, *head = nla_data(nla);
222
Johannes Berg8cb08172019-04-26 14:07:28 +0200223 err = nla_validate_deprecated(head, len, TCA_TUNNEL_KEY_ENC_OPTS_MAX,
224 enc_opts_policy, extack);
Simon Horman0ed52692018-06-26 21:39:37 -0700225 if (err)
226 return err;
227
228 nla_for_each_attr(attr, head, len, rem) {
229 switch (nla_type(attr)) {
230 case TCA_TUNNEL_KEY_ENC_OPTS_GENEVE:
Xin Longfca3f912019-11-21 18:03:26 +0800231 if (type && type != TUNNEL_GENEVE_OPT) {
232 NL_SET_ERR_MSG(extack, "Duplicate type for geneve options");
233 return -EINVAL;
234 }
Simon Horman0ed52692018-06-26 21:39:37 -0700235 opt_len = tunnel_key_copy_geneve_opt(attr, dst,
236 dst_len, extack);
237 if (opt_len < 0)
238 return opt_len;
239 opts_len += opt_len;
Xin Long4f0e97d2019-11-18 17:39:34 +0800240 if (opts_len > IP_TUNNEL_OPTS_MAX) {
241 NL_SET_ERR_MSG(extack, "Tunnel options exceeds max size");
242 return -EINVAL;
243 }
Simon Horman0ed52692018-06-26 21:39:37 -0700244 if (dst) {
245 dst_len -= opt_len;
246 dst += opt_len;
247 }
Xin Longfca3f912019-11-21 18:03:26 +0800248 type = TUNNEL_GENEVE_OPT;
249 break;
250 case TCA_TUNNEL_KEY_ENC_OPTS_VXLAN:
251 if (type) {
252 NL_SET_ERR_MSG(extack, "Duplicate type for vxlan options");
253 return -EINVAL;
254 }
255 opt_len = tunnel_key_copy_vxlan_opt(attr, dst,
256 dst_len, extack);
257 if (opt_len < 0)
258 return opt_len;
259 opts_len += opt_len;
260 type = TUNNEL_VXLAN_OPT;
Simon Horman0ed52692018-06-26 21:39:37 -0700261 break;
Xin Longe20d4ff2019-11-21 18:03:27 +0800262 case TCA_TUNNEL_KEY_ENC_OPTS_ERSPAN:
263 if (type) {
264 NL_SET_ERR_MSG(extack, "Duplicate type for erspan options");
265 return -EINVAL;
266 }
267 opt_len = tunnel_key_copy_erspan_opt(attr, dst,
268 dst_len, extack);
269 if (opt_len < 0)
270 return opt_len;
271 opts_len += opt_len;
272 type = TUNNEL_ERSPAN_OPT;
273 break;
Simon Horman0ed52692018-06-26 21:39:37 -0700274 }
275 }
276
277 if (!opts_len) {
278 NL_SET_ERR_MSG(extack, "Empty list of tunnel options");
279 return -EINVAL;
280 }
281
282 if (rem > 0) {
283 NL_SET_ERR_MSG(extack, "Trailing data after parsing tunnel key options attributes");
284 return -EINVAL;
285 }
286
287 return opts_len;
288}
289
290static int tunnel_key_get_opts_len(struct nlattr *nla,
291 struct netlink_ext_ack *extack)
292{
293 return tunnel_key_copy_opts(nla, NULL, 0, extack);
294}
295
296static int tunnel_key_opts_set(struct nlattr *nla, struct ip_tunnel_info *info,
297 int opts_len, struct netlink_ext_ack *extack)
298{
299 info->options_len = opts_len;
300 switch (nla_type(nla_data(nla))) {
301 case TCA_TUNNEL_KEY_ENC_OPTS_GENEVE:
302#if IS_ENABLED(CONFIG_INET)
303 info->key.tun_flags |= TUNNEL_GENEVE_OPT;
304 return tunnel_key_copy_opts(nla, ip_tunnel_info_opts(info),
305 opts_len, extack);
306#else
307 return -EAFNOSUPPORT;
308#endif
Xin Longfca3f912019-11-21 18:03:26 +0800309 case TCA_TUNNEL_KEY_ENC_OPTS_VXLAN:
310#if IS_ENABLED(CONFIG_INET)
311 info->key.tun_flags |= TUNNEL_VXLAN_OPT;
312 return tunnel_key_copy_opts(nla, ip_tunnel_info_opts(info),
313 opts_len, extack);
314#else
315 return -EAFNOSUPPORT;
316#endif
Xin Longe20d4ff2019-11-21 18:03:27 +0800317 case TCA_TUNNEL_KEY_ENC_OPTS_ERSPAN:
318#if IS_ENABLED(CONFIG_INET)
319 info->key.tun_flags |= TUNNEL_ERSPAN_OPT;
320 return tunnel_key_copy_opts(nla, ip_tunnel_info_opts(info),
321 opts_len, extack);
322#else
323 return -EAFNOSUPPORT;
324#endif
Simon Horman0ed52692018-06-26 21:39:37 -0700325 default:
326 NL_SET_ERR_MSG(extack, "Cannot set tunnel options for unknown tunnel type");
327 return -EINVAL;
328 }
329}
330
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300331static const struct nla_policy tunnel_key_policy[TCA_TUNNEL_KEY_MAX + 1] = {
332 [TCA_TUNNEL_KEY_PARMS] = { .len = sizeof(struct tc_tunnel_key) },
333 [TCA_TUNNEL_KEY_ENC_IPV4_SRC] = { .type = NLA_U32 },
334 [TCA_TUNNEL_KEY_ENC_IPV4_DST] = { .type = NLA_U32 },
335 [TCA_TUNNEL_KEY_ENC_IPV6_SRC] = { .len = sizeof(struct in6_addr) },
336 [TCA_TUNNEL_KEY_ENC_IPV6_DST] = { .len = sizeof(struct in6_addr) },
337 [TCA_TUNNEL_KEY_ENC_KEY_ID] = { .type = NLA_U32 },
Hadar Hen Zion75bfbca2016-11-07 15:14:41 +0200338 [TCA_TUNNEL_KEY_ENC_DST_PORT] = {.type = NLA_U16},
Jiri Benc86087e12017-06-14 21:19:31 +0200339 [TCA_TUNNEL_KEY_NO_CSUM] = { .type = NLA_U8 },
Simon Horman0ed52692018-06-26 21:39:37 -0700340 [TCA_TUNNEL_KEY_ENC_OPTS] = { .type = NLA_NESTED },
Or Gerlitz07a557f2018-07-17 19:27:16 +0300341 [TCA_TUNNEL_KEY_ENC_TOS] = { .type = NLA_U8 },
342 [TCA_TUNNEL_KEY_ENC_TTL] = { .type = NLA_U8 },
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300343};
344
Davide Caratti9174c3d2019-01-10 20:21:02 +0100345static void tunnel_key_release_params(struct tcf_tunnel_key_params *p)
346{
347 if (!p)
348 return;
wenxu4177c5d2019-03-05 08:29:28 +0800349 if (p->tcft_action == TCA_TUNNEL_KEY_ACT_SET)
Davide Caratti9174c3d2019-01-10 20:21:02 +0100350 dst_release(&p->tcft_enc_metadata->dst);
wenxu4177c5d2019-03-05 08:29:28 +0800351
Davide Caratti9174c3d2019-01-10 20:21:02 +0100352 kfree_rcu(p, rcu);
353}
354
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300355static int tunnel_key_init(struct net *net, struct nlattr *nla,
356 struct nlattr *est, struct tc_action **a,
Vlad Buslov789871b2018-07-05 17:24:25 +0300357 int ovr, int bind, bool rtnl_held,
Vlad Buslovabbb0d32019-10-30 16:09:05 +0200358 struct tcf_proto *tp, u32 act_flags,
Vlad Buslov789871b2018-07-05 17:24:25 +0300359 struct netlink_ext_ack *extack)
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300360{
361 struct tc_action_net *tn = net_generic(net, tunnel_key_net_id);
362 struct nlattr *tb[TCA_TUNNEL_KEY_MAX + 1];
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300363 struct tcf_tunnel_key_params *params_new;
364 struct metadata_dst *metadata = NULL;
Davide Carattie5fdaba2019-03-20 15:00:13 +0100365 struct tcf_chain *goto_ch = NULL;
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300366 struct tc_tunnel_key *parm;
367 struct tcf_tunnel_key *t;
368 bool exists = false;
Hadar Hen Zion75bfbca2016-11-07 15:14:41 +0200369 __be16 dst_port = 0;
Adi Nissim80ef0f22018-12-02 14:55:20 +0200370 __be64 key_id = 0;
Simon Horman0ed52692018-06-26 21:39:37 -0700371 int opts_len = 0;
Adi Nissim80ef0f22018-12-02 14:55:20 +0200372 __be16 flags = 0;
Or Gerlitz07a557f2018-07-17 19:27:16 +0300373 u8 tos, ttl;
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300374 int ret = 0;
Dmytro Linkin7be8ef22019-08-01 13:02:51 +0000375 u32 index;
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300376 int err;
377
Simon Horman9d7298c2018-06-26 21:39:35 -0700378 if (!nla) {
379 NL_SET_ERR_MSG(extack, "Tunnel requires attributes to be passed");
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300380 return -EINVAL;
Simon Horman9d7298c2018-06-26 21:39:35 -0700381 }
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300382
Johannes Berg8cb08172019-04-26 14:07:28 +0200383 err = nla_parse_nested_deprecated(tb, TCA_TUNNEL_KEY_MAX, nla,
384 tunnel_key_policy, extack);
Simon Horman9d7298c2018-06-26 21:39:35 -0700385 if (err < 0) {
386 NL_SET_ERR_MSG(extack, "Failed to parse nested tunnel key attributes");
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300387 return err;
Simon Horman9d7298c2018-06-26 21:39:35 -0700388 }
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300389
Simon Horman9d7298c2018-06-26 21:39:35 -0700390 if (!tb[TCA_TUNNEL_KEY_PARMS]) {
391 NL_SET_ERR_MSG(extack, "Missing tunnel key parameters");
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300392 return -EINVAL;
Simon Horman9d7298c2018-06-26 21:39:35 -0700393 }
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300394
395 parm = nla_data(tb[TCA_TUNNEL_KEY_PARMS]);
Dmytro Linkin7be8ef22019-08-01 13:02:51 +0000396 index = parm->index;
397 err = tcf_idr_check_alloc(tn, &index, a, bind);
Vlad Buslov0190c1d2018-07-05 17:24:32 +0300398 if (err < 0)
399 return err;
400 exists = err;
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300401 if (exists && bind)
402 return 0;
403
404 switch (parm->t_action) {
405 case TCA_TUNNEL_KEY_ACT_RELEASE:
406 break;
407 case TCA_TUNNEL_KEY_ACT_SET:
Adi Nissim80ef0f22018-12-02 14:55:20 +0200408 if (tb[TCA_TUNNEL_KEY_ENC_KEY_ID]) {
409 __be32 key32;
410
411 key32 = nla_get_be32(tb[TCA_TUNNEL_KEY_ENC_KEY_ID]);
412 key_id = key32_to_tunnel_id(key32);
413 flags = TUNNEL_KEY;
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300414 }
415
Adi Nissim80ef0f22018-12-02 14:55:20 +0200416 flags |= TUNNEL_CSUM;
Jiri Benc86087e12017-06-14 21:19:31 +0200417 if (tb[TCA_TUNNEL_KEY_NO_CSUM] &&
418 nla_get_u8(tb[TCA_TUNNEL_KEY_NO_CSUM]))
419 flags &= ~TUNNEL_CSUM;
420
Hadar Hen Zion75bfbca2016-11-07 15:14:41 +0200421 if (tb[TCA_TUNNEL_KEY_ENC_DST_PORT])
422 dst_port = nla_get_be16(tb[TCA_TUNNEL_KEY_ENC_DST_PORT]);
423
Simon Horman0ed52692018-06-26 21:39:37 -0700424 if (tb[TCA_TUNNEL_KEY_ENC_OPTS]) {
425 opts_len = tunnel_key_get_opts_len(tb[TCA_TUNNEL_KEY_ENC_OPTS],
426 extack);
427 if (opts_len < 0) {
428 ret = opts_len;
429 goto err_out;
430 }
431 }
432
Or Gerlitz07a557f2018-07-17 19:27:16 +0300433 tos = 0;
434 if (tb[TCA_TUNNEL_KEY_ENC_TOS])
435 tos = nla_get_u8(tb[TCA_TUNNEL_KEY_ENC_TOS]);
436 ttl = 0;
437 if (tb[TCA_TUNNEL_KEY_ENC_TTL])
438 ttl = nla_get_u8(tb[TCA_TUNNEL_KEY_ENC_TTL]);
439
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300440 if (tb[TCA_TUNNEL_KEY_ENC_IPV4_SRC] &&
441 tb[TCA_TUNNEL_KEY_ENC_IPV4_DST]) {
442 __be32 saddr;
443 __be32 daddr;
444
445 saddr = nla_get_in_addr(tb[TCA_TUNNEL_KEY_ENC_IPV4_SRC]);
446 daddr = nla_get_in_addr(tb[TCA_TUNNEL_KEY_ENC_IPV4_DST]);
447
Or Gerlitz07a557f2018-07-17 19:27:16 +0300448 metadata = __ip_tun_set_dst(saddr, daddr, tos, ttl,
Jiri Benc86087e12017-06-14 21:19:31 +0200449 dst_port, flags,
Simon Horman0ed52692018-06-26 21:39:37 -0700450 key_id, opts_len);
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300451 } else if (tb[TCA_TUNNEL_KEY_ENC_IPV6_SRC] &&
452 tb[TCA_TUNNEL_KEY_ENC_IPV6_DST]) {
453 struct in6_addr saddr;
454 struct in6_addr daddr;
455
456 saddr = nla_get_in6_addr(tb[TCA_TUNNEL_KEY_ENC_IPV6_SRC]);
457 daddr = nla_get_in6_addr(tb[TCA_TUNNEL_KEY_ENC_IPV6_DST]);
458
Or Gerlitz07a557f2018-07-17 19:27:16 +0300459 metadata = __ipv6_tun_set_dst(&saddr, &daddr, tos, ttl, dst_port,
Jiri Benc86087e12017-06-14 21:19:31 +0200460 0, flags,
Hadar Hen Zion75bfbca2016-11-07 15:14:41 +0200461 key_id, 0);
Simon Hormana1165b52018-06-26 21:39:34 -0700462 } else {
Simon Horman9d7298c2018-06-26 21:39:35 -0700463 NL_SET_ERR_MSG(extack, "Missing either ipv4 or ipv6 src and dst");
Simon Hormana1165b52018-06-26 21:39:34 -0700464 ret = -EINVAL;
465 goto err_out;
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300466 }
467
468 if (!metadata) {
Simon Horman9d7298c2018-06-26 21:39:35 -0700469 NL_SET_ERR_MSG(extack, "Cannot allocate tunnel metadata dst");
Simon Hormana1165b52018-06-26 21:39:34 -0700470 ret = -ENOMEM;
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300471 goto err_out;
472 }
473
wenxu41411e22019-02-22 15:58:12 +0800474#ifdef CONFIG_DST_CACHE
475 ret = dst_cache_init(&metadata->u.tun_info.dst_cache, GFP_KERNEL);
476 if (ret)
477 goto release_tun_meta;
478#endif
479
Simon Horman0ed52692018-06-26 21:39:37 -0700480 if (opts_len) {
481 ret = tunnel_key_opts_set(tb[TCA_TUNNEL_KEY_ENC_OPTS],
482 &metadata->u.tun_info,
483 opts_len, extack);
484 if (ret < 0)
wenxu4177c5d2019-03-05 08:29:28 +0800485 goto release_tun_meta;
Simon Horman0ed52692018-06-26 21:39:37 -0700486 }
487
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300488 metadata->u.tun_info.mode |= IP_TUNNEL_INFO_TX;
489 break;
490 default:
Simon Horman9d7298c2018-06-26 21:39:35 -0700491 NL_SET_ERR_MSG(extack, "Unknown tunnel key action");
Roman Mashak51d47402018-03-12 16:20:58 -0400492 ret = -EINVAL;
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300493 goto err_out;
494 }
495
496 if (!exists) {
Vlad Buslove3822672019-10-30 16:09:06 +0200497 ret = tcf_idr_create_from_flags(tn, index, est, a,
498 &act_tunnel_key_ops, bind,
499 act_flags);
Simon Horman9d7298c2018-06-26 21:39:35 -0700500 if (ret) {
501 NL_SET_ERR_MSG(extack, "Cannot create TC IDR");
wenxu4177c5d2019-03-05 08:29:28 +0800502 goto release_tun_meta;
Simon Horman9d7298c2018-06-26 21:39:35 -0700503 }
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300504
505 ret = ACT_P_CREATED;
Vlad Buslov4e8ddd72018-07-05 17:24:30 +0300506 } else if (!ovr) {
Vlad Buslov4e8ddd72018-07-05 17:24:30 +0300507 NL_SET_ERR_MSG(extack, "TC IDR already exists");
Davide Carattiee28bb52018-09-04 19:00:19 +0200508 ret = -EEXIST;
wenxu4177c5d2019-03-05 08:29:28 +0800509 goto release_tun_meta;
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300510 }
511
Davide Carattie5fdaba2019-03-20 15:00:13 +0100512 err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack);
513 if (err < 0) {
514 ret = err;
515 exists = true;
516 goto release_tun_meta;
517 }
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300518 t = to_tunnel_key(*a);
519
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300520 params_new = kzalloc(sizeof(*params_new), GFP_KERNEL);
521 if (unlikely(!params_new)) {
Simon Horman9d7298c2018-06-26 21:39:35 -0700522 NL_SET_ERR_MSG(extack, "Cannot allocate tunnel key parameters");
Davide Carattiee28bb52018-09-04 19:00:19 +0200523 ret = -ENOMEM;
524 exists = true;
Davide Carattie5fdaba2019-03-20 15:00:13 +0100525 goto put_chain;
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300526 }
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300527 params_new->tcft_action = parm->t_action;
528 params_new->tcft_enc_metadata = metadata;
529
Vlad Buslov653cd282018-08-14 21:46:16 +0300530 spin_lock_bh(&t->tcf_lock);
Davide Carattie5fdaba2019-03-20 15:00:13 +0100531 goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch);
Paul E. McKenney445d3742019-09-23 16:09:18 -0700532 params_new = rcu_replace_pointer(t->params, params_new,
533 lockdep_is_held(&t->tcf_lock));
Vlad Buslov653cd282018-08-14 21:46:16 +0300534 spin_unlock_bh(&t->tcf_lock);
Davide Caratti9174c3d2019-01-10 20:21:02 +0100535 tunnel_key_release_params(params_new);
Davide Carattie5fdaba2019-03-20 15:00:13 +0100536 if (goto_ch)
537 tcf_chain_put_by_act(goto_ch);
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300538
539 if (ret == ACT_P_CREATED)
Chris Mi65a206c2017-08-30 02:31:59 -0400540 tcf_idr_insert(tn, *a);
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300541
542 return ret;
543
Davide Carattie5fdaba2019-03-20 15:00:13 +0100544put_chain:
545 if (goto_ch)
546 tcf_chain_put_by_act(goto_ch);
547
Davide Carattiee28bb52018-09-04 19:00:19 +0200548release_tun_meta:
Vlad Buslova3df6332019-02-25 17:28:27 +0200549 if (metadata)
550 dst_release(&metadata->dst);
Davide Carattiee28bb52018-09-04 19:00:19 +0200551
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300552err_out:
553 if (exists)
Chris Mi65a206c2017-08-30 02:31:59 -0400554 tcf_idr_release(*a, bind);
Vlad Buslov0190c1d2018-07-05 17:24:32 +0300555 else
Dmytro Linkin7be8ef22019-08-01 13:02:51 +0000556 tcf_idr_cleanup(tn, index);
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300557 return ret;
558}
559
Cong Wang9a63b252017-12-05 12:53:07 -0800560static void tunnel_key_release(struct tc_action *a)
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300561{
562 struct tcf_tunnel_key *t = to_tunnel_key(a);
563 struct tcf_tunnel_key_params *params;
564
Hadar Hen Zion07c0f092016-09-12 15:19:21 +0300565 params = rcu_dereference_protected(t->params, 1);
Davide Caratti9174c3d2019-01-10 20:21:02 +0100566 tunnel_key_release_params(params);
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300567}
568
Simon Horman0ed52692018-06-26 21:39:37 -0700569static int tunnel_key_geneve_opts_dump(struct sk_buff *skb,
570 const struct ip_tunnel_info *info)
571{
572 int len = info->options_len;
573 u8 *src = (u8 *)(info + 1);
574 struct nlattr *start;
575
Michal Kubecekae0be8d2019-04-26 11:13:06 +0200576 start = nla_nest_start_noflag(skb, TCA_TUNNEL_KEY_ENC_OPTS_GENEVE);
Simon Horman0ed52692018-06-26 21:39:37 -0700577 if (!start)
578 return -EMSGSIZE;
579
580 while (len > 0) {
581 struct geneve_opt *opt = (struct geneve_opt *)src;
582
583 if (nla_put_be16(skb, TCA_TUNNEL_KEY_ENC_OPT_GENEVE_CLASS,
584 opt->opt_class) ||
585 nla_put_u8(skb, TCA_TUNNEL_KEY_ENC_OPT_GENEVE_TYPE,
586 opt->type) ||
587 nla_put(skb, TCA_TUNNEL_KEY_ENC_OPT_GENEVE_DATA,
Cong Wanga162c352018-09-06 14:50:16 -0700588 opt->length * 4, opt + 1)) {
589 nla_nest_cancel(skb, start);
Simon Horman0ed52692018-06-26 21:39:37 -0700590 return -EMSGSIZE;
Cong Wanga162c352018-09-06 14:50:16 -0700591 }
Simon Horman0ed52692018-06-26 21:39:37 -0700592
593 len -= sizeof(struct geneve_opt) + opt->length * 4;
594 src += sizeof(struct geneve_opt) + opt->length * 4;
595 }
596
597 nla_nest_end(skb, start);
598 return 0;
599}
600
Xin Longfca3f912019-11-21 18:03:26 +0800601static int tunnel_key_vxlan_opts_dump(struct sk_buff *skb,
602 const struct ip_tunnel_info *info)
603{
604 struct vxlan_metadata *md = (struct vxlan_metadata *)(info + 1);
605 struct nlattr *start;
606
607 start = nla_nest_start_noflag(skb, TCA_TUNNEL_KEY_ENC_OPTS_VXLAN);
608 if (!start)
609 return -EMSGSIZE;
610
611 if (nla_put_u32(skb, TCA_TUNNEL_KEY_ENC_OPT_VXLAN_GBP, md->gbp)) {
612 nla_nest_cancel(skb, start);
613 return -EMSGSIZE;
614 }
615
616 nla_nest_end(skb, start);
617 return 0;
618}
619
Xin Longe20d4ff2019-11-21 18:03:27 +0800620static int tunnel_key_erspan_opts_dump(struct sk_buff *skb,
621 const struct ip_tunnel_info *info)
622{
623 struct erspan_metadata *md = (struct erspan_metadata *)(info + 1);
624 struct nlattr *start;
625
626 start = nla_nest_start_noflag(skb, TCA_TUNNEL_KEY_ENC_OPTS_ERSPAN);
627 if (!start)
628 return -EMSGSIZE;
629
630 if (nla_put_u8(skb, TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_VER, md->version))
631 goto err;
632
633 if (md->version == 1 &&
634 nla_put_be32(skb, TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_INDEX, md->u.index))
635 goto err;
636
637 if (md->version == 2 &&
638 (nla_put_u8(skb, TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_DIR,
639 md->u.md2.dir) ||
640 nla_put_u8(skb, TCA_TUNNEL_KEY_ENC_OPT_ERSPAN_HWID,
641 get_hwid(&md->u.md2))))
642 goto err;
643
644 nla_nest_end(skb, start);
645 return 0;
646err:
647 nla_nest_cancel(skb, start);
648 return -EMSGSIZE;
649}
650
Simon Horman0ed52692018-06-26 21:39:37 -0700651static int tunnel_key_opts_dump(struct sk_buff *skb,
652 const struct ip_tunnel_info *info)
653{
654 struct nlattr *start;
Cong Wanga162c352018-09-06 14:50:16 -0700655 int err = -EINVAL;
Simon Horman0ed52692018-06-26 21:39:37 -0700656
657 if (!info->options_len)
658 return 0;
659
Michal Kubecekae0be8d2019-04-26 11:13:06 +0200660 start = nla_nest_start_noflag(skb, TCA_TUNNEL_KEY_ENC_OPTS);
Simon Horman0ed52692018-06-26 21:39:37 -0700661 if (!start)
662 return -EMSGSIZE;
663
664 if (info->key.tun_flags & TUNNEL_GENEVE_OPT) {
665 err = tunnel_key_geneve_opts_dump(skb, info);
666 if (err)
Cong Wanga162c352018-09-06 14:50:16 -0700667 goto err_out;
Xin Longfca3f912019-11-21 18:03:26 +0800668 } else if (info->key.tun_flags & TUNNEL_VXLAN_OPT) {
669 err = tunnel_key_vxlan_opts_dump(skb, info);
670 if (err)
671 goto err_out;
Xin Longe20d4ff2019-11-21 18:03:27 +0800672 } else if (info->key.tun_flags & TUNNEL_ERSPAN_OPT) {
673 err = tunnel_key_erspan_opts_dump(skb, info);
674 if (err)
675 goto err_out;
Simon Horman0ed52692018-06-26 21:39:37 -0700676 } else {
Cong Wanga162c352018-09-06 14:50:16 -0700677err_out:
678 nla_nest_cancel(skb, start);
679 return err;
Simon Horman0ed52692018-06-26 21:39:37 -0700680 }
681
682 nla_nest_end(skb, start);
683 return 0;
684}
685
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300686static int tunnel_key_dump_addresses(struct sk_buff *skb,
687 const struct ip_tunnel_info *info)
688{
689 unsigned short family = ip_tunnel_info_af(info);
690
691 if (family == AF_INET) {
692 __be32 saddr = info->key.u.ipv4.src;
693 __be32 daddr = info->key.u.ipv4.dst;
694
695 if (!nla_put_in_addr(skb, TCA_TUNNEL_KEY_ENC_IPV4_SRC, saddr) &&
696 !nla_put_in_addr(skb, TCA_TUNNEL_KEY_ENC_IPV4_DST, daddr))
697 return 0;
698 }
699
700 if (family == AF_INET6) {
701 const struct in6_addr *saddr6 = &info->key.u.ipv6.src;
702 const struct in6_addr *daddr6 = &info->key.u.ipv6.dst;
703
704 if (!nla_put_in6_addr(skb,
705 TCA_TUNNEL_KEY_ENC_IPV6_SRC, saddr6) &&
706 !nla_put_in6_addr(skb,
707 TCA_TUNNEL_KEY_ENC_IPV6_DST, daddr6))
708 return 0;
709 }
710
711 return -EINVAL;
712}
713
714static int tunnel_key_dump(struct sk_buff *skb, struct tc_action *a,
715 int bind, int ref)
716{
717 unsigned char *b = skb_tail_pointer(skb);
718 struct tcf_tunnel_key *t = to_tunnel_key(a);
719 struct tcf_tunnel_key_params *params;
720 struct tc_tunnel_key opt = {
721 .index = t->tcf_index,
Vlad Buslov036bb442018-07-05 17:24:24 +0300722 .refcnt = refcount_read(&t->tcf_refcnt) - ref,
723 .bindcnt = atomic_read(&t->tcf_bindcnt) - bind,
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300724 };
725 struct tcf_t tm;
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300726
Vlad Buslov653cd282018-08-14 21:46:16 +0300727 spin_lock_bh(&t->tcf_lock);
Vlad Buslov729e0122018-08-10 20:51:50 +0300728 params = rcu_dereference_protected(t->params,
729 lockdep_is_held(&t->tcf_lock));
730 opt.action = t->tcf_action;
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300731 opt.t_action = params->tcft_action;
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300732
733 if (nla_put(skb, TCA_TUNNEL_KEY_PARMS, sizeof(opt), &opt))
734 goto nla_put_failure;
735
736 if (params->tcft_action == TCA_TUNNEL_KEY_ACT_SET) {
Simon Horman0ed52692018-06-26 21:39:37 -0700737 struct ip_tunnel_info *info =
738 &params->tcft_enc_metadata->u.tun_info;
739 struct ip_tunnel_key *key = &info->key;
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300740 __be32 key_id = tunnel_id_to_key32(key->tun_id);
741
Adi Nissim80ef0f22018-12-02 14:55:20 +0200742 if (((key->tun_flags & TUNNEL_KEY) &&
743 nla_put_be32(skb, TCA_TUNNEL_KEY_ENC_KEY_ID, key_id)) ||
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300744 tunnel_key_dump_addresses(skb,
Hadar Hen Zion75bfbca2016-11-07 15:14:41 +0200745 &params->tcft_enc_metadata->u.tun_info) ||
Adi Nissim1c253242018-12-02 14:55:21 +0200746 (key->tp_dst &&
747 nla_put_be16(skb, TCA_TUNNEL_KEY_ENC_DST_PORT,
748 key->tp_dst)) ||
Jiri Benc86087e12017-06-14 21:19:31 +0200749 nla_put_u8(skb, TCA_TUNNEL_KEY_NO_CSUM,
Simon Horman0ed52692018-06-26 21:39:37 -0700750 !(key->tun_flags & TUNNEL_CSUM)) ||
751 tunnel_key_opts_dump(skb, info))
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300752 goto nla_put_failure;
Or Gerlitz07a557f2018-07-17 19:27:16 +0300753
754 if (key->tos && nla_put_u8(skb, TCA_TUNNEL_KEY_ENC_TOS, key->tos))
755 goto nla_put_failure;
756
757 if (key->ttl && nla_put_u8(skb, TCA_TUNNEL_KEY_ENC_TTL, key->ttl))
758 goto nla_put_failure;
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300759 }
760
761 tcf_tm_dump(&tm, &t->tcf_tm);
762 if (nla_put_64bit(skb, TCA_TUNNEL_KEY_TM, sizeof(tm),
763 &tm, TCA_TUNNEL_KEY_PAD))
764 goto nla_put_failure;
Vlad Buslov653cd282018-08-14 21:46:16 +0300765 spin_unlock_bh(&t->tcf_lock);
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300766
Hadar Hen Zion07c0f092016-09-12 15:19:21 +0300767 return skb->len;
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300768
769nla_put_failure:
Vlad Buslov653cd282018-08-14 21:46:16 +0300770 spin_unlock_bh(&t->tcf_lock);
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300771 nlmsg_trim(skb, b);
Hadar Hen Zion07c0f092016-09-12 15:19:21 +0300772 return -1;
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300773}
774
775static int tunnel_key_walker(struct net *net, struct sk_buff *skb,
776 struct netlink_callback *cb, int type,
Alexander Aring41780102018-02-15 10:54:58 -0500777 const struct tc_action_ops *ops,
778 struct netlink_ext_ack *extack)
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300779{
780 struct tc_action_net *tn = net_generic(net, tunnel_key_net_id);
781
Alexander Aringb3620142018-02-15 10:54:59 -0500782 return tcf_generic_walker(tn, skb, cb, type, ops, extack);
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300783}
784
Cong Wangf061b482018-08-29 10:15:35 -0700785static int tunnel_key_search(struct net *net, struct tc_action **a, u32 index)
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300786{
787 struct tc_action_net *tn = net_generic(net, tunnel_key_net_id);
788
Chris Mi65a206c2017-08-30 02:31:59 -0400789 return tcf_idr_search(tn, a, index);
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300790}
791
792static struct tc_action_ops act_tunnel_key_ops = {
793 .kind = "tunnel_key",
Eli Coheneddd2cf2019-02-10 14:25:00 +0200794 .id = TCA_ID_TUNNEL_KEY,
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300795 .owner = THIS_MODULE,
796 .act = tunnel_key_act,
797 .dump = tunnel_key_dump,
798 .init = tunnel_key_init,
799 .cleanup = tunnel_key_release,
800 .walk = tunnel_key_walker,
801 .lookup = tunnel_key_search,
802 .size = sizeof(struct tcf_tunnel_key),
803};
804
805static __net_init int tunnel_key_init_net(struct net *net)
806{
807 struct tc_action_net *tn = net_generic(net, tunnel_key_net_id);
808
Cong Wang981471b2019-08-25 10:01:32 -0700809 return tc_action_net_init(net, tn, &act_tunnel_key_ops);
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300810}
811
Cong Wang039af9c2017-12-11 15:35:03 -0800812static void __net_exit tunnel_key_exit_net(struct list_head *net_list)
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300813{
Cong Wang039af9c2017-12-11 15:35:03 -0800814 tc_action_net_exit(net_list, tunnel_key_net_id);
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300815}
816
817static struct pernet_operations tunnel_key_net_ops = {
818 .init = tunnel_key_init_net,
Cong Wang039af9c2017-12-11 15:35:03 -0800819 .exit_batch = tunnel_key_exit_net,
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300820 .id = &tunnel_key_net_id,
821 .size = sizeof(struct tc_action_net),
Amir Vadaid0f6dd82016-09-08 16:23:48 +0300822};
823
824static int __init tunnel_key_init_module(void)
825{
826 return tcf_register_action(&act_tunnel_key_ops, &tunnel_key_net_ops);
827}
828
829static void __exit tunnel_key_cleanup_module(void)
830{
831 tcf_unregister_action(&act_tunnel_key_ops, &tunnel_key_net_ops);
832}
833
834module_init(tunnel_key_init_module);
835module_exit(tunnel_key_cleanup_module);
836
837MODULE_AUTHOR("Amir Vadai <amir@vadai.me>");
838MODULE_DESCRIPTION("ip tunnel manipulation actions");
839MODULE_LICENSE("GPL v2");