aboutsummaryrefslogtreecommitdiffstats
path: root/vnet
diff options
context:
space:
mode:
authorJuraj Sloboda <jsloboda@cisco.com>2016-12-05 13:20:37 +0100
committerDamjan Marion <dmarion.lists@gmail.com>2016-12-06 18:12:50 +0000
commitdfc19232dfc518e51e5bca7c698ace9ea53038be (patch)
tree061b031fc718097e916c2386f522ac744f023afb /vnet
parent3a2a1c47bc1f319d1f46abd2a364b3cf82404405 (diff)
Add binary API for reading interface/vrf assignment (VPP-439)
Change-Id: I9b7cb90127e464fea520bb1b0a3e93c05a0e9e8e Signed-off-by: Juraj Sloboda <jsloboda@cisco.com>
Diffstat (limited to 'vnet')
-rw-r--r--vnet/vnet/interface.api28
-rw-r--r--vnet/vnet/interface_api.c51
2 files changed, 77 insertions, 2 deletions
diff --git a/vnet/vnet/interface.api b/vnet/vnet/interface.api
index de8ca68cdd8..752e79c5ed1 100644
--- a/vnet/vnet/interface.api
+++ b/vnet/vnet/interface.api
@@ -181,7 +181,7 @@ define sw_interface_add_del_address
u8 address[16];
};
-/** \brief Reply for interface events registration
+/** \brief Reply to sw_interface_add_del_address
@param context - returned sender context, to match reply w/ request
@param retval - return code
*/
@@ -207,7 +207,7 @@ define sw_interface_set_table
u32 vrf_id;
};
-/** \brief Reply for interface events registration
+/** \brief Reply to sw_interface_set_table
@param context - returned sender context, to match reply w/ request
@param retval - return code
*/
@@ -217,6 +217,30 @@ define sw_interface_set_table_reply
i32 retval;
};
+/** \brief Get VRF id assigned to interface
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param sw_if_index - index of the interface
+*/
+define sw_interface_get_table
+{
+ u32 client_index;
+ u32 context;
+ u32 sw_if_index;
+ u8 is_ipv6;
+};
+
+/** \brief Reply to get_sw_interface_vrf
+ @param context - sender context which was passed in the request
+ @param vrf_id - VRF id assigned to the interface
+*/
+define sw_interface_get_table_reply
+{
+ u32 context;
+ i32 retval;
+ u32 vrf_id;
+};
+
/** \brief Stats counters structure
@param vnet_counter_type- such as ip4, ip6, punts, etc
@param is_combined - rx & tx total (all types) counts
diff --git a/vnet/vnet/interface_api.c b/vnet/vnet/interface_api.c
index 70b70fbc477..3529b528415 100644
--- a/vnet/vnet/interface_api.c
+++ b/vnet/vnet/interface_api.c
@@ -52,6 +52,7 @@ _(SW_INTERFACE_DUMP, sw_interface_dump) \
_(SW_INTERFACE_DETAILS, sw_interface_details) \
_(SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address) \
_(SW_INTERFACE_SET_TABLE, sw_interface_set_table) \
+_(SW_INTERFACE_GET_TABLE, sw_interface_get_table) \
_(SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered) \
_(SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats) \
_(SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del)
@@ -327,6 +328,56 @@ vl_api_sw_interface_set_table_t_handler (vl_api_sw_interface_set_table_t * mp)
REPLY_MACRO (VL_API_SW_INTERFACE_SET_TABLE_REPLY);
}
+static void
+send_sw_interface_get_table_reply (unix_shared_memory_queue_t * q,
+ u32 context, int retval, u32 vrf_id)
+{
+ vl_api_sw_interface_get_table_reply_t *mp;
+
+ mp = vl_msg_api_alloc (sizeof (*mp));
+ memset (mp, 0, sizeof (*mp));
+ mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_GET_TABLE_REPLY);
+ mp->context = context;
+ mp->retval = htonl (retval);
+ mp->vrf_id = htonl (vrf_id);
+
+ vl_msg_api_send_shmem (q, (u8 *) & mp);
+}
+
+static void
+vl_api_sw_interface_get_table_t_handler (vl_api_sw_interface_get_table_t * mp)
+{
+ unix_shared_memory_queue_t *q;
+ fib_table_t *fib_table = 0;
+ u32 sw_if_index = ~0;
+ u32 fib_index = ~0;
+ u32 table_id = ~0;
+ fib_protocol_t fib_proto = FIB_PROTOCOL_IP4;
+ int rv = 0;
+
+ q = vl_api_client_index_to_input_queue (mp->client_index);
+ if (q == 0)
+ return;
+
+ VALIDATE_SW_IF_INDEX (mp);
+
+ sw_if_index = ntohl (mp->sw_if_index);
+
+ if (mp->is_ipv6)
+ fib_proto = FIB_PROTOCOL_IP6;
+
+ fib_index = fib_table_get_index_for_sw_if_index (fib_proto, sw_if_index);
+ if (fib_index != ~0)
+ {
+ fib_table = fib_table_get (fib_index, fib_proto);
+ table_id = fib_table->ft_table_id;
+ }
+
+ BAD_SW_IF_INDEX_LABEL;
+
+ send_sw_interface_get_table_reply (q, mp->context, rv, table_id);
+}
+
static void vl_api_sw_interface_set_unnumbered_t_handler
(vl_api_sw_interface_set_unnumbered_t * mp)
{