blob: fab12b4f9c050ef3a2d81b5bb074de055be8e51a [file] [log] [blame]
Ed Warnickecb9cada2015-12-08 15:45:58 -07001/*
2 * gre_interface.c: gre interfaces
3 *
4 * Copyright (c) 2012 Cisco and/or its affiliates.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#include <vnet/vnet.h>
19#include <vnet/pg/pg.h>
20#include <vnet/gre/gre.h>
Chris Luke27fe48f2016-04-28 13:44:38 -040021#include <vnet/ip/format.h>
Neale Ranns0bfe5d82016-08-25 15:29:12 +010022#include <vnet/fib/ip4_fib.h>
Ciara Loftus7eac9162016-09-30 15:47:03 +010023#include <vnet/fib/ip6_fib.h>
Neale Ranns0bfe5d82016-08-25 15:29:12 +010024#include <vnet/adj/adj_midchain.h>
Neale Rannsb80c5362016-10-08 13:03:40 +010025#include <vnet/adj/adj_nbr.h>
Neale Ranns0bfe5d82016-08-25 15:29:12 +010026#include <vnet/mpls/mpls.h>
Neale Ranns3b81a1e2018-09-06 09:50:26 -070027#include <vnet/l2/l2_input.h>
Neale Ranns4c16d802019-12-17 20:15:03 +000028#include <vnet/nhrp/nhrp.h>
Ed Warnickecb9cada2015-12-08 15:45:58 -070029
Neale Ranns5f8f6172019-04-18 10:23:56 +000030u8 *
31format_gre_tunnel_type (u8 * s, va_list * args)
32{
33 gre_tunnel_type_t type = va_arg (*args, int);
34
35 switch (type)
36 {
37#define _(n, v) case GRE_TUNNEL_TYPE_##n: \
38 s = format (s, "%s", v); \
39 break;
40 foreach_gre_tunnel_type
41#undef _
42 }
43
44 return (s);
45}
46
47u8 *
48format_gre_tunnel_mode (u8 * s, va_list * args)
49{
50 gre_tunnel_mode_t mode = va_arg (*args, int);
51
52 switch (mode)
53 {
54#define _(n, v) case GRE_TUNNEL_MODE_##n: \
55 s = format (s, "%s", v); \
56 break;
57 foreach_gre_tunnel_mode
58#undef _
59 }
60
61 return (s);
62}
Neale Ranns177bbdc2016-11-15 09:46:51 +000063
Neale Ranns0bfe5d82016-08-25 15:29:12 +010064static u8 *
65format_gre_tunnel (u8 * s, va_list * args)
Chris Luke27fe48f2016-04-28 13:44:38 -040066{
Swarup Nayak9ff647a2017-11-27 10:27:43 +053067 gre_tunnel_t *t = va_arg (*args, gre_tunnel_t *);
Chris Luke27fe48f2016-04-28 13:44:38 -040068
John Loa43ccae2018-02-13 17:15:23 -050069 s = format (s, "[%d] instance %d src %U dst %U fib-idx %d sw-if-idx %d ",
70 t->dev_instance, t->user_instance,
John Lo4478d8e2018-01-12 17:15:25 -050071 format_ip46_address, &t->tunnel_src, IP46_TYPE_ANY,
72 format_ip46_address, &t->tunnel_dst.fp_addr, IP46_TYPE_ANY,
73 t->outer_fib_index, t->sw_if_index);
74
Neale Ranns5f8f6172019-04-18 10:23:56 +000075 s = format (s, "payload %U ", format_gre_tunnel_type, t->type);
76 s = format (s, "%U ", format_gre_tunnel_mode, t->mode);
John Loa43ccae2018-02-13 17:15:23 -050077
78 if (t->type == GRE_TUNNEL_TYPE_ERSPAN)
79 s = format (s, "session %d ", t->session_id);
80
81 if (t->type != GRE_TUNNEL_TYPE_L3)
82 s = format (s, "l2-adj-idx %d ", t->l2_adj_index);
Neale Ranns0bfe5d82016-08-25 15:29:12 +010083
Chris Luke27fe48f2016-04-28 13:44:38 -040084 return s;
85}
86
Neale Ranns0bfe5d82016-08-25 15:29:12 +010087static gre_tunnel_t *
Neale Ranns5a8844b2019-04-16 07:15:35 +000088gre_tunnel_db_find (const vnet_gre_tunnel_add_del_args_t * a,
John Loa43ccae2018-02-13 17:15:23 -050089 u32 outer_fib_index, gre_tunnel_key_t * key)
Neale Ranns0bfe5d82016-08-25 15:29:12 +010090{
Swarup Nayak9ff647a2017-11-27 10:27:43 +053091 gre_main_t *gm = &gre_main;
92 uword *p;
Neale Ranns0bfe5d82016-08-25 15:29:12 +010093
John Loa43ccae2018-02-13 17:15:23 -050094 if (!a->is_ipv6)
Ciara Loftus7eac9162016-09-30 15:47:03 +010095 {
John Loa43ccae2018-02-13 17:15:23 -050096 gre_mk_key4 (a->src.ip4, a->dst.ip4, outer_fib_index,
Neale Ranns4c16d802019-12-17 20:15:03 +000097 a->type, a->mode, a->session_id, &key->gtk_v4);
Neale Ranns33ce60d2017-12-14 08:51:32 -080098 p = hash_get_mem (gm->tunnel_by_key4, &key->gtk_v4);
Ciara Loftus7eac9162016-09-30 15:47:03 +010099 }
100 else
101 {
John Loa43ccae2018-02-13 17:15:23 -0500102 gre_mk_key6 (&a->src.ip6, &a->dst.ip6, outer_fib_index,
Neale Ranns4c16d802019-12-17 20:15:03 +0000103 a->type, a->mode, a->session_id, &key->gtk_v6);
Neale Ranns33ce60d2017-12-14 08:51:32 -0800104 p = hash_get_mem (gm->tunnel_by_key6, &key->gtk_v6);
Ciara Loftus7eac9162016-09-30 15:47:03 +0100105 }
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100106
107 if (NULL == p)
108 return (NULL);
109
110 return (pool_elt_at_index (gm->tunnels, p[0]));
111}
112
113static void
Neale Ranns33ce60d2017-12-14 08:51:32 -0800114gre_tunnel_db_add (gre_tunnel_t * t, gre_tunnel_key_t * key)
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100115{
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530116 gre_main_t *gm = &gre_main;
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100117
Neale Ranns33ce60d2017-12-14 08:51:32 -0800118 if (t->tunnel_dst.fp_proto == FIB_PROTOCOL_IP6)
Ciara Loftus7eac9162016-09-30 15:47:03 +0100119 {
Neale Ranns4c16d802019-12-17 20:15:03 +0000120 hash_set_mem_alloc (&gm->tunnel_by_key6, &key->gtk_v6, t->dev_instance);
Ciara Loftus7eac9162016-09-30 15:47:03 +0100121 }
122 else
123 {
Neale Ranns4c16d802019-12-17 20:15:03 +0000124 hash_set_mem_alloc (&gm->tunnel_by_key4, &key->gtk_v4, t->dev_instance);
Ciara Loftus7eac9162016-09-30 15:47:03 +0100125 }
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100126}
127
128static void
Neale Ranns4c16d802019-12-17 20:15:03 +0000129gre_tunnel_db_remove (gre_tunnel_t * t, gre_tunnel_key_t * key)
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100130{
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530131 gre_main_t *gm = &gre_main;
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100132
Neale Ranns33ce60d2017-12-14 08:51:32 -0800133 if (t->tunnel_dst.fp_proto == FIB_PROTOCOL_IP6)
Ciara Loftus7eac9162016-09-30 15:47:03 +0100134 {
Neale Ranns4c16d802019-12-17 20:15:03 +0000135 hash_unset_mem_free (&gm->tunnel_by_key6, &key->gtk_v6);
Ciara Loftus7eac9162016-09-30 15:47:03 +0100136 }
137 else
138 {
Neale Ranns4c16d802019-12-17 20:15:03 +0000139 hash_unset_mem_free (&gm->tunnel_by_key4, &key->gtk_v4);
Ciara Loftus7eac9162016-09-30 15:47:03 +0100140 }
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100141}
142
Neale Ranns5e575b12016-10-03 09:40:25 +0100143/**
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100144 * gre_tunnel_stack
145 *
146 * 'stack' (resolve the recursion for) the tunnel's midchain adjacency
147 */
Neale Ranns5e575b12016-10-03 09:40:25 +0100148void
Neale Rannsb80c5362016-10-08 13:03:40 +0100149gre_tunnel_stack (adj_index_t ai)
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100150{
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530151 gre_main_t *gm = &gre_main;
152 ip_adjacency_t *adj;
153 gre_tunnel_t *gt;
154 u32 sw_if_index;
Neale Rannsb80c5362016-10-08 13:03:40 +0100155
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530156 adj = adj_get (ai);
157 sw_if_index = adj->rewrite_header.sw_if_index;
Neale Rannsb80c5362016-10-08 13:03:40 +0100158
Eyal Baricd307742018-07-22 12:45:15 +0300159 if ((vec_len (gm->tunnel_index_by_sw_if_index) <= sw_if_index) ||
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530160 (~0 == gm->tunnel_index_by_sw_if_index[sw_if_index]))
161 return;
Neale Rannsb80c5362016-10-08 13:03:40 +0100162
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530163 gt = pool_elt_at_index (gm->tunnels,
164 gm->tunnel_index_by_sw_if_index[sw_if_index]);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100165
John Loa43ccae2018-02-13 17:15:23 -0500166 if ((vnet_hw_interface_get_flags (vnet_get_main (), gt->hw_if_index) &
167 VNET_HW_INTERFACE_FLAG_LINK_UP) == 0)
Neale Rannsb80c5362016-10-08 13:03:40 +0100168 {
Neale Ranns4c3ba812019-03-26 07:02:58 +0000169 adj_midchain_delegate_unstack (ai);
Neale Rannsb80c5362016-10-08 13:03:40 +0100170 }
Neale Ranns521a8d72018-12-06 13:46:49 +0000171 else
John Loa43ccae2018-02-13 17:15:23 -0500172 {
Neale Ranns4c3ba812019-03-26 07:02:58 +0000173 adj_midchain_delegate_stack (ai, gt->outer_fib_index, &gt->tunnel_dst);
John Loa43ccae2018-02-13 17:15:23 -0500174 }
Neale Rannsb80c5362016-10-08 13:03:40 +0100175}
176
177/**
178 * @brief Call back when restacking all adjacencies on a GRE interface
179 */
180static adj_walk_rc_t
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530181gre_adj_walk_cb (adj_index_t ai, void *ctx)
Neale Rannsb80c5362016-10-08 13:03:40 +0100182{
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530183 gre_tunnel_stack (ai);
Neale Rannsb80c5362016-10-08 13:03:40 +0100184
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530185 return (ADJ_WALK_RC_CONTINUE);
Neale Rannsb80c5362016-10-08 13:03:40 +0100186}
187
188static void
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530189gre_tunnel_restack (gre_tunnel_t * gt)
Neale Rannsb80c5362016-10-08 13:03:40 +0100190{
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530191 fib_protocol_t proto;
Neale Rannsb80c5362016-10-08 13:03:40 +0100192
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530193 /*
194 * walk all the adjacencies on th GRE interface and restack them
195 */
196 FOR_EACH_FIB_IP_PROTOCOL (proto)
197 {
198 adj_nbr_walk (gt->sw_if_index, proto, gre_adj_walk_cb, NULL);
199 }
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100200}
201
Neale Ranns4c16d802019-12-17 20:15:03 +0000202static void
203gre_nhrp_mk_key (const gre_tunnel_t * t,
204 const nhrp_entry_t * ne, gre_tunnel_key_t * key)
205{
206 const fib_prefix_t *nh;
207
208 nh = nhrp_entry_get_nh (ne);
209
210 /* construct the key using mode P2P so it can be found in the DP */
211 if (FIB_PROTOCOL_IP4 == nh->fp_proto)
212 gre_mk_key4 (t->tunnel_src.ip4,
213 nh->fp_addr.ip4,
214 nhrp_entry_get_fib_index (ne),
215 t->type, GRE_TUNNEL_MODE_P2P, 0, &key->gtk_v4);
216 else
217 gre_mk_key6 (&t->tunnel_src.ip6,
218 &nh->fp_addr.ip6,
219 nhrp_entry_get_fib_index (ne),
220 t->type, GRE_TUNNEL_MODE_P2P, 0, &key->gtk_v6);
221}
222
223static void
224gre_nhrp_entry_added (const nhrp_entry_t * ne)
225{
226 gre_main_t *gm = &gre_main;
227 gre_tunnel_key_t key;
228 gre_tunnel_t *t;
229 u32 sw_if_index;
230 u32 t_idx;
231
232 sw_if_index = nhrp_entry_get_sw_if_index (ne);
233 if (vec_len (gm->tunnel_index_by_sw_if_index) < sw_if_index)
234 return;
235
236 t_idx = gm->tunnel_index_by_sw_if_index[sw_if_index];
237
238 if (INDEX_INVALID == t_idx)
239 return;
240
241 t = pool_elt_at_index (gm->tunnels, t_idx);
242
243 gre_nhrp_mk_key (t, ne, &key);
244 gre_tunnel_db_add (t, &key);
245}
246
247static void
248gre_nhrp_entry_deleted (const nhrp_entry_t * ne)
249{
250 gre_main_t *gm = &gre_main;
251 gre_tunnel_key_t key;
252 gre_tunnel_t *t;
253 u32 sw_if_index;
254 u32 t_idx;
255
256 sw_if_index = nhrp_entry_get_sw_if_index (ne);
257 if (vec_len (gm->tunnel_index_by_sw_if_index) < sw_if_index)
258 return;
259
260 t_idx = gm->tunnel_index_by_sw_if_index[sw_if_index];
261
262 if (INDEX_INVALID == t_idx)
263 return;
264
265 t = pool_elt_at_index (gm->tunnels, t_idx);
266
267 gre_nhrp_mk_key (t, ne, &key);
268 gre_tunnel_db_remove (t, &key);
269}
270
271static walk_rc_t
272gre_tunnel_delete_nhrp_walk (index_t nei, void *ctx)
273{
274 gre_tunnel_t *t = ctx;
275 gre_tunnel_key_t key;
276
277 gre_nhrp_mk_key (t, nhrp_entry_get (nei), &key);
278 gre_tunnel_db_remove (t, &key);
279
280 return (WALK_CONTINUE);
281}
282
283static walk_rc_t
284gre_tunnel_add_nhrp_walk (index_t nei, void *ctx)
285{
286 gre_tunnel_t *t = ctx;
287 gre_tunnel_key_t key;
288
289 gre_nhrp_mk_key (t, nhrp_entry_get (nei), &key);
290 gre_tunnel_db_add (t, &key);
291
292 return (WALK_CONTINUE);
293}
294
Ciara Loftus7eac9162016-09-30 15:47:03 +0100295static int
Neale Ranns5a8844b2019-04-16 07:15:35 +0000296vnet_gre_tunnel_add (vnet_gre_tunnel_add_del_args_t * a,
John Loa43ccae2018-02-13 17:15:23 -0500297 u32 outer_fib_index, u32 * sw_if_indexp)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700298{
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530299 gre_main_t *gm = &gre_main;
300 vnet_main_t *vnm = gm->vnet_main;
301 ip4_main_t *im4 = &ip4_main;
302 ip6_main_t *im6 = &ip6_main;
303 gre_tunnel_t *t;
304 vnet_hw_interface_t *hi;
Chris Luke27fe48f2016-04-28 13:44:38 -0400305 u32 hw_if_index, sw_if_index;
David Hothama8cd3092016-09-19 09:55:07 -0700306 clib_error_t *error;
Ciara Loftus7eac9162016-09-30 15:47:03 +0100307 u8 is_ipv6 = a->is_ipv6;
Neale Ranns33ce60d2017-12-14 08:51:32 -0800308 gre_tunnel_key_t key;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700309
John Loa43ccae2018-02-13 17:15:23 -0500310 t = gre_tunnel_db_find (a, outer_fib_index, &key);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100311 if (NULL != t)
John Loa43ccae2018-02-13 17:15:23 -0500312 return VNET_API_ERROR_IF_ALREADY_EXISTS;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700313
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100314 pool_get_aligned (gm->tunnels, t, CLIB_CACHE_LINE_BYTES);
Dave Barachb7b92992018-10-17 10:38:51 -0400315 clib_memset (t, 0, sizeof (*t));
John Loa43ccae2018-02-13 17:15:23 -0500316
317 /* Reconcile the real dev_instance and a possible requested instance */
318 u32 t_idx = t - gm->tunnels; /* tunnel index (or instance) */
319 u32 u_idx = a->instance; /* user specified instance */
320 if (u_idx == ~0)
321 u_idx = t_idx;
322 if (hash_get (gm->instance_used, u_idx))
323 {
324 pool_put (gm->tunnels, t);
325 return VNET_API_ERROR_INSTANCE_IN_USE;
326 }
327 hash_set (gm->instance_used, u_idx, 1);
328
329 t->dev_instance = t_idx; /* actual */
330 t->user_instance = u_idx; /* name */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700331
Neale Ranns5a8844b2019-04-16 07:15:35 +0000332 t->type = a->type;
Neale Ranns5f8f6172019-04-18 10:23:56 +0000333 t->mode = a->mode;
John Loa43ccae2018-02-13 17:15:23 -0500334 if (t->type == GRE_TUNNEL_TYPE_ERSPAN)
335 t->session_id = a->session_id;
Neale Ranns177bbdc2016-11-15 09:46:51 +0000336
John Loa43ccae2018-02-13 17:15:23 -0500337 if (t->type == GRE_TUNNEL_TYPE_L3)
Neale Ranns5f8f6172019-04-18 10:23:56 +0000338 {
339 if (t->mode == GRE_TUNNEL_MODE_P2P)
340 hw_if_index =
341 vnet_register_interface (vnm, gre_device_class.index, t_idx,
342 gre_hw_interface_class.index, t_idx);
343 else
344 hw_if_index =
345 vnet_register_interface (vnm, gre_device_class.index, t_idx,
346 mgre_hw_interface_class.index, t_idx);
347 }
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530348 else
349 {
John Loa43ccae2018-02-13 17:15:23 -0500350 /* Default MAC address (d00b:eed0:0000 + sw_if_index) */
John Lo25d417f2018-02-15 15:47:53 -0500351 u8 address[6] =
352 { 0xd0, 0x0b, 0xee, 0xd0, (u8) (t_idx >> 8), (u8) t_idx };
353 error =
354 ethernet_register_interface (vnm, gre_device_class.index, t_idx,
355 address, &hw_if_index, 0);
John Loa43ccae2018-02-13 17:15:23 -0500356 if (error)
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530357 {
John Loa43ccae2018-02-13 17:15:23 -0500358 clib_error_report (error);
359 return VNET_API_ERROR_INVALID_REGISTRATION;
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530360 }
Chris Luke27fe48f2016-04-28 13:44:38 -0400361 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700362
John Loa43ccae2018-02-13 17:15:23 -0500363 /* Set GRE tunnel interface output node (not used for L3 payload) */
364 vnet_set_interface_output_node (vnm, hw_if_index, gre_encap_node.index);
365
366 hi = vnet_get_hw_interface (vnm, hw_if_index);
367 sw_if_index = hi->sw_if_index;
368
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100369 t->hw_if_index = hw_if_index;
370 t->outer_fib_index = outer_fib_index;
371 t->sw_if_index = sw_if_index;
Neale Rannsad422ed2016-11-02 14:20:04 +0000372 t->l2_adj_index = ADJ_INDEX_INVALID;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700373
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100374 vec_validate_init_empty (gm->tunnel_index_by_sw_if_index, sw_if_index, ~0);
John Loa43ccae2018-02-13 17:15:23 -0500375 gm->tunnel_index_by_sw_if_index[sw_if_index] = t_idx;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700376
Ciara Loftus7eac9162016-09-30 15:47:03 +0100377 if (!is_ipv6)
378 {
379 vec_validate (im4->fib_index_by_sw_if_index, sw_if_index);
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530380 hi->min_packet_bytes =
381 64 + sizeof (gre_header_t) + sizeof (ip4_header_t);
Ciara Loftus7eac9162016-09-30 15:47:03 +0100382 }
383 else
384 {
385 vec_validate (im6->fib_index_by_sw_if_index, sw_if_index);
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530386 hi->min_packet_bytes =
387 64 + sizeof (gre_header_t) + sizeof (ip6_header_t);
Ciara Loftus7eac9162016-09-30 15:47:03 +0100388 }
Chris Luke71649002016-05-06 11:51:54 -0400389
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100390 /* Standard default gre MTU. */
Ole Troand7231612018-06-07 10:17:57 +0200391 vnet_sw_interface_set_mtu (vnm, sw_if_index, 9000);
Damjan Marionfe7d4a22018-04-13 19:43:39 +0200392
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100393 /*
394 * source the FIB entry for the tunnel's destination
395 * and become a child thereof. The tunnel will then get poked
396 * when the forwarding for the entry updates, and the tunnel can
397 * re-stack accordingly
398 */
Ciara Loftus7eac9162016-09-30 15:47:03 +0100399
400 clib_memcpy (&t->tunnel_src, &a->src, sizeof (t->tunnel_src));
401 t->tunnel_dst.fp_len = !is_ipv6 ? 32 : 128;
402 t->tunnel_dst.fp_proto = !is_ipv6 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
403 t->tunnel_dst.fp_addr = a->dst;
404
Neale Ranns33ce60d2017-12-14 08:51:32 -0800405 gre_tunnel_db_add (t, &key);
Neale Ranns4c16d802019-12-17 20:15:03 +0000406
407 if (t->mode == GRE_TUNNEL_MODE_MP)
408 nhrp_walk_itf (t->sw_if_index, gre_tunnel_add_nhrp_walk, t);
409
John Loa43ccae2018-02-13 17:15:23 -0500410 if (t->type == GRE_TUNNEL_TYPE_ERSPAN)
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530411 {
John Loa43ccae2018-02-13 17:15:23 -0500412 gre_sn_key_t skey;
413 gre_sn_t *gre_sn;
414
415 gre_mk_sn_key (t, &skey);
416 gre_sn = (gre_sn_t *) hash_get_mem (gm->seq_num_by_key, &skey);
417 if (gre_sn != NULL)
418 {
419 gre_sn->ref_count++;
420 t->gre_sn = gre_sn;
421 }
422 else
423 {
424 gre_sn = clib_mem_alloc (sizeof (gre_sn_t));
425 gre_sn->seq_num = 0;
426 gre_sn->ref_count = 1;
427 t->gre_sn = gre_sn;
428 hash_set_mem_alloc (&gm->seq_num_by_key, &skey, (uword) gre_sn);
429 }
430 }
431
John Loa43ccae2018-02-13 17:15:23 -0500432 if (t->type != GRE_TUNNEL_TYPE_L3)
433 {
434 t->l2_adj_index = adj_nbr_add_or_lock
435 (t->tunnel_dst.fp_proto, VNET_LINK_ETHERNET, &zero_addr, sw_if_index);
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530436 gre_update_adj (vnm, t->sw_if_index, t->l2_adj_index);
437 }
Chris Luke27fe48f2016-04-28 13:44:38 -0400438
439 if (sw_if_indexp)
440 *sw_if_indexp = sw_if_index;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700441
Jakub Grajciarf03beca2019-05-24 08:25:03 +0200442 /* register gre46-input nodes */
443 ip4_register_protocol (IP_PROTOCOL_GRE, gre4_input_node.index);
444 ip6_register_protocol (IP_PROTOCOL_GRE, gre6_input_node.index);
445
Ed Warnickecb9cada2015-12-08 15:45:58 -0700446 return 0;
447}
448
Ciara Loftus7eac9162016-09-30 15:47:03 +0100449static int
Neale Ranns5a8844b2019-04-16 07:15:35 +0000450vnet_gre_tunnel_delete (vnet_gre_tunnel_add_del_args_t * a,
John Loa43ccae2018-02-13 17:15:23 -0500451 u32 outer_fib_index, u32 * sw_if_indexp)
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100452{
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530453 gre_main_t *gm = &gre_main;
454 vnet_main_t *vnm = gm->vnet_main;
455 gre_tunnel_t *t;
Neale Ranns33ce60d2017-12-14 08:51:32 -0800456 gre_tunnel_key_t key;
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100457 u32 sw_if_index;
John Lo101e0052018-01-06 00:22:54 -0500458
John Loa43ccae2018-02-13 17:15:23 -0500459 t = gre_tunnel_db_find (a, outer_fib_index, &key);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100460 if (NULL == t)
461 return VNET_API_ERROR_NO_SUCH_ENTRY;
462
Neale Ranns4c16d802019-12-17 20:15:03 +0000463 if (t->mode == GRE_TUNNEL_MODE_MP)
464 nhrp_walk_itf (t->sw_if_index, gre_tunnel_delete_nhrp_walk, t);
465
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100466 sw_if_index = t->sw_if_index;
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530467 vnet_sw_interface_set_flags (vnm, sw_if_index, 0 /* down */ );
John Loa43ccae2018-02-13 17:15:23 -0500468
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100469 /* make sure tunnel is removed from l2 bd or xconnect */
Neale Rannsb4743802018-09-05 09:13:57 -0700470 set_int_l2_mode (gm->vlib_main, vnm, MODE_L3, sw_if_index, 0,
471 L2_BD_PORT_TYPE_NORMAL, 0, 0);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100472 gm->tunnel_index_by_sw_if_index[sw_if_index] = ~0;
Neale Ranns177bbdc2016-11-15 09:46:51 +0000473
John Loa43ccae2018-02-13 17:15:23 -0500474 if (t->type == GRE_TUNNEL_TYPE_L3)
475 vnet_delete_hw_interface (vnm, t->hw_if_index);
476 else
477 ethernet_delete_interface (vnm, t->hw_if_index);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100478
Neale Rannsad422ed2016-11-02 14:20:04 +0000479 if (t->l2_adj_index != ADJ_INDEX_INVALID)
Neale Ranns4c3ba812019-03-26 07:02:58 +0000480 {
481 adj_midchain_delegate_unstack (t->l2_adj_index);
482 adj_unlock (t->l2_adj_index);
483 }
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100484
John Loa43ccae2018-02-13 17:15:23 -0500485 ASSERT ((t->type != GRE_TUNNEL_TYPE_ERSPAN) || (t->gre_sn != NULL));
486 if ((t->type == GRE_TUNNEL_TYPE_ERSPAN) && (t->gre_sn->ref_count-- == 1))
487 {
488 gre_sn_key_t skey;
489 gre_mk_sn_key (t, &skey);
490 hash_unset_mem_free (&gm->seq_num_by_key, &skey);
491 clib_mem_free (t->gre_sn);
492 }
493
494 hash_unset (gm->instance_used, t->user_instance);
Neale Ranns4c16d802019-12-17 20:15:03 +0000495 gre_tunnel_db_remove (t, &key);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100496 pool_put (gm->tunnels, t);
497
498 if (sw_if_indexp)
499 *sw_if_indexp = sw_if_index;
500
501 return 0;
502}
503
504int
Neale Ranns5a8844b2019-04-16 07:15:35 +0000505vnet_gre_tunnel_add_del (vnet_gre_tunnel_add_del_args_t * a,
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530506 u32 * sw_if_indexp)
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100507{
John Loa43ccae2018-02-13 17:15:23 -0500508 u32 outer_fib_index;
509
510 if (!a->is_ipv6)
Neale Ranns5f8f6172019-04-18 10:23:56 +0000511 outer_fib_index = ip4_fib_index_from_table_id (a->outer_table_id);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100512 else
Neale Ranns5f8f6172019-04-18 10:23:56 +0000513 outer_fib_index = ip6_fib_index_from_table_id (a->outer_table_id);
John Loa43ccae2018-02-13 17:15:23 -0500514
515 if (~0 == outer_fib_index)
516 return VNET_API_ERROR_NO_SUCH_FIB;
517
518 if (a->session_id > GTK_SESSION_ID_MAX)
519 return VNET_API_ERROR_INVALID_SESSION_ID;
520
Neale Ranns4c16d802019-12-17 20:15:03 +0000521 if (a->mode == GRE_TUNNEL_MODE_MP && !ip46_address_is_zero (&a->dst))
522 return (VNET_API_ERROR_INVALID_DST_ADDRESS);
523
John Loa43ccae2018-02-13 17:15:23 -0500524 if (a->is_add)
525 return (vnet_gre_tunnel_add (a, outer_fib_index, sw_if_indexp));
526 else
527 return (vnet_gre_tunnel_delete (a, outer_fib_index, sw_if_indexp));
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100528}
529
Neale Rannsb80c5362016-10-08 13:03:40 +0100530clib_error_t *
531gre_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags)
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100532{
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530533 gre_main_t *gm = &gre_main;
534 vnet_hw_interface_t *hi;
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100535 gre_tunnel_t *t;
Neale Rannsb80c5362016-10-08 13:03:40 +0100536 u32 ti;
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100537
Neale Rannsb80c5362016-10-08 13:03:40 +0100538 hi = vnet_get_hw_interface (vnm, hw_if_index);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100539
Neale Rannsb80c5362016-10-08 13:03:40 +0100540 if (NULL == gm->tunnel_index_by_sw_if_index ||
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530541 hi->sw_if_index >= vec_len (gm->tunnel_index_by_sw_if_index))
542 return (NULL);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100543
Neale Rannsb80c5362016-10-08 13:03:40 +0100544 ti = gm->tunnel_index_by_sw_if_index[hi->sw_if_index];
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100545
Neale Rannsb80c5362016-10-08 13:03:40 +0100546 if (~0 == ti)
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530547 /* not one of ours */
548 return (NULL);
Neale Rannsb80c5362016-10-08 13:03:40 +0100549
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530550 t = pool_elt_at_index (gm->tunnels, ti);
Neale Rannsb80c5362016-10-08 13:03:40 +0100551
552 if (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP)
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530553 vnet_hw_interface_set_flags (vnm, hw_if_index,
554 VNET_HW_INTERFACE_FLAG_LINK_UP);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100555 else
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530556 vnet_hw_interface_set_flags (vnm, hw_if_index, 0 /* down */ );
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100557
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530558 gre_tunnel_restack (t);
Neale Rannsb80c5362016-10-08 13:03:40 +0100559
560 return /* no error */ 0;
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100561}
Ed Warnickecb9cada2015-12-08 15:45:58 -0700562
563static clib_error_t *
564create_gre_tunnel_command_fn (vlib_main_t * vm,
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530565 unformat_input_t * input,
566 vlib_cli_command_t * cmd)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700567{
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530568 unformat_input_t _line_input, *line_input = &_line_input;
Neale Ranns5a8844b2019-04-16 07:15:35 +0000569 vnet_gre_tunnel_add_del_args_t _a, *a = &_a;
Neale Ranns5f8f6172019-04-18 10:23:56 +0000570 ip46_address_t src = ip46_address_initializer, dst =
571 ip46_address_initializer;
John Loa43ccae2018-02-13 17:15:23 -0500572 u32 instance = ~0;
Neale Ranns5f8f6172019-04-18 10:23:56 +0000573 u32 outer_table_id = 0;
John Loa43ccae2018-02-13 17:15:23 -0500574 gre_tunnel_type_t t_type = GRE_TUNNEL_TYPE_L3;
Neale Ranns5f8f6172019-04-18 10:23:56 +0000575 gre_tunnel_mode_t t_mode = GRE_TUNNEL_MODE_P2P;
John Loa43ccae2018-02-13 17:15:23 -0500576 u32 session_id = 0;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700577 int rv;
Chris Luke27fe48f2016-04-28 13:44:38 -0400578 u8 is_add = 1;
Pierre Pfister78ea9c22016-05-23 12:51:54 +0100579 u32 sw_if_index;
Billy McFalla9a20e72017-02-15 11:39:12 -0500580 clib_error_t *error = NULL;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700581
582 /* Get a line of input. */
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530583 if (!unformat_user (input, unformat_line_input, line_input))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700584 return 0;
585
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530586 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
587 {
588 if (unformat (line_input, "del"))
589 is_add = 0;
John Loa43ccae2018-02-13 17:15:23 -0500590 else if (unformat (line_input, "instance %d", &instance))
591 ;
Neale Ranns5f8f6172019-04-18 10:23:56 +0000592 else if (unformat (line_input, "src %U", unformat_ip46_address, &src))
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530593 ;
Neale Ranns5f8f6172019-04-18 10:23:56 +0000594 else if (unformat (line_input, "dst %U", unformat_ip46_address, &dst))
595 ;
596 else if (unformat (line_input, "outer-table-id %d", &outer_table_id))
597 ;
598 else if (unformat (line_input, "multipoint"))
599 t_mode = GRE_TUNNEL_MODE_MP;
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530600 else if (unformat (line_input, "teb"))
John Loa43ccae2018-02-13 17:15:23 -0500601 t_type = GRE_TUNNEL_TYPE_TEB;
602 else if (unformat (line_input, "erspan %d", &session_id))
603 t_type = GRE_TUNNEL_TYPE_ERSPAN;
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530604 else
605 {
606 error = clib_error_return (0, "unknown input `%U'",
607 format_unformat_error, line_input);
608 goto done;
609 }
610 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700611
Neale Ranns5f8f6172019-04-18 10:23:56 +0000612 if (ip46_address_is_equal (&src, &dst))
Billy McFalla9a20e72017-02-15 11:39:12 -0500613 {
614 error = clib_error_return (0, "src and dst are identical");
615 goto done;
616 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700617
Neale Ranns5f8f6172019-04-18 10:23:56 +0000618 if (t_mode != GRE_TUNNEL_MODE_MP && ip46_address_is_zero (&dst))
Ciara Loftus7eac9162016-09-30 15:47:03 +0100619 {
Neale Ranns5f8f6172019-04-18 10:23:56 +0000620 error = clib_error_return (0, "destination address not specified");
621 goto done;
622 }
623
624 if (ip46_address_is_zero (&src))
625 {
626 error = clib_error_return (0, "source address not specified");
627 goto done;
628 }
629
630 if (ip46_address_is_ip4 (&src) != ip46_address_is_ip4 (&dst))
631 {
632 error =
633 clib_error_return (0, "src and dst address must be the same AF");
Ciara Loftus7eac9162016-09-30 15:47:03 +0100634 goto done;
635 }
636
Dave Barachb7b92992018-10-17 10:38:51 -0400637 clib_memset (a, 0, sizeof (*a));
John Loa43ccae2018-02-13 17:15:23 -0500638 a->is_add = is_add;
Neale Ranns5f8f6172019-04-18 10:23:56 +0000639 a->outer_table_id = outer_table_id;
Neale Ranns5a8844b2019-04-16 07:15:35 +0000640 a->type = t_type;
Neale Ranns5f8f6172019-04-18 10:23:56 +0000641 a->mode = t_mode;
John Loa43ccae2018-02-13 17:15:23 -0500642 a->session_id = session_id;
Neale Ranns5f8f6172019-04-18 10:23:56 +0000643 a->is_ipv6 = !ip46_address_is_ip4 (&src);
John Loa43ccae2018-02-13 17:15:23 -0500644 a->instance = instance;
Neale Ranns5f8f6172019-04-18 10:23:56 +0000645 clib_memcpy (&a->src, &src, sizeof (a->src));
646 clib_memcpy (&a->dst, &dst, sizeof (a->dst));
Chris Luke27fe48f2016-04-28 13:44:38 -0400647
Neale Ranns5a8844b2019-04-16 07:15:35 +0000648 rv = vnet_gre_tunnel_add_del (a, &sw_if_index);
Chris Luke27fe48f2016-04-28 13:44:38 -0400649
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530650 switch (rv)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700651 {
652 case 0:
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530653 vlib_cli_output (vm, "%U\n", format_vnet_sw_if_index_name,
654 vnet_get_main (), sw_if_index);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700655 break;
John Loa43ccae2018-02-13 17:15:23 -0500656 case VNET_API_ERROR_IF_ALREADY_EXISTS:
Billy McFalla9a20e72017-02-15 11:39:12 -0500657 error = clib_error_return (0, "GRE tunnel already exists...");
658 goto done;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700659 case VNET_API_ERROR_NO_SUCH_FIB:
Neale Ranns5f8f6172019-04-18 10:23:56 +0000660 error = clib_error_return (0, "outer table ID %d doesn't exist\n",
661 outer_table_id);
Billy McFalla9a20e72017-02-15 11:39:12 -0500662 goto done;
John Loa43ccae2018-02-13 17:15:23 -0500663 case VNET_API_ERROR_NO_SUCH_ENTRY:
664 error = clib_error_return (0, "GRE tunnel doesn't exist");
665 goto done;
666 case VNET_API_ERROR_INVALID_SESSION_ID:
667 error = clib_error_return (0, "session ID %d out of range\n",
668 session_id);
669 goto done;
670 case VNET_API_ERROR_INSTANCE_IN_USE:
671 error = clib_error_return (0, "Instance is in use");
672 goto done;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700673 default:
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530674 error =
Neale Ranns5a8844b2019-04-16 07:15:35 +0000675 clib_error_return (0, "vnet_gre_tunnel_add_del returned %d", rv);
Billy McFalla9a20e72017-02-15 11:39:12 -0500676 goto done;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700677 }
678
Billy McFalla9a20e72017-02-15 11:39:12 -0500679done:
680 unformat_free (line_input);
681
682 return error;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700683}
684
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530685/* *INDENT-OFF* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700686VLIB_CLI_COMMAND (create_gre_tunnel_command, static) = {
687 .path = "create gre tunnel",
John Loa43ccae2018-02-13 17:15:23 -0500688 .short_help = "create gre tunnel src <addr> dst <addr> [instance <n>] "
689 "[outer-fib-id <fib>] [teb | erspan <session-id>] [del]",
Ed Warnickecb9cada2015-12-08 15:45:58 -0700690 .function = create_gre_tunnel_command_fn,
691};
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530692/* *INDENT-ON* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700693
Chris Luke27fe48f2016-04-28 13:44:38 -0400694static clib_error_t *
695show_gre_tunnel_command_fn (vlib_main_t * vm,
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530696 unformat_input_t * input,
697 vlib_cli_command_t * cmd)
Chris Luke27fe48f2016-04-28 13:44:38 -0400698{
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530699 gre_main_t *gm = &gre_main;
700 gre_tunnel_t *t;
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100701 u32 ti = ~0;
Chris Luke27fe48f2016-04-28 13:44:38 -0400702
703 if (pool_elts (gm->tunnels) == 0)
704 vlib_cli_output (vm, "No GRE tunnels configured...");
705
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100706 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
707 {
708 if (unformat (input, "%d", &ti))
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530709 ;
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100710 else
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530711 break;
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100712 }
713
714 if (~0 == ti)
715 {
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530716 /* *INDENT-OFF* */
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100717 pool_foreach (t, gm->tunnels,
718 ({
Neale Rannsb80c5362016-10-08 13:03:40 +0100719 vlib_cli_output (vm, "%U", format_gre_tunnel, t);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100720 }));
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530721 /* *INDENT-ON* */
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100722 }
723 else
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530724 {
725 t = pool_elt_at_index (gm->tunnels, ti);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100726
Neale Rannsb80c5362016-10-08 13:03:40 +0100727 vlib_cli_output (vm, "%U", format_gre_tunnel, t);
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530728 }
Chris Luke27fe48f2016-04-28 13:44:38 -0400729
730 return 0;
731}
732
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530733/* *INDENT-OFF* */
Chris Luke27fe48f2016-04-28 13:44:38 -0400734VLIB_CLI_COMMAND (show_gre_tunnel_command, static) = {
735 .path = "show gre tunnel",
736 .function = show_gre_tunnel_command_fn,
737};
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530738/* *INDENT-ON* */
Chris Luke27fe48f2016-04-28 13:44:38 -0400739
Neale Ranns4c16d802019-12-17 20:15:03 +0000740const static nhrp_vft_t gre_nhrp_vft = {
741 .nv_added = gre_nhrp_entry_added,
742 .nv_deleted = gre_nhrp_entry_deleted,
743};
744
Ed Warnickecb9cada2015-12-08 15:45:58 -0700745/* force inclusion from application's main.c */
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530746clib_error_t *
747gre_interface_init (vlib_main_t * vm)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700748{
Neale Ranns4c16d802019-12-17 20:15:03 +0000749 nhrp_register (&gre_nhrp_vft);
750
Neale Ranns4c3ba812019-03-26 07:02:58 +0000751 return (NULL);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700752}
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530753
754VLIB_INIT_FUNCTION (gre_interface_init);
755
756/*
757 * fd.io coding-style-patch-verification: ON
758 *
759 * Local Variables:
760 * eval: (c-set-style "gnu")
761 * End:
762 */