tap: Move client registration check to top
Type: fix
Change-Id: I33dc4cf7b6c69f74c7bf4971ce59442678b878ef
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
diff --git a/src/vnet/devices/tap/tapv2.api b/src/vnet/devices/tap/tapv2.api
index dee7304..c11a07c 100644
--- a/src/vnet/devices/tap/tapv2.api
+++ b/src/vnet/devices/tap/tapv2.api
@@ -55,7 +55,7 @@
{
u32 client_index;
u32 context;
- u32 id;
+ u32 id [default= 0xffffffff] ;
u8 use_random_mac;
u8 mac_address[6];
u16 tx_ring_sz; /* optional, default is 256 entries, must be power of 2 */
diff --git a/src/vnet/devices/tap/tapv2_api.c b/src/vnet/devices/tap/tapv2_api.c
index 2471d00..a1acacf 100644
--- a/src/vnet/devices/tap/tapv2_api.c
+++ b/src/vnet/devices/tap/tapv2_api.c
@@ -52,10 +52,15 @@
static void
vl_api_tap_create_v2_t_handler (vl_api_tap_create_v2_t * mp)
{
+ vl_api_registration_t *reg;
+ reg = vl_api_client_index_to_registration (mp->client_index);
+ if (!reg)
+ return;
+
vnet_main_t *vnm = vnet_get_main ();
vlib_main_t *vm = vlib_get_main ();
vl_api_tap_create_v2_reply_t *rmp;
- vl_api_registration_t *reg;
+
tap_create_if_args_t _a, *ap = &_a;
clib_memset (ap, 0, sizeof (*ap));
@@ -119,9 +124,6 @@
tap_create_if (vm, ap);
- reg = vl_api_client_index_to_registration (mp->client_index);
- if (!reg)
- return;;
/* If a tag was supplied... */
if (mp->tag[0])
@@ -145,18 +147,21 @@
static void
vl_api_tap_delete_v2_t_handler (vl_api_tap_delete_v2_t * mp)
{
+ vl_api_registration_t *reg;
+ reg = vl_api_client_index_to_registration (mp->client_index);
+ if (!reg)
+ return;
+
vnet_main_t *vnm = vnet_get_main ();
vlib_main_t *vm = vlib_get_main ();
int rv;
vl_api_tap_delete_v2_reply_t *rmp;
- vl_api_registration_t *reg;
+
u32 sw_if_index = ntohl (mp->sw_if_index);
rv = tap_delete_if (vm, sw_if_index);
- reg = vl_api_client_index_to_registration (mp->client_index);
- if (!reg)
- return;
+
rmp = vl_msg_api_alloc (sizeof (*rmp));
rmp->_vl_msg_id = ntohs (VL_API_TAP_DELETE_V2_REPLY);