aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp/api/api.c
diff options
context:
space:
mode:
authorJon Loeliger <jdl@netgate.com>2017-02-23 13:57:35 -0600
committerJohn Lo <loj@cisco.com>2017-03-03 23:19:21 +0000
commitc83c3b7f117b981b677f646a0e30f44ec70de239 (patch)
tree323266bab831bcbfb14f089e803b7cbc13b857e1 /src/vpp/api/api.c
parenta084d62a6e47d3505b3ed314230598704314f7bc (diff)
Implement a loopback instance allocation scheme.
To support creating loopback interfaces with a specific instance number, a new CREATE_LOOPBACK_INSTANCE API call with flag is_specified and value user_instance is introduced. Presumably the existing CREATE_LOOPBACK API message will be obsoleted and revmoved. The VAT cli commands can now mention and format the new field as 'instance %d' data. If no instance number is named, the old call CREATE_LOOPBACK is used to maintain backward compatibility. However, if the instance is named, the new CREATE_LOOPBACK_INSTANCE message will be used. Both the dynamically allocated and user-requested instance number are tracked in a bitvector. If is_specified is 0, the next free instance will be used.. A request for a specific instance number will be granted if it is available. On error, the value ~0 is returned. Change-Id: I849815563a5da736dcd6bccd262ef49b963f6643 Signed-off-by: Jon Loeliger <jdl@netgate.com>
Diffstat (limited to 'src/vpp/api/api.c')
-rw-r--r--src/vpp/api/api.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/vpp/api/api.c b/src/vpp/api/api.c
index e028fad4a39..f06894e8783 100644
--- a/src/vpp/api/api.c
+++ b/src/vpp/api/api.c
@@ -116,6 +116,7 @@ _(PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable) \
_(VNET_GET_SUMMARY_STATS, vnet_get_summary_stats) \
_(RESET_FIB, reset_fib) \
_(CREATE_LOOPBACK, create_loopback) \
+_(CREATE_LOOPBACK_INSTANCE, create_loopback_instance) \
_(CONTROL_PING, control_ping) \
_(CLI_REQUEST, cli_request) \
_(CLI_INBAND, cli_inband) \
@@ -1026,7 +1027,7 @@ vl_api_create_loopback_t_handler (vl_api_create_loopback_t * mp)
u32 sw_if_index;
int rv;
- rv = vnet_create_loopback_interface (&sw_if_index, mp->mac_address);
+ rv = vnet_create_loopback_interface (&sw_if_index, mp->mac_address, 0, 0);
/* *INDENT-OFF* */
REPLY_MACRO2(VL_API_CREATE_LOOPBACK_REPLY,
@@ -1036,6 +1037,26 @@ vl_api_create_loopback_t_handler (vl_api_create_loopback_t * mp)
/* *INDENT-ON* */
}
+static void vl_api_create_loopback_instance_t_handler
+ (vl_api_create_loopback_instance_t * mp)
+{
+ vl_api_create_loopback_instance_reply_t *rmp;
+ u32 sw_if_index;
+ u8 is_specified = mp->is_specified;
+ u32 user_instance = ntohl (mp->user_instance);
+ int rv;
+
+ rv = vnet_create_loopback_interface (&sw_if_index, mp->mac_address,
+ is_specified, user_instance);
+
+ /* *INDENT-OFF* */
+ REPLY_MACRO2(VL_API_CREATE_LOOPBACK_INSTANCE_REPLY,
+ ({
+ rmp->sw_if_index = ntohl (sw_if_index);
+ }));
+ /* *INDENT-ON* */
+}
+
static void
vl_api_delete_loopback_t_handler (vl_api_delete_loopback_t * mp)
{