aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vnet/vnet/api_errno.h3
-rw-r--r--vnet/vnet/ethernet/ethernet.h1
-rw-r--r--vnet/vnet/ethernet/interface.c65
-rw-r--r--vpp-api-test/vat/api_format.c39
-rw-r--r--vpp/vpp-api/api.c14
-rw-r--r--vpp/vpp-api/custom_dump.c13
-rw-r--r--vpp/vpp-api/vpe.api20
7 files changed, 149 insertions, 6 deletions
diff --git a/vnet/vnet/api_errno.h b/vnet/vnet/api_errno.h
index bb842eb2494..252832202c3 100644
--- a/vnet/vnet/api_errno.h
+++ b/vnet/vnet/api_errno.h
@@ -87,7 +87,8 @@ _(CANNOT_CREATE_PCAP_FILE, -93, "Cannot create pcap file") \
_(INCORRECT_ADJACENCY_TYPE, -94, "Invalid adjacency type for this operation") \
_(EXCEEDED_NUMBER_OF_RANGES_CAPACITY, -95, "Operation would exceed configured capacity of ranges") \
_(EXCEEDED_NUMBER_OF_PORTS_CAPACITY, -96, "Operation would exceed capacity of number of ports") \
-_(INVALID_ADDRESS_FAMILY, -97, "Invalid address family")
+_(INVALID_ADDRESS_FAMILY, -97, "Invalid address family") \
+_(INVALID_SUB_SW_IF_INDEX, -98, "Invalid sub-interface sw_if_index")
typedef enum
{
diff --git a/vnet/vnet/ethernet/ethernet.h b/vnet/vnet/ethernet/ethernet.h
index d0eec1fc6b4..b5c4ee919e5 100644
--- a/vnet/vnet/ethernet/ethernet.h
+++ b/vnet/vnet/ethernet/ethernet.h
@@ -387,6 +387,7 @@ clib_error_t *next_by_ethertype_register (next_by_ethertype_t * l3_next,
int vnet_create_loopback_interface (u32 * sw_if_indexp, u8 * mac_address);
int vnet_delete_loopback_interface (u32 sw_if_index);
+int vnet_delete_sub_interface (u32 sw_if_index);
// Perform ethernet subinterface classification table lookups given
// the ports's sw_if_index and fields extracted from the ethernet header.
diff --git a/vnet/vnet/ethernet/interface.c b/vnet/vnet/ethernet/interface.c
index 88daa347fc2..285fd895f01 100644
--- a/vnet/vnet/ethernet/interface.c
+++ b/vnet/vnet/ethernet/interface.c
@@ -507,6 +507,35 @@ vnet_delete_loopback_interface (u32 sw_if_index)
return 0;
}
+int
+vnet_delete_sub_interface (u32 sw_if_index)
+{
+ vnet_main_t *vnm = vnet_get_main ();
+ int rv = 0;
+
+ if (pool_is_free_index (vnm->interface_main.sw_interfaces, sw_if_index))
+ return VNET_API_ERROR_INVALID_SW_IF_INDEX;
+
+
+ vnet_interface_main_t *im = &vnm->interface_main;
+ vnet_sw_interface_t *si = vnet_get_sw_interface (vnm, sw_if_index);
+
+ if (si->type == VNET_SW_INTERFACE_TYPE_SUB)
+ {
+ vnet_sw_interface_t *si = vnet_get_sw_interface (vnm, sw_if_index);
+ u64 sup_and_sub_key =
+ ((u64) (si->sup_sw_if_index) << 32) | (u64) si->sub.id;
+
+ hash_unset_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key);
+ vnet_delete_sw_interface (vnm, sw_if_index);
+ }
+ else
+ {
+ rv = VNET_API_ERROR_INVALID_SUB_SW_IF_INDEX;
+ }
+ return rv;
+}
+
static clib_error_t *
delete_simulated_ethernet_interfaces (vlib_main_t * vm,
unformat_input_t * input,
@@ -536,6 +565,34 @@ delete_simulated_ethernet_interfaces (vlib_main_t * vm,
return 0;
}
+static clib_error_t *
+delete_sub_interface (vlib_main_t * vm,
+ unformat_input_t * input, vlib_cli_command_t * cmd)
+{
+ int rv = 0;
+ u32 sw_if_index = ~0;
+ vnet_main_t *vnm = vnet_get_main ();
+
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat
+ (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
+ ;
+ else
+ break;
+ }
+ if (sw_if_index == ~0)
+ return clib_error_return (0, "interface doesn't exist");
+
+ if (pool_is_free_index (vnm->interface_main.sw_interfaces, sw_if_index))
+ rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
+ else
+ rv = vnet_delete_sub_interface (sw_if_index);
+ if (rv)
+ return clib_error_return (0, "delete_subinterface_interface failed");
+ return 0;
+}
+
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (delete_simulated_ethernet_interface_command, static) = {
.path = "loopback delete-interface",
@@ -552,6 +609,14 @@ VLIB_CLI_COMMAND (delete_loopback_interface_command, static) = {
};
/* *INDENT-ON* */
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (delete_sub_interface_command, static) = {
+ .path = "delete sub-interface",
+ .short_help = "delete sub-interface <interface>",
+ .function = delete_sub_interface,
+};
+/* *INDENT-ON* */
+
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/vpp-api-test/vat/api_format.c b/vpp-api-test/vat/api_format.c
index fbe4aedbca5..c1a472a3c8a 100644
--- a/vpp-api-test/vat/api_format.c
+++ b/vpp-api-test/vat/api_format.c
@@ -3385,7 +3385,8 @@ _(ipfix_enable_reply) \
_(pg_capture_reply) \
_(pg_enable_disable_reply) \
_(ip_source_and_port_range_check_add_del_reply) \
-_(ip_source_and_port_range_check_interface_add_del_reply)
+_(ip_source_and_port_range_check_interface_add_del_reply)\
+_(delete_subif_reply)
#define _(n) \
static void vl_api_##n##_t_handler \
@@ -3604,7 +3605,8 @@ _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
_(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
ip_source_and_port_range_check_interface_add_del_reply) \
_(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
-_(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details)
+_(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
+_(DELETE_SUBIF_REPLY, delete_subif_reply)
/* M: construct, but don't yet send a message */
@@ -15210,6 +15212,36 @@ api_ipsec_gre_tunnel_dump (vat_main_t * vam)
}
static int
+api_delete_subif (vat_main_t * vam)
+{
+ unformat_input_t *i = vam->input;
+ vl_api_delete_subif_t *mp;
+ f64 timeout;
+ u32 sw_if_index = ~0;
+
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (i, "sw_if_index %d", &sw_if_index))
+ ;
+ else
+ break;
+ }
+
+ if (sw_if_index == ~0)
+ {
+ errmsg ("missing sw_if_index\n");
+ return -99;
+ }
+
+ /* Construct the API message */
+ M (DELETE_SUBIF, delete_subif);
+ mp->sw_if_index = ntohl (sw_if_index);
+
+ S;
+ W;
+}
+
+static int
q_or_quit (vat_main_t * vam)
{
longjmp (vam->jump_buf, 1);
@@ -15789,7 +15821,8 @@ _(ip_source_and_port_range_check_interface_add_del, \
"[udp-in-vrf <id>] [udp-out-vrf <id>]") \
_(ipsec_gre_add_del_tunnel, \
"src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
-_(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]")
+_(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
+_(delete_subif,"sub_sw_if_index <nn> sub_if_id <nn>")
/* List of command functions, CLI names map directly to functions */
#define foreach_cli_function \
diff --git a/vpp/vpp-api/api.c b/vpp/vpp-api/api.c
index fb44aaa8371..8d54ba75d99 100644
--- a/vpp/vpp-api/api.c
+++ b/vpp/vpp-api/api.c
@@ -384,7 +384,8 @@ _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, \
_(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, \
ip_source_and_port_range_check_interface_add_del) \
_(IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel) \
-_(IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump)
+_(IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump) \
+_(DELETE_SUBIF, delete_subif)
#define QUOTE_(x) #x
#define QUOTE(x) QUOTE_(x)
@@ -8155,6 +8156,17 @@ static void vl_api_ipsec_gre_tunnel_dump_t_handler
}
}
+static void
+vl_api_delete_subif_t_handler (vl_api_delete_subif_t * mp)
+{
+ vl_api_delete_subif_reply_t *rmp;
+ int rv;
+
+ rv = vnet_delete_sub_interface (ntohl (mp->sw_if_index));
+
+ REPLY_MACRO (VL_API_DELETE_SUBIF_REPLY);
+}
+
#define BOUNCE_HANDLER(nn) \
static void vl_api_##nn##_t_handler ( \
vl_api_##nn##_t *mp) \
diff --git a/vpp/vpp-api/custom_dump.c b/vpp/vpp-api/custom_dump.c
index 375535f63c5..87331eb166c 100644
--- a/vpp/vpp-api/custom_dump.c
+++ b/vpp/vpp-api/custom_dump.c
@@ -728,6 +728,16 @@ static void *vl_api_create_subif_t_print
foreach_create_subif_bit;
#undef _
+ FINISH;
+}
+
+static void *vl_api_delete_subif_t_print
+ (vl_api_delete_subif_t * mp, void *handle)
+{
+ u8 *s;
+
+ s = format (0, "SCRIPT: delete_subif ");
+ s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
FINISH;
}
@@ -2732,7 +2742,8 @@ _(LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump) \
_(LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump) \
_(LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump) \
_(IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel) \
-_(IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump)
+_(IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump) \
+_(DELETE_SUBIF, delete_subif)
void
vl_msg_api_custom_dump_configure (api_main_t * am)
{
diff --git a/vpp/vpp-api/vpe.api b/vpp/vpp-api/vpe.api
index a2a7be4542e..386ff1639ee 100644
--- a/vpp/vpp-api/vpe.api
+++ b/vpp/vpp-api/vpe.api
@@ -4831,3 +4831,23 @@ define ipsec_gre_tunnel_details {
u8 src_address[4];
u8 dst_address[4];
};
+
+/** \brief Delete sub interface request
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param sw_if_index - sw index of the interface that was created by create_subif
+*/
+define delete_subif {
+ u32 client_index;
+ u32 context;
+ u32 sw_if_index;
+};
+
+/** \brief Delete sub interface response
+ @param context - sender context, to match reply w/ request
+ @param retval - return code for the request
+*/
+define delete_subif_reply {
+ u32 context;
+ i32 retval;
+};