aboutsummaryrefslogtreecommitdiffstats
path: root/vpp
diff options
context:
space:
mode:
Diffstat (limited to 'vpp')
-rw-r--r--vpp/vpp-api/api.c74
-rw-r--r--vpp/vpp-api/custom_dump.c23
-rw-r--r--vpp/vpp-api/vpe.api28
3 files changed, 119 insertions, 6 deletions
diff --git a/vpp/vpp-api/api.c b/vpp/vpp-api/api.c
index 2c0256cc34e..b5253726915 100644
--- a/vpp/vpp-api/api.c
+++ b/vpp/vpp-api/api.c
@@ -255,8 +255,8 @@ _(COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable) \
_(COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable) \
_(GET_NODE_GRAPH, get_node_graph) \
_(SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats) \
-_(IOAM_ENABLE, ioam_enable) \
-_(IOAM_DISABLE, ioam_disable) \
+_(IOAM_ENABLE, ioam_enable) \
+_(IOAM_DISABLE, ioam_disable) \
_(LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set) \
_(LISP_ADD_DEL_LOCATOR, lisp_add_del_locator) \
_(LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid) \
@@ -332,7 +332,8 @@ _(IP_FIB_DUMP, ip_fib_dump) \
_(IP_FIB_DETAILS, ip_fib_details) \
_(IP6_FIB_DUMP, ip6_fib_dump) \
_(IP6_FIB_DETAILS, ip6_fib_details) \
-_(FEATURE_ENABLE_DISABLE, feature_enable_disable)
+_(FEATURE_ENABLE_DISABLE, feature_enable_disable) \
+_(SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del)
#define QUOTE_(x) #x
#define QUOTE(x) QUOTE_(x)
@@ -1997,8 +1998,10 @@ vl_api_tap_connect_t_handler (vl_api_tap_connect_t * mp, vlib_main_t * vm)
{
int rv;
vl_api_tap_connect_reply_t *rmp;
+ vnet_main_t *vnm = vnet_get_main ();
unix_shared_memory_queue_t *q;
u32 sw_if_index = (u32) ~ 0;
+ u8 *tag;
rv = vnet_tap_connect_renumber (vm, mp->tap_name,
mp->use_random_mac ? 0 : mp->mac_address,
@@ -2009,6 +2012,14 @@ vl_api_tap_connect_t_handler (vl_api_tap_connect_t * mp, vlib_main_t * vm)
if (!q)
return;
+ /* Add tag if supplied */
+ if (rv == 0 && mp->tag[0])
+ {
+ mp->tag[ARRAY_LEN (mp->tag) - 1] = 0;
+ tag = format (0, "%s%c", mp->tag, 0);
+ vnet_set_sw_interface_tag (vnm, tag, sw_if_index);
+ }
+
rmp = vl_msg_api_alloc (sizeof (*rmp));
rmp->_vl_msg_id = ntohs (VL_API_TAP_CONNECT_REPLY);
rmp->context = mp->context;
@@ -2054,6 +2065,11 @@ vl_api_tap_delete_t_handler (vl_api_tap_delete_t * mp, vlib_main_t * vm)
u32 sw_if_index = ntohl (mp->sw_if_index);
rv = vnet_tap_delete (vm, sw_if_index);
+ if (!rv)
+ {
+ vnet_main_t *vnm = vnet_get_main ();
+ vnet_clear_sw_interface_tag (vnm, sw_if_index);
+ }
q = vl_api_client_index_to_input_queue (mp->client_index);
if (!q)
@@ -2684,7 +2700,9 @@ send_sw_interface_details (vpe_api_main_t * am,
u8 * interface_name, u32 context)
{
vl_api_sw_interface_details_t *mp;
+ vnet_main_t *vnm = vnet_get_main ();
vnet_hw_interface_t *hi;
+ u8 *tag;
hi = vnet_get_sup_hw_interface (am->vnet_main, swif->sw_if_index);
@@ -2752,6 +2770,10 @@ send_sw_interface_details (vpe_api_main_t * am,
}
}
+ tag = vnet_get_sw_interface_tag (vnm, swif->sw_if_index);
+ if (tag)
+ strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
+
vl_msg_api_send_shmem (q, (u8 *) & mp);
}
@@ -4020,7 +4042,6 @@ vl_api_create_vhost_user_if_t_handler (vl_api_create_vhost_user_if_t * mp)
int rv = 0;
vl_api_create_vhost_user_if_reply_t *rmp;
u32 sw_if_index = (u32) ~ 0;
-
vnet_main_t *vnm = vnet_get_main ();
vlib_main_t *vm = vlib_get_main ();
@@ -4029,6 +4050,19 @@ vl_api_create_vhost_user_if_t_handler (vl_api_create_vhost_user_if_t * mp)
mp->renumber, ntohl (mp->custom_dev_instance),
(mp->use_custom_mac) ? mp->mac_address : NULL);
+ /* Remember an interface tag for the new interface */
+ if (rv == 0)
+ {
+ /* 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, sw_if_index);
+ }
+ }
+
/* *INDENT-OFF* */
REPLY_MACRO2(VL_API_CREATE_VHOST_USER_IF_REPLY,
({
@@ -4074,6 +4108,7 @@ vl_api_delete_vhost_user_if_t_handler (vl_api_delete_vhost_user_if_t * mp)
if (!q)
return;
+ vnet_clear_sw_interface_tag (vnm, sw_if_index);
send_sw_interface_flags_deleted (vam, q, sw_if_index);
}
}
@@ -9113,6 +9148,37 @@ vl_api_feature_enable_disable_t_handler (vl_api_feature_enable_disable_t * mp)
REPLY_MACRO (VL_API_FEATURE_ENABLE_DISABLE_REPLY);
}
+static void vl_api_sw_interface_tag_add_del_t_handler
+ (vl_api_sw_interface_tag_add_del_t * mp)
+{
+ vnet_main_t *vnm = vnet_get_main ();
+ vl_api_sw_interface_tag_add_del_reply_t *rmp;
+ int rv = 0;
+ u8 *tag;
+ u32 sw_if_index = ntohl (mp->sw_if_index);
+
+ VALIDATE_SW_IF_INDEX (mp);
+
+ if (mp->is_add)
+ {
+ if (mp->tag[0] == 0)
+ {
+ rv = VNET_API_ERROR_INVALID_VALUE;
+ goto out;
+ }
+
+ mp->tag[ARRAY_LEN (mp->tag) - 1] = 0;
+ tag = format (0, "%s%c", mp->tag, 0);
+ vnet_set_sw_interface_tag (vnm, tag, sw_if_index);
+ }
+ else
+ vnet_clear_sw_interface_tag (vnm, sw_if_index);
+
+ BAD_SW_IF_INDEX_LABEL;
+out:
+ REPLY_MACRO (VL_API_SW_INTERFACE_TAG_ADD_DEL_REPLY);
+}
+
#define BOUNCE_HANDLER(nn) \
static void vl_api_##nn##_t_handler ( \
vl_api_##nn##_t *mp) \
diff --git a/vpp/vpp-api/custom_dump.c b/vpp/vpp-api/custom_dump.c
index 28d3341de8c..a36a8a43af0 100644
--- a/vpp/vpp-api/custom_dump.c
+++ b/vpp/vpp-api/custom_dump.c
@@ -431,7 +431,8 @@ static void *vl_api_tap_connect_t_print
s = format (s, "tapname %s ", mp->tap_name);
if (mp->use_random_mac)
s = format (s, "random-mac ");
-
+ if (mp->tag[0])
+ s = format (s, "tag %s ", mp->tag);
if (memcmp (mp->mac_address, null_mac, 6))
s = format (s, "mac %U ", format_ethernet_address, mp->mac_address);
@@ -1568,6 +1569,8 @@ static void *vl_api_create_vhost_user_if_t_print
s = format (s, "server ");
if (mp->renumber)
s = format (s, "renumber %d ", ntohl (mp->custom_dev_instance));
+ if (mp->tag[0])
+ s = format (s, "tag %s", mp->tag);
FINISH;
}
@@ -2926,6 +2929,21 @@ static void *vl_api_feature_enable_disable_t_print
FINISH;
}
+static void *vl_api_sw_interface_tag_add_del_t_print
+ (vl_api_sw_interface_tag_add_del_t * mp, void *handle)
+{
+ u8 *s;
+
+ s = format (0, "SCRIPT: sw_interface_tag_add_del ");
+ s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
+ if (mp->is_add)
+ s = format (s, "tag %s ", mp->tag);
+ else
+ s = format (s, "del ");
+
+ FINISH;
+}
+
#define foreach_custom_print_no_arg_function \
_(lisp_eid_table_vni_dump) \
_(lisp_map_resolver_dump) \
@@ -3098,7 +3116,8 @@ _(IOAM_ENABLE, ioam_enable) \
_(IOAM_DISABLE, ioam_disable) \
_(IP_FIB_DUMP, ip_fib_dump) \
_(IP6_FIB_DUMP, ip6_fib_dump) \
-_(FEATURE_ENABLE_DISABLE, feature_enable_disable)
+_(FEATURE_ENABLE_DISABLE, feature_enable_disable) \
+_(SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del)
void
vl_msg_api_custom_dump_configure (api_main_t * am)
{
diff --git a/vpp/vpp-api/vpe.api b/vpp/vpp-api/vpe.api
index 5ab21029fd3..bcc3f4ec1b3 100644
--- a/vpp/vpp-api/vpe.api
+++ b/vpp/vpp-api/vpe.api
@@ -117,6 +117,7 @@ define sw_interface_details
u32 vtr_push_dot1q; // ethertype of first pushed tag is dot1q/dot1ad
u32 vtr_tag1; // first pushed tag
u32 vtr_tag2; // second pushed tag
+ u8 tag[64];
};
/* works */
@@ -226,6 +227,7 @@ define tap_connect
u8 mac_address[6];
u8 renumber;
u32 custom_dev_instance;
+ u8 tag[64];
};
/** \brief Reply for tap connect request
@@ -2269,6 +2271,7 @@ define create_vhost_user_if
u32 custom_dev_instance;
u8 use_custom_mac;
u8 mac_address[6];
+ u8 tag[64];
};
/** \brief vhost-user interface create response
@@ -5518,3 +5521,28 @@ define feature_enable_disable_reply
u32 context;
i32 retval;
};
+
+/** \brief Set / clear software interface tag
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param sw_if_index - the interface
+ @param add_del - 1 = add, 0 = delete
+ @param tag - an ascii tag
+*/
+define sw_interface_tag_add_del {
+ u32 client_index;
+ u32 context;
+ u8 is_add;
+ u32 sw_if_index;
+ u8 tag[64];
+};
+
+/** \brief Reply to set / clear software interface tag
+ @param context - sender context which was passed in the request
+ @param retval - return code for the request
+*/
+define sw_interface_tag_add_del_reply
+{
+ u32 context;
+ i32 retval;
+};