FIB table add/delete API only 37/8037/2
authorNeale Ranns <nranns@cisco.com>
Mon, 14 Aug 2017 14:18:42 +0000 (07:18 -0700)
committerFlorin Coras <florin.coras@gmail.com>
Mon, 14 Aug 2017 17:57:20 +0000 (17:57 +0000)
commit only the addition of the .api definition and their invocation through VAT so CSIT can use it

Change-Id: Id510f14b1ce007fe5e92120507ea34100652fc64
Signed-off-by: Neale Ranns <nranns@cisco.com>
src/vat/api_format.c
src/vnet/ip/ip.api
src/vnet/ip/ip_api.c
src/vnet/mpls/mpls.api
src/vnet/mpls/mpls_api.c

index ddcd562..9381ec5 100644 (file)
@@ -4615,8 +4615,10 @@ _(l2fib_add_del_reply)                                  \
 _(l2fib_flush_int_reply)                                \
 _(l2fib_flush_bd_reply)                                 \
 _(ip_add_del_route_reply)                               \
+_(ip_table_add_del_reply)                               \
 _(ip_mroute_add_del_reply)                              \
 _(mpls_route_add_del_reply)                             \
+_(mpls_table_add_del_reply)                             \
 _(mpls_ip_bind_unbind_reply)                            \
 _(proxy_arp_add_del_reply)                              \
 _(proxy_arp_intfc_enable_disable_reply)                 \
@@ -4801,7 +4803,9 @@ _(TAP_MODIFY_REPLY, tap_modify_reply)                                     \
 _(TAP_DELETE_REPLY, tap_delete_reply)                                  \
 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details)                   \
 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply)                      \
+_(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply)                      \
 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply)                    \
+_(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply)                  \
 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply)                  \
 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply)                        \
 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply)                     \
@@ -7048,6 +7052,56 @@ api_tap_delete (vat_main_t * vam)
   return ret;
 }
 
+static int
+api_ip_table_add_del (vat_main_t * vam)
+{
+  unformat_input_t *i = vam->input;
+  vl_api_ip_table_add_del_t *mp;
+  u32 table_id = ~0;
+  u8 is_ipv6 = 0;
+  u8 is_add = 1;
+  int ret = 0;
+
+  /* Parse args required to build the message */
+  while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+    {
+      if (unformat (i, "ipv6"))
+       is_ipv6 = 1;
+      else if (unformat (i, "del"))
+       is_add = 0;
+      else if (unformat (i, "add"))
+       is_add = 1;
+      else if (unformat (i, "table %d", &table_id))
+       ;
+      else
+       {
+         clib_warning ("parse error '%U'", format_unformat_error, i);
+         return -99;
+       }
+    }
+
+  if (~0 == table_id)
+    {
+      errmsg ("missing table-ID");
+      return -99;
+    }
+
+  /* Construct the API message */
+  M (IP_TABLE_ADD_DEL, mp);
+
+  mp->table_id = ntohl (table_id);
+  mp->is_ipv6 = is_ipv6;
+  mp->is_add = is_add;
+
+  /* send it... */
+  S (mp);
+
+  /* Wait for a reply... */
+  W (ret);
+
+  return ret;
+}
+
 static int
 api_ip_add_del_route (vat_main_t * vam)
 {
@@ -7466,6 +7520,52 @@ api_ip_mroute_add_del (vat_main_t * vam)
   return ret;
 }
 
+static int
+api_mpls_table_add_del (vat_main_t * vam)
+{
+  unformat_input_t *i = vam->input;
+  vl_api_mpls_table_add_del_t *mp;
+  u32 table_id = ~0;
+  u8 is_add = 1;
+  int ret = 0;
+
+  /* Parse args required to build the message */
+  while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+    {
+      if (unformat (i, "table %d", &table_id))
+       ;
+      else if (unformat (i, "del"))
+       is_add = 0;
+      else if (unformat (i, "add"))
+       is_add = 1;
+      else
+       {
+         clib_warning ("parse error '%U'", format_unformat_error, i);
+         return -99;
+       }
+    }
+
+  if (~0 == table_id)
+    {
+      errmsg ("missing table-ID");
+      return -99;
+    }
+
+  /* Construct the API message */
+  M (MPLS_TABLE_ADD_DEL, mp);
+
+  mp->mt_table_id = ntohl (table_id);
+  mp->mt_is_add = is_add;
+
+  /* send it... */
+  S (mp);
+
+  /* Wait for a reply... */
+  W (ret);
+
+  return ret;
+}
+
 static int
 api_mpls_route_add_del (vat_main_t * vam)
 {
@@ -20000,6 +20100,8 @@ _(tap_modify,                                                           \
 _(tap_delete,                                                           \
   "<vpp-if-name> | sw_if_index <id>")                                   \
 _(sw_interface_tap_dump, "")                                            \
+_(ip_table_add_del,                                                     \
+  "table-id <n> [ipv6]\n")                                              \
 _(ip_add_del_route,                                                     \
   "<addr>/<mask> via <addr> [table-id <n>]\n"                           \
   "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"               \
@@ -20008,6 +20110,8 @@ _(ip_add_del_route,                                                     \
 _(ip_mroute_add_del,                                                    \
   "<src> <grp>/<mask> [table-id <n>]\n"                                 \
   "[<intfc> | sw_if_index <id>] [local] [del]")                         \
+_(mpls_table_add_del,                                                   \
+  "table-id <n>\n")                                                     \
 _(mpls_route_add_del,                                                   \
   "<label> <eos> via <addr> [table-id <n>]\n"                           \
   "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"               \
index fa36337..e57c2fe 100644 (file)
     called through a shared memory interface. 
 */
 
+/** \brief Add / del table request
+           A table can be added multiple times, but need be deleted only once.
+    @param client_index - opaque cookie to identify the sender
+    @param context - sender context, to match reply w/ request
+    @param is_ipv6 - V4 or V6 table
+    @param table_id - table ID associated with the route
+                      This table ID will apply to both the unicats
+                     and mlticast FIBs
+*/
+autoreply define ip_table_add_del
+{
+  u32 client_index;
+  u32 context;
+  u32 table_id;
+  u8 is_ipv6;
+  u8 is_add;
+};
+
 /** \brief Dump IP fib table
     @param client_index - opaque cookie to identify the sender
 */
index 0676a38..bba65ab 100644 (file)
@@ -69,6 +69,7 @@ _(IP_ADDRESS_DUMP, ip_address_dump)                                     \
 _(IP_DUMP, ip_dump)                                                     \
 _(IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del)                             \
 _(IP_ADD_DEL_ROUTE, ip_add_del_route)                                   \
+_(IP_TABLE_ADD_DEL, ip_table_add_del)                                   \
 _(SET_IP_FLOW_HASH,set_ip_flow_hash)                                    \
 _(SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config)           \
 _(SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix)           \
@@ -698,6 +699,15 @@ vl_api_ip_neighbor_add_del_t_handler (vl_api_ip_neighbor_add_del_t * mp,
   REPLY_MACRO (VL_API_IP_NEIGHBOR_ADD_DEL_REPLY);
 }
 
+void
+vl_api_ip_table_add_del_t_handler (vl_api_ip_table_add_del_t * mp)
+{
+  vl_api_ip_table_add_del_reply_t *rmp;
+  int rv = 0;
+
+  REPLY_MACRO (VL_API_IP_TABLE_ADD_DEL_REPLY);
+}
+
 int
 add_del_route_t_handler (u8 is_multipath,
                         u8 is_add,
index 5973a0a..bb84999 100644 (file)
@@ -136,6 +136,20 @@ manual_endian manual_print define mpls_tunnel_details
   vl_api_fib_path2_t mt_paths[mt_count];
 };
 
+/** \brief MPLS Route Add / del route
+    @param client_index - opaque cookie to identify the sender
+    @param context - sender context, to match reply w/ request
+    @param mt_table_id - The MPLS table-id the route is added in
+    @param mt_is_add - Is this a route add or delete
+*/
+autoreply define mpls_table_add_del
+{
+  u32 client_index;
+  u32 context;
+  u32 mt_table_id;
+  u8  mt_is_add;
+};
+
 /** \brief MPLS Route Add / del route
     @param client_index - opaque cookie to identify the sender
     @param context - sender context, to match reply w/ request
index 737299e..2af6af8 100644 (file)
@@ -50,6 +50,7 @@
 #define foreach_vpe_api_msg                                 \
 _(MPLS_IP_BIND_UNBIND, mpls_ip_bind_unbind)                 \
 _(MPLS_ROUTE_ADD_DEL, mpls_route_add_del)                   \
+_(MPLS_TABLE_ADD_DEL, mpls_table_add_del)                   \
 _(MPLS_TUNNEL_ADD_DEL, mpls_tunnel_add_del)                 \
 _(MPLS_TUNNEL_DUMP, mpls_tunnel_dump)                       \
 _(MPLS_FIB_DUMP, mpls_fib_dump)
@@ -57,6 +58,22 @@ _(MPLS_FIB_DUMP, mpls_fib_dump)
 extern void stats_dslock_with_hint (int hint, int tag);
 extern void stats_dsunlock (void);
 
+void
+vl_api_mpls_table_add_del_t_handler (vl_api_mpls_table_add_del_t * mp)
+{
+  vl_api_mpls_table_add_del_reply_t *rmp;
+  vnet_main_t *vnm;
+  int rv = 0;
+
+  vnm = vnet_get_main ();
+  vnm->api_errno = 0;
+
+
+  rv = (rv == 0) ? vnm->api_errno : rv;
+
+  REPLY_MACRO (VL_API_MPLS_TABLE_ADD_DEL_REPLY);
+}
+
 static int
 mpls_ip_bind_unbind_handler (vnet_main_t * vnm,
                             vl_api_mpls_ip_bind_unbind_t * mp)