GBP: use sclass in the DP for policy
[vpp.git] / src / plugins / gbp / gbp_vxlan.c
1 /*
2  * Copyright (c) 2018 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 #include <plugins/gbp/gbp_vxlan.h>
17 #include <plugins/gbp/gbp_itf.h>
18 #include <plugins/gbp/gbp_learn.h>
19 #include <plugins/gbp/gbp_bridge_domain.h>
20 #include <plugins/gbp/gbp_route_domain.h>
21
22 #include <vnet/vxlan-gbp/vxlan_gbp.h>
23 #include <vlibmemory/api.h>
24 #include <vnet/fib/fib_table.h>
25
26 /**
27  * A reference to a VXLAN-GBP tunnel created as a child/dependent tunnel
28  * of the tempplate GBP-VXLAN tunnel
29  */
30 typedef struct vxlan_tunnel_ref_t_
31 {
32   u32 vxr_sw_if_index;
33   index_t vxr_itf;
34   u32 vxr_locks;
35   index_t vxr_parent;
36   gbp_vxlan_tunnel_layer_t vxr_layer;
37 } vxlan_tunnel_ref_t;
38
39 /**
40  * DB of added tunnels
41  */
42 uword *gv_db;
43
44 /**
45  * Logger
46  */
47 vlib_log_class_t gt_logger;
48
49 /**
50  * Pool of template tunnels
51  */
52 gbp_vxlan_tunnel_t *gbp_vxlan_tunnel_pool;
53
54 /**
55  * Pool of child tunnels
56  */
57 vxlan_tunnel_ref_t *vxlan_tunnel_ref_pool;
58
59 /**
60  * DB of template interfaces by SW interface index
61  */
62 index_t *gbp_vxlan_tunnel_db;
63
64 /**
65  * DB of child interfaces by SW interface index
66  */
67 index_t *vxlan_tunnel_ref_db;
68
69
70 static char *gbp_vxlan_tunnel_layer_strings[] = {
71 #define _(n,s) [GBP_VXLAN_TUN_##n] = s,
72   forecah_gbp_vxlan_tunnel_layer
73 #undef _
74 };
75
76 #define GBP_VXLAN_TUN_DBG(...)                          \
77     vlib_log_debug (gt_logger, __VA_ARGS__);
78
79
80
81 gbp_vxlan_tunnel_t *
82 gbp_vxlan_tunnel_get (index_t gti)
83 {
84   return (pool_elt_at_index (gbp_vxlan_tunnel_pool, gti));
85 }
86
87 static vxlan_tunnel_ref_t *
88 vxlan_tunnel_ref_get (index_t vxri)
89 {
90   return (pool_elt_at_index (vxlan_tunnel_ref_pool, vxri));
91 }
92
93 static u8 *
94 format_vxlan_tunnel_ref (u8 * s, va_list * args)
95 {
96   index_t vxri = va_arg (*args, u32);
97   vxlan_tunnel_ref_t *vxr;
98
99   vxr = vxlan_tunnel_ref_get (vxri);
100
101   s = format (s, "[%U locks:%d]", format_vnet_sw_if_index_name,
102               vnet_get_main (), vxr->vxr_sw_if_index, vxr->vxr_locks);
103
104   return (s);
105 }
106
107 static u32
108 gdb_vxlan_dep_add (gbp_vxlan_tunnel_t * gt,
109                    const ip46_address_t * src, const ip46_address_t * dst)
110 {
111   vnet_vxlan_gbp_tunnel_add_del_args_t args = {
112     .is_add = 1,
113     .is_ip6 = !ip46_address_is_ip4 (src),
114     .vni = gt->gt_vni,
115     .src = *src,
116     .dst = *dst,
117     .instance = ~0,
118     .mode = (GBP_VXLAN_TUN_L2 == gt->gt_layer ?
119              VXLAN_GBP_TUNNEL_MODE_L2 : VXLAN_GBP_TUNNEL_MODE_L3),
120   };
121   vxlan_tunnel_ref_t *vxr;
122   u32 sw_if_index;
123   index_t vxri;
124   int rv;
125
126   sw_if_index = ~0;
127   rv = vnet_vxlan_gbp_tunnel_add_del (&args, &sw_if_index);
128
129   if (VNET_API_ERROR_TUNNEL_EXIST == rv)
130     {
131       vxri = vxlan_tunnel_ref_db[sw_if_index];
132
133       vxr = vxlan_tunnel_ref_get (vxri);
134       vxr->vxr_locks++;
135     }
136   else if (0 == rv)
137     {
138       ASSERT (~0 != sw_if_index);
139       GBP_VXLAN_TUN_DBG ("add-dep:%U %U %U %d", format_vnet_sw_if_index_name,
140                          vnet_get_main (), sw_if_index,
141                          format_ip46_address, src, IP46_TYPE_ANY,
142                          format_ip46_address, dst, IP46_TYPE_ANY, gt->gt_vni);
143
144       pool_get_zero (vxlan_tunnel_ref_pool, vxr);
145
146       vxri = (vxr - vxlan_tunnel_ref_pool);
147       vxr->vxr_parent = gt - gbp_vxlan_tunnel_pool;
148       vxr->vxr_sw_if_index = sw_if_index;
149       vxr->vxr_locks = 1;
150       vxr->vxr_layer = gt->gt_layer;
151
152       /*
153        * store the child both on the parent's list and the global DB
154        */
155       vec_add1 (gt->gt_tuns, vxri);
156
157       vec_validate_init_empty (vxlan_tunnel_ref_db,
158                                vxr->vxr_sw_if_index, INDEX_INVALID);
159       vxlan_tunnel_ref_db[vxr->vxr_sw_if_index] = vxri;
160
161       if (GBP_VXLAN_TUN_L2 == vxr->vxr_layer)
162         {
163           l2output_feat_masks_t ofeat;
164           l2input_feat_masks_t ifeat;
165           gbp_bridge_domain_t *gbd;
166
167           gbd = gbp_bridge_domain_get (gt->gt_gbd);
168           vxr->vxr_itf = gbp_itf_add_and_lock (vxr->vxr_sw_if_index,
169                                                gt->gt_bd_index);
170
171           ofeat = L2OUTPUT_FEAT_GBP_POLICY_MAC;
172           ifeat = L2INPUT_FEAT_NONE;
173
174           if (!(gbd->gb_flags & GBP_BD_FLAG_DO_NOT_LEARN))
175             ifeat |= L2INPUT_FEAT_GBP_LEARN;
176
177           gbp_itf_set_l2_output_feature (vxr->vxr_itf,
178                                          vxr->vxr_sw_if_index, ofeat);
179           gbp_itf_set_l2_input_feature (vxr->vxr_itf,
180                                         vxr->vxr_sw_if_index, ifeat);
181         }
182       else
183         {
184           const gbp_route_domain_t *grd;
185           fib_protocol_t fproto;
186
187           grd = gbp_route_domain_get (gt->gt_grd);
188
189           FOR_EACH_FIB_IP_PROTOCOL (fproto)
190             ip_table_bind (fproto, vxr->vxr_sw_if_index,
191                            grd->grd_table_id[fproto], 1);
192
193           gbp_learn_enable (vxr->vxr_sw_if_index, GBP_LEARN_MODE_L3);
194         }
195     }
196
197   return (sw_if_index);
198 }
199
200 u32
201 vxlan_gbp_tunnel_get_parent (u32 sw_if_index)
202 {
203   ASSERT ((sw_if_index < vec_len (vxlan_tunnel_ref_db)) &&
204           (INDEX_INVALID != vxlan_tunnel_ref_db[sw_if_index]));
205
206   gbp_vxlan_tunnel_t *gt;
207   vxlan_tunnel_ref_t *vxr;
208
209   vxr = vxlan_tunnel_ref_get (vxlan_tunnel_ref_db[sw_if_index]);
210   gt = gbp_vxlan_tunnel_get (vxr->vxr_parent);
211
212   return (gt->gt_sw_if_index);
213 }
214
215 gbp_vxlan_tunnel_type_t
216 gbp_vxlan_tunnel_get_type (u32 sw_if_index)
217 {
218   if (sw_if_index < vec_len (vxlan_tunnel_ref_db) &&
219       INDEX_INVALID != vxlan_tunnel_ref_db[sw_if_index])
220     {
221       return (VXLAN_GBP_TUNNEL);
222     }
223   else if (sw_if_index < vec_len (gbp_vxlan_tunnel_db) &&
224            INDEX_INVALID != gbp_vxlan_tunnel_db[sw_if_index])
225     {
226       return (GBP_VXLAN_TEMPLATE_TUNNEL);
227     }
228
229   ASSERT (0);
230   return (GBP_VXLAN_TEMPLATE_TUNNEL);
231 }
232
233 u32
234 gbp_vxlan_tunnel_clone_and_lock (u32 sw_if_index,
235                                  const ip46_address_t * src,
236                                  const ip46_address_t * dst)
237 {
238   gbp_vxlan_tunnel_t *gt;
239   index_t gti;
240
241   gti = gbp_vxlan_tunnel_db[sw_if_index];
242
243   if (INDEX_INVALID == gti)
244     return (~0);
245
246   gt = pool_elt_at_index (gbp_vxlan_tunnel_pool, gti);
247
248   return (gdb_vxlan_dep_add (gt, src, dst));
249 }
250
251 static void
252 gdb_vxlan_dep_del (index_t vxri)
253 {
254   vxlan_tunnel_ref_t *vxr;
255   gbp_vxlan_tunnel_t *gt;
256   u32 pos;
257
258   vxr = vxlan_tunnel_ref_get (vxri);
259   gt = gbp_vxlan_tunnel_get (vxr->vxr_parent);
260
261   GBP_VXLAN_TUN_DBG ("del-dep:%U", format_vxlan_tunnel_ref, vxri);
262
263   vxlan_tunnel_ref_db[vxr->vxr_sw_if_index] = INDEX_INVALID;
264   pos = vec_search (gt->gt_tuns, vxri);
265
266   ASSERT (~0 != pos);
267   vec_del1 (gt->gt_tuns, pos);
268
269   if (GBP_VXLAN_TUN_L2 == vxr->vxr_layer)
270     {
271       gbp_itf_set_l2_output_feature (vxr->vxr_itf, vxr->vxr_sw_if_index,
272                                      L2OUTPUT_FEAT_NONE);
273       gbp_itf_set_l2_input_feature (vxr->vxr_itf, vxr->vxr_sw_if_index,
274                                     L2INPUT_FEAT_NONE);
275       gbp_itf_unlock (vxr->vxr_itf);
276     }
277   else
278     {
279       fib_protocol_t fproto;
280
281       FOR_EACH_FIB_IP_PROTOCOL (fproto)
282         ip_table_bind (fproto, vxr->vxr_sw_if_index, 0, 0);
283       gbp_learn_disable (vxr->vxr_sw_if_index, GBP_LEARN_MODE_L3);
284     }
285
286   vnet_vxlan_gbp_tunnel_del (vxr->vxr_sw_if_index);
287
288   pool_put (vxlan_tunnel_ref_pool, vxr);
289 }
290
291 void
292 vxlan_gbp_tunnel_unlock (u32 sw_if_index)
293 {
294   vxlan_tunnel_ref_t *vxr;
295   index_t vxri;
296
297   vxri = vxlan_tunnel_ref_db[sw_if_index];
298
299   ASSERT (vxri != INDEX_INVALID);
300
301   vxr = vxlan_tunnel_ref_get (vxri);
302   vxr->vxr_locks--;
303
304   if (0 == vxr->vxr_locks)
305     {
306       gdb_vxlan_dep_del (vxri);
307     }
308 }
309
310 void
311 vxlan_gbp_tunnel_lock (u32 sw_if_index)
312 {
313   vxlan_tunnel_ref_t *vxr;
314   index_t vxri;
315
316   vxri = vxlan_tunnel_ref_db[sw_if_index];
317
318   ASSERT (vxri != INDEX_INVALID);
319
320   vxr = vxlan_tunnel_ref_get (vxri);
321   vxr->vxr_locks++;
322 }
323
324 void
325 gbp_vxlan_walk (gbp_vxlan_cb_t cb, void *ctx)
326 {
327   gbp_vxlan_tunnel_t *gt;
328
329   /* *INDENT-OFF* */
330   pool_foreach (gt, gbp_vxlan_tunnel_pool,
331     ({
332       if (WALK_CONTINUE != cb(gt, ctx))
333         break;
334     }));
335   /* *INDENT-ON* */
336 }
337
338 static walk_rc_t
339 gbp_vxlan_tunnel_show_one (gbp_vxlan_tunnel_t * gt, void *ctx)
340 {
341   vlib_cli_output (ctx, "%U", format_gbp_vxlan_tunnel,
342                    gt - gbp_vxlan_tunnel_pool);
343
344   return (WALK_CONTINUE);
345 }
346
347 static u8 *
348 format_gbp_vxlan_tunnel_name (u8 * s, va_list * args)
349 {
350   u32 dev_instance = va_arg (*args, u32);
351
352   return format (s, "gbp-vxlan-%d", dev_instance);
353 }
354
355 u8 *
356 format_gbp_vxlan_tunnel_layer (u8 * s, va_list * args)
357 {
358   gbp_vxlan_tunnel_layer_t gl = va_arg (*args, gbp_vxlan_tunnel_layer_t);
359   s = format (s, "%s", gbp_vxlan_tunnel_layer_strings[gl]);
360
361   return (s);
362 }
363
364 u8 *
365 format_gbp_vxlan_tunnel (u8 * s, va_list * args)
366 {
367   u32 dev_instance = va_arg (*args, u32);
368   CLIB_UNUSED (int verbose) = va_arg (*args, int);
369   gbp_vxlan_tunnel_t *gt = gbp_vxlan_tunnel_get (dev_instance);
370   index_t *vxri;
371
372   s = format (s, "GBP VXLAN tunnel: hw:%d sw:%d vni:%d %U",
373               gt->gt_hw_if_index, gt->gt_sw_if_index, gt->gt_vni,
374               format_gbp_vxlan_tunnel_layer, gt->gt_layer);
375   if (GBP_VXLAN_TUN_L2 == gt->gt_layer)
376     s = format (s, " BD:%d bd-index:%d", gt->gt_bd_rd_id, gt->gt_bd_index);
377   else
378     s = format (s, " RD:%d fib-index:[%d,%d]",
379                 gt->gt_bd_rd_id,
380                 gt->gt_fib_index[FIB_PROTOCOL_IP4],
381                 gt->gt_fib_index[FIB_PROTOCOL_IP6]);
382
383   s = format (s, " children:[");
384   vec_foreach (vxri, gt->gt_tuns)
385   {
386     s = format (s, "%U, ", format_vxlan_tunnel_ref, *vxri);
387   }
388   s = format (s, "]");
389
390   return s;
391 }
392
393 typedef struct gbp_vxlan_tx_trace_t_
394 {
395   u32 vni;
396 } gbp_vxlan_tx_trace_t;
397
398 u8 *
399 format_gbp_vxlan_tx_trace (u8 * s, va_list * args)
400 {
401   CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
402   CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
403   gbp_vxlan_tx_trace_t *t = va_arg (*args, gbp_vxlan_tx_trace_t *);
404
405   s = format (s, "GBP-VXLAN: vni:%d", t->vni);
406
407   return (s);
408 }
409
410 clib_error_t *
411 gbp_vxlan_interface_admin_up_down (vnet_main_t * vnm,
412                                    u32 hw_if_index, u32 flags)
413 {
414   vnet_hw_interface_t *hi;
415   u32 ti;
416
417   hi = vnet_get_hw_interface (vnm, hw_if_index);
418
419   if (NULL == gbp_vxlan_tunnel_db ||
420       hi->sw_if_index >= vec_len (gbp_vxlan_tunnel_db))
421     return (NULL);
422
423   ti = gbp_vxlan_tunnel_db[hi->sw_if_index];
424
425   if (~0 == ti)
426     /* not one of ours */
427     return (NULL);
428
429   if (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP)
430     vnet_hw_interface_set_flags (vnm, hw_if_index,
431                                  VNET_HW_INTERFACE_FLAG_LINK_UP);
432   else
433     vnet_hw_interface_set_flags (vnm, hw_if_index, 0);
434
435   return (NULL);
436 }
437
438 static uword
439 gbp_vxlan_interface_tx (vlib_main_t * vm,
440                         vlib_node_runtime_t * node, vlib_frame_t * frame)
441 {
442   clib_warning ("you shouldn't be here, leaking buffers...");
443   return frame->n_vectors;
444 }
445
446 /* *INDENT-OFF* */
447 VNET_DEVICE_CLASS (gbp_vxlan_device_class) = {
448   .name = "GBP VXLAN tunnel-template",
449   .format_device_name = format_gbp_vxlan_tunnel_name,
450   .format_device = format_gbp_vxlan_tunnel,
451   .format_tx_trace = format_gbp_vxlan_tx_trace,
452   .admin_up_down_function = gbp_vxlan_interface_admin_up_down,
453   .tx_function = gbp_vxlan_interface_tx,
454 };
455
456 VNET_HW_INTERFACE_CLASS (gbp_vxlan_hw_interface_class) = {
457   .name = "GBP-VXLAN",
458   .flags = VNET_HW_INTERFACE_CLASS_FLAG_P2P,
459 };
460 /* *INDENT-ON* */
461
462 int
463 gbp_vxlan_tunnel_add (u32 vni, gbp_vxlan_tunnel_layer_t layer,
464                       u32 bd_rd_id,
465                       const ip4_address_t * src, u32 * sw_if_indexp)
466 {
467   gbp_vxlan_tunnel_t *gt;
468   index_t gti;
469   uword *p;
470   int rv;
471
472   rv = 0;
473   p = hash_get (gv_db, vni);
474
475   GBP_VXLAN_TUN_DBG ("add: %d %d %d", vni, layer, bd_rd_id);
476
477   if (NULL == p)
478     {
479       vnet_sw_interface_t *si;
480       vnet_hw_interface_t *hi;
481       index_t gbi, grdi;
482       vnet_main_t *vnm;
483
484       gbi = grdi = INDEX_INVALID;
485
486       if (layer == GBP_VXLAN_TUN_L2)
487         {
488           gbi = gbp_bridge_domain_find_and_lock (bd_rd_id);
489
490           if (INDEX_INVALID == gbi)
491             {
492               return (VNET_API_ERROR_BD_NOT_MODIFIABLE);
493             }
494         }
495       else
496         {
497           grdi = gbp_route_domain_find_and_lock (bd_rd_id);
498
499           if (INDEX_INVALID == grdi)
500             {
501               return (VNET_API_ERROR_NO_SUCH_FIB);
502             }
503         }
504
505       vnm = vnet_get_main ();
506       pool_get (gbp_vxlan_tunnel_pool, gt);
507       gti = gt - gbp_vxlan_tunnel_pool;
508
509       gt->gt_vni = vni;
510       gt->gt_layer = layer;
511       gt->gt_bd_rd_id = bd_rd_id;
512       gt->gt_src.ip4.as_u32 = src->as_u32;
513       gt->gt_hw_if_index = vnet_register_interface (vnm,
514                                                     gbp_vxlan_device_class.index,
515                                                     gti,
516                                                     gbp_vxlan_hw_interface_class.index,
517                                                     gti);
518
519       hi = vnet_get_hw_interface (vnm, gt->gt_hw_if_index);
520
521       gt->gt_sw_if_index = hi->sw_if_index;
522
523       /* don't flood packets in a BD to these interfaces */
524       si = vnet_get_sw_interface (vnm, gt->gt_sw_if_index);
525       si->flood_class = VNET_FLOOD_CLASS_NO_FLOOD;
526
527       if (layer == GBP_VXLAN_TUN_L2)
528         {
529           gbp_bridge_domain_t *gb;
530
531           gb = gbp_bridge_domain_get (gbi);
532
533           gt->gt_gbd = gbi;
534           gt->gt_bd_index = gb->gb_bd_index;
535           gb->gb_vni = gti;
536           /* set it up as a GBP interface */
537           gt->gt_itf = gbp_itf_add_and_lock (gt->gt_sw_if_index,
538                                              gt->gt_bd_index);
539           gbp_learn_enable (gt->gt_sw_if_index, GBP_LEARN_MODE_L2);
540         }
541       else
542         {
543           gbp_route_domain_t *grd;
544           fib_protocol_t fproto;
545
546           grd = gbp_route_domain_get (grdi);
547
548           gt->gt_grd = grdi;
549           grd->grd_vni_sw_if_index = gt->gt_sw_if_index;
550
551           gbp_learn_enable (gt->gt_sw_if_index, GBP_LEARN_MODE_L3);
552
553           ip4_sw_interface_enable_disable (gt->gt_sw_if_index, 1);
554           ip6_sw_interface_enable_disable (gt->gt_sw_if_index, 1);
555
556           FOR_EACH_FIB_IP_PROTOCOL (fproto)
557           {
558             gt->gt_fib_index[fproto] = grd->grd_fib_index[fproto];
559
560             ip_table_bind (fproto, gt->gt_sw_if_index,
561                            grd->grd_table_id[fproto], 1);
562           }
563         }
564
565       /*
566        * save the tunnel by VNI and by sw_if_index
567        */
568       hash_set (gv_db, vni, gti);
569
570       vec_validate_init_empty (gbp_vxlan_tunnel_db,
571                                gt->gt_sw_if_index, INDEX_INVALID);
572       gbp_vxlan_tunnel_db[gt->gt_sw_if_index] = gti;
573
574       if (sw_if_indexp)
575         *sw_if_indexp = gt->gt_sw_if_index;
576
577       vxlan_gbp_register_udp_ports ();
578     }
579   else
580     {
581       gti = p[0];
582       rv = VNET_API_ERROR_IF_ALREADY_EXISTS;
583     }
584
585   GBP_VXLAN_TUN_DBG ("add: %U", format_gbp_vxlan_tunnel, gti);
586
587   return (rv);
588 }
589
590 int
591 gbp_vxlan_tunnel_del (u32 vni)
592 {
593   gbp_vxlan_tunnel_t *gt;
594   uword *p;
595
596   p = hash_get (gv_db, vni);
597
598   if (NULL != p)
599     {
600       vnet_main_t *vnm;
601
602       vnm = vnet_get_main ();
603       gt = gbp_vxlan_tunnel_get (p[0]);
604
605       vxlan_gbp_unregister_udp_ports ();
606
607       GBP_VXLAN_TUN_DBG ("del: %U", format_gbp_vxlan_tunnel,
608                          gt - gbp_vxlan_tunnel_pool);
609
610       gbp_endpoint_flush (GBP_ENDPOINT_SRC_DP, gt->gt_sw_if_index);
611       ASSERT (0 == vec_len (gt->gt_tuns));
612       vec_free (gt->gt_tuns);
613
614       if (GBP_VXLAN_TUN_L2 == gt->gt_layer)
615         {
616           gbp_learn_disable (gt->gt_sw_if_index, GBP_LEARN_MODE_L2);
617           gbp_itf_unlock (gt->gt_itf);
618           gbp_bridge_domain_unlock (gt->gt_gbd);
619         }
620       else
621         {
622           fib_protocol_t fproto;
623
624           FOR_EACH_FIB_IP_PROTOCOL (fproto)
625             ip_table_bind (fproto, gt->gt_sw_if_index, 0, 0);
626
627           ip4_sw_interface_enable_disable (gt->gt_sw_if_index, 0);
628           ip6_sw_interface_enable_disable (gt->gt_sw_if_index, 0);
629
630           gbp_learn_disable (gt->gt_sw_if_index, GBP_LEARN_MODE_L3);
631           gbp_route_domain_unlock (gt->gt_grd);
632         }
633
634       vnet_sw_interface_set_flags (vnm, gt->gt_sw_if_index, 0);
635       vnet_delete_hw_interface (vnm, gt->gt_hw_if_index);
636
637       hash_unset (gv_db, vni);
638       gbp_vxlan_tunnel_db[gt->gt_sw_if_index] = INDEX_INVALID;
639
640       pool_put (gbp_vxlan_tunnel_pool, gt);
641     }
642   else
643     return VNET_API_ERROR_NO_SUCH_ENTRY;
644
645   return (0);
646 }
647
648 static clib_error_t *
649 gbp_vxlan_show (vlib_main_t * vm,
650                 unformat_input_t * input, vlib_cli_command_t * cmd)
651 {
652   gbp_vxlan_walk (gbp_vxlan_tunnel_show_one, vm);
653
654   return (NULL);
655 }
656
657 /*?
658  * Show Group Based Policy VXLAN tunnels
659  *
660  * @cliexpar
661  * @cliexstart{show gbp vxlan}
662  * @cliexend
663  ?*/
664 /* *INDENT-OFF* */
665 VLIB_CLI_COMMAND (gbp_vxlan_show_node, static) = {
666   .path = "show gbp vxlan",
667   .short_help = "show gbp vxlan\n",
668   .function = gbp_vxlan_show,
669 };
670 /* *INDENT-ON* */
671
672 static clib_error_t *
673 gbp_vxlan_init (vlib_main_t * vm)
674 {
675   u32 slot4;
676   vlib_node_t *node = vlib_get_node_by_name (vm, (u8 *) "gbp-vxlan4");
677
678   /*
679    * insert ourselves into the VXLAN-GBP arc to collect the no-tunnel
680    * packets.
681    */
682   slot4 = vlib_node_add_next_with_slot (vm,
683                                         vxlan4_gbp_input_node.index,
684                                         node->index,
685                                         VXLAN_GBP_INPUT_NEXT_NO_TUNNEL);
686   ASSERT (slot4 == VXLAN_GBP_INPUT_NEXT_NO_TUNNEL);
687
688   /* slot6 = vlib_node_add_next_with_slot (vm, */
689   /*                                    vxlan6_gbp_input_node.index, */
690   /*                                    gbp_vxlan6_input_node.index, */
691   /*                                    VXLAN_GBP_INPUT_NEXT_NO_TUNNEL); */
692   /* ASSERT (slot6 == VXLAN_GBP_INPUT_NEXT_NO_TUNNEL); */
693
694   gt_logger = vlib_log_register_class ("gbp", "tun");
695
696   return (NULL);
697 }
698
699 VLIB_INIT_FUNCTION (gbp_vxlan_init);
700
701 /*
702  * fd.io coding-style-patch-verification: ON
703  *
704  * Local Variables:
705  * eval: (c-set-style "gnu")
706  * End:
707  */