blob: 8b1ad6b7dbef770a86996ce4ff388be5e7649ec7 [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>
Ed Warnickecb9cada2015-12-08 15:45:58 -070027
Neale Ranns177bbdc2016-11-15 09:46:51 +000028static const char *gre_tunnel_type_names[] = GRE_TUNNEL_TYPE_NAMES;
29
Neale Ranns0bfe5d82016-08-25 15:29:12 +010030static u8 *
Neale Ranns177bbdc2016-11-15 09:46:51 +000031format_gre_tunnel_type (u8 * s, va_list * args)
32{
33 gre_tunnel_type_t type = va_arg (*args, gre_tunnel_type_t);
34
Swarup Nayak9ff647a2017-11-27 10:27:43 +053035 return (format (s, "%s", gre_tunnel_type_names[type]));
Neale Ranns177bbdc2016-11-15 09:46:51 +000036}
37
38static u8 *
Neale Ranns0bfe5d82016-08-25 15:29:12 +010039format_gre_tunnel (u8 * s, va_list * args)
Chris Luke27fe48f2016-04-28 13:44:38 -040040{
Swarup Nayak9ff647a2017-11-27 10:27:43 +053041 gre_tunnel_t *t = va_arg (*args, gre_tunnel_t *);
42 gre_main_t *gm = &gre_main;
Ciara Loftus7eac9162016-09-30 15:47:03 +010043 u8 is_ipv6 = t->tunnel_dst.fp_proto == FIB_PROTOCOL_IP6 ? 1 : 0;
Chris Luke27fe48f2016-04-28 13:44:38 -040044
Ciara Loftus7eac9162016-09-30 15:47:03 +010045 if (!is_ipv6)
Swarup Nayak9ff647a2017-11-27 10:27:43 +053046 s = format (s,
47 "[%d] %U (src) %U (dst) payload %U outer_fib_index %d",
48 t - gm->tunnels,
49 format_ip4_address, &t->tunnel_src.ip4,
50 format_ip4_address, &t->tunnel_dst.fp_addr.ip4,
51 format_gre_tunnel_type, t->type, t->outer_fib_index);
Ciara Loftus7eac9162016-09-30 15:47:03 +010052 else
Swarup Nayak9ff647a2017-11-27 10:27:43 +053053 s = format (s,
54 "[%d] %U (src) %U (dst) payload %U outer_fib_index %d",
55 t - gm->tunnels,
56 format_ip6_address, &t->tunnel_src.ip6,
57 format_ip6_address, &t->tunnel_dst.fp_addr.ip6,
58 format_gre_tunnel_type, t->type, t->outer_fib_index);
Neale Ranns0bfe5d82016-08-25 15:29:12 +010059
Chris Luke27fe48f2016-04-28 13:44:38 -040060 return s;
61}
62
Neale Ranns0bfe5d82016-08-25 15:29:12 +010063static gre_tunnel_t *
Swarup Nayak9ff647a2017-11-27 10:27:43 +053064gre_tunnel_db_find (const ip46_address_t * src,
Neale Ranns33ce60d2017-12-14 08:51:32 -080065 const ip46_address_t * dst,
66 u32 out_fib_index, u8 is_ipv6, gre_tunnel_key_t * key)
Neale Ranns0bfe5d82016-08-25 15:29:12 +010067{
Swarup Nayak9ff647a2017-11-27 10:27:43 +053068 gre_main_t *gm = &gre_main;
69 uword *p;
Neale Ranns0bfe5d82016-08-25 15:29:12 +010070
Ciara Loftus7eac9162016-09-30 15:47:03 +010071 if (!is_ipv6)
72 {
Neale Ranns33ce60d2017-12-14 08:51:32 -080073 gre_mk_key4 (&src->ip4, &dst->ip4, out_fib_index, &key->gtk_v4);
74 p = hash_get_mem (gm->tunnel_by_key4, &key->gtk_v4);
Ciara Loftus7eac9162016-09-30 15:47:03 +010075 }
76 else
77 {
Neale Ranns33ce60d2017-12-14 08:51:32 -080078 gre_mk_key6 (&src->ip6, &dst->ip6, out_fib_index, &key->gtk_v6);
79 p = hash_get_mem (gm->tunnel_by_key6, &key->gtk_v6);
Ciara Loftus7eac9162016-09-30 15:47:03 +010080 }
Neale Ranns0bfe5d82016-08-25 15:29:12 +010081
82 if (NULL == p)
83 return (NULL);
84
85 return (pool_elt_at_index (gm->tunnels, p[0]));
86}
87
88static void
Neale Ranns33ce60d2017-12-14 08:51:32 -080089gre_tunnel_db_add (gre_tunnel_t * t, 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;
Neale Ranns0bfe5d82016-08-25 15:29:12 +010092
Neale Ranns33ce60d2017-12-14 08:51:32 -080093 t->key = clib_mem_alloc (sizeof (*t->key));
94 clib_memcpy (t->key, key, sizeof (*key));
95
96 if (t->tunnel_dst.fp_proto == FIB_PROTOCOL_IP6)
Ciara Loftus7eac9162016-09-30 15:47:03 +010097 {
Neale Ranns33ce60d2017-12-14 08:51:32 -080098 hash_set_mem (gm->tunnel_by_key6, &t->key->gtk_v6, t - gm->tunnels);
Ciara Loftus7eac9162016-09-30 15:47:03 +010099 }
100 else
101 {
Neale Ranns33ce60d2017-12-14 08:51:32 -0800102 hash_set_mem (gm->tunnel_by_key4, &t->key->gtk_v4, t - gm->tunnels);
Ciara Loftus7eac9162016-09-30 15:47:03 +0100103 }
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100104}
105
106static void
Neale Ranns33ce60d2017-12-14 08:51:32 -0800107gre_tunnel_db_remove (gre_tunnel_t * t)
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100108{
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530109 gre_main_t *gm = &gre_main;
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100110
Neale Ranns33ce60d2017-12-14 08:51:32 -0800111 if (t->tunnel_dst.fp_proto == FIB_PROTOCOL_IP6)
Ciara Loftus7eac9162016-09-30 15:47:03 +0100112 {
Neale Ranns33ce60d2017-12-14 08:51:32 -0800113 hash_unset_mem (gm->tunnel_by_key6, &t->key->gtk_v6);
Ciara Loftus7eac9162016-09-30 15:47:03 +0100114 }
115 else
116 {
Neale Ranns33ce60d2017-12-14 08:51:32 -0800117 hash_unset_mem (gm->tunnel_by_key4, &t->key->gtk_v4);
Ciara Loftus7eac9162016-09-30 15:47:03 +0100118 }
119
Neale Ranns33ce60d2017-12-14 08:51:32 -0800120 clib_mem_free (t->key);
121 t->key = NULL;
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100122}
123
124static gre_tunnel_t *
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530125gre_tunnel_from_fib_node (fib_node_t * node)
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100126{
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530127 ASSERT (FIB_NODE_TYPE_GRE_TUNNEL == node->fn_type);
128 return ((gre_tunnel_t *) (((char *) node) -
129 STRUCT_OFFSET_OF (gre_tunnel_t, node)));
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100130}
131
Neale Ranns5e575b12016-10-03 09:40:25 +0100132/**
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100133 * gre_tunnel_stack
134 *
135 * 'stack' (resolve the recursion for) the tunnel's midchain adjacency
136 */
Neale Ranns5e575b12016-10-03 09:40:25 +0100137void
Neale Rannsb80c5362016-10-08 13:03:40 +0100138gre_tunnel_stack (adj_index_t ai)
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100139{
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530140 gre_main_t *gm = &gre_main;
141 ip_adjacency_t *adj;
142 gre_tunnel_t *gt;
143 u32 sw_if_index;
Neale Rannsb80c5362016-10-08 13:03:40 +0100144
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530145 adj = adj_get (ai);
146 sw_if_index = adj->rewrite_header.sw_if_index;
Neale Rannsb80c5362016-10-08 13:03:40 +0100147
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530148 if ((vec_len (gm->tunnel_index_by_sw_if_index) < sw_if_index) ||
149 (~0 == gm->tunnel_index_by_sw_if_index[sw_if_index]))
150 return;
Neale Rannsb80c5362016-10-08 13:03:40 +0100151
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530152 gt = pool_elt_at_index (gm->tunnels,
153 gm->tunnel_index_by_sw_if_index[sw_if_index]);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100154
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530155 /*
156 * find the adjacency that is contributed by the FIB entry
157 * that this tunnel resovles via, and use it as the next adj
158 * in the midchain
159 */
160 if (vnet_hw_interface_get_flags (vnet_get_main (),
161 gt->hw_if_index) &
162 VNET_HW_INTERFACE_FLAG_LINK_UP)
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100163 {
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530164 adj_nbr_midchain_stack (ai,
165 fib_entry_contribute_ip_forwarding
166 (gt->fib_entry_index));
Neale Rannsb80c5362016-10-08 13:03:40 +0100167 }
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530168 else
Neale Rannsb80c5362016-10-08 13:03:40 +0100169 {
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530170 adj_nbr_midchain_unstack (ai);
Neale Rannsb80c5362016-10-08 13:03:40 +0100171 }
172}
173
174/**
175 * @brief Call back when restacking all adjacencies on a GRE interface
176 */
177static adj_walk_rc_t
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530178gre_adj_walk_cb (adj_index_t ai, void *ctx)
Neale Rannsb80c5362016-10-08 13:03:40 +0100179{
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530180 gre_tunnel_stack (ai);
Neale Rannsb80c5362016-10-08 13:03:40 +0100181
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530182 return (ADJ_WALK_RC_CONTINUE);
Neale Rannsb80c5362016-10-08 13:03:40 +0100183}
184
185static void
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530186gre_tunnel_restack (gre_tunnel_t * gt)
Neale Rannsb80c5362016-10-08 13:03:40 +0100187{
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530188 fib_protocol_t proto;
Neale Rannsb80c5362016-10-08 13:03:40 +0100189
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530190 /*
191 * walk all the adjacencies on th GRE interface and restack them
192 */
193 FOR_EACH_FIB_IP_PROTOCOL (proto)
194 {
195 adj_nbr_walk (gt->sw_if_index, proto, gre_adj_walk_cb, NULL);
196 }
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100197}
198
199/**
200 * Function definition to backwalk a FIB node
201 */
202static fib_node_back_walk_rc_t
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530203gre_tunnel_back_walk (fib_node_t * node, fib_node_back_walk_ctx_t * ctx)
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100204{
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530205 gre_tunnel_restack (gre_tunnel_from_fib_node (node));
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100206
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530207 return (FIB_NODE_BACK_WALK_CONTINUE);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100208}
209
210/**
211 * Function definition to get a FIB node from its index
212 */
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530213static fib_node_t *
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100214gre_tunnel_fib_node_get (fib_node_index_t index)
215{
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530216 gre_tunnel_t *gt;
217 gre_main_t *gm;
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100218
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530219 gm = &gre_main;
220 gt = pool_elt_at_index (gm->tunnels, index);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100221
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530222 return (&gt->node);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100223}
224
225/**
226 * Function definition to inform the FIB node that its last lock has gone.
227 */
228static void
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530229gre_tunnel_last_lock_gone (fib_node_t * node)
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100230{
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530231 /*
232 * The MPLS GRE tunnel is a root of the graph. As such
233 * it never has children and thus is never locked.
234 */
235 ASSERT (0);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100236}
237
238/*
239 * Virtual function table registered by MPLS GRE tunnels
240 * for participation in the FIB object graph.
241 */
242const static fib_node_vft_t gre_vft = {
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530243 .fnv_get = gre_tunnel_fib_node_get,
244 .fnv_last_lock = gre_tunnel_last_lock_gone,
245 .fnv_back_walk = gre_tunnel_back_walk,
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100246};
247
Ciara Loftus7eac9162016-09-30 15:47:03 +0100248static int
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530249vnet_gre_tunnel_add (vnet_gre_add_del_tunnel_args_t * a, u32 * sw_if_indexp)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700250{
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530251 gre_main_t *gm = &gre_main;
252 vnet_main_t *vnm = gm->vnet_main;
253 ip4_main_t *im4 = &ip4_main;
254 ip6_main_t *im6 = &ip6_main;
255 gre_tunnel_t *t;
256 vnet_hw_interface_t *hi;
Chris Luke27fe48f2016-04-28 13:44:38 -0400257 u32 hw_if_index, sw_if_index;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700258 u32 outer_fib_index;
David Hothama8cd3092016-09-19 09:55:07 -0700259 u8 address[6];
260 clib_error_t *error;
Ciara Loftus7eac9162016-09-30 15:47:03 +0100261 u8 is_ipv6 = a->is_ipv6;
Neale Ranns33ce60d2017-12-14 08:51:32 -0800262 gre_tunnel_key_t key;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700263
Ciara Loftus7eac9162016-09-30 15:47:03 +0100264 if (!is_ipv6)
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530265 outer_fib_index = ip4_fib_index_from_table_id (a->outer_fib_id);
Ciara Loftus7eac9162016-09-30 15:47:03 +0100266 else
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530267 outer_fib_index = ip6_fib_index_from_table_id (a->outer_fib_id);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700268
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100269 if (~0 == outer_fib_index)
270 return VNET_API_ERROR_NO_SUCH_FIB;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700271
Neale Ranns33ce60d2017-12-14 08:51:32 -0800272 t =
John Lo101e0052018-01-06 00:22:54 -0500273 gre_tunnel_db_find (&a->src, &a->dst, outer_fib_index, a->is_ipv6, &key);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700274
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100275 if (NULL != t)
276 return VNET_API_ERROR_INVALID_VALUE;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700277
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100278 pool_get_aligned (gm->tunnels, t, CLIB_CACHE_LINE_BYTES);
279 memset (t, 0, sizeof (*t));
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530280 fib_node_init (&t->node, FIB_NODE_TYPE_GRE_TUNNEL);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700281
Neale Ranns177bbdc2016-11-15 09:46:51 +0000282 if (a->teb)
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530283 t->type = GRE_TUNNEL_TYPE_TEB;
Neale Ranns177bbdc2016-11-15 09:46:51 +0000284 else
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530285 t->type = GRE_TUNNEL_TYPE_L3;
Neale Ranns177bbdc2016-11-15 09:46:51 +0000286
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530287 if (vec_len (gm->free_gre_tunnel_hw_if_indices[t->type]) > 0)
288 {
289 vnet_interface_main_t *im = &vnm->interface_main;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700290
Neale Ranns177bbdc2016-11-15 09:46:51 +0000291 hw_if_index = gm->free_gre_tunnel_hw_if_indices[t->type]
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530292 [vec_len (gm->free_gre_tunnel_hw_if_indices[t->type]) - 1];
Neale Ranns177bbdc2016-11-15 09:46:51 +0000293 _vec_len (gm->free_gre_tunnel_hw_if_indices[t->type]) -= 1;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700294
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100295 hi = vnet_get_hw_interface (vnm, hw_if_index);
296 hi->dev_instance = t - gm->tunnels;
297 hi->hw_instance = hi->dev_instance;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700298
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100299 /* clear old stats of freed tunnel before reuse */
300 sw_if_index = hi->sw_if_index;
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530301 vnet_interface_counter_lock (im);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100302 vlib_zero_combined_counter
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530303 (&im->combined_sw_if_counters[VNET_INTERFACE_COUNTER_TX],
304 sw_if_index);
305 vlib_zero_combined_counter (&im->combined_sw_if_counters
306 [VNET_INTERFACE_COUNTER_RX], sw_if_index);
307 vlib_zero_simple_counter (&im->sw_if_counters
308 [VNET_INTERFACE_COUNTER_DROP], sw_if_index);
309 vnet_interface_counter_unlock (im);
Neale Ranns177bbdc2016-11-15 09:46:51 +0000310 if (GRE_TUNNEL_TYPE_TEB == t->type)
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530311 {
312 t->l2_tx_arc = vlib_node_add_named_next (vlib_get_main (),
313 hi->tx_node_index,
314 "adj-l2-midchain");
315 }
316 }
317 else
318 {
Neale Ranns177bbdc2016-11-15 09:46:51 +0000319 if (GRE_TUNNEL_TYPE_TEB == t->type)
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530320 {
321 /* Default MAC address (d00b:eed0:0000 + sw_if_index) */
322 memset (address, 0, sizeof (address));
323 address[0] = 0xd0;
324 address[1] = 0x0b;
325 address[2] = 0xee;
326 address[3] = 0xd0;
327 address[4] = t - gm->tunnels;
David Hothama8cd3092016-09-19 09:55:07 -0700328
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530329 error = ethernet_register_interface (vnm,
330 gre_device_teb_class.index,
331 t - gm->tunnels, address,
332 &hw_if_index, 0);
David Hothama8cd3092016-09-19 09:55:07 -0700333
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530334 if (error)
335 {
336 clib_error_report (error);
337 return VNET_API_ERROR_INVALID_REGISTRATION;
338 }
339 hi = vnet_get_hw_interface (vnm, hw_if_index);
Neale Ranns5e575b12016-10-03 09:40:25 +0100340
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530341 t->l2_tx_arc = vlib_node_add_named_next (vlib_get_main (),
342 hi->tx_node_index,
343 "adj-l2-midchain");
344 }
345 else
346 {
347 hw_if_index = vnet_register_interface (vnm,
348 gre_device_class.index,
349 t - gm->tunnels,
350 gre_hw_interface_class.index,
351 t - gm->tunnels);
352 }
David Hothama8cd3092016-09-19 09:55:07 -0700353 hi = vnet_get_hw_interface (vnm, hw_if_index);
354 sw_if_index = hi->sw_if_index;
Chris Luke27fe48f2016-04-28 13:44:38 -0400355 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700356
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100357 t->hw_if_index = hw_if_index;
358 t->outer_fib_index = outer_fib_index;
359 t->sw_if_index = sw_if_index;
Neale Rannsad422ed2016-11-02 14:20:04 +0000360 t->l2_adj_index = ADJ_INDEX_INVALID;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700361
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100362 vec_validate_init_empty (gm->tunnel_index_by_sw_if_index, sw_if_index, ~0);
363 gm->tunnel_index_by_sw_if_index[sw_if_index] = t - gm->tunnels;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700364
Ciara Loftus7eac9162016-09-30 15:47:03 +0100365 if (!is_ipv6)
366 {
367 vec_validate (im4->fib_index_by_sw_if_index, sw_if_index);
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530368 hi->min_packet_bytes =
369 64 + sizeof (gre_header_t) + sizeof (ip4_header_t);
Ciara Loftus7eac9162016-09-30 15:47:03 +0100370 }
371 else
372 {
373 vec_validate (im6->fib_index_by_sw_if_index, sw_if_index);
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530374 hi->min_packet_bytes =
375 64 + sizeof (gre_header_t) + sizeof (ip6_header_t);
Ciara Loftus7eac9162016-09-30 15:47:03 +0100376 }
Chris Luke71649002016-05-06 11:51:54 -0400377
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100378 hi->per_packet_overhead_bytes =
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530379 /* preamble */ 8 + /* inter frame gap */ 12;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700380
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100381 /* Standard default gre MTU. */
382 hi->max_l3_packet_bytes[VLIB_RX] = hi->max_l3_packet_bytes[VLIB_TX] = 9000;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700383
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100384 /*
385 * source the FIB entry for the tunnel's destination
386 * and become a child thereof. The tunnel will then get poked
387 * when the forwarding for the entry updates, and the tunnel can
388 * re-stack accordingly
389 */
Ciara Loftus7eac9162016-09-30 15:47:03 +0100390
391 clib_memcpy (&t->tunnel_src, &a->src, sizeof (t->tunnel_src));
392 t->tunnel_dst.fp_len = !is_ipv6 ? 32 : 128;
393 t->tunnel_dst.fp_proto = !is_ipv6 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
394 t->tunnel_dst.fp_addr = a->dst;
395
Neale Ranns33ce60d2017-12-14 08:51:32 -0800396 gre_tunnel_db_add (t, &key);
Chris Luke27fe48f2016-04-28 13:44:38 -0400397
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100398 t->fib_entry_index =
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530399 fib_table_entry_special_add (outer_fib_index,
400 &t->tunnel_dst,
401 FIB_SOURCE_RR, FIB_ENTRY_FLAG_NONE);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100402 t->sibling_index =
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530403 fib_entry_child_add (t->fib_entry_index,
404 FIB_NODE_TYPE_GRE_TUNNEL, t - gm->tunnels);
Chris Luke27fe48f2016-04-28 13:44:38 -0400405
Neale Ranns177bbdc2016-11-15 09:46:51 +0000406 if (GRE_TUNNEL_TYPE_TEB == t->type)
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530407 {
408 t->l2_adj_index = adj_nbr_add_or_lock (t->tunnel_dst.fp_proto,
409 VNET_LINK_ETHERNET,
410 &zero_addr, sw_if_index);
411 gre_update_adj (vnm, t->sw_if_index, t->l2_adj_index);
412 }
Chris Luke27fe48f2016-04-28 13:44:38 -0400413
414 if (sw_if_indexp)
415 *sw_if_indexp = sw_if_index;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700416
417 return 0;
418}
419
Ciara Loftus7eac9162016-09-30 15:47:03 +0100420static int
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530421vnet_gre_tunnel_delete (vnet_gre_add_del_tunnel_args_t * a,
422 u32 * sw_if_indexp)
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100423{
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530424 gre_main_t *gm = &gre_main;
425 vnet_main_t *vnm = gm->vnet_main;
426 gre_tunnel_t *t;
Neale Ranns33ce60d2017-12-14 08:51:32 -0800427 gre_tunnel_key_t key;
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100428 u32 sw_if_index;
John Lo101e0052018-01-06 00:22:54 -0500429 u32 outer_fib_index;
430
431 if (!a->is_ipv6)
432 outer_fib_index = ip4_fib_index_from_table_id (a->outer_fib_id);
433 else
434 outer_fib_index = ip6_fib_index_from_table_id (a->outer_fib_id);
435
436 if (~0 == outer_fib_index)
437 return VNET_API_ERROR_NO_SUCH_FIB;
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100438
Neale Ranns33ce60d2017-12-14 08:51:32 -0800439 t =
John Lo101e0052018-01-06 00:22:54 -0500440 gre_tunnel_db_find (&a->src, &a->dst, outer_fib_index, a->is_ipv6, &key);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100441
442 if (NULL == t)
443 return VNET_API_ERROR_NO_SUCH_ENTRY;
444
445 sw_if_index = t->sw_if_index;
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530446 vnet_sw_interface_set_flags (vnm, sw_if_index, 0 /* down */ );
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100447 /* make sure tunnel is removed from l2 bd or xconnect */
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530448 set_int_l2_mode (gm->vlib_main, vnm, MODE_L3, sw_if_index, 0, 0, 0, 0);
Neale Ranns177bbdc2016-11-15 09:46:51 +0000449 vec_add1 (gm->free_gre_tunnel_hw_if_indices[t->type], t->hw_if_index);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100450 gm->tunnel_index_by_sw_if_index[sw_if_index] = ~0;
Neale Ranns177bbdc2016-11-15 09:46:51 +0000451
452 if (GRE_TUNNEL_TYPE_TEB == t->type)
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530453 adj_unlock (t->l2_adj_index);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100454
Neale Rannsad422ed2016-11-02 14:20:04 +0000455 if (t->l2_adj_index != ADJ_INDEX_INVALID)
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530456 adj_unlock (t->l2_adj_index);
Neale Rannsad422ed2016-11-02 14:20:04 +0000457
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530458 fib_entry_child_remove (t->fib_entry_index, t->sibling_index);
459 fib_table_entry_delete_index (t->fib_entry_index, FIB_SOURCE_RR);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100460
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530461 gre_tunnel_db_remove (t);
462 fib_node_deinit (&t->node);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100463 pool_put (gm->tunnels, t);
464
465 if (sw_if_indexp)
466 *sw_if_indexp = sw_if_index;
467
468 return 0;
469}
470
471int
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530472vnet_gre_add_del_tunnel (vnet_gre_add_del_tunnel_args_t * a,
473 u32 * sw_if_indexp)
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100474{
475 if (a->is_add)
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530476 return (vnet_gre_tunnel_add (a, sw_if_indexp));
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100477 else
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530478 return (vnet_gre_tunnel_delete (a, sw_if_indexp));
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100479}
480
Neale Rannsb80c5362016-10-08 13:03:40 +0100481clib_error_t *
482gre_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags)
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100483{
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530484 gre_main_t *gm = &gre_main;
485 vnet_hw_interface_t *hi;
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100486 gre_tunnel_t *t;
Neale Rannsb80c5362016-10-08 13:03:40 +0100487 u32 ti;
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100488
Neale Rannsb80c5362016-10-08 13:03:40 +0100489 hi = vnet_get_hw_interface (vnm, hw_if_index);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100490
Neale Rannsb80c5362016-10-08 13:03:40 +0100491 if (NULL == gm->tunnel_index_by_sw_if_index ||
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530492 hi->sw_if_index >= vec_len (gm->tunnel_index_by_sw_if_index))
493 return (NULL);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100494
Neale Rannsb80c5362016-10-08 13:03:40 +0100495 ti = gm->tunnel_index_by_sw_if_index[hi->sw_if_index];
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100496
Neale Rannsb80c5362016-10-08 13:03:40 +0100497 if (~0 == ti)
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530498 /* not one of ours */
499 return (NULL);
Neale Rannsb80c5362016-10-08 13:03:40 +0100500
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530501 t = pool_elt_at_index (gm->tunnels, ti);
Neale Rannsb80c5362016-10-08 13:03:40 +0100502
503 if (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP)
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530504 vnet_hw_interface_set_flags (vnm, hw_if_index,
505 VNET_HW_INTERFACE_FLAG_LINK_UP);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100506 else
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530507 vnet_hw_interface_set_flags (vnm, hw_if_index, 0 /* down */ );
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100508
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530509 gre_tunnel_restack (t);
Neale Rannsb80c5362016-10-08 13:03:40 +0100510
511 return /* no error */ 0;
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100512}
Ed Warnickecb9cada2015-12-08 15:45:58 -0700513
514static clib_error_t *
515create_gre_tunnel_command_fn (vlib_main_t * vm,
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530516 unformat_input_t * input,
517 vlib_cli_command_t * cmd)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700518{
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530519 unformat_input_t _line_input, *line_input = &_line_input;
520 vnet_gre_add_del_tunnel_args_t _a, *a = &_a;
Ciara Loftus7eac9162016-09-30 15:47:03 +0100521 ip46_address_t src, dst;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700522 u32 outer_fib_id = 0;
David Hothama8cd3092016-09-19 09:55:07 -0700523 u8 teb = 0;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700524 int rv;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700525 u32 num_m_args = 0;
Chris Luke27fe48f2016-04-28 13:44:38 -0400526 u8 is_add = 1;
Pierre Pfister78ea9c22016-05-23 12:51:54 +0100527 u32 sw_if_index;
Billy McFalla9a20e72017-02-15 11:39:12 -0500528 clib_error_t *error = NULL;
Ciara Loftus7eac9162016-09-30 15:47:03 +0100529 u8 ipv4_set = 0;
530 u8 ipv6_set = 0;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700531
532 /* Get a line of input. */
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530533 if (!unformat_user (input, unformat_line_input, line_input))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700534 return 0;
535
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530536 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
537 {
538 if (unformat (line_input, "del"))
539 is_add = 0;
540 else
541 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
542 {
543 num_m_args++;
544 ipv4_set = 1;
545 }
546 else
547 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
548 {
549 num_m_args++;
550 ipv4_set = 1;
551 }
552 else
553 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
554 {
555 num_m_args++;
556 ipv6_set = 1;
557 }
558 else
559 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
560 {
561 num_m_args++;
562 ipv6_set = 1;
563 }
564 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
565 ;
566 else if (unformat (line_input, "teb"))
567 teb = 1;
568 else
569 {
570 error = clib_error_return (0, "unknown input `%U'",
571 format_unformat_error, line_input);
572 goto done;
573 }
574 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700575
576 if (num_m_args < 2)
Billy McFalla9a20e72017-02-15 11:39:12 -0500577 {
578 error = clib_error_return (0, "mandatory argument(s) missing");
579 goto done;
580 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700581
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530582 if ((ipv4_set && memcmp (&src.ip4, &dst.ip4, sizeof (src.ip4)) == 0) ||
583 (ipv6_set && memcmp (&src.ip6, &dst.ip6, sizeof (src.ip6)) == 0))
Billy McFalla9a20e72017-02-15 11:39:12 -0500584 {
585 error = clib_error_return (0, "src and dst are identical");
586 goto done;
587 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700588
Ciara Loftus7eac9162016-09-30 15:47:03 +0100589 if (ipv4_set && ipv6_set)
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530590 return clib_error_return (0, "both IPv4 and IPv6 addresses specified");
Ciara Loftus7eac9162016-09-30 15:47:03 +0100591
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530592 if ((ipv4_set && memcmp (&dst.ip4, &zero_addr.ip4, sizeof (dst.ip4)) == 0)
593 || (ipv6_set
594 && memcmp (&dst.ip6, &zero_addr.ip6, sizeof (dst.ip6)) == 0))
Ciara Loftus7eac9162016-09-30 15:47:03 +0100595 {
596 error = clib_error_return (0, "dst address cannot be zero");
597 goto done;
598 }
599
Chris Luke27fe48f2016-04-28 13:44:38 -0400600 memset (a, 0, sizeof (*a));
Hongjun Ni11bfc2f2016-07-22 18:19:19 +0800601 a->outer_fib_id = outer_fib_id;
David Hothama8cd3092016-09-19 09:55:07 -0700602 a->teb = teb;
Ciara Loftus7eac9162016-09-30 15:47:03 +0100603 a->is_ipv6 = ipv6_set;
604 if (!ipv6_set)
605 {
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530606 clib_memcpy (&a->src.ip4, &src.ip4, sizeof (src.ip4));
607 clib_memcpy (&a->dst.ip4, &dst.ip4, sizeof (dst.ip4));
Ciara Loftus7eac9162016-09-30 15:47:03 +0100608 }
609 else
610 {
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530611 clib_memcpy (&a->src.ip6, &src.ip6, sizeof (src.ip6));
612 clib_memcpy (&a->dst.ip6, &dst.ip6, sizeof (dst.ip6));
Ciara Loftus7eac9162016-09-30 15:47:03 +0100613 }
Chris Luke27fe48f2016-04-28 13:44:38 -0400614
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100615 if (is_add)
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530616 rv = vnet_gre_tunnel_add (a, &sw_if_index);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100617 else
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530618 rv = vnet_gre_tunnel_delete (a, &sw_if_index);
Chris Luke27fe48f2016-04-28 13:44:38 -0400619
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530620 switch (rv)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700621 {
622 case 0:
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530623 vlib_cli_output (vm, "%U\n", format_vnet_sw_if_index_name,
624 vnet_get_main (), sw_if_index);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700625 break;
626 case VNET_API_ERROR_INVALID_VALUE:
Billy McFalla9a20e72017-02-15 11:39:12 -0500627 error = clib_error_return (0, "GRE tunnel already exists...");
628 goto done;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700629 case VNET_API_ERROR_NO_SUCH_FIB:
Billy McFalla9a20e72017-02-15 11:39:12 -0500630 error = clib_error_return (0, "outer fib ID %d doesn't exist\n",
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530631 outer_fib_id);
Billy McFalla9a20e72017-02-15 11:39:12 -0500632 goto done;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700633 default:
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530634 error =
635 clib_error_return (0, "vnet_gre_add_del_tunnel returned %d", rv);
Billy McFalla9a20e72017-02-15 11:39:12 -0500636 goto done;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700637 }
638
Billy McFalla9a20e72017-02-15 11:39:12 -0500639done:
640 unformat_free (line_input);
641
642 return error;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700643}
644
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530645/* *INDENT-OFF* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700646VLIB_CLI_COMMAND (create_gre_tunnel_command, static) = {
647 .path = "create gre tunnel",
Chris Luke27fe48f2016-04-28 13:44:38 -0400648 .short_help = "create gre tunnel src <addr> dst <addr> "
David Hothama8cd3092016-09-19 09:55:07 -0700649 "[outer-fib-id <fib>] [teb] [del]",
Ed Warnickecb9cada2015-12-08 15:45:58 -0700650 .function = create_gre_tunnel_command_fn,
651};
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530652/* *INDENT-ON* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700653
Chris Luke27fe48f2016-04-28 13:44:38 -0400654static clib_error_t *
655show_gre_tunnel_command_fn (vlib_main_t * vm,
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530656 unformat_input_t * input,
657 vlib_cli_command_t * cmd)
Chris Luke27fe48f2016-04-28 13:44:38 -0400658{
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530659 gre_main_t *gm = &gre_main;
660 gre_tunnel_t *t;
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100661 u32 ti = ~0;
Chris Luke27fe48f2016-04-28 13:44:38 -0400662
663 if (pool_elts (gm->tunnels) == 0)
664 vlib_cli_output (vm, "No GRE tunnels configured...");
665
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100666 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
667 {
668 if (unformat (input, "%d", &ti))
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530669 ;
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100670 else
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530671 break;
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100672 }
673
674 if (~0 == ti)
675 {
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530676 /* *INDENT-OFF* */
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100677 pool_foreach (t, gm->tunnels,
678 ({
Neale Rannsb80c5362016-10-08 13:03:40 +0100679 vlib_cli_output (vm, "%U", format_gre_tunnel, t);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100680 }));
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530681 /* *INDENT-ON* */
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100682 }
683 else
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530684 {
685 t = pool_elt_at_index (gm->tunnels, ti);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100686
Neale Rannsb80c5362016-10-08 13:03:40 +0100687 vlib_cli_output (vm, "%U", format_gre_tunnel, t);
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530688 }
Chris Luke27fe48f2016-04-28 13:44:38 -0400689
690 return 0;
691}
692
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530693/* *INDENT-OFF* */
Chris Luke27fe48f2016-04-28 13:44:38 -0400694VLIB_CLI_COMMAND (show_gre_tunnel_command, static) = {
695 .path = "show gre tunnel",
696 .function = show_gre_tunnel_command_fn,
697};
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530698/* *INDENT-ON* */
Chris Luke27fe48f2016-04-28 13:44:38 -0400699
Ed Warnickecb9cada2015-12-08 15:45:58 -0700700/* force inclusion from application's main.c */
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530701clib_error_t *
702gre_interface_init (vlib_main_t * vm)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700703{
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530704 fib_node_register_type (FIB_NODE_TYPE_GRE_TUNNEL, &gre_vft);
Neale Ranns0bfe5d82016-08-25 15:29:12 +0100705
Ed Warnickecb9cada2015-12-08 15:45:58 -0700706 return 0;
707}
Swarup Nayak9ff647a2017-11-27 10:27:43 +0530708
709VLIB_INIT_FUNCTION (gre_interface_init);
710
711/*
712 * fd.io coding-style-patch-verification: ON
713 *
714 * Local Variables:
715 * eval: (c-set-style "gnu")
716 * End:
717 */