fib: constify the adjacency in the rewrite nodes
[vpp.git] / src / vnet / gre / gre.c
index 72c76fc..4f16b5d 100644 (file)
@@ -276,7 +276,7 @@ gre_build_rewrite (vnet_main_t * vnm,
 
 static void
 gre4_fixup (vlib_main_t * vm,
-           ip_adjacency_t * adj, vlib_buffer_t * b0, const void *data)
+           const ip_adjacency_t * adj, vlib_buffer_t * b0, const void *data)
 {
   ip4_header_t *ip0;
 
@@ -290,7 +290,7 @@ gre4_fixup (vlib_main_t * vm,
 
 static void
 gre6_fixup (vlib_main_t * vm,
-           ip_adjacency_t * adj, vlib_buffer_t * b0, const void *data)
+           const ip_adjacency_t * adj, vlib_buffer_t * b0, const void *data)
 {
   ip6_header_t *ip0;
 
@@ -530,6 +530,29 @@ format_gre_device (u8 * s, va_list * args)
   return s;
 }
 
+static int
+gre_tunnel_desc (u32 sw_if_index,
+                ip46_address_t * src, ip46_address_t * dst, u8 * is_l2)
+{
+  gre_main_t *gm = &gre_main;
+  gre_tunnel_t *t;
+  u32 ti;
+
+  ti = gm->tunnel_index_by_sw_if_index[sw_if_index];
+
+  if (~0 == ti)
+    /* not one of ours */
+    return -1;
+
+  t = pool_elt_at_index (gm->tunnels, ti);
+
+  *src = t->tunnel_src;
+  *dst = t->tunnel_dst.fp_addr;
+  *is_l2 = t->type == GRE_TUNNEL_TYPE_TEB;
+
+  return (0);
+}
+
 /* *INDENT-OFF* */
 VNET_DEVICE_CLASS (gre_device_class) = {
   .name = "GRE tunnel device",
@@ -537,6 +560,7 @@ VNET_DEVICE_CLASS (gre_device_class) = {
   .format_device = format_gre_device,
   .format_tx_trace = format_gre_tx_trace,
   .admin_up_down_function = gre_interface_admin_up_down,
+  .ip_tun_desc = gre_tunnel_desc,
 #ifdef SOON
   .clear counter = 0;
 #endif