summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vpp-api-test/vat/api_format.c72
-rw-r--r--vpp-api-test/vat/vat.h1
-rw-r--r--vpp/api/api.c6
-rw-r--r--vpp/api/custom_dump.c28
-rw-r--r--vpp/api/vpe.api1
5 files changed, 96 insertions, 12 deletions
diff --git a/vpp-api-test/vat/api_format.c b/vpp-api-test/vat/api_format.c
index 086c888c465..d4e53929bff 100644
--- a/vpp-api-test/vat/api_format.c
+++ b/vpp-api-test/vat/api_format.c
@@ -533,8 +533,9 @@ static void vl_api_create_loopback_reply_t_handler
i32 retval = ntohl(mp->retval);
vam->retval = retval;
- vam->result_ready = 1;
vam->regenerate_interface_table = 1;
+ vam->sw_if_index = ntohl (mp->sw_if_index);
+ vam->result_ready = 1;
}
static void vl_api_create_loopback_reply_t_handler_json
@@ -549,6 +550,34 @@ static void vl_api_create_loopback_reply_t_handler_json
vat_json_print(vam->ofp, &node);
vat_json_free(&node);
+ vam->retval = ntohl(mp->retval);
+ vam->result_ready = 1;
+}
+
+static void vl_api_af_packet_create_reply_t_handler
+(vl_api_af_packet_create_reply_t * mp)
+{
+ vat_main_t * vam = &vat_main;
+ i32 retval = ntohl(mp->retval);
+
+ vam->retval = retval;
+ vam->regenerate_interface_table = 1;
+ vam->sw_if_index = ntohl (mp->sw_if_index);
+ vam->result_ready = 1;
+}
+
+static void vl_api_af_packet_create_reply_t_handler_json
+(vl_api_af_packet_create_reply_t * mp)
+{
+ vat_main_t * vam = &vat_main;
+ vat_json_node_t node;
+
+ vat_json_init_object(&node);
+ vat_json_object_add_int(&node, "retval", ntohl(mp->retval));
+ vat_json_object_add_uint(&node, "sw_if_index", ntohl(mp->sw_if_index));
+
+ vat_json_print(vam->ofp, &node);
+ vat_json_free(&node);
vam->retval = ntohl(mp->retval);
vam->result_ready = 1;
@@ -561,8 +590,9 @@ static void vl_api_create_vlan_subif_reply_t_handler
i32 retval = ntohl(mp->retval);
vam->retval = retval;
- vam->result_ready = 1;
vam->regenerate_interface_table = 1;
+ vam->sw_if_index = ntohl (mp->sw_if_index);
+ vam->result_ready = 1;
}
static void vl_api_create_vlan_subif_reply_t_handler_json
@@ -589,8 +619,9 @@ static void vl_api_create_subif_reply_t_handler
i32 retval = ntohl(mp->retval);
vam->retval = retval;
- vam->result_ready = 1;
vam->regenerate_interface_table = 1;
+ vam->sw_if_index = ntohl (mp->sw_if_index);
+ vam->result_ready = 1;
}
static void vl_api_create_subif_reply_t_handler_json
@@ -617,8 +648,8 @@ static void vl_api_interface_name_renumber_reply_t_handler
i32 retval = ntohl(mp->retval);
vam->retval = retval;
- vam->result_ready = 1;
vam->regenerate_interface_table = 1;
+ vam->result_ready = 1;
}
static void vl_api_interface_name_renumber_reply_t_handler_json
@@ -784,7 +815,6 @@ static void vl_api_classify_add_del_table_reply_t_handler
vam->async_errors += (retval < 0);
} else {
vam->retval = retval;
- vam->result_ready = 1;
if (retval == 0 &&
((mp->new_table_index != 0xFFFFFFFF) ||
(mp->skip_n_vectors != 0xFFFFFFFF) ||
@@ -796,6 +826,7 @@ static void vl_api_classify_add_del_table_reply_t_handler
errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d\n",
ntohl(mp->new_table_index),
ntohl(mp->skip_n_vectors), ntohl(mp->match_n_vectors));
+ vam->result_ready = 1;
}
}
@@ -827,9 +858,9 @@ static void vl_api_get_node_index_reply_t_handler
vam->async_errors += (retval < 0);
} else {
vam->retval = retval;
- vam->result_ready = 1;
if (retval == 0)
errmsg ("node index %d\n", ntohl(mp->node_index));
+ vam->result_ready = 1;
}
}
@@ -859,9 +890,9 @@ static void vl_api_add_node_next_reply_t_handler
vam->async_errors += (retval < 0);
} else {
vam->retval = retval;
- vam->result_ready = 1;
if (retval == 0)
errmsg ("next index %d\n", ntohl(mp->next_index));
+ vam->result_ready = 1;
}
}
@@ -1159,8 +1190,10 @@ static void vl_api_tap_connect_reply_t_handler
vam->async_errors += (retval < 0);
} else {
vam->retval = retval;
- vam->result_ready = 1;
+ vam->sw_if_index = ntohl (mp->sw_if_index);
+ vam->result_ready = 1;
}
+
}
static void vl_api_tap_connect_reply_t_handler_json
@@ -1178,6 +1211,7 @@ static void vl_api_tap_connect_reply_t_handler_json
vam->retval = ntohl(mp->retval);
vam->result_ready = 1;
+
}
static void vl_api_tap_modify_reply_t_handler
@@ -1189,6 +1223,7 @@ static void vl_api_tap_modify_reply_t_handler
vam->async_errors += (retval < 0);
} else {
vam->retval = retval;
+ vam->sw_if_index = ntohl (mp->sw_if_index);
vam->result_ready = 1;
}
}
@@ -1278,6 +1313,7 @@ static void vl_api_l2tpv3_create_tunnel_reply_t_handler
vam->async_errors += (retval < 0);
} else {
vam->retval = retval;
+ vam->sw_if_index = ntohl (mp->sw_if_index);
vam->result_ready = 1;
}
}
@@ -1308,6 +1344,7 @@ static void vl_api_vxlan_add_del_tunnel_reply_t_handler
vam->async_errors += (retval < 0);
} else {
vam->retval = retval;
+ vam->sw_if_index = ntohl (mp->sw_if_index);
vam->result_ready = 1;
}
}
@@ -1338,6 +1375,7 @@ static void vl_api_gre_add_del_tunnel_reply_t_handler
vam->async_errors += (retval < 0);
} else {
vam->retval = retval;
+ vam->sw_if_index = ntohl (mp->sw_if_index);
vam->result_ready = 1;
}
}
@@ -1368,6 +1406,7 @@ static void vl_api_create_vhost_user_if_reply_t_handler
vam->async_errors += (retval < 0);
} else {
vam->retval = retval;
+ vam->sw_if_index = ntohl (mp->sw_if_index);
vam->result_ready = 1;
}
}
@@ -2371,7 +2410,6 @@ _(lisp_gpe_add_del_iface_reply) \
_(lisp_enable_disable_reply) \
_(lisp_pitr_set_locator_set_reply) \
_(vxlan_gpe_add_del_tunnel_reply) \
-_(af_packet_create_reply) \
_(af_packet_delete_reply) \
_(policer_add_del_reply) \
_(netmap_create_reply) \
@@ -2600,6 +2638,20 @@ do { \
return -99; \
} while(0);
+/* W2: wait for results, with timeout */
+#define W2(body) \
+do { \
+ timeout = vat_time_now (vam) + 1.0; \
+ \
+ while (vat_time_now (vam) < timeout) { \
+ if (vam->result_ready == 1) { \
+ (body); \
+ return (vam->retval); \
+ } \
+ } \
+ return -99; \
+} while(0);
+
typedef struct {
u8 * name;
u32 value;
@@ -10554,7 +10606,7 @@ api_af_packet_create (vat_main_t * vam)
mp->use_random_hw_addr = random_hw_addr;
vec_free (host_if_name);
- S; W;
+ S; W2(fprintf(vam->ofp," new sw_if_index = %d ", vam->sw_if_index));
/* NOTREACHED */
return 0;
}
diff --git a/vpp-api-test/vat/vat.h b/vpp-api-test/vat/vat.h
index b32d9ffc754..4772f2e3681 100644
--- a/vpp-api-test/vat/vat.h
+++ b/vpp-api-test/vat/vat.h
@@ -125,6 +125,7 @@ typedef struct {
u32 async_errors;
volatile u32 result_ready;
volatile i32 retval;
+ volatile u32 sw_if_index;
volatile u8 *shmem_result;
/* our client index */
diff --git a/vpp/api/api.c b/vpp/api/api.c
index 95301f4c26c..f398e4f9fb1 100644
--- a/vpp/api/api.c
+++ b/vpp/api/api.c
@@ -6001,16 +6001,18 @@ vl_api_af_packet_create_t_handler
vl_api_af_packet_create_reply_t *rmp;
int rv = 0;
u8 *host_if_name = NULL;
+ u32 sw_if_index;
host_if_name = format(0, "%s", mp->host_if_name);
vec_add1 (host_if_name, 0);
rv = af_packet_create_if(vm, host_if_name,
- mp->use_random_hw_addr ? 0 : mp->hw_addr, 0);
+ mp->use_random_hw_addr ? 0 : mp->hw_addr, &sw_if_index);
vec_free(host_if_name);
- REPLY_MACRO(VL_API_AF_PACKET_CREATE_REPLY);
+ REPLY_MACRO2(VL_API_AF_PACKET_CREATE_REPLY,
+ rmp->sw_if_index = clib_host_to_net_u32(sw_if_index));
}
static void
diff --git a/vpp/api/custom_dump.c b/vpp/api/custom_dump.c
index f49e1b05cb2..388c7e50173 100644
--- a/vpp/api/custom_dump.c
+++ b/vpp/api/custom_dump.c
@@ -1717,6 +1717,32 @@ static void * vl_api_cop_whitelist_enable_disable_t_print
FINISH;
}
+static void * vl_api_af_packet_create_t_print
+(vl_api_af_packet_create_t * mp, void *handle)
+{
+ u8 * s;
+
+ s = format (0, "SCRIPT: af_packet_create ");
+ s = format (s, "host_if_name %s ", mp->host_if_name);
+ if ( mp->use_random_hw_addr)
+ s = format (s, "hw_addr random ");
+ else
+ s = format (s, "hw_addr %U ", format_ethernet_address, mp->hw_addr);
+
+ FINISH;
+}
+
+static void * vl_api_af_packet_delete_t_print
+(vl_api_af_packet_delete_t * mp, void *handle)
+{
+ u8 * s;
+
+ s = format (0, "SCRIPT: af_packet_delete ");
+ s = format (s, "host_if_name %s ", mp->host_if_name);
+
+ FINISH;
+}
+
static void *vl_api_sw_interface_clear_stats_t_print
(vl_api_sw_interface_clear_stats_t * mp, void *handle)
{
@@ -1814,6 +1840,8 @@ _(DELETE_LOOPBACK, delete_loopback) \
_(BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del) \
_(COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable) \
_(COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable) \
+_(AF_PACKET_CREATE, af_packet_create) \
+_(AF_PACKET_DELETE, af_packet_delete) \
_(SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats)
void vl_msg_api_custom_dump_configure (api_main_t *am)
diff --git a/vpp/api/vpe.api b/vpp/api/vpe.api
index 9a639c61f8d..71783a463b3 100644
--- a/vpp/api/vpe.api
+++ b/vpp/api/vpe.api
@@ -3443,6 +3443,7 @@ define af_packet_create {
define af_packet_create_reply {
u32 context;
i32 retval;
+ u32 sw_if_index;
};
/** \brief Delete host-interface