summaryrefslogtreecommitdiffstats
path: root/src/vlibapi
diff options
context:
space:
mode:
authorEyal Bari <ebari@cisco.com>2017-03-14 14:39:51 +0200
committerJohn Lo <loj@cisco.com>2017-03-14 18:15:46 +0000
commit1c82cd4f491ff83127fbacfb6b09b9492eff1b62 (patch)
treeeec87672471edb2749260da96ce8031016a21bdf /src/vlibapi
parent3d6b2b5649fc2858c6ebc433a79c45d9bff3175e (diff)
API:support hidden sw interfaces
validate interfaces - added check for hidden interfaces interface dump - dont send hidden interfaces set_unnumbered - test for hidden vl_api_create_vlan_subif_t_handler, vl_api_create_subif_t_handler - fixed potential memory leak some other minor refactors to make code clearer and shorter Change-Id: Icce6b724336b7d1536fbd07a74bf7abe4916d2c0 Signed-off-by: Eyal Bari <ebari@cisco.com>
Diffstat (limited to 'src/vlibapi')
-rw-r--r--src/vlibapi/api_helper_macros.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/vlibapi/api_helper_macros.h b/src/vlibapi/api_helper_macros.h
index 7f94e446e18..4e281342db5 100644
--- a/src/vlibapi/api_helper_macros.h
+++ b/src/vlibapi/api_helper_macros.h
@@ -103,11 +103,15 @@ do { \
/* "trust, but verify" */
+static inline uword
+vnet_sw_if_index_is_api_valid (u32 sw_if_index)
+{
+ return vnet_sw_interface_is_api_valid (vnet_get_main (), sw_if_index);
+}
+
#define VALIDATE_SW_IF_INDEX(mp) \
do { u32 __sw_if_index = ntohl(mp->sw_if_index); \
- vnet_main_t *__vnm = vnet_get_main(); \
- if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \
- __sw_if_index)) { \
+ if (!vnet_sw_if_index_is_api_valid(__sw_if_index)) { \
rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \
goto bad_sw_if_index; \
} \
@@ -121,9 +125,7 @@ bad_sw_if_index: \
#define VALIDATE_RX_SW_IF_INDEX(mp) \
do { u32 __rx_sw_if_index = ntohl(mp->rx_sw_if_index); \
- vnet_main_t *__vnm = vnet_get_main(); \
- if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \
- __rx_sw_if_index)) { \
+ if (!vnet_sw_if_index_is_api_valid(__rx_sw_if_index)) { \
rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \
goto bad_rx_sw_if_index; \
} \
@@ -137,9 +139,7 @@ bad_rx_sw_if_index: \
#define VALIDATE_TX_SW_IF_INDEX(mp) \
do { u32 __tx_sw_if_index = ntohl(mp->tx_sw_if_index); \
- vnet_main_t *__vnm = vnet_get_main(); \
- if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \
- __tx_sw_if_index)) { \
+ if (!vnet_sw_if_index_is_api_valid(__tx_sw_if_index)) { \
rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \
goto bad_tx_sw_if_index; \
} \