fib: path flag FIB_API_PATH_TYPE_INTERFACE_RX not copied to client
[vpp.git] / src / vnet / fib / fib_api.c
index 5aa5c4e..64e2887 100644 (file)
@@ -21,6 +21,7 @@
 #include <vnet/mfib/mfib_table.h>
 #include <vnet/bier/bier_disp_table.h>
 #include <vpp/api/types.h>
+#include <vnet/classify/vnet_classify.h>
 
 #include <vnet/vnet_msg_enum.h>
 
@@ -75,9 +76,9 @@ fib_api_next_hop_decode (const vl_api_fib_path_t *in,
                          ip46_address_t *out)
 {
     if (in->proto == FIB_API_PATH_NH_PROTO_IP4)
-        memcpy (&out->ip4, &in->nh.address.ip4, sizeof (out->ip4));
+        clib_memcpy (&out->ip4, &in->nh.address.ip4, sizeof (out->ip4));
     else if (in->proto == FIB_API_PATH_NH_PROTO_IP6)
-        memcpy (&out->ip6, &in->nh.address.ip6, sizeof (out->ip6));
+        clib_memcpy (&out->ip6, &in->nh.address.ip6, sizeof (out->ip6));
 }
 
 static vl_api_fib_path_nh_proto_t
@@ -110,11 +111,11 @@ fib_api_next_hop_encode (const fib_route_path_t *rpath,
     fp->proto = fib_api_path_dpo_proto_to_nh(rpath->frp_proto);
 
     if (rpath->frp_proto == DPO_PROTO_IP4)
-        memcpy (&fp->nh.address.ip4,
+        clib_memcpy (&fp->nh.address.ip4,
                 &rpath->frp_addr.ip4,
                 sizeof (rpath->frp_addr.ip4));
     else if (rpath->frp_proto == DPO_PROTO_IP6)
-        memcpy (&fp->nh.address.ip6,
+        clib_memcpy (&fp->nh.address.ip6,
                 &rpath->frp_addr.ip6,
                 sizeof (rpath->frp_addr.ip6));
 }
@@ -186,6 +187,8 @@ fib_api_path_decode (vl_api_fib_path_t *in,
         out->frp_flags |= FIB_ROUTE_PATH_RESOLVE_VIA_HOST;
     if (in->flags & FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED)
         out->frp_flags |= FIB_ROUTE_PATH_RESOLVE_VIA_ATTACHED;
+    if (in->flags & FIB_API_PATH_FLAG_POP_PW_CW)
+        out->frp_flags |= FIB_ROUTE_PATH_POP_PW_CW;
 
     switch (in->type)
     {
@@ -415,6 +418,10 @@ fib_api_path_encode (const fib_route_path_t * rpath,
         out->type = FIB_API_PATH_TYPE_BIER_IMP;
         out->nh.obj_id = rpath->frp_bier_imp;
     }
+    else if (rpath->frp_flags & FIB_ROUTE_PATH_INTF_RX)
+    {
+        out->type = FIB_API_PATH_TYPE_INTERFACE_RX;
+    }
     else
     {
         out->type = FIB_API_PATH_TYPE_NORMAL;
@@ -449,7 +456,7 @@ fib_api_path_encode (const fib_route_path_t * rpath,
     }
 }
 
-void
+int
 fib_api_route_add_del (u8 is_add,
                        u8 is_multipath,
                        u32 fib_index,
@@ -457,36 +464,46 @@ fib_api_route_add_del (u8 is_add,
                        fib_entry_flag_t entry_flags,
                        fib_route_path_t *rpaths)
 {
-  if (is_multipath)
+    if (is_multipath)
     {
-      /* Iterative path add/remove */
-      if (is_add)
-       fib_table_entry_path_add2 (fib_index,
-                                  prefix,
-                                  FIB_SOURCE_API,
-                                   entry_flags,
-                                   rpaths);
-      else
-       fib_table_entry_path_remove2 (fib_index,
-                                     prefix,
-                                      FIB_SOURCE_API,
-                                      rpaths);
+        if (vec_len(rpaths) == 0)
+            return (VNET_API_ERROR_NO_PATHS_IN_ROUTE);
+
+        /* Iterative path add/remove */
+        if (is_add)
+            fib_table_entry_path_add2 (fib_index,
+                                       prefix,
+                                       FIB_SOURCE_API,
+                                       entry_flags,
+                                       rpaths);
+        else
+            fib_table_entry_path_remove2 (fib_index,
+                                          prefix,
+                                          FIB_SOURCE_API,
+                                          rpaths);
     }
-  else
+    else
     {
-      if (is_add)
-        /* path replacement */
-       fib_table_entry_update (fib_index,
-                                prefix,
-                                FIB_SOURCE_API,
-                                entry_flags,
-                                rpaths);
-      else
-        /* entry delete */
-       fib_table_entry_delete (fib_index,
-                                prefix,
-                                FIB_SOURCE_API);
+        if (is_add)
+        {
+            if (vec_len(rpaths) == 0)
+                return (VNET_API_ERROR_NO_PATHS_IN_ROUTE);
+
+            /* path replacement */
+            fib_table_entry_update (fib_index,
+                                    prefix,
+                                    FIB_SOURCE_API,
+                                    entry_flags,
+                                    rpaths);
+        }
+        else
+            /* entry delete */
+            fib_table_entry_delete (fib_index,
+                                    prefix,
+                                    FIB_SOURCE_API);
     }
+
+    return (0);
 }
 
 u8*