From 0b061112f73fda45084671120411a6484d9c11d2 Mon Sep 17 00:00:00 2001 From: Jerome Tollet Date: Mon, 4 Jun 2018 16:40:26 +0100 Subject: VPP-1305: Add support for tags Change-Id: I9e759037295fe675abe426e565a562b1ec1e7d33 Signed-off-by: Jerome Tollet --- src/vnet/devices/tap/tapv2.api | 3 ++- src/vnet/devices/tap/tapv2_api.c | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'src/vnet/devices/tap') diff --git a/src/vnet/devices/tap/tapv2.api b/src/vnet/devices/tap/tapv2.api index 21c3ffb275c..167b7a601a1 100644 --- a/src/vnet/devices/tap/tapv2.api +++ b/src/vnet/devices/tap/tapv2.api @@ -19,7 +19,7 @@ the Linux kernel TAP device driver */ -option version = "1.1.0"; +option version = "2.0.0"; /** \brief Initialize a new tap interface with the given paramters @param client_index - opaque cookie to identify the sender @@ -75,6 +75,7 @@ define tap_create_v2 u8 host_ip4_gw[4]; u8 host_ip6_gw_set; u8 host_ip6_gw[16]; + u8 tag[64]; }; /** \brief Reply for tap create reply diff --git a/src/vnet/devices/tap/tapv2_api.c b/src/vnet/devices/tap/tapv2_api.c index c6da0c9deae..f0c980a64fa 100644 --- a/src/vnet/devices/tap/tapv2_api.c +++ b/src/vnet/devices/tap/tapv2_api.c @@ -52,6 +52,7 @@ _(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) { + 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; @@ -114,6 +115,16 @@ vl_api_tap_create_v2_t_handler (vl_api_tap_create_v2_t * mp) if (!reg) return;; + /* If a tag was supplied... */ + if (mp->tag[0]) + { + /* Make sure it's a proper C-string */ + mp->tag[ARRAY_LEN (mp->tag) - 1] = 0; + u8 *tag = format (0, "%s%c", mp->tag, 0); + vnet_set_sw_interface_tag (vnm, tag, ap->sw_if_index); + } + + rmp = vl_msg_api_alloc (sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_TAP_CREATE_V2_REPLY); rmp->context = mp->context; @@ -144,6 +155,7 @@ tap_send_sw_interface_event_deleted (vpe_api_main_t * am, static void vl_api_tap_delete_v2_t_handler (vl_api_tap_delete_v2_t * mp) { + vnet_main_t *vnm = vnet_get_main (); vlib_main_t *vm = vlib_get_main (); int rv; vpe_api_main_t *vam = &vpe_api_main; @@ -165,7 +177,10 @@ vl_api_tap_delete_v2_t_handler (vl_api_tap_delete_v2_t * mp) vl_api_send_msg (reg, (u8 *) rmp); if (!rv) - tap_send_sw_interface_event_deleted (vam, reg, sw_if_index); + { + vnet_clear_sw_interface_tag (vnm, sw_if_index); + tap_send_sw_interface_event_deleted (vam, reg, sw_if_index); + } } static void -- cgit 1.2.3-korg