aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/devices
diff options
context:
space:
mode:
authorPaul Vinciguerra <pvinci@vinciconsulting.com>2019-10-30 01:53:25 +0000
committerFlorin Coras <florin.coras@gmail.com>2019-11-12 23:52:36 +0000
commit44d06916b9654f393176e9fa85d0442184decbea (patch)
treeb388fda47c121f5e9c194448641a80b90e9ae6c2 /src/vnet/devices
parent867b9ec6abed648ad95e263b65eb1dd60835c17d (diff)
tap: Move client registration check to top
Type: fix Change-Id: I33dc4cf7b6c69f74c7bf4971ce59442678b878ef Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Diffstat (limited to 'src/vnet/devices')
-rw-r--r--src/vnet/devices/tap/tapv2.api2
-rw-r--r--src/vnet/devices/tap/tapv2_api.c21
2 files changed, 14 insertions, 9 deletions
diff --git a/src/vnet/devices/tap/tapv2.api b/src/vnet/devices/tap/tapv2.api
index dee73043c0f..c11a07cf72a 100644
--- a/src/vnet/devices/tap/tapv2.api
+++ b/src/vnet/devices/tap/tapv2.api
@@ -55,7 +55,7 @@ define tap_create_v2
{
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 2471d0084e1..a1acacf4719 100644
--- a/src/vnet/devices/tap/tapv2_api.c
+++ b/src/vnet/devices/tap/tapv2_api.c
@@ -52,10 +52,15 @@ _(SW_INTERFACE_TAP_V2_DUMP, sw_interface_tap_v2_dump)
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 @@ vl_api_tap_create_v2_t_handler (vl_api_tap_create_v2_t * mp)
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 @@ vl_api_tap_create_v2_t_handler (vl_api_tap_create_v2_t * mp)
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);