diff options
author | Pavel Kotucek <pkotucek@cisco.com> | 2016-11-04 09:58:01 +0100 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2016-11-15 17:49:14 +0000 |
commit | f6e3dc4778ef910d4ae6114783bd8f50887e6d0d (patch) | |
tree | 0782a31c7c5e6d16c349278744264e90875245fa /vpp | |
parent | 7c8eda16d4bc10bf779200b23369e2ee12843dc1 (diff) |
span: add feature (rx only) (VPP-185)
Change-Id: I0f7cbf06b5a5acd745d13c9f5c761ea18132107b
Signed-off-by: marek <mazavods@gmail.com>
Signed-off-by: Damjan Marion <damarion@cisco.com>
Signed-off-by: Pavel Kotucek <pkotucek@cisco.com>
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'vpp')
-rw-r--r-- | vpp/vpp-api/api.c | 46 | ||||
-rw-r--r-- | vpp/vpp-api/custom_dump.c | 27 | ||||
-rw-r--r-- | vpp/vpp-api/vpe.api | 43 |
3 files changed, 116 insertions, 0 deletions
diff --git a/vpp/vpp-api/api.c b/vpp/vpp-api/api.c index ff0e9e82..1ecd1481 100644 --- a/vpp/vpp-api/api.c +++ b/vpp/vpp-api/api.c @@ -110,6 +110,7 @@ #include <vnet/l2/l2_fib.h> #include <vnet/l2/l2_bd.h> #include <vpp-api/vpe_msg_enum.h> +#include <vnet/span/span.h> #include <vnet/fib/ip6_fib.h> #include <vnet/fib/ip4_fib.h> @@ -444,6 +445,8 @@ _(SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream) \ _(IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump) \ _(IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del) \ _(IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump) \ +_(SW_INTERFACE_SPAN_ENABLE_DISABLE, sw_interface_span_enable_disable) \ +_(SW_INTERFACE_SPAN_DUMP, sw_interface_span_dump) \ _(GET_NEXT_INDEX, get_next_index) \ _(PG_CREATE_INTERFACE, pg_create_interface) \ _(PG_CAPTURE, pg_capture) \ @@ -8595,6 +8598,49 @@ static void } static void + vl_api_sw_interface_span_enable_disable_t_handler + (vl_api_sw_interface_span_enable_disable_t * mp) +{ + vl_api_sw_interface_span_enable_disable_reply_t *rmp; + int rv; + + vlib_main_t *vm = vlib_get_main (); + + rv = span_add_delete_entry (vm, ntohl (mp->sw_if_index_from), + ntohl (mp->sw_if_index_to), mp->enable); + + REPLY_MACRO (VL_API_SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY); +} + +static void +vl_api_sw_interface_span_dump_t_handler (vl_api_sw_interface_span_dump_t * mp) +{ + + unix_shared_memory_queue_t *q; + vl_api_sw_interface_span_details_t *rmp; + span_main_t *sm = &span_main; + u32 src_sw_if_index = 0, *dst_sw_if_index; + + q = vl_api_client_index_to_input_queue (mp->client_index); + vec_foreach (dst_sw_if_index, sm->dst_by_src_sw_if_index) + { + if (*dst_sw_if_index > 0) + { + rmp = vl_msg_api_alloc (sizeof (*rmp)); + memset (rmp, 0, sizeof (*rmp)); + rmp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_SPAN_DETAILS); + rmp->context = mp->context; + + rmp->sw_if_index_from = htonl (src_sw_if_index); + rmp->sw_if_index_to = htonl (*dst_sw_if_index); + + vl_msg_api_send_shmem (q, (u8 *) & rmp); + } + src_sw_if_index++; + } +} + +static void vl_api_pg_create_interface_t_handler (vl_api_pg_create_interface_t * mp) { vl_api_pg_create_interface_reply_t *rmp; diff --git a/vpp/vpp-api/custom_dump.c b/vpp/vpp-api/custom_dump.c index 220ba988..b42130d6 100644 --- a/vpp/vpp-api/custom_dump.c +++ b/vpp/vpp-api/custom_dump.c @@ -2199,6 +2199,31 @@ static void *vl_api_ipfix_classify_table_dump_t_print FINISH; } +static void *vl_api_sw_interface_span_enable_disable_t_print + (vl_api_sw_interface_span_enable_disable_t * mp, void *handle) +{ + u8 *s; + + s = format (0, "SCRIPT: sw_interface_span_enable_disable "); + s = format (s, "src_sw_if_index %u ", ntohl (mp->sw_if_index_from)); + s = format (s, "dst_sw_if_index %u ", ntohl (mp->sw_if_index_to)); + if (!mp->enable) + s = format (s, "disable "); + + FINISH; +} + +static void * +vl_api_sw_interface_span_dump_t_print (vl_api_sw_interface_span_dump_t * mp, + void *handle) +{ + u8 *s; + + s = format (0, "SCRIPT: sw_interface_span_dump "); + + FINISH; +} + static void *vl_api_get_next_index_t_print (vl_api_get_next_index_t * mp, void *handle) { @@ -2981,6 +3006,8 @@ _(SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream) \ _(IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump) \ _(IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del) \ _(IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump) \ +_(SW_INTERFACE_SPAN_ENABLE_DISABLE, sw_interface_span_enable_disable) \ +_(SW_INTERFACE_SPAN_DUMP, sw_interface_span_dump) \ _(GET_NEXT_INDEX, get_next_index) \ _(PG_CREATE_INTERFACE,pg_create_interface) \ _(PG_CAPTURE, pg_capture) \ diff --git a/vpp/vpp-api/vpe.api b/vpp/vpp-api/vpe.api index dc2d4850..e69979c6 100644 --- a/vpp/vpp-api/vpe.api +++ b/vpp/vpp-api/vpe.api @@ -4980,6 +4980,49 @@ define flow_classify_details { u32 table_index; }; +/** \brief Enable/Disable span to mirror traffic from one interface to another + @param client_index - opaque cookie to identify the sender + @param context - sender context which was passed in the request + @param sw_if_index_from - interface to be mirorred + @param sw_if_index_to - interface where the traffic is mirrored + @param enable - 1 enable SPAN, 0 SPAN on given interface +*/ +define sw_interface_span_enable_disable{ + u32 client_index; + u32 context; + u32 sw_if_index_from; + u32 sw_if_index_to; + u8 enable; +}; + +/** \brief Reply to SPAN enable/disable request + @param context - sender context which was passed in the request +*/ +define sw_interface_span_enable_disable_reply { + u32 context; + i32 retval; +}; + +/** \brief SPAN dump request + @param client_index - opaque cookie to identify the sender + @param context - sender context, to match reply w/ request +*/ +define sw_interface_span_dump { + u32 client_index; + u32 context; +}; + +/** \brief Reply to SPAN dump request + @param context - sender context which was passed in the request + @param sw_if_index_from - mirorred interface + @param sw_if_index_to - interface where the traffic is mirrored +*/ +define sw_interface_span_details { + u32 context; + u32 sw_if_index_from; + u32 sw_if_index_to; +}; + /** \brief Query relative index via node names @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request |