GBP: fixes for l3-out routing
[vpp.git] / src / vnet / vxlan-gbp / vxlan_gbp_api.c
index 1bba74d..6a87d4d 100644 (file)
@@ -66,10 +66,29 @@ static void
   REPLY_MACRO (VL_API_SW_INTERFACE_SET_VXLAN_GBP_BYPASS_REPLY);
 }
 
+static int
+vxlan_gbp_tunnel_mode_decode (vl_api_vxlan_gbp_api_tunnel_mode_t in,
+                             vxlan_gbp_tunnel_mode_t * out)
+{
+  in = clib_net_to_host_u32 (in);
+
+  switch (in)
+    {
+    case VXLAN_GBP_API_TUNNEL_MODE_L2:
+      *out = VXLAN_GBP_TUNNEL_MODE_L2;
+      return (0);
+    case VXLAN_GBP_API_TUNNEL_MODE_L3:
+      *out = VXLAN_GBP_TUNNEL_MODE_L3;
+      return (0);
+    }
+  return (1);
+}
+
 static void vl_api_vxlan_gbp_tunnel_add_del_t_handler
   (vl_api_vxlan_gbp_tunnel_add_del_t * mp)
 {
   vl_api_vxlan_gbp_tunnel_add_del_reply_t *rmp;
+  vxlan_gbp_tunnel_mode_t mode;
   ip46_address_t src, dst;
   ip46_type_t itype;
   int rv = 0;
@@ -86,16 +105,21 @@ static void vl_api_vxlan_gbp_tunnel_add_del_t_handler
       goto out;
     }
 
+  rv = vxlan_gbp_tunnel_mode_decode (mp->tunnel.mode, &mode);
+
+  if (rv)
+    goto out;
+
   vnet_vxlan_gbp_tunnel_add_del_args_t a = {
     .is_add = mp->is_add,
     .is_ip6 = (itype == IP46_TYPE_IP6),
     .instance = ntohl (mp->tunnel.instance),
     .mcast_sw_if_index = ntohl (mp->tunnel.mcast_sw_if_index),
     .encap_fib_index = fib_index,
-    .decap_next_index = ntohl (mp->tunnel.decap_next_index),
     .vni = ntohl (mp->tunnel.vni),
     .dst = dst,
     .src = src,
+    .mode = mode,
   };
 
   /* Check src & dst are different */
@@ -131,7 +155,7 @@ static void send_vxlan_gbp_tunnel_details
                       IP46_TYPE_IP4 : IP46_TYPE_IP6);
 
   rmp = vl_msg_api_alloc (sizeof (*rmp));
-  memset (rmp, 0, sizeof (*rmp));
+  clib_memset (rmp, 0, sizeof (*rmp));
   rmp->_vl_msg_id = ntohs (VL_API_VXLAN_GBP_TUNNEL_DETAILS);
 
   ip_address_encode (&t->src, itype, &rmp->tunnel.src);
@@ -142,7 +166,6 @@ static void send_vxlan_gbp_tunnel_details
   rmp->tunnel.instance = htonl (t->user_instance);
   rmp->tunnel.mcast_sw_if_index = htonl (t->mcast_sw_if_index);
   rmp->tunnel.vni = htonl (t->vni);
-  rmp->tunnel.decap_next_index = htonl (t->decap_next_index);
   rmp->tunnel.sw_if_index = htonl (t->sw_if_index);
   rmp->context = context;
 
@@ -187,7 +210,7 @@ static void vl_api_vxlan_gbp_tunnel_dump_t_handler
 /*
  * vpe_api_hookup
  * Add vpe's API message handlers to the table.
- * vlib has alread mapped shared memory and
+ * vlib has already mapped shared memory and
  * added the client registration handlers.
  * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
  */