FIB: store the node type not the function pointer.
[vpp.git] / src / vnet / mpls / mpls_tunnel.c
index 5211c92..efd9e2d 100644 (file)
@@ -778,11 +778,11 @@ vnet_create_mpls_tunnel_command_fn (vlib_main_t * vm,
     vnet_main_t * vnm = vnet_get_main();
     u8 is_del = 0, l2_only = 0, is_multicast =0;
     fib_route_path_t rpath, *rpaths = NULL;
-    mpls_label_t out_label = MPLS_LABEL_INVALID;
-    u32 sw_if_index = ~0;
+    u32 sw_if_index = ~0, payload_proto;
     clib_error_t *error = NULL;
 
     memset(&rpath, 0, sizeof(rpath));
+    payload_proto = DPO_PROTO_MPLS;
 
     /* Get a line of input. */
     if (! unformat_user (input, unformat_line_input, line_input))
@@ -800,65 +800,14 @@ vnet_create_mpls_tunnel_command_fn (vlib_main_t * vm,
             is_del = 0;
         else if (unformat (line_input, "add"))
             is_del = 0;
-        else if (unformat (line_input, "out-labels"))
-       {
-            if (vec_len (rpaths) == 0)
-           {
-                error = clib_error_return (0, "Paths then labels");
-                goto done;
-            }
-            else
-            {
-                while (unformat (line_input, "%U",
-                                 unformat_mpls_unicast_label,
-                                 &out_label))
-                {
-                    vec_add1 (rpaths[vec_len (rpaths) - 1].frp_label_stack,
-                              out_label);
-                }
-            }
-       }
-        else if (unformat (line_input, "via %U %U",
-                           unformat_ip4_address,
-                           &rpath.frp_addr.ip4,
-                           unformat_vnet_sw_interface, vnm,
-                           &rpath.frp_sw_if_index))
-        {
-            rpath.frp_weight = 1;
-            rpath.frp_proto = DPO_PROTO_IP4;
-        }
-
-        else if (unformat (line_input, "via %U %U",
-                           unformat_ip6_address,
-                           &rpath.frp_addr.ip6,
-                           unformat_vnet_sw_interface, vnm,
-                           &rpath.frp_sw_if_index))
-        {
-            rpath.frp_weight = 1;
-            rpath.frp_proto = DPO_PROTO_IP6;
-        }
-        else if (unformat (line_input, "via %U",
-                           unformat_ip6_address,
-                           &rpath.frp_addr.ip6))
-        {
-            rpath.frp_fib_index = 0;
-            rpath.frp_weight = 1;
-            rpath.frp_sw_if_index = ~0;
-            rpath.frp_proto = DPO_PROTO_IP6;
-        }
-        else if (unformat (line_input, "via %U",
-                           unformat_ip4_address,
-                           &rpath.frp_addr.ip4))
-        {
-            rpath.frp_fib_index = 0;
-            rpath.frp_weight = 1;
-            rpath.frp_sw_if_index = ~0;
-            rpath.frp_proto = DPO_PROTO_IP4;
-        }
         else if (unformat (line_input, "l2-only"))
             l2_only = 1;
         else if (unformat (line_input, "multicast"))
             is_multicast = 1;
+        else if (unformat (line_input, "via %U",
+                           unformat_fib_route_path,
+                           &rpath, &payload_proto))
+            vec_add1(rpaths, rpath);
         else
         {
             error = clib_error_return (0, "unknown input '%U'",
@@ -867,8 +816,6 @@ vnet_create_mpls_tunnel_command_fn (vlib_main_t * vm,
         }
     }
 
-    vec_add1(rpaths, rpath);
-
     if (is_del)
     {
         if (!vnet_mpls_tunnel_path_remove(sw_if_index, rpaths))
@@ -910,7 +857,7 @@ done:
 VLIB_CLI_COMMAND (create_mpls_tunnel_command, static) = {
   .path = "mpls tunnel",
   .short_help =
-  "mpls tunnel via [addr] [interface] [out-labels]",
+  "mpls tunnel [multicast] [l2-only] via [next-hop-address] [next-hop-interface] [next-hop-table <value>] [weight <value>] [preference <value>] [udp-encap-id <value>] [ip4-lookup-in-table <value>] [ip6-lookup-in-table <value>] [mpls-lookup-in-table <value>] [resolve-via-host] [resolve-via-connected] [rx-ip4 <interface>] [out-labels <value value value>]",
   .function = vnet_create_mpls_tunnel_command_fn,
 };
 
@@ -1014,9 +961,7 @@ VLIB_CLI_COMMAND (show_mpls_tunnel_command, static) = {
 static mpls_tunnel_t *
 mpls_tunnel_from_fib_node (fib_node_t *node)
 {
-#if (CLIB_DEBUG > 0)
     ASSERT(FIB_NODE_TYPE_MPLS_TUNNEL == node->fn_type);
-#endif
     return ((mpls_tunnel_t*) (((char*)node) -
                              STRUCT_OFFSET_OF(mpls_tunnel_t, mt_node)));
 }