From cb034b9b374927c7552e36dcbc306d8456b2a0cb Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Wed, 28 Dec 2016 18:38:59 +0100 Subject: Move java,lua api and remaining plugins to src/ Change-Id: I1c3b87e886603678368428ae56a6bd3327cbc90d Signed-off-by: Damjan Marion --- src/plugins/lb/api.c | 228 +++++++++++ src/plugins/lb/cli.c | 250 ++++++++++++ src/plugins/lb/lb.api | 71 ++++ src/plugins/lb/lb.c | 844 ++++++++++++++++++++++++++++++++++++++++ src/plugins/lb/lb.h | 333 ++++++++++++++++ src/plugins/lb/lb_plugin_doc.md | 141 +++++++ src/plugins/lb/lb_test.c | 293 ++++++++++++++ src/plugins/lb/lbhash.h | 216 ++++++++++ src/plugins/lb/node.c | 419 ++++++++++++++++++++ src/plugins/lb/refcount.c | 41 ++ src/plugins/lb/refcount.h | 67 ++++ src/plugins/lb/util.c | 72 ++++ src/plugins/lb/util.h | 40 ++ 13 files changed, 3015 insertions(+) create mode 100644 src/plugins/lb/api.c create mode 100644 src/plugins/lb/cli.c create mode 100644 src/plugins/lb/lb.api create mode 100644 src/plugins/lb/lb.c create mode 100644 src/plugins/lb/lb.h create mode 100644 src/plugins/lb/lb_plugin_doc.md create mode 100644 src/plugins/lb/lb_test.c create mode 100644 src/plugins/lb/lbhash.h create mode 100644 src/plugins/lb/node.c create mode 100644 src/plugins/lb/refcount.c create mode 100644 src/plugins/lb/refcount.h create mode 100644 src/plugins/lb/util.c create mode 100644 src/plugins/lb/util.h (limited to 'src/plugins/lb') diff --git a/src/plugins/lb/api.c b/src/plugins/lb/api.c new file mode 100644 index 00000000..06c53fa1 --- /dev/null +++ b/src/plugins/lb/api.c @@ -0,0 +1,228 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include +#include +#include +#include + +#define vl_msg_id(n,h) n, +typedef enum { +#include + /* We'll want to know how many messages IDs we need... */ + VL_MSG_FIRST_AVAILABLE, +} vl_msg_id_t; +#undef vl_msg_id + + +/* define message structures */ +#define vl_typedefs +#include +#undef vl_typedefs + +/* define generated endian-swappers */ +#define vl_endianfun +#include +#undef vl_endianfun + +#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) + +/* Get the API version number */ +#define vl_api_version(n,v) static u32 api_version=(v); +#include +#undef vl_api_version + +#define vl_msg_name_crc_list +#include +#undef vl_msg_name_crc_list + +static void +setup_message_id_table (lb_main_t * lbm, api_main_t * am) +{ +#define _(id,n,crc) \ + vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + lbm->msg_id_base); + foreach_vl_msg_name_crc_lb; +#undef _ +} + +/* Macro to finish up custom dump fns */ +#define FINISH \ + vec_add1 (s, 0); \ + vl_print (handle, (char *)s); \ + vec_free (s); \ + return handle; + +/* + * A handy macro to set up a message reply. + * Assumes that the following variables are available: + * mp - pointer to request message + * rmp - pointer to reply message type + * rv - return value + */ + +#define REPLY_MACRO(t) \ +do { \ + unix_shared_memory_queue_t * q = \ + vl_api_client_index_to_input_queue (mp->client_index); \ + if (!q) \ + return; \ + \ + rmp = vl_msg_api_alloc (sizeof (*rmp)); \ + rmp->_vl_msg_id = ntohs((t)+lbm->msg_id_base); \ + rmp->context = mp->context; \ + rmp->retval = ntohl(rv); \ + \ + vl_msg_api_send_shmem (q, (u8 *)&rmp); \ +} while(0); + +static void +vl_api_lb_conf_t_handler +(vl_api_lb_conf_t * mp) +{ + lb_main_t *lbm = &lb_main; + vl_api_lb_conf_reply_t * rmp; + int rv = 0; + + rv = lb_conf((ip4_address_t *)&mp->ip4_src_address, + (ip6_address_t *)mp->ip6_src_address, + mp->sticky_buckets_per_core, + mp->flow_timeout); + + REPLY_MACRO (VL_API_LB_CONF_REPLY); +} + +static void *vl_api_lb_conf_t_print +(vl_api_lb_conf_t *mp, void * handle) +{ + u8 * s; + s = format (0, "SCRIPT: lb_conf "); + s = format (s, "%U ", format_ip4_address, (ip4_address_t *)&mp->ip4_src_address); + s = format (s, "%U ", format_ip6_address, (ip6_address_t *)mp->ip6_src_address); + s = format (s, "%u ", mp->sticky_buckets_per_core); + s = format (s, "%u ", mp->flow_timeout); + FINISH; +} + + +static void +vl_api_lb_add_del_vip_t_handler +(vl_api_lb_add_del_vip_t * mp) +{ + lb_main_t *lbm = &lb_main; + vl_api_lb_conf_reply_t * rmp; + int rv = 0; + ip46_address_t prefix; + memcpy(&prefix.ip6, mp->ip_prefix, sizeof(prefix.ip6)); + + if (mp->is_del) { + u32 vip_index; + if (!(rv = lb_vip_find_index(&prefix, mp->prefix_length, &vip_index))) + rv = lb_vip_del(vip_index); + } else { + u32 vip_index; + lb_vip_type_t type; + if (ip46_prefix_is_ip4(&prefix, mp->prefix_length)) { + type = mp->is_gre4?LB_VIP_TYPE_IP4_GRE4:LB_VIP_TYPE_IP4_GRE6; + } else { + type = mp->is_gre4?LB_VIP_TYPE_IP6_GRE4:LB_VIP_TYPE_IP6_GRE6; + } + + rv = lb_vip_add(&prefix, mp->prefix_length, type, + mp->new_flows_table_length, &vip_index); + } + REPLY_MACRO (VL_API_LB_CONF_REPLY); +} + +static void *vl_api_lb_add_del_vip_t_print +(vl_api_lb_add_del_vip_t *mp, void * handle) +{ + u8 * s; + s = format (0, "SCRIPT: lb_add_del_vip "); + s = format (s, "%U ", format_ip46_prefix, + (ip46_address_t *)mp->ip_prefix, mp->prefix_length, IP46_TYPE_ANY); + s = format (s, "%s ", mp->is_gre4?"gre4":"gre6"); + s = format (s, "%u ", mp->new_flows_table_length); + s = format (s, "%s ", mp->is_del?"del":"add"); + FINISH; +} + +static void +vl_api_lb_add_del_as_t_handler +(vl_api_lb_add_del_as_t * mp) +{ + lb_main_t *lbm = &lb_main; + vl_api_lb_conf_reply_t * rmp; + int rv = 0; + u32 vip_index; + if ((rv = lb_vip_find_index((ip46_address_t *)mp->vip_ip_prefix, + mp->vip_prefix_length, &vip_index))) + goto done; + + if (mp->is_del) + rv = lb_vip_del_ass(vip_index, (ip46_address_t *)mp->as_address, 1); + else + rv = lb_vip_add_ass(vip_index, (ip46_address_t *)mp->as_address, 1); + +done: + REPLY_MACRO (VL_API_LB_CONF_REPLY); +} + +static void *vl_api_lb_add_del_as_t_print +(vl_api_lb_add_del_as_t *mp, void * handle) +{ + u8 * s; + s = format (0, "SCRIPT: lb_add_del_as "); + s = format (s, "%U ", format_ip46_prefix, + (ip46_address_t *)mp->vip_ip_prefix, mp->vip_prefix_length, IP46_TYPE_ANY); + s = format (s, "%U ", format_ip46_address, + (ip46_address_t *)mp->as_address, IP46_TYPE_ANY); + s = format (s, "%s ", mp->is_del?"del":"add"); + FINISH; +} + +/* List of message types that this plugin understands */ +#define foreach_lb_plugin_api_msg \ +_(LB_CONF, lb_conf) \ +_(LB_ADD_DEL_VIP, lb_add_del_vip) \ +_(LB_ADD_DEL_AS, lb_add_del_as) + +static clib_error_t * lb_api_init (vlib_main_t * vm) +{ + lb_main_t *lbm = &lb_main; + u8 *name = format (0, "lb_%08x%c", api_version, 0); + lbm->msg_id_base = vl_msg_api_get_msg_ids + ((char *) name, VL_MSG_FIRST_AVAILABLE); + +#define _(N,n) \ + vl_msg_api_set_handlers((VL_API_##N + lbm->msg_id_base), \ + #n, \ + vl_api_##n##_t_handler, \ + vl_noop_handler, \ + vl_api_##n##_t_endian, \ + vl_api_##n##_t_print, \ + sizeof(vl_api_##n##_t), 1); + foreach_lb_plugin_api_msg; +#undef _ + + /* Add our API messages to the global name_crc hash table */ + setup_message_id_table (lbm, &api_main); + + return 0; +} + +VLIB_INIT_FUNCTION (lb_api_init); diff --git a/src/plugins/lb/cli.c b/src/plugins/lb/cli.c new file mode 100644 index 00000000..b59c6426 --- /dev/null +++ b/src/plugins/lb/cli.c @@ -0,0 +1,250 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +static clib_error_t * +lb_vip_command_fn (vlib_main_t * vm, + unformat_input_t * input, vlib_cli_command_t * cmd) +{ + unformat_input_t _line_input, *line_input = &_line_input; + ip46_address_t prefix; + u8 plen; + u32 new_len = 1024; + u8 del = 0; + int ret; + u32 gre4 = 0; + lb_vip_type_t type; + + if (!unformat_user (input, unformat_line_input, line_input)) + return 0; + + if (!unformat(line_input, "%U", unformat_ip46_prefix, &prefix, &plen, IP46_TYPE_ANY, &plen)) + return clib_error_return (0, "invalid vip prefix: '%U'", + format_unformat_error, line_input); + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) + { + if (unformat(line_input, "new_len %d", &new_len)) + ; + else if (unformat(line_input, "del")) + del = 1; + else if (unformat(line_input, "encap gre4")) + gre4 = 1; + else if (unformat(line_input, "encap gre6")) + gre4 = 0; + else + return clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + } + + unformat_free (line_input); + + + if (ip46_prefix_is_ip4(&prefix, plen)) { + type = (gre4)?LB_VIP_TYPE_IP4_GRE4:LB_VIP_TYPE_IP4_GRE6; + } else { + type = (gre4)?LB_VIP_TYPE_IP6_GRE4:LB_VIP_TYPE_IP6_GRE6; + } + + lb_garbage_collection(); + + u32 index; + if (!del) { + if ((ret = lb_vip_add(&prefix, plen, type, new_len, &index))) { + return clib_error_return (0, "lb_vip_add error %d", ret); + } else { + vlib_cli_output(vm, "lb_vip_add ok %d", index); + } + } else { + if ((ret = lb_vip_find_index(&prefix, plen, &index))) + return clib_error_return (0, "lb_vip_find_index error %d", ret); + else if ((ret = lb_vip_del(index))) + return clib_error_return (0, "lb_vip_del error %d", ret); + } + return NULL; +} + +VLIB_CLI_COMMAND (lb_vip_command, static) = +{ + .path = "lb vip", + .short_help = "lb vip [encap (gre6|gre4)] [new_len ] [del]", + .function = lb_vip_command_fn, +}; + +static clib_error_t * +lb_as_command_fn (vlib_main_t * vm, + unformat_input_t * input, vlib_cli_command_t * cmd) +{ + unformat_input_t _line_input, *line_input = &_line_input; + ip46_address_t vip_prefix, as_addr; + u8 vip_plen; + ip46_address_t *as_array = 0; + u32 vip_index; + u8 del = 0; + int ret; + + if (!unformat_user (input, unformat_line_input, line_input)) + return 0; + + if (!unformat(line_input, "%U", unformat_ip46_prefix, &vip_prefix, &vip_plen, IP46_TYPE_ANY)) + return clib_error_return (0, "invalid as address: '%U'", + format_unformat_error, line_input); + + if ((ret = lb_vip_find_index(&vip_prefix, vip_plen, &vip_index))) + return clib_error_return (0, "lb_vip_find_index error %d", ret); + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) + { + if (unformat(line_input, "%U", unformat_ip46_address, &as_addr, IP46_TYPE_ANY)) { + vec_add1(as_array, as_addr); + } else if (unformat(line_input, "del")) { + del = 1; + } else { + vec_free(as_array); + return clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + } + } + + if (!vec_len(as_array)) { + vec_free(as_array); + return clib_error_return (0, "No AS address provided"); + } + + lb_garbage_collection(); + clib_warning("vip index is %d", vip_index); + + if (del) { + if ((ret = lb_vip_del_ass(vip_index, as_array, vec_len(as_array)))) { + vec_free(as_array); + return clib_error_return (0, "lb_vip_del_ass error %d", ret); + } + } else { + if ((ret = lb_vip_add_ass(vip_index, as_array, vec_len(as_array)))) { + vec_free(as_array); + return clib_error_return (0, "lb_vip_add_ass error %d", ret); + } + } + + vec_free(as_array); + return 0; +} + +VLIB_CLI_COMMAND (lb_as_command, static) = +{ + .path = "lb as", + .short_help = "lb as [
[
[...]]] [del]", + .function = lb_as_command_fn, +}; + +static clib_error_t * +lb_conf_command_fn (vlib_main_t * vm, + unformat_input_t * input, vlib_cli_command_t * cmd) +{ + lb_main_t *lbm = &lb_main; + unformat_input_t _line_input, *line_input = &_line_input; + ip4_address_t ip4 = lbm->ip4_src_address; + ip6_address_t ip6 = lbm->ip6_src_address; + u32 per_cpu_sticky_buckets = lbm->per_cpu_sticky_buckets; + u32 per_cpu_sticky_buckets_log2 = 0; + u32 flow_timeout = lbm->flow_timeout; + int ret; + + if (!unformat_user (input, unformat_line_input, line_input)) + return 0; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) + { + if (unformat(line_input, "ip4-src-address %U", unformat_ip4_address, &ip4)) + ; + else if (unformat(line_input, "ip6-src-address %U", unformat_ip6_address, &ip6)) + ; + else if (unformat(line_input, "buckets %d", &per_cpu_sticky_buckets)) + ; + else if (unformat(line_input, "buckets-log2 %d", &per_cpu_sticky_buckets_log2)) { + if (per_cpu_sticky_buckets_log2 >= 32) + return clib_error_return (0, "buckets-log2 value is too high"); + per_cpu_sticky_buckets = 1 << per_cpu_sticky_buckets_log2; + } else if (unformat(line_input, "timeout %d", &flow_timeout)) + ; + else + return clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + } + + unformat_free (line_input); + + lb_garbage_collection(); + + if ((ret = lb_conf(&ip4, &ip6, per_cpu_sticky_buckets, flow_timeout))) + return clib_error_return (0, "lb_conf error %d", ret); + + return NULL; +} + +VLIB_CLI_COMMAND (lb_conf_command, static) = +{ + .path = "lb conf", + .short_help = "lb conf [ip4-src-address ] [ip6-src-address ] [buckets ] [timeout ]", + .function = lb_conf_command_fn, +}; + +static clib_error_t * +lb_show_command_fn (vlib_main_t * vm, + unformat_input_t * input, vlib_cli_command_t * cmd) +{ + vlib_cli_output(vm, "%U", format_lb_main); + return NULL; +} + + +VLIB_CLI_COMMAND (lb_show_command, static) = +{ + .path = "show lb", + .short_help = "show lb", + .function = lb_show_command_fn, +}; + +static clib_error_t * +lb_show_vips_command_fn (vlib_main_t * vm, + unformat_input_t * input, vlib_cli_command_t * cmd) +{ + unformat_input_t line_input; + lb_main_t *lbm = &lb_main; + lb_vip_t *vip; + u8 verbose = 0; + + if (!unformat_user (input, unformat_line_input, &line_input)) + return 0; + + if (unformat(&line_input, "verbose")) + verbose = 1; + + pool_foreach(vip, lbm->vips, { + vlib_cli_output(vm, "%U\n", verbose?format_lb_vip_detailed:format_lb_vip, vip); + }); + + unformat_free (&line_input); + return NULL; +} + +VLIB_CLI_COMMAND (lb_show_vips_command, static) = +{ + .path = "show lb vips", + .short_help = "show lb vips [verbose]", + .function = lb_show_vips_command_fn, +}; diff --git a/src/plugins/lb/lb.api b/src/plugins/lb/lb.api new file mode 100644 index 00000000..39ee3c8f --- /dev/null +++ b/src/plugins/lb/lb.api @@ -0,0 +1,71 @@ +/** \brief Configure Load-Balancer global parameters + @param client_index - opaque cookie to identify the sender + @param context - sender context, to match reply w/ request + @param ip4_src_address - IPv4 address to be used as source for IPv4 GRE traffic. + @param ip6_src_address - IPv6 address to be used as source for IPv6 GRE traffic. + @param n_sticky_buckets - Number of buckets *per worker thread* in the + established flow table (must be power of 2). + @param flow_timeout - Time in seconds after which, if no packet is received + for a given flow, the flow is removed from the established flow table. +*/ +define lb_conf +{ + u32 client_index; + u32 context; + u32 ip4_src_address; + u8 ip6_src_address[16]; + u32 sticky_buckets_per_core; + u32 flow_timeout; +}; + +define lb_conf_reply { + u32 context; + i32 retval; +}; + +/** \brief Add a virtual address (or prefix) + @param client_index - opaque cookie to identify the sender + @param context - sender context, to match reply w/ request + @param ip_prefix - IP address (IPv4 in lower order 32 bits). + @param prefix_length - IP prefix length (96 + 'IPv4 prefix length' for IPv4). + @param is_gre4 - Encap is ip4 GRE (ip6 GRE otherwise). + @param new_flows_table_length - Size of the new connections flow table used + for this VIP (must be power of 2). + @param is_del - The VIP should be removed. +*/ +define lb_add_del_vip { + u32 client_index; + u32 context; + u8 ip_prefix[16]; + u8 prefix_length; + u8 is_gre4; + u32 new_flows_table_length; + u8 is_del; +}; + +define lb_add_del_vip_reply { + u32 context; + i32 retval; +}; + +/** \brief Add an application server for a given VIP + @param client_index - opaque cookie to identify the sender + @param context - sender context, to match reply w/ request + @param vip_ip_prefix - VIP IP address (IPv4 in lower order 32 bits). + @param vip_ip_prefix - VIP IP prefix length (96 + 'IPv4 prefix length' for IPv4). + @param as_address - The application server address (IPv4 in lower order 32 bits). + @param is_del - The AS should be removed. +*/ +define lb_add_del_as { + u32 client_index; + u32 context; + u8 vip_ip_prefix[16]; + u8 vip_prefix_length; + u8 as_address[16]; + u8 is_del; +}; + +define lb_add_del_as_reply { + u32 context; + i32 retval; +}; diff --git a/src/plugins/lb/lb.c b/src/plugins/lb/lb.c new file mode 100644 index 00000000..1d9b9870 --- /dev/null +++ b/src/plugins/lb/lb.c @@ -0,0 +1,844 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +//GC runs at most once every so many seconds +#define LB_GARBAGE_RUN 60 + +//After so many seconds. It is assumed that inter-core race condition will not occur. +#define LB_CONCURRENCY_TIMEOUT 10 + +lb_main_t lb_main; + +#define lb_get_writer_lock() do {} while(__sync_lock_test_and_set (lb_main.writer_lock, 1)) +#define lb_put_writer_lock() lb_main.writer_lock[0] = 0 + +static void lb_as_stack (lb_as_t *as); + + +const static char * const lb_dpo_gre4_ip4[] = { "lb4-gre4" , NULL }; +const static char * const lb_dpo_gre4_ip6[] = { "lb6-gre4" , NULL }; +const static char* const * const lb_dpo_gre4_nodes[DPO_PROTO_NUM] = + { + [DPO_PROTO_IP4] = lb_dpo_gre4_ip4, + [DPO_PROTO_IP6] = lb_dpo_gre4_ip6, + }; + +const static char * const lb_dpo_gre6_ip4[] = { "lb4-gre6" , NULL }; +const static char * const lb_dpo_gre6_ip6[] = { "lb6-gre6" , NULL }; +const static char* const * const lb_dpo_gre6_nodes[DPO_PROTO_NUM] = + { + [DPO_PROTO_IP4] = lb_dpo_gre6_ip4, + [DPO_PROTO_IP6] = lb_dpo_gre6_ip6, + }; + +u32 lb_hash_time_now(vlib_main_t * vm) +{ + return (u32) (vlib_time_now(vm) + 10000); +} + +u8 *format_lb_main (u8 * s, va_list * args) +{ + vlib_thread_main_t *tm = vlib_get_thread_main(); + lb_main_t *lbm = &lb_main; + s = format(s, "lb_main"); + s = format(s, " ip4-src-address: %U \n", format_ip4_address, &lbm->ip4_src_address); + s = format(s, " ip6-src-address: %U \n", format_ip6_address, &lbm->ip6_src_address); + s = format(s, " #vips: %u\n", pool_elts(lbm->vips)); + s = format(s, " #ass: %u\n", pool_elts(lbm->ass) - 1); + + u32 cpu_index; + for(cpu_index = 0; cpu_index < tm->n_vlib_mains; cpu_index++ ) { + lb_hash_t *h = lbm->per_cpu[cpu_index].sticky_ht; + if (h) { + s = format(s, "core %d\n", cpu_index); + s = format(s, " timeout: %ds\n", h->timeout); + s = format(s, " usage: %d / %d\n", lb_hash_elts(h, lb_hash_time_now(vlib_get_main())), lb_hash_size(h)); + } + } + + return s; +} + +static char *lb_vip_type_strings[] = { + [LB_VIP_TYPE_IP6_GRE6] = "ip6-gre6", + [LB_VIP_TYPE_IP6_GRE4] = "ip6-gre4", + [LB_VIP_TYPE_IP4_GRE6] = "ip4-gre6", + [LB_VIP_TYPE_IP4_GRE4] = "ip4-gre4", +}; + +u8 *format_lb_vip_type (u8 * s, va_list * args) +{ + lb_vip_type_t vipt = va_arg (*args, lb_vip_type_t); + u32 i; + for (i=0; itype, + format_ip46_prefix, &vip->prefix, vip->plen, IP46_TYPE_ANY, + vip->new_flow_table_mask + 1, + pool_elts(vip->as_indexes), + (vip->flags & LB_VIP_FLAGS_USED)?"":" removed"); +} + +u8 *format_lb_as (u8 * s, va_list * args) +{ + lb_as_t *as = va_arg (*args, lb_as_t *); + return format(s, "%U %s", format_ip46_address, + &as->address, IP46_TYPE_ANY, + (as->flags & LB_AS_FLAGS_USED)?"used":"removed"); +} + +u8 *format_lb_vip_detailed (u8 * s, va_list * args) +{ + lb_main_t *lbm = &lb_main; + lb_vip_t *vip = va_arg (*args, lb_vip_t *); + uword indent = format_get_indent (s); + + s = format(s, "%U %U [%u] %U%s\n" + "%U new_size:%u\n", + format_white_space, indent, + format_lb_vip_type, vip->type, + vip - lbm->vips, format_ip46_prefix, &vip->prefix, vip->plen, IP46_TYPE_ANY, + (vip->flags & LB_VIP_FLAGS_USED)?"":" removed", + format_white_space, indent, + vip->new_flow_table_mask + 1); + + //Print counters + s = format(s, "%U counters:\n", + format_white_space, indent); + u32 i; + for (i=0; ivip_counters[i].name, + vlib_get_simple_counter(&lbm->vip_counters[i], vip - lbm->vips)); + + + s = format(s, "%U #as:%u\n", + format_white_space, indent, + pool_elts(vip->as_indexes)); + + //Let's count the buckets for each AS + u32 *count = 0; + vec_validate(count, pool_len(lbm->ass)); //Possibly big alloc for not much... + lb_new_flow_entry_t *nfe; + vec_foreach(nfe, vip->new_flow_table) + count[nfe->as_index]++; + + lb_as_t *as; + u32 *as_index; + pool_foreach(as_index, vip->as_indexes, { + as = &lbm->ass[*as_index]; + s = format(s, "%U %U %d buckets %d flows dpo:%u %s\n", + format_white_space, indent, + format_ip46_address, &as->address, IP46_TYPE_ANY, + count[as - lbm->ass], + vlib_refcount_get(&lbm->as_refcount, as - lbm->ass), + as->dpo.dpoi_index, + (as->flags & LB_AS_FLAGS_USED)?"used":" removed"); + }); + + vec_free(count); + + /* + s = format(s, "%U new flows table:\n", format_white_space, indent); + lb_new_flow_entry_t *nfe; + vec_foreach(nfe, vip->new_flow_table) { + s = format(s, "%U %d: %d\n", format_white_space, indent, nfe - vip->new_flow_table, nfe->as_index); + } + */ + return s; +} + +typedef struct { + u32 as_index; + u32 last; + u32 skip; +} lb_pseudorand_t; + +static int lb_pseudorand_compare(void *a, void *b) +{ + lb_as_t *asa, *asb; + lb_main_t *lbm = &lb_main; + asa = &lbm->ass[((lb_pseudorand_t *)a)->as_index]; + asb = &lbm->ass[((lb_pseudorand_t *)b)->as_index]; + return memcmp(&asa->address, &asb->address, sizeof(asb->address)); +} + +static void lb_vip_garbage_collection(lb_vip_t *vip) +{ + lb_main_t *lbm = &lb_main; + ASSERT (lbm->writer_lock[0]); + + u32 now = (u32) vlib_time_now(vlib_get_main()); + if (!clib_u32_loop_gt(now, vip->last_garbage_collection + LB_GARBAGE_RUN)) + return; + + vip->last_garbage_collection = now; + lb_as_t *as; + u32 *as_index; + pool_foreach(as_index, vip->as_indexes, { + as = &lbm->ass[*as_index]; + if (!(as->flags & LB_AS_FLAGS_USED) && //Not used + clib_u32_loop_gt(now, as->last_used + LB_CONCURRENCY_TIMEOUT) && //Not recently used + (vlib_refcount_get(&lbm->as_refcount, as - lbm->ass) == 0)) + { //Not referenced + fib_entry_child_remove(as->next_hop_fib_entry_index, + as->next_hop_child_index); + fib_table_entry_delete_index(as->next_hop_fib_entry_index, + FIB_SOURCE_RR); + as->next_hop_fib_entry_index = FIB_NODE_INDEX_INVALID; + + pool_put(vip->as_indexes, as_index); + pool_put(lbm->ass, as); + } + }); +} + +void lb_garbage_collection() +{ + lb_main_t *lbm = &lb_main; + lb_get_writer_lock(); + lb_vip_t *vip; + u32 *to_be_removed_vips = 0, *i; + pool_foreach(vip, lbm->vips, { + lb_vip_garbage_collection(vip); + + if (!(vip->flags & LB_VIP_FLAGS_USED) && + (pool_elts(vip->as_indexes) == 0)) { + vec_add1(to_be_removed_vips, vip - lbm->vips); + } + }); + + vec_foreach(i, to_be_removed_vips) { + vip = &lbm->vips[*i]; + pool_put(lbm->vips, vip); + pool_free(vip->as_indexes); + } + + vec_free(to_be_removed_vips); + lb_put_writer_lock(); +} + +static void lb_vip_update_new_flow_table(lb_vip_t *vip) +{ + lb_main_t *lbm = &lb_main; + lb_new_flow_entry_t *old_table; + u32 i, *as_index; + lb_new_flow_entry_t *new_flow_table = 0; + lb_as_t *as; + lb_pseudorand_t *pr, *sort_arr = 0; + u32 count; + + ASSERT (lbm->writer_lock[0]); //We must have the lock + + //Check if some AS is configured or not + i = 0; + pool_foreach(as_index, vip->as_indexes, { + as = &lbm->ass[*as_index]; + if (as->flags & LB_AS_FLAGS_USED) { //Not used anymore + i = 1; + goto out; //Not sure 'break' works in this macro-loop + } + }); + +out: + if (i == 0) { + //Only the default. i.e. no AS + vec_validate(new_flow_table, vip->new_flow_table_mask); + for (i=0; ias_indexes)); + + i = 0; + pool_foreach(as_index, vip->as_indexes, { + as = &lbm->ass[*as_index]; + if (!(as->flags & LB_AS_FLAGS_USED)) //Not used anymore + continue; + + sort_arr[i].as_index = as - lbm->ass; + i++; + }); + _vec_len(sort_arr) = i; + + vec_sort_with_function(sort_arr, lb_pseudorand_compare); + + //Now let's pseudo-randomly generate permutations + vec_foreach(pr, sort_arr) { + lb_as_t *as = &lbm->ass[pr->as_index]; + + u64 seed = clib_xxhash(as->address.as_u64[0] ^ + as->address.as_u64[1]); + /* We have 2^n buckets. + * skip must be prime with 2^n. + * So skip must be odd. + * MagLev actually state that M should be prime, + * but this has a big computation cost (% operation). + * Using 2^n is more better (& operation). + */ + pr->skip = ((seed & 0xffffffff) | 1) & vip->new_flow_table_mask; + pr->last = (seed >> 32) & vip->new_flow_table_mask; + } + + //Let's create a new flow table + vec_validate(new_flow_table, vip->new_flow_table_mask); + for (i=0; ilast; + pr->last = (pr->last + pr->skip) & vip->new_flow_table_mask; + if (new_flow_table[last].as_index == ~0) { + new_flow_table[last].as_index = pr->as_index; + break; + } + } + done++; + if (done == vec_len(new_flow_table)) + goto finished; + } + } + + vec_free(sort_arr); + +finished: + +//Count number of changed entries + count = 0; + for (i=0; inew_flow_table == 0 || + new_flow_table[i].as_index != vip->new_flow_table[i].as_index) + count++; + + old_table = vip->new_flow_table; + vip->new_flow_table = new_flow_table; + vec_free(old_table); +} + +int lb_conf(ip4_address_t *ip4_address, ip6_address_t *ip6_address, + u32 per_cpu_sticky_buckets, u32 flow_timeout) +{ + lb_main_t *lbm = &lb_main; + + if (!is_pow2(per_cpu_sticky_buckets)) + return VNET_API_ERROR_INVALID_MEMORY_SIZE; + + lb_get_writer_lock(); //Not exactly necessary but just a reminder that it exists for my future self + lbm->ip4_src_address = *ip4_address; + lbm->ip6_src_address = *ip6_address; + lbm->per_cpu_sticky_buckets = per_cpu_sticky_buckets; + lbm->flow_timeout = flow_timeout; + lb_put_writer_lock(); + return 0; +} + +static +int lb_vip_find_index_with_lock(ip46_address_t *prefix, u8 plen, u32 *vip_index) +{ + lb_main_t *lbm = &lb_main; + lb_vip_t *vip; + ASSERT (lbm->writer_lock[0]); //This must be called with the lock owned + ip46_prefix_normalize(prefix, plen); + pool_foreach(vip, lbm->vips, { + if ((vip->flags & LB_AS_FLAGS_USED) && + vip->plen == plen && + vip->prefix.as_u64[0] == prefix->as_u64[0] && + vip->prefix.as_u64[1] == prefix->as_u64[1]) { + *vip_index = vip - lbm->vips; + return 0; + } + }); + return VNET_API_ERROR_NO_SUCH_ENTRY; +} + +int lb_vip_find_index(ip46_address_t *prefix, u8 plen, u32 *vip_index) +{ + int ret; + lb_get_writer_lock(); + ret = lb_vip_find_index_with_lock(prefix, plen, vip_index); + lb_put_writer_lock(); + return ret; +} + +static int lb_as_find_index_vip(lb_vip_t *vip, ip46_address_t *address, u32 *as_index) +{ + lb_main_t *lbm = &lb_main; + ASSERT (lbm->writer_lock[0]); //This must be called with the lock owned + lb_as_t *as; + u32 *asi; + pool_foreach(asi, vip->as_indexes, { + as = &lbm->ass[*asi]; + if (as->vip_index == (vip - lbm->vips) && + as->address.as_u64[0] == address->as_u64[0] && + as->address.as_u64[1] == address->as_u64[1]) { + *as_index = as - lbm->ass; + return 0; + } + }); + return -1; +} + +int lb_vip_add_ass(u32 vip_index, ip46_address_t *addresses, u32 n) +{ + lb_main_t *lbm = &lb_main; + lb_get_writer_lock(); + lb_vip_t *vip; + if (!(vip = lb_vip_get_by_index(vip_index))) { + lb_put_writer_lock(); + return VNET_API_ERROR_NO_SUCH_ENTRY; + } + + ip46_type_t type = lb_vip_is_gre4(vip)?IP46_TYPE_IP4:IP46_TYPE_IP6; + u32 *to_be_added = 0; + u32 *to_be_updated = 0; + u32 i; + u32 *ip; + + //Sanity check + while (n--) { + + if (!lb_as_find_index_vip(vip, &addresses[n], &i)) { + if (lbm->ass[i].flags & LB_AS_FLAGS_USED) { + vec_free(to_be_added); + vec_free(to_be_updated); + lb_put_writer_lock(); + return VNET_API_ERROR_VALUE_EXIST; + } + vec_add1(to_be_updated, i); + goto next; + } + + if (ip46_address_type(&addresses[n]) != type) { + vec_free(to_be_added); + vec_free(to_be_updated); + lb_put_writer_lock(); + return VNET_API_ERROR_INVALID_ADDRESS_FAMILY; + } + + if (n) { + u32 n2 = n; + while(n2--) //Check for duplicates + if (addresses[n2].as_u64[0] == addresses[n].as_u64[0] && + addresses[n2].as_u64[1] == addresses[n].as_u64[1]) + goto next; + } + + vec_add1(to_be_added, n); + +next: + continue; + } + + //Update reused ASs + vec_foreach(ip, to_be_updated) { + lbm->ass[*ip].flags = LB_AS_FLAGS_USED; + } + vec_free(to_be_updated); + + //Create those who have to be created + vec_foreach(ip, to_be_added) { + lb_as_t *as; + u32 *as_index; + pool_get(lbm->ass, as); + as->address = addresses[*ip]; + as->flags = LB_AS_FLAGS_USED; + as->vip_index = vip_index; + pool_get(vip->as_indexes, as_index); + *as_index = as - lbm->ass; + + /* + * become a child of the FIB entry + * so we are informed when its forwarding changes + */ + fib_prefix_t nh = {}; + if (lb_vip_is_gre4(vip)) { + nh.fp_addr.ip4 = as->address.ip4; + nh.fp_len = 32; + nh.fp_proto = FIB_PROTOCOL_IP4; + } else { + nh.fp_addr.ip6 = as->address.ip6; + nh.fp_len = 128; + nh.fp_proto = FIB_PROTOCOL_IP6; + } + + as->next_hop_fib_entry_index = + fib_table_entry_special_add(0, + &nh, + FIB_SOURCE_RR, + FIB_ENTRY_FLAG_NONE, + ADJ_INDEX_INVALID); + as->next_hop_child_index = + fib_entry_child_add(as->next_hop_fib_entry_index, + lbm->fib_node_type, + as - lbm->ass); + + lb_as_stack(as); + } + vec_free(to_be_added); + + //Recompute flows + lb_vip_update_new_flow_table(vip); + + //Garbage collection maybe + lb_vip_garbage_collection(vip); + + lb_put_writer_lock(); + return 0; +} + +int lb_vip_del_ass_withlock(u32 vip_index, ip46_address_t *addresses, u32 n) +{ + lb_main_t *lbm = &lb_main; + u32 now = (u32) vlib_time_now(vlib_get_main()); + u32 *ip = 0; + + lb_vip_t *vip; + if (!(vip = lb_vip_get_by_index(vip_index))) { + return VNET_API_ERROR_NO_SUCH_ENTRY; + } + + u32 *indexes = NULL; + while (n--) { + u32 i; + if (lb_as_find_index_vip(vip, &addresses[n], &i)) { + vec_free(indexes); + return VNET_API_ERROR_NO_SUCH_ENTRY; + } + + if (n) { //Check for duplicates + u32 n2 = n - 1; + while(n2--) { + if (addresses[n2].as_u64[0] == addresses[n].as_u64[0] && + addresses[n2].as_u64[1] == addresses[n].as_u64[1]) + goto next; + } + } + + vec_add1(indexes, i); +next: + continue; + } + + //Garbage collection maybe + lb_vip_garbage_collection(vip); + + if (indexes != NULL) { + vec_foreach(ip, indexes) { + lbm->ass[*ip].flags &= ~LB_AS_FLAGS_USED; + lbm->ass[*ip].last_used = now; + } + + //Recompute flows + lb_vip_update_new_flow_table(vip); + } + + vec_free(indexes); + return 0; +} + +int lb_vip_del_ass(u32 vip_index, ip46_address_t *addresses, u32 n) +{ + lb_get_writer_lock(); + int ret = lb_vip_del_ass_withlock(vip_index, addresses, n); + lb_put_writer_lock(); + return ret; +} + +/** + * Add the VIP adjacency to the ip4 or ip6 fib + */ +static void lb_vip_add_adjacency(lb_main_t *lbm, lb_vip_t *vip) +{ + dpo_proto_t proto = 0; + dpo_id_t dpo = DPO_INVALID; + fib_prefix_t pfx = {}; + if (lb_vip_is_ip4(vip)) { + pfx.fp_addr.ip4 = vip->prefix.ip4; + pfx.fp_len = vip->plen - 96; + pfx.fp_proto = FIB_PROTOCOL_IP4; + proto = DPO_PROTO_IP4; + } else { + pfx.fp_addr.ip6 = vip->prefix.ip6; + pfx.fp_len = vip->plen; + pfx.fp_proto = FIB_PROTOCOL_IP6; + proto = DPO_PROTO_IP6; + } + dpo_set(&dpo, lb_vip_is_gre4(vip)?lbm->dpo_gre4_type:lbm->dpo_gre6_type, + proto, vip - lbm->vips); + fib_table_entry_special_dpo_add(0, + &pfx, + FIB_SOURCE_PLUGIN_HI, + FIB_ENTRY_FLAG_EXCLUSIVE, + &dpo); + dpo_reset(&dpo); +} + +/** + * Deletes the adjacency associated with the VIP + */ +static void lb_vip_del_adjacency(lb_main_t *lbm, lb_vip_t *vip) +{ + fib_prefix_t pfx = {}; + if (lb_vip_is_ip4(vip)) { + pfx.fp_addr.ip4 = vip->prefix.ip4; + pfx.fp_len = vip->plen - 96; + pfx.fp_proto = FIB_PROTOCOL_IP4; + } else { + pfx.fp_addr.ip6 = vip->prefix.ip6; + pfx.fp_len = vip->plen; + pfx.fp_proto = FIB_PROTOCOL_IP6; + } + fib_table_entry_special_remove(0, &pfx, FIB_SOURCE_PLUGIN_HI); +} + +int lb_vip_add(ip46_address_t *prefix, u8 plen, lb_vip_type_t type, u32 new_length, u32 *vip_index) +{ + lb_main_t *lbm = &lb_main; + lb_vip_t *vip; + lb_get_writer_lock(); + ip46_prefix_normalize(prefix, plen); + + if (!lb_vip_find_index_with_lock(prefix, plen, vip_index)) { + lb_put_writer_lock(); + return VNET_API_ERROR_VALUE_EXIST; + } + + if (!is_pow2(new_length)) { + lb_put_writer_lock(); + return VNET_API_ERROR_INVALID_MEMORY_SIZE; + } + + if (ip46_prefix_is_ip4(prefix, plen) && + (type != LB_VIP_TYPE_IP4_GRE4) && + (type != LB_VIP_TYPE_IP4_GRE6)) + return VNET_API_ERROR_INVALID_ADDRESS_FAMILY; + + + //Allocate + pool_get(lbm->vips, vip); + + //Init + vip->prefix = *prefix; + vip->plen = plen; + vip->last_garbage_collection = (u32) vlib_time_now(vlib_get_main()); + vip->type = type; + vip->flags = LB_VIP_FLAGS_USED; + vip->as_indexes = 0; + + //Validate counters + u32 i; + for (i = 0; i < LB_N_VIP_COUNTERS; i++) { + vlib_validate_simple_counter(&lbm->vip_counters[i], vip - lbm->vips); + vlib_zero_simple_counter(&lbm->vip_counters[i], vip - lbm->vips); + } + + //Configure new flow table + vip->new_flow_table_mask = new_length - 1; + vip->new_flow_table = 0; + + //Create a new flow hash table full of the default entry + lb_vip_update_new_flow_table(vip); + + //Create adjacency to direct traffic + lb_vip_add_adjacency(lbm, vip); + + //Return result + *vip_index = vip - lbm->vips; + + lb_put_writer_lock(); + return 0; +} + +int lb_vip_del(u32 vip_index) +{ + lb_main_t *lbm = &lb_main; + lb_vip_t *vip; + lb_get_writer_lock(); + if (!(vip = lb_vip_get_by_index(vip_index))) { + lb_put_writer_lock(); + return VNET_API_ERROR_NO_SUCH_ENTRY; + } + + //FIXME: This operation is actually not working + //We will need to remove state before performing this. + + { + //Remove all ASs + ip46_address_t *ass = 0; + lb_as_t *as; + u32 *as_index; + pool_foreach(as_index, vip->as_indexes, { + as = &lbm->ass[*as_index]; + vec_add1(ass, as->address); + }); + if (vec_len(ass)) + lb_vip_del_ass_withlock(vip_index, ass, vec_len(ass)); + vec_free(ass); + } + + //Delete adjacency + lb_vip_del_adjacency(lbm, vip); + + //Set the VIP as unused + vip->flags &= ~LB_VIP_FLAGS_USED; + + lb_put_writer_lock(); + return 0; +} + +clib_error_t * +vlib_plugin_register (vlib_main_t * vm, + vnet_plugin_handoff_t * h, + int from_early_init) +{ + clib_error_t *error = 0; + return error; +} + + +u8 *format_lb_dpo (u8 * s, va_list * va) +{ + index_t index = va_arg (*va, index_t); + CLIB_UNUSED(u32 indent) = va_arg (*va, u32); + lb_main_t *lbm = &lb_main; + lb_vip_t *vip = pool_elt_at_index (lbm->vips, index); + return format (s, "%U", format_lb_vip, vip); +} + +static void lb_dpo_lock (dpo_id_t *dpo) {} +static void lb_dpo_unlock (dpo_id_t *dpo) {} + +static fib_node_t * +lb_fib_node_get_node (fib_node_index_t index) +{ + lb_main_t *lbm = &lb_main; + lb_as_t *as = pool_elt_at_index (lbm->ass, index); + return (&as->fib_node); +} + +static void +lb_fib_node_last_lock_gone (fib_node_t *node) +{ +} + +static lb_as_t * +lb_as_from_fib_node (fib_node_t *node) +{ + return ((lb_as_t*)(((char*)node) - + STRUCT_OFFSET_OF(lb_as_t, fib_node))); +} + +static void +lb_as_stack (lb_as_t *as) +{ + lb_main_t *lbm = &lb_main; + lb_vip_t *vip = &lbm->vips[as->vip_index]; + dpo_stack(lb_vip_is_gre4(vip)?lbm->dpo_gre4_type:lbm->dpo_gre6_type, + lb_vip_is_ip4(vip)?DPO_PROTO_IP4:DPO_PROTO_IP6, + &as->dpo, + fib_entry_contribute_ip_forwarding( + as->next_hop_fib_entry_index)); +} + +static fib_node_back_walk_rc_t +lb_fib_node_back_walk_notify (fib_node_t *node, + fib_node_back_walk_ctx_t *ctx) +{ + lb_as_stack(lb_as_from_fib_node(node)); + return (FIB_NODE_BACK_WALK_CONTINUE); +} + +clib_error_t * +lb_init (vlib_main_t * vm) +{ + vlib_thread_main_t *tm = vlib_get_thread_main (); + lb_main_t *lbm = &lb_main; + lb_as_t *default_as; + fib_node_vft_t lb_fib_node_vft = { + .fnv_get = lb_fib_node_get_node, + .fnv_last_lock = lb_fib_node_last_lock_gone, + .fnv_back_walk = lb_fib_node_back_walk_notify, + }; + dpo_vft_t lb_vft = { + .dv_lock = lb_dpo_lock, + .dv_unlock = lb_dpo_unlock, + .dv_format = format_lb_dpo, + }; + + lbm->vips = 0; + lbm->per_cpu = 0; + vec_validate(lbm->per_cpu, tm->n_vlib_mains - 1); + lbm->writer_lock = clib_mem_alloc_aligned (CLIB_CACHE_LINE_BYTES, CLIB_CACHE_LINE_BYTES); + lbm->writer_lock[0] = 0; + lbm->per_cpu_sticky_buckets = LB_DEFAULT_PER_CPU_STICKY_BUCKETS; + lbm->flow_timeout = LB_DEFAULT_FLOW_TIMEOUT; + lbm->ip4_src_address.as_u32 = 0xffffffff; + lbm->ip6_src_address.as_u64[0] = 0xffffffffffffffffL; + lbm->ip6_src_address.as_u64[1] = 0xffffffffffffffffL; + lbm->dpo_gre4_type = dpo_register_new_type(&lb_vft, lb_dpo_gre4_nodes); + lbm->dpo_gre6_type = dpo_register_new_type(&lb_vft, lb_dpo_gre6_nodes); + lbm->fib_node_type = fib_node_register_new_type(&lb_fib_node_vft); + + //Init AS reference counters + vlib_refcount_init(&lbm->as_refcount); + + //Allocate and init default AS. + lbm->ass = 0; + pool_get(lbm->ass, default_as); + default_as->flags = 0; + default_as->dpo.dpoi_next_node = LB_NEXT_DROP; + default_as->vip_index = ~0; + default_as->address.ip6.as_u64[0] = 0xffffffffffffffffL; + default_as->address.ip6.as_u64[1] = 0xffffffffffffffffL; + +#define _(a,b,c) lbm->vip_counters[c].name = b; + lb_foreach_vip_counter +#undef _ + return NULL; +} + +VLIB_INIT_FUNCTION (lb_init); diff --git a/src/plugins/lb/lb.h b/src/plugins/lb/lb.h new file mode 100644 index 00000000..882b9b30 --- /dev/null +++ b/src/plugins/lb/lb.h @@ -0,0 +1,333 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * lb-plugin implements a MagLev-like load balancer. + * http://research.google.com/pubs/pub44824.html + * + * It hasn't been tested for interoperability with the original MagLev + * but intends to provide similar functionality. + * The load-balancer receives traffic destined to VIP (Virtual IP) + * addresses from one or multiple(ECMP) routers. + * The load-balancer tunnels the traffic toward many application servers + * ensuring session stickyness (i.e. that a single sessions is tunneled + * towards a single application server). + * + */ + +#ifndef LB_PLUGIN_LB_LB_H_ +#define LB_PLUGIN_LB_LB_H_ + +#include +#include + +#include +#include +#include +#include + +#include + +#define LB_DEFAULT_PER_CPU_STICKY_BUCKETS 1 << 10 +#define LB_DEFAULT_FLOW_TIMEOUT 40 + +typedef enum { + LB_NEXT_DROP, + LB_N_NEXT, +} lb_next_t; + +/** + * Each VIP is configured with a set of + * application server. + */ +typedef struct { + /** + * Registration to FIB event. + */ + fib_node_t fib_node; + + /** + * Destination address used to tunnel traffic towards + * that application server. + * The address is also used as ID and pseudo-random + * seed for the load-balancing process. + */ + ip46_address_t address; + + /** + * ASs are indexed by address and VIP Index. + * Which means there will be duplicated if the same server + * address is used for multiple VIPs. + */ + u32 vip_index; + + /** + * Some per-AS flags. + * For now only LB_AS_FLAGS_USED is defined. + */ + u8 flags; + +#define LB_AS_FLAGS_USED 0x1 + + /** + * Rotating timestamp of when LB_AS_FLAGS_USED flag was last set. + * + * AS removal is based on garbage collection and reference counting. + * When an AS is removed, there is a race between configuration core + * and worker cores which may still add a reference while it should not + * be used. This timestamp is used to not remove the AS while a race condition + * may happen. + */ + u32 last_used; + + /** + * The FIB entry index for the next-hop + */ + fib_node_index_t next_hop_fib_entry_index; + + /** + * The child index on the FIB entry + */ + u32 next_hop_child_index; + + /** + * The next DPO in the graph to follow. + */ + dpo_id_t dpo; + +} lb_as_t; + +format_function_t format_lb_as; + +typedef struct { + u32 as_index; +} lb_new_flow_entry_t; + +#define lb_foreach_vip_counter \ + _(NEXT_PACKET, "packet from existing sessions", 0) \ + _(FIRST_PACKET, "first session packet", 1) \ + _(UNTRACKED_PACKET, "untracked packet", 2) \ + _(NO_SERVER, "no server configured", 3) + +typedef enum { +#define _(a,b,c) LB_VIP_COUNTER_##a = c, + lb_foreach_vip_counter +#undef _ + LB_N_VIP_COUNTERS +} lb_vip_counter_t; + +/** + * The load balancer supports IPv4 and IPv6 traffic + * and GRE4 and GRE6 encap. + */ +typedef enum { + LB_VIP_TYPE_IP6_GRE6, + LB_VIP_TYPE_IP6_GRE4, + LB_VIP_TYPE_IP4_GRE6, + LB_VIP_TYPE_IP4_GRE4, + LB_VIP_N_TYPES, +} lb_vip_type_t; + +format_function_t format_lb_vip_type; +unformat_function_t unformat_lb_vip_type; + +/** + * Load balancing service is provided per VIP. + * In this data model, a VIP can be a whole prefix. + * But load balancing only + * occurs on a per-source-address/port basis. Meaning that if a given source + * reuses the same port for multiple destinations within the same VIP, + * they will be considered as a single flow. + */ +typedef struct { + + //Runtime + + /** + * Vector mapping (flow-hash & new_connect_table_mask) to AS index. + * This is used for new flows. + */ + lb_new_flow_entry_t *new_flow_table; + + /** + * New flows table length - 1 + * (length MUST be a power of 2) + */ + u32 new_flow_table_mask; + + /** + * Last time garbage collection was run to free the ASs. + */ + u32 last_garbage_collection; + + //Not runtime + + /** + * A Virtual IP represents a given service delivered + * by a set of application servers. It can be a single + * address or a prefix. + * IPv4 prefixes are encoded using IPv4-in-IPv6 embedded address + * (i.e. ::/96 prefix). + */ + ip46_address_t prefix; + + /** + * The VIP prefix length. + * In case of IPv4, plen = 96 + ip4_plen. + */ + u8 plen; + + /** + * The type of traffic for this. + * LB_TYPE_UNDEFINED if unknown. + */ + lb_vip_type_t type; + + /** + * Flags related to this VIP. + * LB_VIP_FLAGS_USED means the VIP is active. + * When it is not set, the VIP in the process of being removed. + * We cannot immediately remove a VIP because the VIP index still may be stored + * in the adjacency index. + */ + u8 flags; +#define LB_VIP_FLAGS_USED 0x1 + + /** + * Pool of AS indexes used for this VIP. + * This also includes ASs that have been removed (but are still referenced). + */ + u32 *as_indexes; +} lb_vip_t; + +#define lb_vip_is_ip4(vip) ((vip)->type == LB_VIP_TYPE_IP4_GRE6 || (vip)->type == LB_VIP_TYPE_IP4_GRE4) +#define lb_vip_is_gre4(vip) ((vip)->type == LB_VIP_TYPE_IP6_GRE4 || (vip)->type == LB_VIP_TYPE_IP4_GRE4) +format_function_t format_lb_vip; +format_function_t format_lb_vip_detailed; + +typedef struct { + /** + * Each CPU has its own sticky flow hash table. + * One single table is used for all VIPs. + */ + lb_hash_t *sticky_ht; +} lb_per_cpu_t; + +typedef struct { + /** + * Pool of all Virtual IPs + */ + lb_vip_t *vips; + + /** + * Pool of ASs. + * ASs are referenced by address and vip index. + * The first element (index 0) is special and used only to fill + * new_flow_tables when no AS has been configured. + */ + lb_as_t *ass; + + /** + * Each AS has an associated reference counter. + * As ass[0] has a special meaning, its associated counter + * starts at 0 and is decremented instead. i.e. do not use it. + */ + vlib_refcount_t as_refcount; + + /** + * Some global data is per-cpu + */ + lb_per_cpu_t *per_cpu; + + /** + * Node next index for IP adjacencies, for each of the traffic types. + */ + u32 ip_lookup_next_index[LB_VIP_N_TYPES]; + + /** + * Source address used in IPv6 encapsulated traffic + */ + ip6_address_t ip6_src_address; + + /** + * Source address used for IPv4 encapsulated traffic + */ + ip4_address_t ip4_src_address; + + /** + * Number of buckets in the per-cpu sticky hash table. + */ + u32 per_cpu_sticky_buckets; + + /** + * Flow timeout in seconds. + */ + u32 flow_timeout; + + /** + * Per VIP counter + */ + vlib_simple_counter_main_t vip_counters[LB_N_VIP_COUNTERS]; + + /** + * DPO used to send packet from IP4/6 lookup to LB node. + */ + dpo_type_t dpo_gre4_type; + dpo_type_t dpo_gre6_type; + + /** + * Node type for registering to fib changes. + */ + fib_node_type_t fib_node_type; + + /** + * API dynamically registered base ID. + */ + u16 msg_id_base; + + volatile u32 *writer_lock; +} lb_main_t; + +extern lb_main_t lb_main; +extern vlib_node_registration_t lb6_node; +extern vlib_node_registration_t lb4_node; + +/** + * Fix global load-balancer parameters. + * @param ip4_address IPv4 source address used for encapsulated traffic + * @param ip6_address IPv6 source address used for encapsulated traffic + * @return 0 on success. VNET_LB_ERR_XXX on error + */ +int lb_conf(ip4_address_t *ip4_address, ip6_address_t *ip6_address, + u32 sticky_buckets, u32 flow_timeout); + +int lb_vip_add(ip46_address_t *prefix, u8 plen, lb_vip_type_t type, + u32 new_length, u32 *vip_index); +int lb_vip_del(u32 vip_index); + +int lb_vip_find_index(ip46_address_t *prefix, u8 plen, u32 *vip_index); + +#define lb_vip_get_by_index(index) (pool_is_free_index(lb_main.vips, index)?NULL:pool_elt_at_index(lb_main.vips, index)) + +int lb_vip_add_ass(u32 vip_index, ip46_address_t *addresses, u32 n); +int lb_vip_del_ass(u32 vip_index, ip46_address_t *addresses, u32 n); + +u32 lb_hash_time_now(vlib_main_t * vm); + +void lb_garbage_collection(); + +format_function_t format_lb_main; + +#endif /* LB_PLUGIN_LB_LB_H_ */ diff --git a/src/plugins/lb/lb_plugin_doc.md b/src/plugins/lb/lb_plugin_doc.md new file mode 100644 index 00000000..c7885ffb --- /dev/null +++ b/src/plugins/lb/lb_plugin_doc.md @@ -0,0 +1,141 @@ +# Load Balancer plugin for VPP {#lb_plugin_doc} + +## Version + +The load balancer plugin is currently in *beta* version. +Both CLIs and APIs are subject to *heavy* changes. +Wich also means feedback is really welcome regarding features, apis, etc... + +## Overview + +This plugin provides load balancing for VPP in a way that is largely inspired +from Google's MagLev: http://research.google.com/pubs/pub44824.html + +The load balancer is configured with a set of Virtual IPs (VIP, which can be +prefixes), and for each VIP, with a set of Application Server addresses (ASs). + +Traffic received for a given VIP (or VIP prefix) is tunneled using GRE towards +the different ASs in a way that (tries to) ensure that a given session will +always be tunneled to the same AS. + +Both VIPs or ASs can be IPv4 or IPv6, but for a given VIP, all ASs must be using +the same encap. type (i.e. IPv4+GRE or IPv6+GRE). Meaning that for a given VIP, +all AS addresses must be of the same family. + +## Performances + +The load balancer has been tested up to 1 millions flows and still forwards more +than 3Mpps per core in such circumstances. +Although 3Mpps seems already good, it is likely that performances will be improved +in next versions. + +## Configuration + +### Global LB parameters + +The load balancer needs to be configured with some parameters: + + lb conf [ip4-src-address ] [ip6-src-address ] + [buckets ] [timeout ] + +ip4-src-address: the source address used to send encap. packets using IPv4. + +ip6-src-address: the source address used to send encap. packets using IPv6. + +buckets: the *per-thread* established-connexions-table number of buckets. + +timeout: the number of seconds a connection will remain in the + established-connexions-table while no packet for this flow + is received. + + +### Configure the VIPs + + lb vip [encap (gre6|gre4)] [new_len ] [del] + +new_len is the size of the new-connection-table. It should be 1 or 2 orders of +magnitude bigger than the number of ASs for the VIP in order to ensure a good +load balancing. + +Examples: + + lb vip 2002::/16 encap gre6 new_len 1024 + lb vip 2003::/16 encap gre4 new_len 2048 + lb vip 80.0.0.0/8 encap gre6 new_len 16 + lb vip 90.0.0.0/8 encap gre4 new_len 1024 + +### Configure the ASs (for each VIP) + + lb as [
[
[...]]] [del] + +You can add (or delete) as many ASs at a time (for a single VIP). +Note that the AS address family must correspond to the VIP encap. IP family. + +Examples: + + lb as 2002::/16 2001::2 2001::3 2001::4 + lb as 2003::/16 10.0.0.1 10.0.0.2 + lb as 80.0.0.0/8 2001::2 + lb as 90.0.0.0/8 10.0.0.1 + + + +## Monitoring + +The plugin provides quite a bunch of counters and information. +These are still subject to quite significant changes. + + show lb + show lb vip + show lb vip verbose + + show node counters + + +## Design notes + +### Multi-Threading + +MagLev is a distributed system which pseudo-randomly generates a +new-connections-table based on AS names such that each server configured with +the same set of ASs ends up with the same table. Connection stickyness is then +ensured with an established-connections-table. Using ECMP, it is assumed (but +not relied on) that servers will mostly receive traffic for different flows. + +This implementation pushes the parallelism a little bit further by using +one established-connections table per thread. This is equivalent to assuming +that RSS will make a job similar to ECMP, and is pretty useful as threads don't +need to get a lock in order to write in the table. + +### Hash Table + +A load balancer requires an efficient read and write hash table. The hash table +used by ip6-forward is very read-efficient, but not so much for writing. In +addition, it is not a big deal if writing into the hash table fails (again, +MagLev uses a flow table but does not heaviliy relies on it). + +The plugin therefore uses a very specific (and stupid) hash table. + - Fixed (and power of 2) number of buckets (configured at runtime) + - Fixed (and power of 2) elements per buckets (configured at compilation time) + +### Reference counting + +When an AS is removed, there is two possible ways to react. + - Keep using the AS for established connections + - Change AS for established connections (likely to cause error for TCP) + +In the first case, although an AS is removed from the configuration, its +associated state needs to stay around as long as it is used by at least one +thread. + +In order to avoid locks, a specific reference counter is used. The design is quite +similar to clib counters but: + - It is possible to decrease the value + - Summing will not zero the per-thread counters + - Only the thread can reallocate its own counters vector (to avoid concurrency issues) + +This reference counter is lock free, but reading a count of 0 does not mean +the value can be freed unless it is ensured by *other* means that no other thread +is concurrently referencing the object. In the case of this plugin, it is assumed +that no concurrent event will take place after a few seconds. + diff --git a/src/plugins/lb/lb_test.c b/src/plugins/lb/lb_test.c new file mode 100644 index 00000000..8c2eaa91 --- /dev/null +++ b/src/plugins/lb/lb_test.c @@ -0,0 +1,293 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include + +//TODO: Move that to vat/plugin_api.c +////////////////////////// +uword unformat_ip46_address (unformat_input_t * input, va_list * args) +{ + ip46_address_t *ip46 = va_arg (*args, ip46_address_t *); + ip46_type_t type = va_arg (*args, ip46_type_t); + if ((type != IP46_TYPE_IP6) && + unformat(input, "%U", unformat_ip4_address, &ip46->ip4)) { + ip46_address_mask_ip4(ip46); + return 1; + } else if ((type != IP46_TYPE_IP4) && + unformat(input, "%U", unformat_ip6_address, &ip46->ip6)) { + return 1; + } + return 0; +} +uword unformat_ip46_prefix (unformat_input_t * input, va_list * args) +{ + ip46_address_t *ip46 = va_arg (*args, ip46_address_t *); + u8 *len = va_arg (*args, u8 *); + ip46_type_t type = va_arg (*args, ip46_type_t); + + u32 l; + if ((type != IP46_TYPE_IP6) && unformat(input, "%U/%u", unformat_ip4_address, &ip46->ip4, &l)) { + if (l > 32) + return 0; + *len = l + 96; + ip46->pad[0] = ip46->pad[1] = ip46->pad[2] = 0; + } else if ((type != IP46_TYPE_IP4) && unformat(input, "%U/%u", unformat_ip6_address, &ip46->ip6, &l)) { + if (l > 128) + return 0; + *len = l; + } else { + return 0; + } + return 1; +} +///////////////////////// + +#define vl_msg_id(n,h) n, +typedef enum { +#include + /* We'll want to know how many messages IDs we need... */ + VL_MSG_FIRST_AVAILABLE, +} vl_msg_id_t; +#undef vl_msg_id + +/* define message structures */ +#define vl_typedefs +#include +#undef vl_typedefs + +/* declare message handlers for each api */ + +#define vl_endianfun /* define message structures */ +#include +#undef vl_endianfun + +/* instantiate all the print functions we know about */ +#define vl_print(handle, ...) +#define vl_printfun +#include +#undef vl_printfun + +/* Get the API version number. */ +#define vl_api_version(n,v) static u32 api_version=(v); +#include +#undef vl_api_version + +typedef struct { + /* API message ID base */ + u16 msg_id_base; + vat_main_t *vat_main; +} lb_test_main_t; + +lb_test_main_t lb_test_main; + +#define foreach_standard_reply_retval_handler \ +_(lb_conf_reply) \ +_(lb_add_del_vip_reply) \ +_(lb_add_del_as_reply) + +#define _(n) \ + static void vl_api_##n##_t_handler \ + (vl_api_##n##_t * mp) \ + { \ + vat_main_t * vam = lb_test_main.vat_main; \ + i32 retval = ntohl(mp->retval); \ + if (vam->async_mode) { \ + vam->async_errors += (retval < 0); \ + } else { \ + vam->retval = retval; \ + vam->result_ready = 1; \ + } \ + } +foreach_standard_reply_retval_handler; +#undef _ + +/* + * Table of message reply handlers, must include boilerplate handlers + * we just generated + */ +#define foreach_vpe_api_reply_msg \ + _(LB_CONF_REPLY, lb_conf_reply) \ + _(LB_ADD_DEL_VIP_REPLY, lb_add_del_vip_reply) \ + _(LB_ADD_DEL_AS_REPLY, lb_add_del_as_reply) + +/* M: construct, but don't yet send a message */ +#define M(T,t) \ +do { \ + vam->result_ready = 0; \ + mp = vl_msg_api_alloc(sizeof(*mp)); \ + memcpy (mp, &mps, sizeof (*mp)); \ + mp->_vl_msg_id = ntohs (VL_API_##T + lbtm->msg_id_base); \ + mp->client_index = vam->my_client_index; \ +} while(0); + +/* S: send a message */ +#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp)) + +/* W: wait for results, with timeout */ +#define W \ +do { \ + timeout = vat_time_now (vam) + 1.0; \ + \ + while (vat_time_now (vam) < timeout) { \ + if (vam->result_ready == 1) { \ + return (vam->retval); \ + } \ + } \ + return -99; \ +} while(0); + +static int api_lb_conf (vat_main_t * vam) +{ + lb_test_main_t *lbtm = &lb_test_main; + unformat_input_t *i = vam->input; + f64 timeout; + vl_api_lb_conf_t mps, *mp; + + if (!unformat(i, "%U %U %u %u", + unformat_ip4_address, &mps.ip4_src_address, + unformat_ip6_address, mps.ip6_src_address, + &mps.sticky_buckets_per_core, + &mps.flow_timeout)) { + errmsg ("invalid arguments\n"); + return -99; + } + + M(LB_CONF, lb_conf); S; W; + + /* NOTREACHED */ + return 0; +} + +static int api_lb_add_del_vip (vat_main_t * vam) +{ + lb_test_main_t *lbtm = &lb_test_main; + unformat_input_t * i = vam->input; + f64 timeout; + vl_api_lb_add_del_vip_t mps, *mp; + mps.is_del = 0; + mps.is_gre4 = 0; + + if (!unformat(i, "%U", + unformat_ip46_prefix, mps.ip_prefix, &mps.prefix_length, IP46_TYPE_ANY)) { + errmsg ("invalid prefix\n"); + return -99; + } + + if (unformat(i, "gre4")) { + mps.is_gre4 = 1; + } else if (unformat(i, "gre6")) { + mps.is_gre4 = 0; + } else { + errmsg ("no encap\n"); + return -99; + } + + if (!unformat(i, "%d", &mps.new_flows_table_length)) { + errmsg ("no table lentgh\n"); + return -99; + } + + if (unformat(i, "del")) { + mps.is_del = 1; + } + + M(LB_ADD_DEL_VIP, lb_add_del_vip); S; W; + /* NOTREACHED */ + return 0; +} + +static int api_lb_add_del_as (vat_main_t * vam) +{ + lb_test_main_t *lbtm = &lb_test_main; + unformat_input_t * i = vam->input; + f64 timeout; + vl_api_lb_add_del_as_t mps, *mp; + mps.is_del = 0; + + if (!unformat(i, "%U %U", + unformat_ip46_prefix, mps.vip_ip_prefix, &mps.vip_prefix_length, IP46_TYPE_ANY, + unformat_ip46_address, mps.as_address)) { + errmsg ("invalid prefix or address\n"); + return -99; + } + + if (unformat(i, "del")) { + mps.is_del = 1; + } + + M(LB_ADD_DEL_AS, lb_add_del_as); S; W; + /* NOTREACHED */ + return 0; +} + +/* + * List of messages that the api test plugin sends, + * and that the data plane plugin processes + */ +#define foreach_vpe_api_msg \ +_(lb_conf, " ") \ +_(lb_add_del_vip, " [gre4|gre6] [del]") \ +_(lb_add_del_as, "
[del]") + +void vat_api_hookup (vat_main_t *vam) +{ + lb_test_main_t * lbtm = &lb_test_main; + /* Hook up handlers for replies from the data plane plug-in */ +#define _(N,n) \ + vl_msg_api_set_handlers((VL_API_##N + lbtm->msg_id_base), \ + #n, \ + vl_api_##n##_t_handler, \ + vl_noop_handler, \ + vl_api_##n##_t_endian, \ + vl_api_##n##_t_print, \ + sizeof(vl_api_##n##_t), 1); + foreach_vpe_api_reply_msg; +#undef _ + + /* API messages we can send */ +#define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n); + foreach_vpe_api_msg; +#undef _ + + /* Help strings */ +#define _(n,h) hash_set_mem (vam->help_by_name, #n, h); + foreach_vpe_api_msg; +#undef _ +} + +clib_error_t * vat_plugin_register (vat_main_t *vam) +{ + lb_test_main_t * lbtm = &lb_test_main; + + u8 * name; + + lbtm->vat_main = vam; + + /* Ask the vpp engine for the first assigned message-id */ + name = format (0, "lb_%08x%c", api_version, 0); + lbtm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name); + + if (lbtm->msg_id_base != (u16) ~0) + vat_api_hookup (vam); + + vec_free(name); + + return 0; +} diff --git a/src/plugins/lb/lbhash.h b/src/plugins/lb/lbhash.h new file mode 100644 index 00000000..ca3cc143 --- /dev/null +++ b/src/plugins/lb/lbhash.h @@ -0,0 +1,216 @@ +/* + * Copyright (c) 2012 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * vppinfra already includes tons of different hash tables. + * MagLev flow table is a bit different. It has to be very efficient + * for both writing and reading operations. But it does not need to + * be 100% reliable (write can fail). It also needs to recycle + * old entries in a lazy way. + * + * This hash table is the most dummy hash table you can do. + * Fixed total size, fixed bucket size. + * Advantage is that it could be very efficient (maybe). + * + */ + +#ifndef LB_PLUGIN_LB_LBHASH_H_ +#define LB_PLUGIN_LB_LBHASH_H_ + +#include + +#if defined (__SSE4_2__) +#include +#endif + +/* + * @brief Number of entries per bucket. + */ +#define LBHASH_ENTRY_PER_BUCKET 4 + +#define LB_HASH_DO_NOT_USE_SSE_BUCKETS 0 + +/* + * @brief One bucket contains 4 entries. + * Each bucket takes one 64B cache line in memory. + */ +typedef struct { + CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); + u32 hash[LBHASH_ENTRY_PER_BUCKET]; + u32 timeout[LBHASH_ENTRY_PER_BUCKET]; + u32 vip[LBHASH_ENTRY_PER_BUCKET]; + u32 value[LBHASH_ENTRY_PER_BUCKET]; +} lb_hash_bucket_t; + +typedef struct { + u32 buckets_mask; + u32 timeout; + lb_hash_bucket_t buckets[]; +} lb_hash_t; + +#define lb_hash_nbuckets(h) (((h)->buckets_mask) + 1) +#define lb_hash_size(h) ((h)->buckets_mask + LBHASH_ENTRY_PER_BUCKET) + +#define lb_hash_foreach_bucket(h, bucket) \ + for (bucket = (h)->buckets; \ + bucket < (h)->buckets + lb_hash_nbuckets(h); \ + bucket++) + +#define lb_hash_foreach_entry(h, bucket, i) \ + lb_hash_foreach_bucket(h, bucket) \ + for (i = 0; i < LBHASH_ENTRY_PER_BUCKET; i++) + +#define lb_hash_foreach_valid_entry(h, bucket, i, now) \ + lb_hash_foreach_entry(h, bucket, i) \ + if (!clib_u32_loop_gt((now), bucket->timeout[i])) + +static_always_inline +lb_hash_t *lb_hash_alloc(u32 buckets, u32 timeout) +{ + if (!is_pow2(buckets)) + return NULL; + + // Allocate 1 more bucket for prefetch + u32 size = ((u64)&((lb_hash_t *)(0))->buckets[0]) + + sizeof(lb_hash_bucket_t) * (buckets + 1); + u8 *mem = 0; + lb_hash_t *h; + vec_alloc_aligned(mem, size, CLIB_CACHE_LINE_BYTES); + h = (lb_hash_t *)mem; + h->buckets_mask = (buckets - 1); + h->timeout = timeout; + return h; +} + +static_always_inline +void lb_hash_free(lb_hash_t *h) +{ + u8 *mem = (u8 *)h; + vec_free(mem); +} + +#if __SSE4_2__ +static_always_inline +u32 lb_hash_hash(u64 k0, u64 k1, u64 k2, u64 k3, u64 k4) +{ + u64 val = 0; + val = _mm_crc32_u64(val, k0); + val = _mm_crc32_u64(val, k1); + val = _mm_crc32_u64(val, k2); + val = _mm_crc32_u64(val, k3); + val = _mm_crc32_u64(val, k4); + return (u32) val; +} +#else +static_always_inline +u32 lb_hash_hash(u64 k0, u64 k1, u64 k2, u64 k3, u64 k4) +{ + u64 tmp = k0 ^ k1 ^ k2 ^ k3 ^ k4; + return (u32)clib_xxhash (tmp); +} +#endif + +static_always_inline +void lb_hash_prefetch_bucket(lb_hash_t *ht, u32 hash) +{ + lb_hash_bucket_t *bucket = &ht->buckets[hash & ht->buckets_mask]; + CLIB_PREFETCH(bucket, sizeof(*bucket), READ); +} + +static_always_inline +void lb_hash_get(lb_hash_t *ht, u32 hash, u32 vip, u32 time_now, + u32 *available_index, u32 *found_value) +{ + lb_hash_bucket_t *bucket = &ht->buckets[hash & ht->buckets_mask]; + *found_value = ~0; + *available_index = ~0; +#if __SSE4_2__ && LB_HASH_DO_NOT_USE_SSE_BUCKETS == 0 + u32 bitmask, found_index; + __m128i mask; + + // mask[*] = timeout[*] > now + mask = _mm_cmpgt_epi32(_mm_loadu_si128 ((__m128i *) bucket->timeout), + _mm_set1_epi32 (time_now)); + // bitmask[*] = now <= timeout[*/4] + bitmask = (~_mm_movemask_epi8(mask)) & 0xffff; + // Get first index with now <= timeout[*], if any. + *available_index = (bitmask)?__builtin_ctz(bitmask)/4:*available_index; + + // mask[*] = (timeout[*] > now) && (hash[*] == hash) + mask = _mm_and_si128(mask, + _mm_cmpeq_epi32( + _mm_loadu_si128 ((__m128i *) bucket->hash), + _mm_set1_epi32 (hash))); + + // Load the array of vip values + // mask[*] = (timeout[*] > now) && (hash[*] == hash) && (vip[*] == vip) + mask = _mm_and_si128(mask, + _mm_cmpeq_epi32( + _mm_loadu_si128 ((__m128i *) bucket->vip), + _mm_set1_epi32 (vip))); + + // mask[*] = (timeout[*x4] > now) && (hash[*x4] == hash) && (vip[*x4] == vip) + bitmask = _mm_movemask_epi8(mask); + // Get first index, if any + found_index = (bitmask)?__builtin_ctzll(bitmask)/4:0; + ASSERT(found_index < 4); + *found_value = (bitmask)?bucket->value[found_index]:*found_value; + bucket->timeout[found_index] = + (bitmask)?time_now + ht->timeout:bucket->timeout[found_index]; +#else + u32 i; + for (i = 0; i < LBHASH_ENTRY_PER_BUCKET; i++) { + u8 cmp = (bucket->hash[i] == hash && bucket->vip[i] == vip); + u8 timeouted = clib_u32_loop_gt(time_now, bucket->timeout[i]); + *found_value = (cmp || timeouted)?*found_value:bucket->value[i]; + bucket->timeout[i] = (cmp || timeouted)?time_now + ht->timeout:bucket->timeout[i]; + *available_index = (timeouted && (*available_index == ~0))?i:*available_index; + + if (!cmp) + return; + } +#endif +} + +static_always_inline +u32 lb_hash_available_value(lb_hash_t *h, u32 hash, u32 available_index) +{ + return h->buckets[hash & h->buckets_mask].value[available_index]; +} + +static_always_inline +void lb_hash_put(lb_hash_t *h, u32 hash, u32 value, u32 vip, + u32 available_index, u32 time_now) +{ + lb_hash_bucket_t *bucket = &h->buckets[hash & h->buckets_mask]; + bucket->hash[available_index] = hash; + bucket->value[available_index] = value; + bucket->timeout[available_index] = time_now + h->timeout; + bucket->vip[available_index] = vip; +} + +static_always_inline +u32 lb_hash_elts(lb_hash_t *h, u32 time_now) +{ + u32 tot = 0; + lb_hash_bucket_t *bucket; + u32 i; + lb_hash_foreach_valid_entry(h, bucket, i, time_now) { + tot++; + } + return tot; +} + +#endif /* LB_PLUGIN_LB_LBHASH_H_ */ diff --git a/src/plugins/lb/node.c b/src/plugins/lb/node.c new file mode 100644 index 00000000..8b763c53 --- /dev/null +++ b/src/plugins/lb/node.c @@ -0,0 +1,419 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include + +#define foreach_lb_error \ + _(NONE, "no error") \ + _(PROTO_NOT_SUPPORTED, "protocol not supported") + +typedef enum { +#define _(sym,str) LB_ERROR_##sym, + foreach_lb_error +#undef _ + LB_N_ERROR, +} lb_error_t; + +static char *lb_error_strings[] = { +#define _(sym,string) string, + foreach_lb_error +#undef _ +}; + +typedef struct { + u32 vip_index; + u32 as_index; +} lb_trace_t; + +u8 * +format_lb_trace (u8 * s, va_list * args) +{ + lb_main_t *lbm = &lb_main; + CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); + CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); + lb_trace_t *t = va_arg (*args, lb_trace_t *); + if (pool_is_free_index(lbm->vips, t->vip_index)) { + s = format(s, "lb vip[%d]: This VIP was freed since capture\n"); + } else { + s = format(s, "lb vip[%d]: %U\n", t->vip_index, format_lb_vip, &lbm->vips[t->vip_index]); + } + if (pool_is_free_index(lbm->ass, t->as_index)) { + s = format(s, "lb as[%d]: This AS was freed since capture\n"); + } else { + s = format(s, "lb as[%d]: %U\n", t->as_index, format_lb_as, &lbm->ass[t->as_index]); + } + return s; +} + +lb_hash_t *lb_get_sticky_table(u32 cpu_index) +{ + lb_main_t *lbm = &lb_main; + lb_hash_t *sticky_ht = lbm->per_cpu[cpu_index].sticky_ht; + //Check if size changed + if (PREDICT_FALSE(sticky_ht && (lbm->per_cpu_sticky_buckets != lb_hash_nbuckets(sticky_ht)))) + { + //Dereference everything in there + lb_hash_bucket_t *b; + u32 i; + lb_hash_foreach_entry(sticky_ht, b, i) { + vlib_refcount_add(&lbm->as_refcount, cpu_index, b->value[i], -1); + vlib_refcount_add(&lbm->as_refcount, cpu_index, 0, 1); + } + + lb_hash_free(sticky_ht); + sticky_ht = NULL; + } + + //Create if necessary + if (PREDICT_FALSE(sticky_ht == NULL)) { + lbm->per_cpu[cpu_index].sticky_ht = lb_hash_alloc(lbm->per_cpu_sticky_buckets, lbm->flow_timeout); + sticky_ht = lbm->per_cpu[cpu_index].sticky_ht; + clib_warning("Regenerated sticky table %p", sticky_ht); + } + + ASSERT(sticky_ht); + + //Update timeout + sticky_ht->timeout = lbm->flow_timeout; + return sticky_ht; +} + +u64 +lb_node_get_other_ports4(ip4_header_t *ip40) +{ + return 0; +} + +u64 +lb_node_get_other_ports6(ip6_header_t *ip60) +{ + return 0; +} + +static_always_inline u32 +lb_node_get_hash(vlib_buffer_t *p, u8 is_input_v4) +{ + u32 hash; + if (is_input_v4) + { + ip4_header_t *ip40; + u64 ports; + ip40 = vlib_buffer_get_current (p); + if (PREDICT_TRUE (ip40->protocol == IP_PROTOCOL_TCP || + ip40->protocol == IP_PROTOCOL_UDP)) + ports = ((u64)((udp_header_t *)(ip40 + 1))->src_port << 16) | + ((u64)((udp_header_t *)(ip40 + 1))->dst_port); + else + ports = lb_node_get_other_ports4(ip40); + + hash = lb_hash_hash(*((u64 *)&ip40->address_pair), ports, + 0, 0, 0); + } + else + { + ip6_header_t *ip60; + ip60 = vlib_buffer_get_current (p); + u64 ports; + if (PREDICT_TRUE (ip60->protocol == IP_PROTOCOL_TCP || + ip60->protocol == IP_PROTOCOL_UDP)) + ports = ((u64)((udp_header_t *)(ip60 + 1))->src_port << 16) | + ((u64)((udp_header_t *)(ip60 + 1))->dst_port); + else + ports = lb_node_get_other_ports6(ip60); + + hash = lb_hash_hash(ip60->src_address.as_u64[0], + ip60->src_address.as_u64[1], + ip60->dst_address.as_u64[0], + ip60->dst_address.as_u64[1], + ports); + } + return hash; +} + +static_always_inline uword +lb_node_fn (vlib_main_t * vm, + vlib_node_runtime_t * node, vlib_frame_t * frame, + u8 is_input_v4, //Compile-time parameter stating that is input is v4 (or v6) + u8 is_encap_v4) //Compile-time parameter stating that is GRE encap is v4 (or v6) +{ + lb_main_t *lbm = &lb_main; + u32 n_left_from, *from, next_index, *to_next, n_left_to_next; + u32 cpu_index = os_get_cpu_number(); + u32 lb_time = lb_hash_time_now(vm); + + lb_hash_t *sticky_ht = lb_get_sticky_table(cpu_index); + from = vlib_frame_vector_args (frame); + n_left_from = frame->n_vectors; + next_index = node->cached_next_index; + + u32 nexthash0 = 0; + if (PREDICT_TRUE(n_left_from > 0)) + nexthash0 = lb_node_get_hash(vlib_get_buffer (vm, from[0]), is_input_v4); + + while (n_left_from > 0) + { + vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); + while (n_left_from > 0 && n_left_to_next > 0) + { + u32 pi0; + vlib_buffer_t *p0; + lb_vip_t *vip0; + u32 asindex0; + u16 len0; + u32 available_index0; + u8 counter = 0; + u32 hash0 = nexthash0; + + if (PREDICT_TRUE(n_left_from > 1)) + { + vlib_buffer_t *p1 = vlib_get_buffer (vm, from[1]); + //Compute next hash and prefetch bucket + nexthash0 = lb_node_get_hash(p1, is_input_v4); + lb_hash_prefetch_bucket(sticky_ht, nexthash0); + //Prefetch for encap, next + CLIB_PREFETCH (vlib_buffer_get_current(p1) - 64, 64, STORE); + } + + if (PREDICT_TRUE(n_left_from > 2)) + { + vlib_buffer_t *p2; + p2 = vlib_get_buffer(vm, from[2]); + /* prefetch packet header and data */ + vlib_prefetch_buffer_header(p2, STORE); + CLIB_PREFETCH (vlib_buffer_get_current(p2), 64, STORE); + } + + pi0 = to_next[0] = from[0]; + from += 1; + n_left_from -= 1; + to_next += 1; + n_left_to_next -= 1; + + p0 = vlib_get_buffer (vm, pi0); + vip0 = pool_elt_at_index (lbm->vips, + vnet_buffer (p0)->ip.adj_index[VLIB_TX]); + + if (is_input_v4) + { + ip4_header_t *ip40; + ip40 = vlib_buffer_get_current (p0); + len0 = clib_net_to_host_u16(ip40->length); + } + else + { + ip6_header_t *ip60; + ip60 = vlib_buffer_get_current (p0); + len0 = clib_net_to_host_u16(ip60->payload_length) + sizeof(ip6_header_t); + } + + lb_hash_get(sticky_ht, hash0, vnet_buffer (p0)->ip.adj_index[VLIB_TX], + lb_time, &available_index0, &asindex0); + + if (PREDICT_TRUE(asindex0 != ~0)) + { + //Found an existing entry + counter = LB_VIP_COUNTER_NEXT_PACKET; + } + else if (PREDICT_TRUE(available_index0 != ~0)) + { + //There is an available slot for a new flow + asindex0 = vip0->new_flow_table[hash0 & vip0->new_flow_table_mask].as_index; + counter = LB_VIP_COUNTER_FIRST_PACKET; + counter = (asindex0 == 0)?LB_VIP_COUNTER_NO_SERVER:counter; + + //TODO: There are race conditions with as0 and vip0 manipulation. + //Configuration may be changed, vectors resized, etc... + + //Dereference previously used + vlib_refcount_add(&lbm->as_refcount, cpu_index, + lb_hash_available_value(sticky_ht, hash0, available_index0), -1); + vlib_refcount_add(&lbm->as_refcount, cpu_index, + asindex0, 1); + + //Add sticky entry + //Note that when there is no AS configured, an entry is configured anyway. + //But no configured AS is not something that should happen + lb_hash_put(sticky_ht, hash0, asindex0, + vnet_buffer (p0)->ip.adj_index[VLIB_TX], + available_index0, lb_time); + } + else + { + //Could not store new entry in the table + asindex0 = vip0->new_flow_table[hash0 & vip0->new_flow_table_mask].as_index; + counter = LB_VIP_COUNTER_UNTRACKED_PACKET; + } + + vlib_increment_simple_counter(&lbm->vip_counters[counter], + cpu_index, + vnet_buffer (p0)->ip.adj_index[VLIB_TX], + 1); + + //Now let's encap + { + gre_header_t *gre0; + if (is_encap_v4) + { + ip4_header_t *ip40; + vlib_buffer_advance(p0, - sizeof(ip4_header_t) - sizeof(gre_header_t)); + ip40 = vlib_buffer_get_current(p0); + gre0 = (gre_header_t *)(ip40 + 1); + ip40->src_address = lbm->ip4_src_address; + ip40->dst_address = lbm->ass[asindex0].address.ip4; + ip40->ip_version_and_header_length = 0x45; + ip40->ttl = 128; + ip40->length = clib_host_to_net_u16(len0 + sizeof(gre_header_t) + sizeof(ip4_header_t)); + ip40->protocol = IP_PROTOCOL_GRE; + ip40->checksum = ip4_header_checksum (ip40); + } + else + { + ip6_header_t *ip60; + vlib_buffer_advance(p0, - sizeof(ip6_header_t) - sizeof(gre_header_t)); + ip60 = vlib_buffer_get_current(p0); + gre0 = (gre_header_t *)(ip60 + 1); + ip60->dst_address = lbm->ass[asindex0].address.ip6; + ip60->src_address = lbm->ip6_src_address; + ip60->hop_limit = 128; + ip60->ip_version_traffic_class_and_flow_label = clib_host_to_net_u32 (0x6<<28); + ip60->payload_length = clib_host_to_net_u16(len0 + sizeof(gre_header_t)); + ip60->protocol = IP_PROTOCOL_GRE; + } + + gre0->flags_and_version = 0; + gre0->protocol = (is_input_v4)? + clib_host_to_net_u16(0x0800): + clib_host_to_net_u16(0x86DD); + } + + if (PREDICT_FALSE (p0->flags & VLIB_BUFFER_IS_TRACED)) + { + lb_trace_t *tr = vlib_add_trace (vm, node, p0, sizeof (*tr)); + tr->as_index = asindex0; + tr->vip_index = vnet_buffer (p0)->ip.adj_index[VLIB_TX]; + } + + //Enqueue to next + //Note that this is going to error if asindex0 == 0 + vnet_buffer (p0)->ip.adj_index[VLIB_TX] = lbm->ass[asindex0].dpo.dpoi_index; + vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, + n_left_to_next, pi0, + lbm->ass[asindex0].dpo.dpoi_next_node); + } + vlib_put_next_frame (vm, node, next_index, n_left_to_next); + } + + return frame->n_vectors; +} + +static uword +lb6_gre6_node_fn (vlib_main_t * vm, + vlib_node_runtime_t * node, vlib_frame_t * frame) +{ + return lb_node_fn(vm, node, frame, 0, 0); +} + +static uword +lb6_gre4_node_fn (vlib_main_t * vm, + vlib_node_runtime_t * node, vlib_frame_t * frame) +{ + return lb_node_fn(vm, node, frame, 0, 1); +} + +static uword +lb4_gre6_node_fn (vlib_main_t * vm, + vlib_node_runtime_t * node, vlib_frame_t * frame) +{ + return lb_node_fn(vm, node, frame, 1, 0); +} + +static uword +lb4_gre4_node_fn (vlib_main_t * vm, + vlib_node_runtime_t * node, vlib_frame_t * frame) +{ + return lb_node_fn(vm, node, frame, 1, 1); +} + +VLIB_REGISTER_NODE (lb6_gre6_node) = +{ + .function = lb6_gre6_node_fn, + .name = "lb6-gre6", + .vector_size = sizeof (u32), + .format_trace = format_lb_trace, + + .n_errors = LB_N_ERROR, + .error_strings = lb_error_strings, + + .n_next_nodes = LB_N_NEXT, + .next_nodes = + { + [LB_NEXT_DROP] = "error-drop" + }, +}; + +VLIB_REGISTER_NODE (lb6_gre4_node) = +{ + .function = lb6_gre4_node_fn, + .name = "lb6-gre4", + .vector_size = sizeof (u32), + .format_trace = format_lb_trace, + + .n_errors = LB_N_ERROR, + .error_strings = lb_error_strings, + + .n_next_nodes = LB_N_NEXT, + .next_nodes = + { + [LB_NEXT_DROP] = "error-drop" + }, +}; + +VLIB_REGISTER_NODE (lb4_gre6_node) = +{ + .function = lb4_gre6_node_fn, + .name = "lb4-gre6", + .vector_size = sizeof (u32), + .format_trace = format_lb_trace, + + .n_errors = LB_N_ERROR, + .error_strings = lb_error_strings, + + .n_next_nodes = LB_N_NEXT, + .next_nodes = + { + [LB_NEXT_DROP] = "error-drop" + }, +}; + +VLIB_REGISTER_NODE (lb4_gre4_node) = +{ + .function = lb4_gre4_node_fn, + .name = "lb4-gre4", + .vector_size = sizeof (u32), + .format_trace = format_lb_trace, + + .n_errors = LB_N_ERROR, + .error_strings = lb_error_strings, + + .n_next_nodes = LB_N_NEXT, + .next_nodes = + { + [LB_NEXT_DROP] = "error-drop" + }, +}; + diff --git a/src/plugins/lb/refcount.c b/src/plugins/lb/refcount.c new file mode 100644 index 00000000..22415c88 --- /dev/null +++ b/src/plugins/lb/refcount.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +void __vlib_refcount_resize(vlib_refcount_per_cpu_t *per_cpu, u32 size) +{ + u32 *new_counter = 0, *old_counter; + vec_validate(new_counter, size); + memcpy(new_counter, per_cpu->counters, per_cpu->length); + old_counter = per_cpu->counters; + per_cpu->counters = new_counter; + CLIB_MEMORY_BARRIER(); + per_cpu->length = vec_len(new_counter); + vec_free(old_counter); +} + +u64 vlib_refcount_get(vlib_refcount_t *r, u32 index) +{ + u64 count = 0; + vlib_thread_main_t *tm = vlib_get_thread_main (); + u32 cpu_index; + for (cpu_index = 0; cpu_index < tm->n_vlib_mains; cpu_index++) { + if (r->per_cpu[cpu_index].length > index) + count += r->per_cpu[cpu_index].counters[index]; + } + return count; +} + diff --git a/src/plugins/lb/refcount.h b/src/plugins/lb/refcount.h new file mode 100644 index 00000000..8c26e7be --- /dev/null +++ b/src/plugins/lb/refcount.h @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * vlib provides lock-free counters but those + * - Have 16bits per-CPU counter, which may overflow. + * - Would only increment. + * + * This is very similar to vlib counters, but may be used to count reference. + * Such a counter includes an arbitrary number of counters. Each counter + * is identified by its index. This is used to aggregate per-cpu memory. + * + * Warning: + * This reference counter is lock-free but is not race-condition free. + * The counting result is approximate and another mechanism needs to be used + * in order to ensure that an object may be freed. + * + */ + +#include + +typedef struct { + u32 *counters; + u32 length; + u32 *reader_lengths; + CLIB_CACHE_LINE_ALIGN_MARK(o); +} vlib_refcount_per_cpu_t; + +typedef struct { + vlib_refcount_per_cpu_t *per_cpu; +} vlib_refcount_t; + +void __vlib_refcount_resize(vlib_refcount_per_cpu_t *per_cpu, u32 size); + +static_always_inline +void vlib_refcount_add(vlib_refcount_t *r, u32 cpu_index, u32 counter_index, i32 v) +{ + vlib_refcount_per_cpu_t *per_cpu = &r->per_cpu[cpu_index]; + if (PREDICT_FALSE(counter_index >= per_cpu->length)) + __vlib_refcount_resize(per_cpu, clib_max(counter_index + 16, per_cpu->length * 2)); + + per_cpu->counters[counter_index] += v; +} + +u64 vlib_refcount_get(vlib_refcount_t *r, u32 index); + +static_always_inline +void vlib_refcount_init(vlib_refcount_t *r) +{ + vlib_thread_main_t *tm = vlib_get_thread_main (); + r->per_cpu = 0; + vec_validate (r->per_cpu, tm->n_vlib_mains - 1); +} + + diff --git a/src/plugins/lb/util.c b/src/plugins/lb/util.c new file mode 100644 index 00000000..d969d168 --- /dev/null +++ b/src/plugins/lb/util.c @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +void ip46_prefix_normalize(ip46_address_t *prefix, u8 plen) +{ + if (plen == 0) { + prefix->as_u64[0] = 0; + prefix->as_u64[1] = 0; + } else if (plen <= 64) { + prefix->as_u64[0] &= clib_host_to_net_u64(0xffffffffffffffffL << (64 - plen)); + prefix->as_u64[1] = 0; + } else { + prefix->as_u64[1] &= clib_host_to_net_u64(0xffffffffffffffffL << (128 - plen)); + } + +} + +uword unformat_ip46_prefix (unformat_input_t * input, va_list * args) +{ + ip46_address_t *ip46 = va_arg (*args, ip46_address_t *); + u8 *len = va_arg (*args, u8 *); + ip46_type_t type = va_arg (*args, ip46_type_t); + + u32 l; + if ((type != IP46_TYPE_IP6) && unformat(input, "%U/%u", unformat_ip4_address, &ip46->ip4, &l)) { + if (l > 32) + return 0; + *len = l + 96; + ip46->pad[0] = ip46->pad[1] = ip46->pad[2] = 0; + } else if ((type != IP46_TYPE_IP4) && unformat(input, "%U/%u", unformat_ip6_address, &ip46->ip6, &l)) { + if (l > 128) + return 0; + *len = l; + } else { + return 0; + } + return 1; +} + +u8 *format_ip46_prefix (u8 * s, va_list * args) +{ + ip46_address_t *ip46 = va_arg (*args, ip46_address_t *); + u32 len = va_arg (*args, u32); //va_arg cannot use u8 or u16 + ip46_type_t type = va_arg (*args, ip46_type_t); + + int is_ip4 = 0; + if (type == IP46_TYPE_IP4) + is_ip4 = 1; + else if (type == IP46_TYPE_IP6) + is_ip4 = 0; + else + is_ip4 = (len >= 96) && ip46_address_is_ip4(ip46); + + return is_ip4 ? + format(s, "%U/%d", format_ip4_address, &ip46->ip4, len - 96): + format(s, "%U/%d", format_ip6_address, &ip46->ip6, len); +} + diff --git a/src/plugins/lb/util.h b/src/plugins/lb/util.h new file mode 100644 index 00000000..3f082310 --- /dev/null +++ b/src/plugins/lb/util.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Non-LB specific stuff comes here + */ + +#ifndef LB_PLUGIN_LB_UTIL_H_ +#define LB_PLUGIN_LB_UTIL_H_ + +#include +#include + +#define ip46_address_type(ip46) (ip46_address_is_ip4(ip46)?IP46_TYPE_IP4:IP46_TYPE_IP6) +#define ip46_prefix_is_ip4(ip46, len) ((len) >= 96 && ip46_address_is_ip4(ip46)) +#define ip46_prefix_type(ip46, len) (ip46_prefix_is_ip4(ip46, len)?IP46_TYPE_IP4:IP46_TYPE_IP6) + +void ip46_prefix_normalize(ip46_address_t *prefix, u8 plen); +uword unformat_ip46_prefix (unformat_input_t * input, va_list * args); +u8 *format_ip46_prefix (u8 * s, va_list * args); + +/** + * 32 bits integer comparison for running values. + * 1 > 0 is true. But 1 > 0xffffffff also is. + */ +#define clib_u32_loop_gt(a, b) (((u32)(a)) - ((u32)(b)) < 0x7fffffff) + +#endif /* LB_PLUGIN_LB_UTIL_H_ */ -- cgit 1.2.3-korg From fe6bdfd84573cd8813a211f9094ee734f088ce16 Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Fri, 20 Jan 2017 19:50:09 -0500 Subject: binary-api debug CLI works with plugins Change-Id: I81f33f5153d5afac94b66b5a8cb91da77463af79 Signed-off-by: Dave Barach --- src/examples/sample-plugin/sample/sample_test.c | 37 +--- src/plugins/acl/acl_test.c | 51 +----- src/plugins/flowperpkt/flowperpkt_test.c | 45 +---- .../export-vxlan-gpe/vxlan_gpe_ioam_export_test.c | 46 +---- src/plugins/ioam/export/ioam_export_test.c | 44 +---- src/plugins/ioam/lib-pot/pot_test.c | 48 +---- src/plugins/ioam/lib-trace/trace_test.c | 48 +---- src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c | 56 +----- src/plugins/lb/lb_test.c | 35 +--- src/plugins/snat/snat_test.c | 57 +----- src/vat/api_format.c | 95 ++++------ src/vat/vat.h | 33 +--- src/vlib/unix/plugin.c | 9 +- src/vlibapi/api_helper_macros.h | 1 - src/vlibapi/vat_helper_macros.h | 76 ++++++++ src/vpp-api-test.am | 3 + src/vpp.am | 6 +- src/vpp/api/api_main.c | 39 ++++ src/vpp/api/plugin.c | 201 +++++++++++++++++++++ src/vpp/api/plugin.h | 61 +++++++ 20 files changed, 476 insertions(+), 515 deletions(-) create mode 100644 src/vlibapi/vat_helper_macros.h create mode 100644 src/vpp/api/plugin.c create mode 100644 src/vpp/api/plugin.h (limited to 'src/plugins/lb') diff --git a/src/examples/sample-plugin/sample/sample_test.c b/src/examples/sample-plugin/sample/sample_test.c index dd1b0215..a47710ee 100644 --- a/src/examples/sample-plugin/sample/sample_test.c +++ b/src/examples/sample-plugin/sample/sample_test.c @@ -23,6 +23,7 @@ #include #include #include +#include uword unformat_sw_if_index (unformat_input_t * input, va_list * args); @@ -87,42 +88,6 @@ foreach_standard_reply_retval_handler; _(SAMPLE_MACSWAP_ENABLE_DISABLE_REPLY, sample_macswap_enable_disable_reply) -/* M: construct, but don't yet send a message */ - -#define M(T,t) \ -do { \ - vam->result_ready = 0; \ - mp = vl_msg_api_alloc(sizeof(*mp)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \ - mp->client_index = vam->my_client_index; \ -} while(0); - -#define M2(T,t,n) \ -do { \ - vam->result_ready = 0; \ - mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \ - mp->client_index = vam->my_client_index; \ -} while(0); - -/* S: send a message */ -#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp)) - -/* W: wait for results, with timeout */ -#define W \ -do { \ - timeout = vat_time_now (vam) + 1.0; \ - \ - while (vat_time_now (vam) < timeout) { \ - if (vam->result_ready == 1) { \ - return (vam->retval); \ - } \ - } \ - return -99; \ -} while(0); - static int api_sample_macswap_enable_disable (vat_main_t * vam) { sample_test_main_t * sm = &sample_test_main; diff --git a/src/plugins/acl/acl_test.c b/src/plugins/acl/acl_test.c index a0e413e1..5cacf716 100644 --- a/src/plugins/acl/acl_test.c +++ b/src/plugins/acl/acl_test.c @@ -25,6 +25,7 @@ #include #include #include +#include uword unformat_sw_if_index (unformat_input_t * input, va_list * args); @@ -259,42 +260,6 @@ _(MACIP_ACL_INTERFACE_ADD_DEL_REPLY, macip_acl_interface_add_del_reply) \ _(MACIP_ACL_INTERFACE_GET_REPLY, macip_acl_interface_get_reply) \ _(ACL_PLUGIN_GET_VERSION_REPLY, acl_plugin_get_version_reply) -/* M: construct, but don't yet send a message */ - -#define M(T,t) \ -do { \ - vam->result_ready = 0; \ - mp = vl_msg_api_alloc(sizeof(*mp)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \ - mp->client_index = vam->my_client_index; \ -} while(0); - -#define M2(T,t,n) \ -do { \ - vam->result_ready = 0; \ - mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \ - mp->client_index = vam->my_client_index; \ -} while(0); - -/* S: send a message */ -#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp)) - -/* W: wait for results, with timeout */ -#define W \ -do { \ - timeout = vat_time_now (vam) + 1.0; \ - \ - while (vat_time_now (vam) < timeout) { \ - if (vam->result_ready == 1) { \ - return (vam->retval); \ - } \ - } \ - return -99; \ -} while(0); - static int api_acl_plugin_get_version (vat_main_t * vam) { acl_test_main_t * sm = &acl_test_main; @@ -520,7 +485,6 @@ static int api_acl_add_replace (vat_main_t * vam) static int api_acl_del (vat_main_t * vam) { - acl_test_main_t * sm = &acl_test_main; unformat_input_t * i = vam->input; f64 timeout; vl_api_acl_del_t * mp; @@ -544,7 +508,6 @@ static int api_acl_del (vat_main_t * vam) static int api_macip_acl_del (vat_main_t * vam) { - acl_test_main_t * sm = &acl_test_main; unformat_input_t * i = vam->input; f64 timeout; vl_api_acl_del_t * mp; @@ -568,7 +531,6 @@ static int api_macip_acl_del (vat_main_t * vam) static int api_acl_interface_add_del (vat_main_t * vam) { - acl_test_main_t * sm = &acl_test_main; unformat_input_t * i = vam->input; f64 timeout; vl_api_acl_interface_add_del_t * mp; @@ -636,7 +598,6 @@ static int api_acl_interface_add_del (vat_main_t * vam) static int api_macip_acl_interface_add_del (vat_main_t * vam) { - acl_test_main_t * sm = &acl_test_main; unformat_input_t * i = vam->input; f64 timeout; vl_api_macip_acl_interface_add_del_t * mp; @@ -687,7 +648,6 @@ static int api_macip_acl_interface_add_del (vat_main_t * vam) static int api_acl_interface_set_acl_list (vat_main_t * vam) { - acl_test_main_t * sm = &acl_test_main; unformat_input_t * i = vam->input; f64 timeout; vl_api_acl_interface_set_acl_list_t * mp; @@ -746,7 +706,6 @@ static int api_acl_interface_set_acl_list (vat_main_t * vam) static int api_acl_interface_list_dump (vat_main_t * vam) { - acl_test_main_t * sm = &acl_test_main; unformat_input_t * i = vam->input; f64 timeout; u32 sw_if_index = ~0; @@ -775,7 +734,6 @@ static int api_acl_interface_list_dump (vat_main_t * vam) static int api_acl_dump (vat_main_t * vam) { - acl_test_main_t * sm = &acl_test_main; unformat_input_t * i = vam->input; f64 timeout; u32 acl_index = ~0; @@ -802,7 +760,6 @@ static int api_acl_dump (vat_main_t * vam) static int api_macip_acl_dump (vat_main_t * vam) { - acl_test_main_t * sm = &acl_test_main; unformat_input_t * i = vam->input; f64 timeout; u32 acl_index = ~0; @@ -978,8 +935,8 @@ _(macip_acl_interface_add_del, " | sw_if_index [add|del] acl msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name); if (sm->msg_id_base != (u16) ~0) - vat_api_hookup (vam); + acl_vat_api_hookup (vam); vec_free(name); diff --git a/src/plugins/flowperpkt/flowperpkt_test.c b/src/plugins/flowperpkt/flowperpkt_test.c index 716818ff..9211ebe3 100644 --- a/src/plugins/flowperpkt/flowperpkt_test.c +++ b/src/plugins/flowperpkt/flowperpkt_test.c @@ -19,6 +19,7 @@ #include #include #include +#include /** * @file vpp_api_test plugin @@ -88,47 +89,9 @@ foreach_standard_reply_retval_handler; _(FLOWPERPKT_TX_INTERFACE_ADD_DEL_REPLY, \ flowperpkt_tx_interface_add_del_reply) - -/* M: construct, but don't yet send a message */ - -#define M(T,t) \ -do { \ - vam->result_ready = 0; \ - mp = vl_msg_api_alloc(sizeof(*mp)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \ - mp->client_index = vam->my_client_index; \ -} while(0); - -#define M2(T,t,n) \ -do { \ - vam->result_ready = 0; \ - mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \ - mp->client_index = vam->my_client_index; \ -} while(0); - -/* S: send a message */ -#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp)) - -/* W: wait for results, with timeout */ -#define W \ -do { \ - timeout = vat_time_now (vam) + 1.0; \ - \ - while (vat_time_now (vam) < timeout) { \ - if (vam->result_ready == 1) { \ - return (vam->retval); \ - } \ - } \ - return -99; \ -} while(0); - static int api_flowperpkt_tx_interface_add_del (vat_main_t * vam) { - flowperpkt_test_main_t *sm = &flowperpkt_test_main; unformat_input_t *i = vam->input; f64 timeout; int enable_disable = 1; @@ -177,8 +140,8 @@ api_flowperpkt_tx_interface_add_del (vat_main_t * vam) #define foreach_vpe_api_msg \ _(flowperpkt_tx_interface_add_del, " [disable]") -void -vat_api_hookup (vat_main_t * vam) +static void +flowperpkt_vat_api_hookup (vat_main_t * vam) { flowperpkt_test_main_t *sm = &flowperpkt_test_main; /* Hook up handlers for replies from the data plane plug-in */ @@ -218,7 +181,7 @@ vat_plugin_register (vat_main_t * vam) /* Don't attempt to hook up API messages if the data plane plugin is AWOL */ if (sm->msg_id_base != (u16) ~ 0) - vat_api_hookup (vam); + flowperpkt_vat_api_hookup (vam); vec_free (name); diff --git a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c index 494263d9..5b641cc7 100644 --- a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c +++ b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c @@ -23,7 +23,7 @@ #include #include #include - +#include /* Declare message IDs */ #include @@ -86,47 +86,9 @@ foreach_standard_reply_retval_handler; #define foreach_vpe_api_reply_msg \ _(VXLAN_GPE_IOAM_EXPORT_ENABLE_DISABLE_REPLY, vxlan_gpe_ioam_export_enable_disable_reply) - -/* M: construct, but don't yet send a message */ - -#define M(T,t) \ -do { \ - vam->result_ready = 0; \ - mp = vl_msg_api_alloc(sizeof(*mp)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \ - mp->client_index = vam->my_client_index; \ -} while(0); - -#define M2(T,t,n) \ -do { \ - vam->result_ready = 0; \ - mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \ - mp->client_index = vam->my_client_index; \ -} while(0); - -/* S: send a message */ -#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp)) - -/* W: wait for results, with timeout */ -#define W \ -do { \ - timeout = vat_time_now (vam) + 1.0; \ - \ - while (vat_time_now (vam) < timeout) { \ - if (vam->result_ready == 1) { \ - return (vam->retval); \ - } \ - } \ - return -99; \ -} while(0); - static int api_vxlan_gpe_ioam_export_enable_disable (vat_main_t * vam) { - export_test_main_t *sm = &export_test_main; unformat_input_t *i = vam->input; f64 timeout; int is_disable = 0; @@ -160,8 +122,8 @@ api_vxlan_gpe_ioam_export_enable_disable (vat_main_t * vam) #define foreach_vpe_api_msg \ _(vxlan_gpe_ioam_export_enable_disable, " [disable]") -void -vat_api_hookup (vat_main_t * vam) +static void +vxlan_gpe_ioam_vat_api_hookup (vat_main_t * vam) { export_test_main_t *sm = &export_test_main; /* Hook up handlers for replies from the data plane plug-in */ @@ -199,7 +161,7 @@ vat_plugin_register (vat_main_t * vam) sm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name); if (sm->msg_id_base != (u16) ~ 0) - vat_api_hookup (vam); + vxlan_gpe_ioam_vat_api_hookup (vam); vec_free (name); diff --git a/src/plugins/ioam/export/ioam_export_test.c b/src/plugins/ioam/export/ioam_export_test.c index f991fc0c..a4ec80d0 100644 --- a/src/plugins/ioam/export/ioam_export_test.c +++ b/src/plugins/ioam/export/ioam_export_test.c @@ -23,6 +23,7 @@ #include #include #include +#include /* Declare message IDs */ @@ -87,46 +88,9 @@ foreach_standard_reply_retval_handler; _(IOAM_EXPORT_IP6_ENABLE_DISABLE_REPLY, ioam_export_ip6_enable_disable_reply) -/* M: construct, but don't yet send a message */ - -#define M(T,t) \ -do { \ - vam->result_ready = 0; \ - mp = vl_msg_api_alloc(sizeof(*mp)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \ - mp->client_index = vam->my_client_index; \ -} while(0); - -#define M2(T,t,n) \ -do { \ - vam->result_ready = 0; \ - mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \ - mp->client_index = vam->my_client_index; \ -} while(0); - -/* S: send a message */ -#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp)) - -/* W: wait for results, with timeout */ -#define W \ -do { \ - timeout = vat_time_now (vam) + 1.0; \ - \ - while (vat_time_now (vam) < timeout) { \ - if (vam->result_ready == 1) { \ - return (vam->retval); \ - } \ - } \ - return -99; \ -} while(0); - static int api_ioam_export_ip6_enable_disable (vat_main_t * vam) { - export_test_main_t *sm = &export_test_main; unformat_input_t *i = vam->input; f64 timeout; int is_disable = 0; @@ -159,8 +123,8 @@ api_ioam_export_ip6_enable_disable (vat_main_t * vam) #define foreach_vpe_api_msg \ _(ioam_export_ip6_enable_disable, " [disable]") -void -vat_api_hookup (vat_main_t * vam) +static void +ioam_export_vat_api_hookup (vat_main_t * vam) { export_test_main_t *sm = &export_test_main; /* Hook up handlers for replies from the data plane plug-in */ @@ -198,7 +162,7 @@ vat_plugin_register (vat_main_t * vam) sm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name); if (sm->msg_id_base != (u16) ~ 0) - vat_api_hookup (vam); + ioam_export_vat_api_hookup (vam); vec_free (name); diff --git a/src/plugins/ioam/lib-pot/pot_test.c b/src/plugins/ioam/lib-pot/pot_test.c index 2e870238..9f9d0c99 100644 --- a/src/plugins/ioam/lib-pot/pot_test.c +++ b/src/plugins/ioam/lib-pot/pot_test.c @@ -23,6 +23,7 @@ #include #include #include +#include /* Declare message IDs */ #include @@ -118,48 +119,9 @@ _(POT_PROFILE_ACTIVATE_REPLY, pot_profile_activate_reply) \ _(POT_PROFILE_DEL_REPLY, pot_profile_del_reply) \ _(POT_PROFILE_SHOW_CONFIG_DETAILS, pot_profile_show_config_details) - -/* M: construct, but don't yet send a message */ - -#define M(T,t) \ -do { \ - vam->result_ready = 0; \ - mp = vl_msg_api_alloc(sizeof(*mp)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \ - mp->client_index = vam->my_client_index; \ -} while(0); - -#define M2(T,t,n) \ -do { \ - vam->result_ready = 0; \ - mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \ - mp->client_index = vam->my_client_index; \ -} while(0); - -/* S: send a message */ -#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp)) - -/* W: wait for results, with timeout */ -#define W \ -do { \ - timeout = vat_time_now (vam) + 1.0; \ - \ - while (vat_time_now (vam) < timeout) { \ - if (vam->result_ready == 1) { \ - return (vam->retval); \ - } \ - } \ - return -99; \ -} while(0); - - static int api_pot_profile_add (vat_main_t *vam) { #define MAX_BITS 64 - pot_test_main_t * sm = &pot_test_main; unformat_input_t *input = vam->input; vl_api_pot_profile_add_t *mp; u8 *name = NULL; @@ -234,7 +196,6 @@ OUT: static int api_pot_profile_activate (vat_main_t *vam) { #define MAX_BITS 64 - pot_test_main_t * sm = &pot_test_main; unformat_input_t *input = vam->input; vl_api_pot_profile_activate_t *mp; u8 *name = NULL; @@ -275,7 +236,6 @@ OUT: static int api_pot_profile_del (vat_main_t *vam) { - pot_test_main_t * sm = &pot_test_main; vl_api_pot_profile_del_t *mp; f64 timeout; @@ -287,7 +247,6 @@ static int api_pot_profile_del (vat_main_t *vam) static int api_pot_profile_show_config_dump (vat_main_t *vam) { - pot_test_main_t * sm = &pot_test_main; unformat_input_t *input = vam->input; vl_api_pot_profile_show_config_dump_t *mp; f64 timeout; @@ -320,7 +279,8 @@ _(pot_profile_activate, "name id [0-1] ") \ _(pot_profile_del, "[id ]") \ _(pot_profile_show_config_dump, "id [0-1]") -void vat_api_hookup (vat_main_t *vam) +static void +pot_vat_api_hookup (vat_main_t *vam) { pot_test_main_t * sm = &pot_test_main; /* Hook up handlers for replies from the data plane plug-in */ @@ -357,7 +317,7 @@ clib_error_t * vat_plugin_register (vat_main_t *vam) sm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name); if (sm->msg_id_base != (u16) ~0) - vat_api_hookup (vam); + pot_vat_api_hookup (vam); vec_free(name); diff --git a/src/plugins/ioam/lib-trace/trace_test.c b/src/plugins/ioam/lib-trace/trace_test.c index 111dd461..f4f1d4d5 100644 --- a/src/plugins/ioam/lib-trace/trace_test.c +++ b/src/plugins/ioam/lib-trace/trace_test.c @@ -23,6 +23,7 @@ #include #include #include +#include /* Declare message IDs */ #include @@ -115,48 +116,9 @@ _(TRACE_PROFILE_ADD_REPLY, trace_profile_add_reply) \ _(TRACE_PROFILE_DEL_REPLY, trace_profile_del_reply) \ _(TRACE_PROFILE_SHOW_CONFIG_REPLY, trace_profile_show_config_reply) - -/* M: construct, but don't yet send a message */ - -#define M(T,t) \ -do { \ - vam->result_ready = 0; \ - mp = vl_msg_api_alloc(sizeof(*mp)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \ - mp->client_index = vam->my_client_index; \ -} while(0); - -#define M2(T,t,n) \ -do { \ - vam->result_ready = 0; \ - mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \ - mp->client_index = vam->my_client_index; \ -} while(0); - -/* S: send a message */ -#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp)) - -/* W: wait for results, with timeout */ -#define W \ -do { \ - timeout = vat_time_now (vam) + 1.0; \ - \ - while (vat_time_now (vam) < timeout) { \ - if (vam->result_ready == 1) { \ - return (vam->retval); \ - } \ - } \ - return -99; \ -} while(0); - - static int api_trace_profile_add (vat_main_t * vam) { - trace_test_main_t *sm = &trace_test_main; unformat_input_t *input = vam->input; vl_api_trace_profile_add_t *mp; u8 trace_type = 0; @@ -204,7 +166,6 @@ api_trace_profile_add (vat_main_t * vam) static int api_trace_profile_del (vat_main_t * vam) { - trace_test_main_t *sm = &trace_test_main; vl_api_trace_profile_del_t *mp; f64 timeout; @@ -217,7 +178,6 @@ api_trace_profile_del (vat_main_t * vam) static int api_trace_profile_show_config (vat_main_t * vam) { - trace_test_main_t *sm = &trace_test_main; vl_api_trace_profile_show_config_t *mp; f64 timeout; M (TRACE_PROFILE_SHOW_CONFIG, trace_profile_show_config); @@ -237,8 +197,8 @@ _(trace_profile_del, "[id ]") \ _(trace_profile_show_config, "[id ]") -void -vat_api_hookup (vat_main_t * vam) +static void +ioam_trace_vat_api_hookup (vat_main_t * vam) { trace_test_main_t *sm = &trace_test_main; /* Hook up handlers for replies from the data plane plug-in */ @@ -276,7 +236,7 @@ vat_plugin_register (vat_main_t * vam) sm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name); if (sm->msg_id_base != (u16) ~ 0) - vat_api_hookup (vam); + ioam_trace_vat_api_hookup (vam); vec_free (name); diff --git a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c index b5fee724..7c4088ee 100644 --- a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c +++ b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c @@ -23,6 +23,7 @@ #include #include #include +#include /* Declare message IDs */ #include @@ -96,49 +97,9 @@ _(VXLAN_GPE_IOAM_VNI_DISABLE_REPLY, vxlan_gpe_ioam_vni_disable_reply) \ _(VXLAN_GPE_IOAM_TRANSIT_ENABLE_REPLY, vxlan_gpe_ioam_transit_enable_reply) \ _(VXLAN_GPE_IOAM_TRANSIT_DISABLE_REPLY, vxlan_gpe_ioam_transit_disable_reply) \ - -/* M: construct, but don't yet send a message */ - -#define M(T,t) \ -do { \ - vam->result_ready = 0; \ - mp = vl_msg_api_alloc(sizeof(*mp)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \ - mp->client_index = vam->my_client_index; \ -} while(0); - -#define M2(T,t,n) \ -do { \ - vam->result_ready = 0; \ - mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \ - mp->client_index = vam->my_client_index; \ -} while(0); - -/* S: send a message */ -#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp)) - -/* W: wait for results, with timeout */ -#define W \ -do { \ - timeout = vat_time_now (vam) + 1.0; \ - \ - while (vat_time_now (vam) < timeout) { \ - if (vam->result_ready == 1) { \ - return (vam->retval); \ - } \ - } \ - return -99; \ -} while(0); - - static int api_vxlan_gpe_ioam_enable (vat_main_t * vam) { - vxlan_gpe_test_main_t *sm = &vxlan_gpe_test_main; - unformat_input_t *input = vam->input; vl_api_vxlan_gpe_ioam_enable_t *mp; f64 timeout; @@ -179,7 +140,6 @@ api_vxlan_gpe_ioam_enable (vat_main_t * vam) static int api_vxlan_gpe_ioam_disable (vat_main_t * vam) { - vxlan_gpe_test_main_t *sm = &vxlan_gpe_test_main; vl_api_vxlan_gpe_ioam_disable_t *mp; f64 timeout; @@ -192,8 +152,6 @@ api_vxlan_gpe_ioam_disable (vat_main_t * vam) static int api_vxlan_gpe_ioam_vni_enable (vat_main_t * vam) { - vxlan_gpe_test_main_t *sm = &vxlan_gpe_test_main; - unformat_input_t *line_input = vam->input; vl_api_vxlan_gpe_ioam_vni_enable_t *mp; ip4_address_t local4, remote4; @@ -289,8 +247,6 @@ api_vxlan_gpe_ioam_vni_enable (vat_main_t * vam) static int api_vxlan_gpe_ioam_vni_disable (vat_main_t * vam) { - vxlan_gpe_test_main_t *sm = &vxlan_gpe_test_main; - unformat_input_t *line_input = vam->input; vl_api_vxlan_gpe_ioam_vni_disable_t *mp; ip4_address_t local4, remote4; @@ -386,8 +342,6 @@ api_vxlan_gpe_ioam_vni_disable (vat_main_t * vam) static int api_vxlan_gpe_ioam_transit_enable (vat_main_t * vam) { - vxlan_gpe_test_main_t *sm = &vxlan_gpe_test_main; - unformat_input_t *line_input = vam->input; vl_api_vxlan_gpe_ioam_transit_enable_t *mp; ip4_address_t local4; @@ -458,8 +412,6 @@ api_vxlan_gpe_ioam_transit_enable (vat_main_t * vam) static int api_vxlan_gpe_ioam_transit_disable (vat_main_t * vam) { - vxlan_gpe_test_main_t *sm = &vxlan_gpe_test_main; - unformat_input_t *line_input = vam->input; vl_api_vxlan_gpe_ioam_transit_disable_t *mp; ip4_address_t local4; @@ -545,8 +497,8 @@ _(vxlan_gpe_ioam_transit_disable, ""\ "dst-ip [outer-fib-index ]") \ -void -vat_api_hookup (vat_main_t * vam) +static void +vxlan_gpe_vat_api_hookup (vat_main_t * vam) { vxlan_gpe_test_main_t *sm = &vxlan_gpe_test_main; /* Hook up handlers for replies from the data plane plug-in */ @@ -584,7 +536,7 @@ vat_plugin_register (vat_main_t * vam) sm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name); if (sm->msg_id_base != (u16) ~ 0) - vat_api_hookup (vam); + vxlan_gpe_vat_api_hookup (vam); vec_free (name); diff --git a/src/plugins/lb/lb_test.c b/src/plugins/lb/lb_test.c index 8c2eaa91..7e3519a8 100644 --- a/src/plugins/lb/lb_test.c +++ b/src/plugins/lb/lb_test.c @@ -19,6 +19,7 @@ #include #include #include +#include //TODO: Move that to vat/plugin_api.c ////////////////////////// @@ -127,35 +128,8 @@ foreach_standard_reply_retval_handler; _(LB_ADD_DEL_VIP_REPLY, lb_add_del_vip_reply) \ _(LB_ADD_DEL_AS_REPLY, lb_add_del_as_reply) -/* M: construct, but don't yet send a message */ -#define M(T,t) \ -do { \ - vam->result_ready = 0; \ - mp = vl_msg_api_alloc(sizeof(*mp)); \ - memcpy (mp, &mps, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T + lbtm->msg_id_base); \ - mp->client_index = vam->my_client_index; \ -} while(0); - -/* S: send a message */ -#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp)) - -/* W: wait for results, with timeout */ -#define W \ -do { \ - timeout = vat_time_now (vam) + 1.0; \ - \ - while (vat_time_now (vam) < timeout) { \ - if (vam->result_ready == 1) { \ - return (vam->retval); \ - } \ - } \ - return -99; \ -} while(0); - static int api_lb_conf (vat_main_t * vam) { - lb_test_main_t *lbtm = &lb_test_main; unformat_input_t *i = vam->input; f64 timeout; vl_api_lb_conf_t mps, *mp; @@ -177,7 +151,6 @@ static int api_lb_conf (vat_main_t * vam) static int api_lb_add_del_vip (vat_main_t * vam) { - lb_test_main_t *lbtm = &lb_test_main; unformat_input_t * i = vam->input; f64 timeout; vl_api_lb_add_del_vip_t mps, *mp; @@ -215,7 +188,6 @@ static int api_lb_add_del_vip (vat_main_t * vam) static int api_lb_add_del_as (vat_main_t * vam) { - lb_test_main_t *lbtm = &lb_test_main; unformat_input_t * i = vam->input; f64 timeout; vl_api_lb_add_del_as_t mps, *mp; @@ -246,7 +218,8 @@ _(lb_conf, " [gre4|gre6] [del]") \ _(lb_add_del_as, "
[del]") -void vat_api_hookup (vat_main_t *vam) +static void +lb_vat_api_hookup (vat_main_t *vam) { lb_test_main_t * lbtm = &lb_test_main; /* Hook up handlers for replies from the data plane plug-in */ @@ -285,7 +258,7 @@ clib_error_t * vat_plugin_register (vat_main_t *vam) lbtm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name); if (lbtm->msg_id_base != (u16) ~0) - vat_api_hookup (vam); + lb_vat_api_hookup (vam); vec_free(name); diff --git a/src/plugins/snat/snat_test.c b/src/plugins/snat/snat_test.c index 013d7d9b..b601d7d9 100644 --- a/src/plugins/snat/snat_test.c +++ b/src/plugins/snat/snat_test.c @@ -21,6 +21,7 @@ #include #include #include +#include uword unformat_sw_if_index (unformat_input_t * input, va_list * args); @@ -103,44 +104,8 @@ _(SNAT_INTERFACE_ADDR_DETAILS, snat_interface_addr_details) \ _(SNAT_IPFIX_ENABLE_DISABLE_REPLY, \ snat_ipfix_enable_disable_reply) -/* M: construct, but don't yet send a message */ -#define M(T,t) \ -do { \ - vam->result_ready = 0; \ - mp = vl_msg_api_alloc(sizeof(*mp)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \ - mp->client_index = vam->my_client_index; \ -} while(0); - -#define M2(T,t,n) \ -do { \ - vam->result_ready = 0; \ - mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \ - mp->client_index = vam->my_client_index; \ -} while(0); - -/* S: send a message */ -#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp)) - -/* W: wait for results, with timeout */ -#define W \ -do { \ - timeout = vat_time_now (vam) + 1.0; \ - \ - while (vat_time_now (vam) < timeout) { \ - if (vam->result_ready == 1) { \ - return (vam->retval); \ - } \ - } \ - return -99; \ -} while(0); - static int api_snat_add_address_range (vat_main_t * vam) { - snat_test_main_t * sm = &snat_test_main; unformat_input_t * i = vam->input; f64 timeout; ip4_address_t start_addr, end_addr; @@ -200,7 +165,6 @@ static int api_snat_add_address_range (vat_main_t * vam) static int api_snat_interface_add_del_feature (vat_main_t * vam) { - snat_test_main_t * sm = &snat_test_main; unformat_input_t * i = vam->input; f64 timeout; vl_api_snat_interface_add_del_feature_t * mp; @@ -246,7 +210,6 @@ static int api_snat_interface_add_del_feature (vat_main_t * vam) static int api_snat_add_static_mapping(vat_main_t * vam) { - snat_test_main_t * sm = &snat_test_main; unformat_input_t * i = vam->input; f64 timeout; vl_api_snat_add_static_mapping_t * mp; @@ -338,7 +301,6 @@ static void vl_api_snat_static_mapping_details_t_handler static int api_snat_static_mapping_dump(vat_main_t * vam) { - snat_test_main_t * sm = &snat_test_main; f64 timeout; vl_api_snat_static_mapping_dump_t * mp; @@ -398,7 +360,6 @@ static void vl_api_snat_show_config_reply_t_handler static int api_snat_show_config(vat_main_t * vam) { - snat_test_main_t * sm = &snat_test_main; f64 timeout; vl_api_snat_show_config_t * mp; @@ -425,7 +386,6 @@ static void vl_api_snat_address_details_t_handler static int api_snat_address_dump(vat_main_t * vam) { - snat_test_main_t * sm = &snat_test_main; f64 timeout; vl_api_snat_address_dump_t * mp; @@ -460,7 +420,6 @@ static void vl_api_snat_interface_details_t_handler static int api_snat_interface_dump(vat_main_t * vam) { - snat_test_main_t * sm = &snat_test_main; f64 timeout; vl_api_snat_interface_dump_t * mp; @@ -485,7 +444,6 @@ static int api_snat_interface_dump(vat_main_t * vam) static int api_snat_set_workers (vat_main_t * vam) { - snat_test_main_t * sm = &snat_test_main; unformat_input_t * i = vam->input; f64 timeout; vl_api_snat_set_workers_t * mp; @@ -523,7 +481,6 @@ static void vl_api_snat_worker_details_t_handler static int api_snat_worker_dump(vat_main_t * vam) { - snat_test_main_t * sm = &snat_test_main; f64 timeout; vl_api_snat_worker_dump_t * mp; @@ -548,7 +505,6 @@ static int api_snat_worker_dump(vat_main_t * vam) static int api_snat_ipfix_enable_disable (vat_main_t * vam) { - snat_test_main_t * sm = &snat_test_main; unformat_input_t * i = vam->input; f64 timeout; vl_api_snat_add_del_interface_addr_t * mp; @@ -597,7 +553,6 @@ static void vl_api_snat_interface_addr_details_t_handler static int api_snat_interface_addr_dump(vat_main_t * vam) { - snat_test_main_t * sm = &snat_test_main; f64 timeout; vl_api_snat_interface_addr_dump_t * mp; @@ -622,7 +577,6 @@ static int api_snat_interface_addr_dump(vat_main_t * vam) static int api_snat_add_del_interface_addr (vat_main_t * vam) { - snat_test_main_t * sm = &snat_test_main; unformat_input_t * i = vam->input; f64 timeout; vl_api_snat_ipfix_enable_disable_t * mp; @@ -677,7 +631,8 @@ _(snat_interface_addr_dump, "") \ _(snat_ipfix_enable_disable, "[domain ] [src_port ] " \ "[disable]") -void vat_api_hookup (vat_main_t *vam) +static void +snat_vat_api_hookup (vat_main_t *vam) { snat_test_main_t * sm __attribute__((unused)) = &snat_test_main; /* Hook up handlers for replies from the data plane plug-in */ @@ -693,7 +648,9 @@ void vat_api_hookup (vat_main_t *vam) #undef _ /* API messages we can send */ -#define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n); +#define _(n,h) \ + hash_set_mem (vam->function_by_name, #n, api_##n); \ + clib_warning ("vam %llx add '%s' handler %llx", vam, #n, api_##n); foreach_vpe_api_msg; #undef _ @@ -715,7 +672,7 @@ clib_error_t * vat_plugin_register (vat_main_t *vam) sm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name); if (sm->msg_id_base != (u16) ~0) - vat_api_hookup (vam); + snat_vat_api_hookup (vam); vec_free(name); diff --git a/src/vat/api_format.c b/src/vat/api_format.c index 1babaf40..653cf79f 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -70,6 +70,46 @@ #include #undef vl_printfun +#include + +f64 +vat_time_now (vat_main_t * vam) +{ +#if VPP_API_TEST_BUILTIN + return vlib_time_now (vam->vlib_main); +#else + return clib_time_now (&vam->clib_time); +#endif +} + +void +errmsg (char *fmt, ...) +{ + vat_main_t *vam = &vat_main; + va_list va; + u8 *s; + + va_start (va, fmt); + s = va_format (0, fmt, &va); + va_end (va); + + vec_add1 (s, 0); + +#if VPP_API_TEST_BUILTIN + vlib_cli_output (vam->vlib_main, (char *) s); +#else + { + if (vam->ifp != stdin) + fformat (vam->ofp, "%s(%d): \n", vam->current_file, + vam->input_line_number); + fformat (vam->ofp, (char *) s); + fflush (vam->ofp); + } +#endif + + vec_free (s); +} + static uword api_unformat_sw_if_index (unformat_input_t * input, va_list * args) { @@ -88,8 +128,6 @@ api_unformat_sw_if_index (unformat_input_t * input, va_list * args) return 1; } -void vat_suspend (vlib_main_t * vm, f64 interval); - #if VPP_API_TEST_BUILTIN == 0 /* Parse an IP4 address %d.%d.%d.%d. */ uword @@ -3867,59 +3905,6 @@ _(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \ sw_interface_set_dpdk_hqos_tctbl_reply) #endif -/* M: construct, but don't yet send a message */ - -#define M(T,t) \ -do { \ - vam->result_ready = 0; \ - mp = vl_msg_api_alloc_as_if_client(sizeof(*mp)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T); \ - mp->client_index = vam->my_client_index; \ -} while(0); - -#define M2(T,t,n) \ -do { \ - vam->result_ready = 0; \ - mp = vl_msg_api_alloc_as_if_client(sizeof(*mp)+(n)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T); \ - mp->client_index = vam->my_client_index; \ -} while(0); - - -/* S: send a message */ -#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp)) - -/* W: wait for results, with timeout */ -#define W \ -do { \ - timeout = vat_time_now (vam) + 1.0; \ - \ - while (vat_time_now (vam) < timeout) { \ - if (vam->result_ready == 1) { \ - return (vam->retval); \ - } \ - vat_suspend (vam->vlib_main, 1e-3); \ - } \ - 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); \ - } \ - vat_suspend (vam->vlib_main, 1e-3); \ - } \ - return -99; \ -} while(0); - typedef struct { u8 *name; diff --git a/src/vat/vat.h b/src/vat/vat.h index 64be2f7f..3d7d96ae 100644 --- a/src/vat/vat.h +++ b/src/vat/vat.h @@ -190,36 +190,11 @@ typedef struct vlib_main_t *vlib_main; } vat_main_t; -vat_main_t vat_main; - -static inline f64 -vat_time_now (vat_main_t * vam) -{ -#if VPP_API_TEST_BUILTIN - return vlib_time_now (vam->vlib_main); -#else - return clib_time_now (&vam->clib_time); -#endif -} - -#if VPP_API_TEST_BUILTIN -#define errmsg(fmt,args...) \ -do { \ - vat_main_t *__vam = &vat_main; \ - vlib_cli_output (__vam->vlib_main, fmt, ##args); \ - } while(0); -#else -#define errmsg(fmt,args...) \ -do { \ - vat_main_t *__vam = &vat_main; \ - if(__vam->ifp != stdin) \ - fformat(__vam->ofp,"%s(%d): \n", __vam->current_file, \ - __vam->input_line_number); \ - fformat(__vam->ofp, fmt "\n", ##args); \ - fflush(__vam->ofp); \ -} while(0); -#endif +extern vat_main_t vat_main; +void vat_suspend (vlib_main_t * vm, f64 interval); +f64 vat_time_now (vat_main_t * vam); +void errmsg (char *fmt, ...); void vat_api_hookup (vat_main_t * vam); int api_sw_interface_dump (vat_main_t * vam); void do_one_file (vat_main_t * vam); diff --git a/src/vlib/unix/plugin.c b/src/vlib/unix/plugin.c index 987f7d05..40399090 100644 --- a/src/vlib/unix/plugin.c +++ b/src/vlib/unix/plugin.c @@ -264,10 +264,15 @@ vlib_plugins_show_cmd_fn (vlib_main_t * vm, return 0; } +/* *INDENT-OFF* */ VLIB_CLI_COMMAND (plugins_show_cmd, static) = { -.path = "show plugins",.short_help = "show loaded plugins",.function = - vlib_plugins_show_cmd_fn,}; + .path = "show plugins", + .short_help = "show loaded plugins", + .function = vlib_plugins_show_cmd_fn, +}; +/* *INDENT-ON* */ + /* * fd.io coding-style-patch-verification: ON * diff --git a/src/vlibapi/api_helper_macros.h b/src/vlibapi/api_helper_macros.h index 16f34cfc..7f94e446 100644 --- a/src/vlibapi/api_helper_macros.h +++ b/src/vlibapi/api_helper_macros.h @@ -17,7 +17,6 @@ *------------------------------------------------------------------ */ - #ifndef __api_helper_macros_h__ #define __api_helper_macros_h__ diff --git a/src/vlibapi/vat_helper_macros.h b/src/vlibapi/vat_helper_macros.h new file mode 100644 index 00000000..7199364a --- /dev/null +++ b/src/vlibapi/vat_helper_macros.h @@ -0,0 +1,76 @@ +/* + *------------------------------------------------------------------ + * vat_helper_macros.h - collect api client helper macros in one place + * + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------ + */ +#ifndef __vat_helper_macros_h__ +#define __vat_helper_macros_h__ + +/* M: construct, but don't yet send a message */ + +#define M(T,t) \ +do { \ + vam->result_ready = 0; \ + mp = vl_msg_api_alloc_as_if_client(sizeof(*mp)); \ + memset (mp, 0, sizeof (*mp)); \ + mp->_vl_msg_id = ntohs (VL_API_##T); \ + mp->client_index = vam->my_client_index; \ +} while(0); + +#define M2(T,t,n) \ +do { \ + vam->result_ready = 0; \ + mp = vl_msg_api_alloc_as_if_client(sizeof(*mp)+(n)); \ + memset (mp, 0, sizeof (*mp)); \ + mp->_vl_msg_id = ntohs (VL_API_##T); \ + mp->client_index = vam->my_client_index; \ +} while(0); + + +/* S: send a message */ +#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp)) + +/* W: wait for results, with timeout */ +#define W \ +do { \ + timeout = vat_time_now (vam) + 1.0; \ + \ + while (vat_time_now (vam) < timeout) { \ + if (vam->result_ready == 1) { \ + return (vam->retval); \ + } \ + vat_suspend (vam->vlib_main, 1e-5); \ + } \ + 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); \ + } \ + vat_suspend (vam->vlib_main, 1e-5); \ + } \ + return -99; \ +} while(0); + + +#endif /* __vat_helper_macros_h__ */ diff --git a/src/vpp-api-test.am b/src/vpp-api-test.am index 32610056..f0d5df62 100644 --- a/src/vpp-api-test.am +++ b/src/vpp-api-test.am @@ -44,7 +44,10 @@ vpp_api_test_LDADD = \ libvnet.la \ -lpthread -lm -lrt -ldl -lcrypto +vpp_api_test_LDFLAGS = -Wl,--export-dynamic + vpp_json_test_LDADD = libvppinfra.la -lm +vpp_json_test_LDFLAGS = -Wl,--export-dynamic nobase_include_HEADERS += \ vat/vat.h \ diff --git a/src/vpp.am b/src/vpp.am index 425f1e32..0b605ec5 100644 --- a/src/vpp.am +++ b/src/vpp.am @@ -28,7 +28,9 @@ bin_vpp_SOURCES += \ if WITH_APICLI bin_vpp_SOURCES += \ vpp/api/api_format.c \ - vpp/api/api_main.c + vpp/api/api_main.c \ + vpp/api/plugin.c \ + vpp/api/plugin.h endif # comment out to disable stats upload to gmond @@ -78,6 +80,8 @@ bin_vpp_LDADD = \ libvppinfra.la \ -lrt -lm -lpthread -ldl +bin_vpp_LDFLAGS = -Wl,--export-dynamic + if ENABLE_TESTS noinst_PROGRAMS += bin/test_client diff --git a/src/vpp/api/api_main.c b/src/vpp/api/api_main.c index fd6998f4..7bf7e8b7 100644 --- a/src/vpp/api/api_main.c +++ b/src/vpp/api/api_main.c @@ -42,11 +42,17 @@ static clib_error_t * api_main_init (vlib_main_t * vm) { vat_main_t *vam = &vat_main; + int rv; + int vat_plugin_init (vat_main_t * vam); vam->vlib_main = vm; vam->my_client_index = (u32) ~ 0; init_error_string_table (vam); vat_api_hookup (vam); + clib_warning ("vam %llx", vam); + rv = vat_plugin_init (vam); + if (rv) + clib_warning ("vat_plugin_init returned %d", rv); return 0; } @@ -183,6 +189,39 @@ api_cli_output (void *notused, const char *fmt, ...) vec_free (s); } +u16 +vl_client_get_first_plugin_msg_id (char *plugin_name) +{ + api_main_t *am = &api_main; + vl_api_msg_range_t *rp; + uword *p; + + p = hash_get_mem (am->msg_range_by_name, plugin_name); + if (p == 0) + return ~0; + + rp = vec_elt_at_index (am->msg_ranges, p[0]); + + return (rp->first_msg_id); +} + +uword +unformat_sw_if_index (unformat_input_t * input, va_list * args) +{ + u32 *result = va_arg (*args, u32 *); + vnet_main_t *vnm = vnet_get_main (); + u32 sw_if_index = ~0; + u8 *if_name; + uword *p; + + if (unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index)) + { + *result = sw_if_index; + return 1; + } + return 0; +} + /* * fd.io coding-style-patch-verification: ON * diff --git a/src/vpp/api/plugin.c b/src/vpp/api/plugin.c new file mode 100644 index 00000000..c1cc928c --- /dev/null +++ b/src/vpp/api/plugin.c @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * plugin.c: plugin handling + */ + +#include +#include +#include +#include + +plugin_main_t vat_plugin_main; + +static int +load_one_plugin (plugin_main_t * pm, plugin_info_t * pi) +{ + void *handle, *register_handle; + clib_error_t *(*fp) (vat_main_t *); + clib_error_t *error; + + handle = dlopen ((char *) pi->name, RTLD_LAZY); + + /* + * Note: this can happen if the plugin has an undefined symbol reference, + * so print a warning. Otherwise, the poor slob won't know what happened. + * Ask me how I know that... + */ + if (handle == 0) + { + clib_warning ("%s", dlerror ()); + return -1; + } + + pi->handle = handle; + + register_handle = dlsym (pi->handle, "vat_plugin_register"); + if (register_handle == 0) + return 0; + + fp = register_handle; + + error = (*fp) (pm->vat_main); + + if (error) + { + clib_error_report (error); + dlclose (handle); + return 1; + } + + clib_warning ("Loaded plugin: %s", pi->name); + + return 0; +} + +static u8 ** +split_plugin_path (plugin_main_t * pm) +{ + int i; + u8 **rv = 0; + u8 *path = pm->plugin_path; + u8 *this = 0; + + for (i = 0; i < vec_len (pm->plugin_path); i++) + { + if (path[i] != ':') + { + vec_add1 (this, path[i]); + continue; + } + vec_add1 (this, 0); + vec_add1 (rv, this); + this = 0; + } + if (this) + { + vec_add1 (this, 0); + vec_add1 (rv, this); + } + return rv; +} + +int +vat_load_new_plugins (plugin_main_t * pm) +{ + DIR *dp; + struct dirent *entry; + struct stat statb; + uword *p; + plugin_info_t *pi; + u8 **plugin_path; + int i; + + plugin_path = split_plugin_path (pm); + + for (i = 0; i < vec_len (plugin_path); i++) + { + dp = opendir ((char *) plugin_path[i]); + + if (dp == 0) + continue; + + while ((entry = readdir (dp))) + { + u8 *plugin_name; + + if (pm->plugin_name_filter) + { + int j; + for (j = 0; j < vec_len (pm->plugin_name_filter); j++) + if (entry->d_name[j] != pm->plugin_name_filter[j]) + goto next; + } + + plugin_name = format (0, "%s/%s%c", plugin_path[i], + entry->d_name, 0); + + /* unreadable */ + if (stat ((char *) plugin_name, &statb) < 0) + { + ignore: + vec_free (plugin_name); + continue; + } + + /* a dir or other things which aren't plugins */ + if (!S_ISREG (statb.st_mode)) + goto ignore; + + p = hash_get_mem (pm->plugin_by_name_hash, plugin_name); + if (p == 0) + { + vec_add2 (pm->plugin_info, pi, 1); + pi->name = plugin_name; + pi->file_info = statb; + + if (load_one_plugin (pm, pi)) + { + vec_free (plugin_name); + _vec_len (pm->plugin_info) = vec_len (pm->plugin_info) - 1; + continue; + } + memset (pi, 0, sizeof (*pi)); + hash_set_mem (pm->plugin_by_name_hash, plugin_name, + pi - pm->plugin_info); + } + next: + ; + } + closedir (dp); + vec_free (plugin_path[i]); + } + vec_free (plugin_path); + return 0; +} + +#define QUOTE_(x) #x +#define QUOTE(x) QUOTE_(x) + +/* + * Load plugins from /usr/lib/vpp_api_test_plugins by default + */ +char *vat_plugin_path = "/usr/lib/vpp_api_test_plugins"; + +char *vat_plugin_name_filter = 0; + +int +vat_plugin_init (vat_main_t * vam) +{ + plugin_main_t *pm = &vat_plugin_main; + + + pm->plugin_path = format (0, "%s%c", vat_plugin_path, 0); + if (vat_plugin_name_filter) + pm->plugin_name_filter = format (0, "%s%c", vat_plugin_name_filter, 0); + + pm->plugin_by_name_hash = hash_create_string (0, sizeof (uword)); + pm->vat_main = vam; + + return vat_load_new_plugins (pm); +} + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/src/vpp/api/plugin.h b/src/vpp/api/plugin.h new file mode 100644 index 00000000..559ec52f --- /dev/null +++ b/src/vpp/api/plugin.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * plugin.h: plugin handling + */ + +#ifndef __included_plugin_h__ +#define __included_plugin_h__ + +#include +#include +#include + +typedef struct +{ + u8 *name; + struct stat file_info; + void *handle; +} plugin_info_t; + +typedef struct +{ + /* loaded plugin info */ + plugin_info_t *plugin_info; + uword *plugin_by_name_hash; + + /* path and name filter */ + u8 *plugin_path; + u8 *plugin_name_filter; + + /* convenience */ + vat_main_t *vat_main; + +} plugin_main_t; + +plugin_main_t vat_plugin_main; + +int vat_plugin_init (vat_main_t * vam); +int vat_load_new_plugins (plugin_main_t * pm); + +#endif + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ -- cgit 1.2.3-korg From 2d6b2d6d1bbb130921ec525a1cc6e88f42717c79 Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Wed, 25 Jan 2017 16:32:08 -0500 Subject: Repair plugin binary API message numbering Change-Id: I422a3f168bd483e011cfaf54af022cb79b78db02 Signed-off-by: Dave Barach --- src/examples/sample-plugin/sample/sample_test.c | 2 ++ src/plugins/acl/acl_test.c | 2 ++ src/plugins/flowperpkt/flowperpkt_test.c | 2 ++ .../ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c | 2 ++ src/plugins/ioam/export/ioam_export_test.c | 2 ++ src/plugins/ioam/lib-pot/pot_test.c | 2 ++ src/plugins/ioam/lib-trace/trace_test.c | 2 ++ src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c | 2 ++ src/plugins/lb/lb_test.c | 2 ++ src/plugins/snat/snat_test.c | 2 ++ src/vat/api_format.c | 1 + src/vlibapi/vat_helper_macros.h | 18 ++++++++---------- 12 files changed, 29 insertions(+), 10 deletions(-) (limited to 'src/plugins/lb') diff --git a/src/examples/sample-plugin/sample/sample_test.c b/src/examples/sample-plugin/sample/sample_test.c index a47710ee..2308e8f4 100644 --- a/src/examples/sample-plugin/sample/sample_test.c +++ b/src/examples/sample-plugin/sample/sample_test.c @@ -23,6 +23,8 @@ #include #include #include + +#define __plugin_msg_base sample_test_main.msg_id_base #include uword unformat_sw_if_index (unformat_input_t * input, va_list * args); diff --git a/src/plugins/acl/acl_test.c b/src/plugins/acl/acl_test.c index 5cacf716..4ea6bcc8 100644 --- a/src/plugins/acl/acl_test.c +++ b/src/plugins/acl/acl_test.c @@ -25,6 +25,8 @@ #include #include #include + +#define __plugin_msg_base acl_test_main.msg_id_base #include uword unformat_sw_if_index (unformat_input_t * input, va_list * args); diff --git a/src/plugins/flowperpkt/flowperpkt_test.c b/src/plugins/flowperpkt/flowperpkt_test.c index 9211ebe3..4dcfdf05 100644 --- a/src/plugins/flowperpkt/flowperpkt_test.c +++ b/src/plugins/flowperpkt/flowperpkt_test.c @@ -19,6 +19,8 @@ #include #include #include + +#define __plugin_msg_base flowperpkt_test_main.msg_id_base #include /** diff --git a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c index 5b641cc7..d35bf399 100644 --- a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c +++ b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c @@ -23,6 +23,8 @@ #include #include #include + +#define __plugin_msg_base export_test_main.msg_id_base #include /* Declare message IDs */ diff --git a/src/plugins/ioam/export/ioam_export_test.c b/src/plugins/ioam/export/ioam_export_test.c index a4ec80d0..8bfee583 100644 --- a/src/plugins/ioam/export/ioam_export_test.c +++ b/src/plugins/ioam/export/ioam_export_test.c @@ -23,6 +23,8 @@ #include #include #include + +#define __plugin_msg_base export_test_main.msg_id_base #include diff --git a/src/plugins/ioam/lib-pot/pot_test.c b/src/plugins/ioam/lib-pot/pot_test.c index 9f9d0c99..deeb563c 100644 --- a/src/plugins/ioam/lib-pot/pot_test.c +++ b/src/plugins/ioam/lib-pot/pot_test.c @@ -23,6 +23,8 @@ #include #include #include + +#define __plugin_msg_base pot_test_main.msg_id_base #include /* Declare message IDs */ diff --git a/src/plugins/ioam/lib-trace/trace_test.c b/src/plugins/ioam/lib-trace/trace_test.c index f4f1d4d5..0ccb675e 100644 --- a/src/plugins/ioam/lib-trace/trace_test.c +++ b/src/plugins/ioam/lib-trace/trace_test.c @@ -23,6 +23,8 @@ #include #include #include + +#define __plugin_msg_base trace_test_main.msg_id_base #include /* Declare message IDs */ diff --git a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c index 7c4088ee..0748c5b7 100644 --- a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c +++ b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c @@ -23,6 +23,8 @@ #include #include #include + +#define __plugin_msg_base vxlan_gpe_test_main.msg_id_base #include /* Declare message IDs */ diff --git a/src/plugins/lb/lb_test.c b/src/plugins/lb/lb_test.c index 7e3519a8..9d55e4a7 100644 --- a/src/plugins/lb/lb_test.c +++ b/src/plugins/lb/lb_test.c @@ -19,6 +19,8 @@ #include #include #include + +#define __plugin_msg_base lb_test_main.msg_id_base #include //TODO: Move that to vat/plugin_api.c diff --git a/src/plugins/snat/snat_test.c b/src/plugins/snat/snat_test.c index 67dc4380..db53470c 100644 --- a/src/plugins/snat/snat_test.c +++ b/src/plugins/snat/snat_test.c @@ -21,6 +21,8 @@ #include #include #include + +#define __plugin_msg_base snat_test_main.msg_id_base #include uword unformat_sw_if_index (unformat_input_t * input, va_list * args); diff --git a/src/vat/api_format.c b/src/vat/api_format.c index 839bcdaa..b83313de 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -70,6 +70,7 @@ #include #undef vl_printfun +#define __plugin_msg_base 0 #include f64 diff --git a/src/vlibapi/vat_helper_macros.h b/src/vlibapi/vat_helper_macros.h index 7199364a..dc91c9f5 100644 --- a/src/vlibapi/vat_helper_macros.h +++ b/src/vlibapi/vat_helper_macros.h @@ -20,14 +20,13 @@ #define __vat_helper_macros_h__ /* M: construct, but don't yet send a message */ - -#define M(T,t) \ -do { \ - vam->result_ready = 0; \ - mp = vl_msg_api_alloc_as_if_client(sizeof(*mp)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T); \ - mp->client_index = vam->my_client_index; \ +#define M(T,t) \ +do { \ + vam->result_ready = 0; \ + mp = vl_msg_api_alloc_as_if_client(sizeof(*mp)); \ + memset (mp, 0, sizeof (*mp)); \ + mp->_vl_msg_id = ntohs (VL_API_##T+__plugin_msg_base); \ + mp->client_index = vam->my_client_index; \ } while(0); #define M2(T,t,n) \ @@ -35,11 +34,10 @@ do { \ vam->result_ready = 0; \ mp = vl_msg_api_alloc_as_if_client(sizeof(*mp)+(n)); \ memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T); \ + mp->_vl_msg_id = ntohs (VL_API_##T+__plugin_msg_base); \ mp->client_index = vam->my_client_index; \ } while(0); - /* S: send a message */ #define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp)) -- cgit 1.2.3-korg From 8a2aea3fce9dad7c729c82ee39ce95b4f357bc83 Mon Sep 17 00:00:00 2001 From: Jon Loeliger Date: Tue, 31 Jan 2017 13:19:40 -0600 Subject: Ensure all M() and M2() second parameters are the message pointer. Rather than maintain (?) an unused second parameter, t, and pull an unbound message pointer, mp, out of context, explicitly list the message pointer as the second parameter. Change-Id: I92143efda6211cdf6b935470f8c71579742a6b64 Signed-off-by: Jon Loeliger --- build-root/emacs-lisp/plugin-test-skel.el | 2 +- src/examples/sample-plugin/sample/sample_test.c | 2 +- src/plugins/acl/acl_test.c | 16 +- src/plugins/flowperpkt/flowperpkt_test.c | 2 +- .../export-vxlan-gpe/vxlan_gpe_ioam_export_test.c | 3 +- src/plugins/ioam/export/ioam_export_test.c | 2 +- src/plugins/ioam/lib-pot/pot_test.c | 8 +- src/plugins/ioam/lib-trace/trace_test.c | 6 +- src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c | 12 +- src/plugins/lb/lb_test.c | 12 +- src/plugins/snat/snat_test.c | 34 +- src/vat/api_format.c | 470 ++++++++++----------- 12 files changed, 285 insertions(+), 284 deletions(-) (limited to 'src/plugins/lb') diff --git a/build-root/emacs-lisp/plugin-test-skel.el b/build-root/emacs-lisp/plugin-test-skel.el index 5231a236..23f792fa 100644 --- a/build-root/emacs-lisp/plugin-test-skel.el +++ b/build-root/emacs-lisp/plugin-test-skel.el @@ -170,7 +170,7 @@ static int api_" plugin-name "_enable_disable (vat_main_t * vam) } /* Construct the API message */ - M(" PLUGIN-NAME "_ENABLE_DISABLE, " plugin-name "_enable_disable); + M(" PLUGIN-NAME "_ENABLE_DISABLE, mp); mp->sw_if_index = ntohl (sw_if_index); mp->enable_disable = enable_disable; diff --git a/src/examples/sample-plugin/sample/sample_test.c b/src/examples/sample-plugin/sample/sample_test.c index 2308e8f4..5dcee809 100644 --- a/src/examples/sample-plugin/sample/sample_test.c +++ b/src/examples/sample-plugin/sample/sample_test.c @@ -117,7 +117,7 @@ static int api_sample_macswap_enable_disable (vat_main_t * vam) } /* Construct the API message */ - M(SAMPLE_MACSWAP_ENABLE_DISABLE, sample_macswap_enable_disable); + M(SAMPLE_MACSWAP_ENABLE_DISABLE, mp); mp->sw_if_index = ntohl (sw_if_index); mp->enable_disable = enable_disable; diff --git a/src/plugins/acl/acl_test.c b/src/plugins/acl/acl_test.c index 4ea6bcc8..04683a12 100644 --- a/src/plugins/acl/acl_test.c +++ b/src/plugins/acl/acl_test.c @@ -498,7 +498,7 @@ static int api_acl_del (vat_main_t * vam) } /* Construct the API message */ - M(ACL_DEL, acl_del); + M(ACL_DEL, mp); mp->acl_index = ntohl(acl_index); /* send it... */ @@ -521,7 +521,7 @@ static int api_macip_acl_del (vat_main_t * vam) } /* Construct the API message */ - M(MACIP_ACL_DEL, acl_del); + M(MACIP_ACL_DEL, mp); mp->acl_index = ntohl(acl_index); /* send it... */ @@ -585,7 +585,7 @@ static int api_acl_interface_add_del (vat_main_t * vam) /* Construct the API message */ - M(ACL_INTERFACE_ADD_DEL, acl_interface_add_del); + M(ACL_INTERFACE_ADD_DEL, mp); mp->acl_index = ntohl(acl_index); mp->sw_if_index = ntohl(sw_if_index); mp->is_add = is_add; @@ -636,7 +636,7 @@ static int api_macip_acl_interface_add_del (vat_main_t * vam) /* Construct the API message */ - M(MACIP_ACL_INTERFACE_ADD_DEL, macip_acl_interface_add_del); + M(MACIP_ACL_INTERFACE_ADD_DEL, mp); mp->acl_index = ntohl(acl_index); mp->sw_if_index = ntohl(sw_if_index); mp->is_add = is_add; @@ -690,7 +690,7 @@ static int api_acl_interface_set_acl_list (vat_main_t * vam) } /* Construct the API message */ - M2(ACL_INTERFACE_SET_ACL_LIST, acl_interface_set_acl_list, sizeof(u32) * (vec_len(inacls) + vec_len(outacls))); + M2(ACL_INTERFACE_SET_ACL_LIST, mp, sizeof(u32) * (vec_len(inacls) + vec_len(outacls))); mp->sw_if_index = ntohl(sw_if_index); mp->n_input = vec_len(inacls); mp->count = vec_len(inacls) + vec_len(outacls); @@ -724,7 +724,7 @@ static int api_acl_interface_list_dump (vat_main_t * vam) } /* Construct the API message */ - M(ACL_INTERFACE_LIST_DUMP, acl_interface_list_dump); + M(ACL_INTERFACE_LIST_DUMP, mp); mp->sw_if_index = ntohl (sw_if_index); /* send it... */ @@ -750,7 +750,7 @@ static int api_acl_dump (vat_main_t * vam) } /* Construct the API message */ - M(ACL_DUMP, acl_dump); + M(ACL_DUMP, mp); mp->acl_index = ntohl (acl_index); /* send it... */ @@ -776,7 +776,7 @@ static int api_macip_acl_dump (vat_main_t * vam) } /* Construct the API message */ - M(MACIP_ACL_DUMP, macip_acl_dump); + M(MACIP_ACL_DUMP, mp); mp->acl_index = ntohl (acl_index); /* send it... */ diff --git a/src/plugins/flowperpkt/flowperpkt_test.c b/src/plugins/flowperpkt/flowperpkt_test.c index 4dcfdf05..70b4a34a 100644 --- a/src/plugins/flowperpkt/flowperpkt_test.c +++ b/src/plugins/flowperpkt/flowperpkt_test.c @@ -123,7 +123,7 @@ api_flowperpkt_tx_interface_add_del (vat_main_t * vam) } /* Construct the API message */ - M (FLOWPERPKT_TX_INTERFACE_ADD_DEL, flowperpkt_tx_interface_add_del); + M (FLOWPERPKT_TX_INTERFACE_ADD_DEL, mp); mp->sw_if_index = ntohl (sw_if_index); mp->is_add = enable_disable; mp->which = which; diff --git a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c index d35bf399..b9f61d9a 100644 --- a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c +++ b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c @@ -106,8 +106,7 @@ api_vxlan_gpe_ioam_export_enable_disable (vat_main_t * vam) } /* Construct the API message */ - M (VXLAN_GPE_IOAM_EXPORT_ENABLE_DISABLE, - vxlan_gpe_ioam_export_enable_disable); + M (VXLAN_GPE_IOAM_EXPORT_ENABLE_DISABLE, mp); mp->is_disable = is_disable; /* send it... */ diff --git a/src/plugins/ioam/export/ioam_export_test.c b/src/plugins/ioam/export/ioam_export_test.c index 8bfee583..b9686058 100644 --- a/src/plugins/ioam/export/ioam_export_test.c +++ b/src/plugins/ioam/export/ioam_export_test.c @@ -108,7 +108,7 @@ api_ioam_export_ip6_enable_disable (vat_main_t * vam) } /* Construct the API message */ - M (IOAM_EXPORT_IP6_ENABLE_DISABLE, ioam_export_ip6_enable_disable); + M(IOAM_EXPORT_IP6_ENABLE_DISABLE, mp); mp->is_disable = is_disable; /* send it... */ diff --git a/src/plugins/ioam/lib-pot/pot_test.c b/src/plugins/ioam/lib-pot/pot_test.c index deeb563c..48d5bd40 100644 --- a/src/plugins/ioam/lib-pot/pot_test.c +++ b/src/plugins/ioam/lib-pot/pot_test.c @@ -168,7 +168,7 @@ static int api_pot_profile_add (vat_main_t *vam) goto OUT; } - M2(POT_PROFILE_ADD, pot_profile_add, vec_len(name)); + M2(POT_PROFILE_ADD, mp, vec_len(name)); mp->list_name_len = vec_len(name); clib_memcpy(mp->list_name, name, mp->list_name_len); @@ -222,7 +222,7 @@ static int api_pot_profile_activate (vat_main_t *vam) goto OUT; } - M2(POT_PROFILE_ACTIVATE, pot_profile_activate, vec_len(name)); + M2(POT_PROFILE_ACTIVATE, mp, vec_len(name)); mp->list_name_len = vec_len(name); clib_memcpy(mp->list_name, name, mp->list_name_len); @@ -241,7 +241,7 @@ static int api_pot_profile_del (vat_main_t *vam) vl_api_pot_profile_del_t *mp; f64 timeout; - M(POT_PROFILE_DEL, pot_profile_del); + M(POT_PROFILE_DEL, mp); mp->list_name_len = 0; S; W; return 0; @@ -260,7 +260,7 @@ static int api_pot_profile_show_config_dump (vat_main_t *vam) else break; } - M(POT_PROFILE_SHOW_CONFIG_DUMP, pot_profile_show_config_dump); + M(POT_PROFILE_SHOW_CONFIG_DUMP, mp); mp->id = id; diff --git a/src/plugins/ioam/lib-trace/trace_test.c b/src/plugins/ioam/lib-trace/trace_test.c index 0ccb675e..a1354327 100644 --- a/src/plugins/ioam/lib-trace/trace_test.c +++ b/src/plugins/ioam/lib-trace/trace_test.c @@ -149,7 +149,7 @@ api_trace_profile_add (vat_main_t * vam) } - M (TRACE_PROFILE_ADD, trace_profile_add); + M (TRACE_PROFILE_ADD, mp); mp->trace_type = trace_type; mp->trace_tsp = trace_tsp; @@ -171,7 +171,7 @@ api_trace_profile_del (vat_main_t * vam) vl_api_trace_profile_del_t *mp; f64 timeout; - M (TRACE_PROFILE_DEL, trace_profile_del); + M (TRACE_PROFILE_DEL, mp); S; W; return 0; @@ -182,7 +182,7 @@ api_trace_profile_show_config (vat_main_t * vam) { vl_api_trace_profile_show_config_t *mp; f64 timeout; - M (TRACE_PROFILE_SHOW_CONFIG, trace_profile_show_config); + M (TRACE_PROFILE_SHOW_CONFIG, mp); S; W; return 0; diff --git a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c index 0748c5b7..5d36547f 100644 --- a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c +++ b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c @@ -125,7 +125,7 @@ api_vxlan_gpe_ioam_enable (vat_main_t * vam) else break; } - M (VXLAN_GPE_IOAM_ENABLE, vxlan_gpe_ioam_enable); + M (VXLAN_GPE_IOAM_ENABLE, mp); mp->id = htons (id); mp->trace_ppc = has_ppc_option; mp->pow_enable = has_pow_option; @@ -145,7 +145,7 @@ api_vxlan_gpe_ioam_disable (vat_main_t * vam) vl_api_vxlan_gpe_ioam_disable_t *mp; f64 timeout; - M (VXLAN_GPE_IOAM_DISABLE, vxlan_gpe_ioam_disable); + M (VXLAN_GPE_IOAM_DISABLE, mp); S; W; return 0; @@ -223,7 +223,7 @@ api_vxlan_gpe_ioam_vni_enable (vat_main_t * vam) return -99; } - M (VXLAN_GPE_IOAM_VNI_ENABLE, vxlan_gpe_ioam_vni_enable); + M (VXLAN_GPE_IOAM_VNI_ENABLE, mp); if (ipv6_set) @@ -318,7 +318,7 @@ api_vxlan_gpe_ioam_vni_disable (vat_main_t * vam) return -99; } - M (VXLAN_GPE_IOAM_VNI_DISABLE, vxlan_gpe_ioam_vni_disable); + M (VXLAN_GPE_IOAM_VNI_DISABLE, mp); if (ipv6_set) @@ -389,7 +389,7 @@ api_vxlan_gpe_ioam_transit_enable (vat_main_t * vam) } - M (VXLAN_GPE_IOAM_TRANSIT_ENABLE, vxlan_gpe_ioam_transit_enable); + M (VXLAN_GPE_IOAM_TRANSIT_ENABLE, mp); if (ipv6_set) @@ -459,7 +459,7 @@ api_vxlan_gpe_ioam_transit_disable (vat_main_t * vam) } - M (VXLAN_GPE_IOAM_TRANSIT_DISABLE, vxlan_gpe_ioam_transit_disable); + M (VXLAN_GPE_IOAM_TRANSIT_DISABLE, mp); if (ipv6_set) diff --git a/src/plugins/lb/lb_test.c b/src/plugins/lb/lb_test.c index 9d55e4a7..c150ea32 100644 --- a/src/plugins/lb/lb_test.c +++ b/src/plugins/lb/lb_test.c @@ -145,7 +145,9 @@ static int api_lb_conf (vat_main_t * vam) return -99; } - M(LB_CONF, lb_conf); S; W; + M(LB_CONF, mp); + S; + W; /* NOTREACHED */ return 0; @@ -183,7 +185,9 @@ static int api_lb_add_del_vip (vat_main_t * vam) mps.is_del = 1; } - M(LB_ADD_DEL_VIP, lb_add_del_vip); S; W; + M(LB_ADD_DEL_VIP, mp); + S; + W; /* NOTREACHED */ return 0; } @@ -206,7 +210,9 @@ static int api_lb_add_del_as (vat_main_t * vam) mps.is_del = 1; } - M(LB_ADD_DEL_AS, lb_add_del_as); S; W; + M(LB_ADD_DEL_AS, mp); + S; + W; /* NOTREACHED */ return 0; } diff --git a/src/plugins/snat/snat_test.c b/src/plugins/snat/snat_test.c index db53470c..c6f9a8ff 100644 --- a/src/plugins/snat/snat_test.c +++ b/src/plugins/snat/snat_test.c @@ -152,7 +152,7 @@ static int api_snat_add_address_range (vat_main_t * vam) count); } - M(SNAT_ADD_ADDRESS_RANGE, snat_add_address_range); + M(SNAT_ADD_ADDRESS_RANGE, mp); memcpy (mp->first_ip_address, &start_addr, 4); memcpy (mp->last_ip_address, &end_addr, 4); @@ -200,7 +200,7 @@ static int api_snat_interface_add_del_feature (vat_main_t * vam) return -99; } - M(SNAT_INTERFACE_ADD_DEL_FEATURE, snat_interface_add_del_feature); + M(SNAT_INTERFACE_ADD_DEL_FEATURE, mp); mp->sw_if_index = ntohl(sw_if_index); mp->is_add = is_add; mp->is_inside = is_inside; @@ -262,7 +262,7 @@ static int api_snat_add_static_mapping(vat_main_t * vam) return -99; } - M(SNAT_ADD_STATIC_MAPPING, snat_add_static_mapping); + M(SNAT_ADD_STATIC_MAPPING, mp); mp->is_add = is_add; mp->is_ip4 = 1; mp->addr_only = addr_only; @@ -330,12 +330,12 @@ static int api_snat_static_mapping_dump(vat_main_t * vam) fformat (vam->ofp, "%15s%6s%15s%6s%11s\n", "address", "port", "address", "port", "vrf"); - M(SNAT_STATIC_MAPPING_DUMP, snat_static_mapping_dump); + M(SNAT_STATIC_MAPPING_DUMP, mp); S; /* Use a control ping for synchronization */ { vl_api_snat_control_ping_t *mp; - M (SNAT_CONTROL_PING, snat_control_ping); + M(SNAT_CONTROL_PING, mp); S; } W; @@ -385,7 +385,7 @@ static int api_snat_show_config(vat_main_t * vam) return -99; } - M(SNAT_SHOW_CONFIG, snat_show_config); + M(SNAT_SHOW_CONFIG, mp); S; W; /* NOTREACHED */ return 0; @@ -411,12 +411,12 @@ static int api_snat_address_dump(vat_main_t * vam) return -99; } - M(SNAT_ADDRESS_DUMP, snat_address_dump); + M(SNAT_ADDRESS_DUMP, mp); S; /* Use a control ping for synchronization */ { vl_api_snat_control_ping_t *mp; - M (SNAT_CONTROL_PING, snat_control_ping); + M(SNAT_CONTROL_PING, mp); S; } W; @@ -445,12 +445,12 @@ static int api_snat_interface_dump(vat_main_t * vam) return -99; } - M(SNAT_INTERFACE_DUMP, snat_interface_dump); + M(SNAT_INTERFACE_DUMP, mp); S; /* Use a control ping for synchronization */ { vl_api_snat_control_ping_t *mp; - M (SNAT_CONTROL_PING, snat_control_ping); + M(SNAT_CONTROL_PING, mp); S; } W; @@ -476,7 +476,7 @@ static int api_snat_set_workers (vat_main_t * vam) } } - M(SNAT_SET_WORKERS, snat_set_workers); + M(SNAT_SET_WORKERS, mp); mp->worker_mask = clib_host_to_net_u64 (bitmap[0]); S; W; @@ -506,12 +506,12 @@ static int api_snat_worker_dump(vat_main_t * vam) return -99; } - M(SNAT_WORKER_DUMP, snat_worker_dump); + M(SNAT_WORKER_DUMP, mp); S; /* Use a control ping for synchronization */ { vl_api_snat_control_ping_t *mp; - M (SNAT_CONTROL_PING, snat_control_ping); + M(SNAT_CONTROL_PING, mp); S; } W; @@ -549,7 +549,7 @@ static int api_snat_ipfix_enable_disable (vat_main_t * vam) return -99; } - M(SNAT_ADD_DEL_INTERFACE_ADDR, snat_add_del_interface_addr); + M(SNAT_ADD_DEL_INTERFACE_ADDR, mp); mp->sw_if_index = ntohl(sw_if_index); mp->is_add = is_add; @@ -578,12 +578,12 @@ static int api_snat_interface_addr_dump(vat_main_t * vam) return -99; } - M(SNAT_INTERFACE_ADDR_DUMP, snat_interface_addr_dump); + M(SNAT_INTERFACE_ADDR_DUMP, mp); S; /* Use a control ping for synchronization */ { vl_api_snat_control_ping_t *mp; - M (SNAT_CONTROL_PING, snat_control_ping); + M(SNAT_CONTROL_PING, mp); S; } W; @@ -615,7 +615,7 @@ static int api_snat_add_del_interface_addr (vat_main_t * vam) } } - M(SNAT_IPFIX_ENABLE_DISABLE, snat_ipfix_enable_disable); + M(SNAT_IPFIX_ENABLE_DISABLE, mp); mp->domain_id = htonl(domain_id); mp->src_port = htons((u16) src_port); mp->enable = enable; diff --git a/src/vat/api_format.c b/src/vat/api_format.c index 0bbefd69..02987eb9 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -4590,7 +4590,7 @@ exec (vat_main_t * vam) } - M (CLI_REQUEST, cli_request); + M (CLI_REQUEST, mp); /* * Copy cmd into shared memory. @@ -4663,7 +4663,7 @@ exec_inband (vat_main_t * vam) * in \n\0. */ u32 len = vec_len (vam->input->buffer); - M2 (CLI_INBAND, cli_inband, len); + M2 (CLI_INBAND, mp, len); clib_memcpy (mp->cmd, vam->input->buffer, len); mp->length = htonl (len); @@ -4691,7 +4691,7 @@ api_create_loopback (vat_main_t * vam) } /* Construct the API message */ - M (CREATE_LOOPBACK, create_loopback); + M (CREATE_LOOPBACK, mp); if (mac_set) clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address)); @@ -4722,7 +4722,7 @@ api_delete_loopback (vat_main_t * vam) } /* Construct the API message */ - M (DELETE_LOOPBACK, delete_loopback); + M (DELETE_LOOPBACK, mp); mp->sw_if_index = ntohl (sw_if_index); S; @@ -4753,7 +4753,7 @@ api_want_stats (vat_main_t * vam) return -99; } - M (WANT_STATS, want_stats); + M (WANT_STATS, mp); mp->enable_disable = enable; S; @@ -4784,7 +4784,7 @@ api_want_interface_events (vat_main_t * vam) return -99; } - M (WANT_INTERFACE_EVENTS, want_interface_events); + M (WANT_INTERFACE_EVENTS, mp); mp->enable_disable = enable; vam->interface_event_display = enable; @@ -4830,64 +4830,64 @@ api_sw_interface_dump (vat_main_t * vam) vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword)); /* Get list of ethernets */ - M (SW_INTERFACE_DUMP, sw_interface_dump); + M (SW_INTERFACE_DUMP, mp); mp->name_filter_valid = 1; strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1); S; /* and local / loopback interfaces */ - M (SW_INTERFACE_DUMP, sw_interface_dump); + M (SW_INTERFACE_DUMP, mp); mp->name_filter_valid = 1; strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1); S; /* and packet-generator interfaces */ - M (SW_INTERFACE_DUMP, sw_interface_dump); + M (SW_INTERFACE_DUMP, mp); mp->name_filter_valid = 1; strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1); S; /* and vxlan-gpe tunnel interfaces */ - M (SW_INTERFACE_DUMP, sw_interface_dump); + M (SW_INTERFACE_DUMP, mp); mp->name_filter_valid = 1; strncpy ((char *) mp->name_filter, "vxlan_gpe", sizeof (mp->name_filter) - 1); S; /* and vxlan tunnel interfaces */ - M (SW_INTERFACE_DUMP, sw_interface_dump); + M (SW_INTERFACE_DUMP, mp); mp->name_filter_valid = 1; strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1); S; /* and host (af_packet) interfaces */ - M (SW_INTERFACE_DUMP, sw_interface_dump); + M (SW_INTERFACE_DUMP, mp); mp->name_filter_valid = 1; strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1); S; /* and l2tpv3 tunnel interfaces */ - M (SW_INTERFACE_DUMP, sw_interface_dump); + M (SW_INTERFACE_DUMP, mp); mp->name_filter_valid = 1; strncpy ((char *) mp->name_filter, "l2tpv3_tunnel", sizeof (mp->name_filter) - 1); S; /* and GRE tunnel interfaces */ - M (SW_INTERFACE_DUMP, sw_interface_dump); + M (SW_INTERFACE_DUMP, mp); mp->name_filter_valid = 1; strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1); S; /* and LISP-GPE interfaces */ - M (SW_INTERFACE_DUMP, sw_interface_dump); + M (SW_INTERFACE_DUMP, mp); mp->name_filter_valid = 1; strncpy ((char *) mp->name_filter, "lisp_gpe", sizeof (mp->name_filter) - 1); S; /* and IPSEC tunnel interfaces */ - M (SW_INTERFACE_DUMP, sw_interface_dump); + M (SW_INTERFACE_DUMP, mp); mp->name_filter_valid = 1; strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1); S; @@ -4895,7 +4895,7 @@ api_sw_interface_dump (vat_main_t * vam) /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } W; @@ -4938,7 +4938,7 @@ api_sw_interface_set_flags (vat_main_t * vam) } /* Construct the API message */ - M (SW_INTERFACE_SET_FLAGS, sw_interface_set_flags); + M (SW_INTERFACE_SET_FLAGS, mp); mp->sw_if_index = ntohl (sw_if_index); mp->admin_up_down = admin_up; mp->link_up_down = link_up; @@ -4971,7 +4971,7 @@ api_sw_interface_clear_stats (vat_main_t * vam) } /* Construct the API message */ - M (SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats); + M (SW_INTERFACE_CLEAR_STATS, mp); if (sw_if_index_set == 1) mp->sw_if_index = ntohl (sw_if_index); @@ -5045,7 +5045,7 @@ api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam) return -99; } - M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe); + M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, mp); mp->sw_if_index = ntohl (sw_if_index); mp->subport = ntohl (subport); @@ -5122,7 +5122,7 @@ api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam) return -99; } - M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport); + M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, mp); mp->sw_if_index = ntohl (sw_if_index); mp->subport = ntohl (subport); @@ -5194,7 +5194,7 @@ api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam) return -99; } - M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl); + M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, mp); mp->sw_if_index = ntohl (sw_if_index); mp->entry = ntohl (entry); @@ -5262,7 +5262,7 @@ api_sw_interface_add_del_address (vat_main_t * vam) } /* Construct the API message */ - M (SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address); + M (SW_INTERFACE_ADD_DEL_ADDRESS, mp); mp->sw_if_index = ntohl (sw_if_index); mp->is_add = is_add; @@ -5317,7 +5317,7 @@ api_sw_interface_set_mpls_enable (vat_main_t * vam) } /* Construct the API message */ - M (SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable); + M (SW_INTERFACE_SET_MPLS_ENABLE, mp); mp->sw_if_index = ntohl (sw_if_index); mp->enable = enable; @@ -5361,7 +5361,7 @@ api_sw_interface_set_table (vat_main_t * vam) } /* Construct the API message */ - M (SW_INTERFACE_SET_TABLE, sw_interface_set_table); + M (SW_INTERFACE_SET_TABLE, mp); mp->sw_if_index = ntohl (sw_if_index); mp->is_ipv6 = is_ipv6; @@ -5431,7 +5431,7 @@ api_sw_interface_get_table (vat_main_t * vam) return -99; } - M (SW_INTERFACE_GET_TABLE, sw_interface_get_table); + M (SW_INTERFACE_GET_TABLE, mp); mp->sw_if_index = htonl (sw_if_index); mp->is_ipv6 = is_ipv6; @@ -5471,7 +5471,7 @@ api_sw_interface_set_vpath (vat_main_t * vam) } /* Construct the API message */ - M (SW_INTERFACE_SET_VPATH, sw_interface_set_vpath); + M (SW_INTERFACE_SET_VPATH, mp); mp->sw_if_index = ntohl (sw_if_index); mp->enable = is_enable; @@ -5520,7 +5520,7 @@ api_sw_interface_set_vxlan_bypass (vat_main_t * vam) } /* Construct the API message */ - M (SW_INTERFACE_SET_VXLAN_BYPASS, sw_interface_set_vxlan_bypass); + M (SW_INTERFACE_SET_VXLAN_BYPASS, mp); mp->sw_if_index = ntohl (sw_if_index); mp->enable = is_enable; @@ -5594,7 +5594,7 @@ api_sw_interface_set_l2_xconnect (vat_main_t * vam) return -99; } - M (SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect); + M (SW_INTERFACE_SET_L2_XCONNECT, mp); mp->rx_sw_if_index = ntohl (rx_sw_if_index); mp->tx_sw_if_index = ntohl (tx_sw_if_index); @@ -5655,7 +5655,7 @@ api_sw_interface_set_l2_bridge (vat_main_t * vam) return -99; } - M (SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge); + M (SW_INTERFACE_SET_L2_BRIDGE, mp); mp->rx_sw_if_index = ntohl (rx_sw_if_index); mp->bd_id = ntohl (bd_id); @@ -5686,14 +5686,14 @@ api_bridge_domain_dump (vat_main_t * vam) break; } - M (BRIDGE_DOMAIN_DUMP, bridge_domain_dump); + M (BRIDGE_DOMAIN_DUMP, mp); mp->bd_id = ntohl (bd_id); S; /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } @@ -5751,7 +5751,7 @@ api_bridge_domain_add_del (vat_main_t * vam) return -99; } - M (BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del); + M (BRIDGE_DOMAIN_ADD_DEL, mp); mp->bd_id = ntohl (bd_id); mp->flood = flood; @@ -5856,7 +5856,7 @@ api_l2fib_add_del (vat_main_t * vam) for (j = 0; j < count; j++) { - M (L2FIB_ADD_DEL, l2fib_add_del); + M (L2FIB_ADD_DEL, mp); mp->mac = mac; mp->bd_id = ntohl (bd_id); @@ -5882,7 +5882,7 @@ api_l2fib_add_del (vat_main_t * vam) /* Shut off async mode */ vam->async_mode = 0; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; timeout = vat_time_now (vam) + 1.0; @@ -5959,7 +5959,7 @@ api_l2_flags (vat_main_t * vam) return -99; } - M (L2_FLAGS, l2_flags); + M (L2_FLAGS, mp); mp->sw_if_index = ntohl (sw_if_index); mp->feature_bitmap = ntohl (feature_bitmap); @@ -6010,7 +6010,7 @@ api_bridge_flags (vat_main_t * vam) return -99; } - M (BRIDGE_FLAGS, bridge_flags); + M (BRIDGE_FLAGS, mp); mp->bd_id = ntohl (bd_id); mp->feature_bitmap = ntohl (flags); @@ -6081,7 +6081,7 @@ api_bd_ip_mac_add_del (vat_main_t * vam) return -99; } - M (BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del); + M (BD_IP_MAC_ADD_DEL, mp); mp->bd_id = ntohl (bd_id); mp->is_ipv6 = is_ipv6; @@ -6159,7 +6159,7 @@ api_tap_connect (vat_main_t * vam) } /* Construct the API message */ - M (TAP_CONNECT, tap_connect); + M (TAP_CONNECT, mp); mp->use_random_mac = random_mac; clib_memcpy (mp->mac_address, mac_address, 6); @@ -6241,7 +6241,7 @@ api_tap_modify (vat_main_t * vam) vec_add1 (tap_name, 0); /* Construct the API message */ - M (TAP_MODIFY, tap_modify); + M (TAP_MODIFY, mp); mp->use_random_mac = random_mac; mp->sw_if_index = ntohl (sw_if_index); @@ -6283,7 +6283,7 @@ api_tap_delete (vat_main_t * vam) } /* Construct the API message */ - M (TAP_DELETE, tap_delete); + M (TAP_DELETE, mp); mp->sw_if_index = ntohl (sw_if_index); @@ -6484,7 +6484,7 @@ api_ip_add_del_route (vat_main_t * vam) for (j = 0; j < count; j++) { /* Construct the API message */ - M2 (IP_ADD_DEL_ROUTE, ip_add_del_route, + M2 (IP_ADD_DEL_ROUTE, mp, sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack)); mp->next_hop_sw_if_index = ntohl (sw_if_index); @@ -6553,7 +6553,7 @@ api_ip_add_del_route (vat_main_t * vam) /* Shut off async mode */ vam->async_mode = 0; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; timeout = vat_time_now (vam) + 1.0; @@ -6676,7 +6676,7 @@ api_ip_mroute_add_del (vat_main_t * vam) } /* Construct the API message */ - M (IP_MROUTE_ADD_DEL, ip_mroute_add_del); + M (IP_MROUTE_ADD_DEL, mp); mp->next_hop_sw_if_index = ntohl (sw_if_index); mp->table_id = ntohl (vrf_id); @@ -6829,7 +6829,7 @@ api_mpls_route_add_del (vat_main_t * vam) for (j = 0; j < count; j++) { /* Construct the API message */ - M2 (MPLS_ROUTE_ADD_DEL, mpls_route_add_del, + M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack)); mp->mr_next_hop_sw_if_index = ntohl (sw_if_index); @@ -6891,7 +6891,7 @@ api_mpls_route_add_del (vat_main_t * vam) /* Shut off async mode */ vam->async_mode = 0; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; timeout = vat_time_now (vam) + 1.0; @@ -6990,7 +6990,7 @@ api_mpls_ip_bind_unbind (vat_main_t * vam) } /* Construct the API message */ - M (MPLS_IP_BIND_UNBIND, mpls_ip_bind_unbind); + M (MPLS_IP_BIND_UNBIND, mp); mp->mb_create_table_if_needed = create_table_if_needed; mp->mb_is_bind = is_bind; @@ -7045,7 +7045,7 @@ api_proxy_arp_add_del (vat_main_t * vam) return -99; } - M (PROXY_ARP_ADD_DEL, proxy_arp_add_del); + M (PROXY_ARP_ADD_DEL, mp); mp->vrf_id = ntohl (vrf_id); mp->is_add = is_add; @@ -7091,7 +7091,7 @@ api_proxy_arp_intfc_enable_disable (vat_main_t * vam) return -99; } - M (PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable); + M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp); mp->sw_if_index = ntohl (sw_if_index); mp->enable_disable = enable; @@ -7153,8 +7153,7 @@ api_mpls_tunnel_add_del (vat_main_t * vam) } } - M2 (MPLS_TUNNEL_ADD_DEL, mpls_tunnel_add_del, - sizeof (mpls_label_t) * vec_len (labels)); + M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels)); mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index); mp->mt_sw_if_index = ntohl (sw_if_index); @@ -7223,7 +7222,7 @@ api_sw_interface_set_unnumbered (vat_main_t * vam) return -99; } - M (SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered); + M (SW_INTERFACE_SET_UNNUMBERED, mp); mp->sw_if_index = ntohl (sw_if_index); mp->unnumbered_sw_if_index = ntohl (unnum_sw_index); @@ -7301,7 +7300,7 @@ api_ip_neighbor_add_del (vat_main_t * vam) } /* Construct the API message */ - M (IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del); + M (IP_NEIGHBOR_ADD_DEL, mp); mp->sw_if_index = ntohl (sw_if_index); mp->is_add = is_add; @@ -7359,7 +7358,7 @@ api_reset_vrf (vat_main_t * vam) return -99; } - M (RESET_VRF, reset_vrf); + M (RESET_VRF, mp); mp->vrf_id = ntohl (vrf_id); mp->is_ipv6 = is_ipv6; @@ -7408,7 +7407,7 @@ api_create_vlan_subif (vat_main_t * vam) errmsg ("missing vlan_id"); return -99; } - M (CREATE_VLAN_SUBIF, create_vlan_subif); + M (CREATE_VLAN_SUBIF, mp); mp->sw_if_index = ntohl (sw_if_index); mp->vlan_id = ntohl (vlan_id); @@ -7486,7 +7485,7 @@ api_create_subif (vat_main_t * vam) errmsg ("missing sub_id"); return -99; } - M (CREATE_SUBIF, create_subif); + M (CREATE_SUBIF, mp); mp->sw_if_index = ntohl (sw_if_index); mp->sub_id = ntohl (sub_id); @@ -7545,7 +7544,7 @@ api_oam_add_del (vat_main_t * vam) return -99; } - M (OAM_ADD_DEL, oam_add_del); + M (OAM_ADD_DEL, mp); mp->vrf_id = ntohl (vrf_id); mp->is_add = is_add; @@ -7587,7 +7586,7 @@ api_reset_fib (vat_main_t * vam) return -99; } - M (RESET_FIB, reset_fib); + M (RESET_FIB, mp); mp->vrf_id = ntohl (vrf_id); mp->is_ipv6 = is_ipv6; @@ -7667,7 +7666,7 @@ api_dhcp_proxy_config (vat_main_t * vam) } /* Construct the API message */ - M (DHCP_PROXY_CONFIG, dhcp_proxy_config); + M (DHCP_PROXY_CONFIG, mp); mp->insert_circuit_id = insert_cid; mp->is_add = is_add; @@ -7765,7 +7764,7 @@ api_dhcp_proxy_config_2 (vat_main_t * vam) } /* Construct the API message */ - M (DHCP_PROXY_CONFIG_2, dhcp_proxy_config_2); + M (DHCP_PROXY_CONFIG_2, mp); mp->insert_circuit_id = insert_cid; mp->is_add = is_add; @@ -7843,7 +7842,7 @@ api_dhcp_proxy_set_vss (vat_main_t * vam) return -99; } - M (DHCP_PROXY_SET_VSS, dhcp_proxy_set_vss); + M (DHCP_PROXY_SET_VSS, mp); mp->tbl_id = ntohl (tbl_id); mp->fib_id = ntohl (fib_id); mp->oui = ntohl (oui); @@ -7899,7 +7898,7 @@ api_dhcp_client_config (vat_main_t * vam) vec_add1 (hostname, 0); /* Construct the API message */ - M (DHCP_CLIENT_CONFIG, dhcp_client_config); + M (DHCP_CLIENT_CONFIG, mp); mp->sw_if_index = ntohl (sw_if_index); clib_memcpy (mp->hostname, hostname, vec_len (hostname)); @@ -7965,7 +7964,7 @@ api_set_ip_flow_hash (vat_main_t * vam) return -99; } - M (SET_IP_FLOW_HASH, set_ip_flow_hash); + M (SET_IP_FLOW_HASH, mp); mp->src = src; mp->dst = dst; mp->sport = sport; @@ -8014,7 +8013,7 @@ api_sw_interface_ip6_enable_disable (vat_main_t * vam) return -99; } - M (SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable); + M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp); mp->sw_if_index = ntohl (sw_if_index); mp->enable = enable; @@ -8061,8 +8060,7 @@ api_sw_interface_ip6_set_link_local_address (vat_main_t * vam) } /* Construct the API message */ - M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, - sw_interface_ip6_set_link_local_address); + M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp); mp->sw_if_index = ntohl (sw_if_index); clib_memcpy (mp->address, &v6address, sizeof (v6address)); @@ -8143,7 +8141,7 @@ api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam) } /* Construct the API message */ - M (SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix); + M (SW_INTERFACE_IP6ND_RA_PREFIX, mp); mp->sw_if_index = ntohl (sw_if_index); clib_memcpy (mp->address, &v6address, sizeof (v6address)); @@ -8237,7 +8235,7 @@ api_sw_interface_ip6nd_ra_config (vat_main_t * vam) } /* Construct the API message */ - M (SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config); + M (SW_INTERFACE_IP6ND_RA_CONFIG, mp); mp->sw_if_index = ntohl (sw_if_index); mp->max_interval = ntohl (max_interval); @@ -8293,7 +8291,7 @@ api_set_arp_neighbor_limit (vat_main_t * vam) return -99; } - M (SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit); + M (SET_ARP_NEIGHBOR_LIMIT, mp); mp->arp_neighbor_limit = ntohl (arp_nbr_limit); mp->is_ipv6 = is_ipv6; @@ -8363,7 +8361,7 @@ api_l2_patch_add_del (vat_main_t * vam) return -99; } - M (L2_PATCH_ADD_DEL, l2_patch_add_del); + M (L2_PATCH_ADD_DEL, mp); mp->rx_sw_if_index = ntohl (rx_sw_if_index); mp->tx_sw_if_index = ntohl (tx_sw_if_index); @@ -8400,7 +8398,7 @@ api_ioam_enable (vat_main_t * vam) else break; } - M (IOAM_ENABLE, ioam_enable); + M (IOAM_ENABLE, mp); mp->id = htons (id); mp->seqno = has_seqno_option; mp->analyse = has_analyse_option; @@ -8421,7 +8419,7 @@ api_ioam_disable (vat_main_t * vam) vl_api_ioam_disable_t *mp; f64 timeout; - M (IOAM_DISABLE, ioam_disable); + M (IOAM_DISABLE, mp); S; W; return 0; @@ -8530,7 +8528,7 @@ api_sr_tunnel_add_del (vat_main_t * vam) return -99; } - M2 (SR_TUNNEL_ADD_DEL, sr_tunnel_add_del, + M2 (SR_TUNNEL_ADD_DEL, mp, vec_len (segments) * sizeof (ip6_address_t) + vec_len (tags) * sizeof (ip6_address_t)); @@ -8613,7 +8611,7 @@ api_sr_policy_add_del (vat_main_t * vam) return -99; } - M2 (SR_POLICY_ADD_DEL, sr_policy_add_del, tunnel_names_length); + M2 (SR_POLICY_ADD_DEL, mp, tunnel_names_length); @@ -8682,7 +8680,7 @@ api_sr_multicast_map_add_del (vat_main_t * vam) return -99; } - M (SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del); + M (SR_MULTICAST_MAP_ADD_DEL, mp); mp->is_add = !is_del; memcpy (mp->policy_name, policy_name, vec_len (policy_name)); @@ -9391,7 +9389,7 @@ api_classify_add_del_table (vat_main_t * vam) return -99; } - M2 (CLASSIFY_ADD_DEL_TABLE, classify_add_del_table, vec_len (mask)); + M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask)); mp->is_add = is_add; mp->del_chain = del_chain; @@ -9926,7 +9924,7 @@ api_classify_add_del_session (vat_main_t * vam) return -99; } - M2 (CLASSIFY_ADD_DEL_SESSION, classify_add_del_session, vec_len (match)); + M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match)); mp->is_add = is_add; mp->table_index = ntohl (table_index); @@ -9976,7 +9974,7 @@ api_classify_set_interface_ip_table (vat_main_t * vam) } - M (CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table); + M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp); mp->sw_if_index = ntohl (sw_if_index); mp->table_index = ntohl (table_index); @@ -10029,7 +10027,7 @@ api_classify_set_interface_l2_tables (vat_main_t * vam) } - M (CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables); + M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp); mp->sw_if_index = ntohl (sw_if_index); mp->ip4_table_index = ntohl (ip4_table_index); @@ -10093,7 +10091,7 @@ api_set_ipfix_exporter (vat_main_t * vam) return -99; } - M (SET_IPFIX_EXPORTER, set_ipfix_exporter); + M (SET_IPFIX_EXPORTER, mp); memcpy (mp->collector_address, collector_address.data, sizeof (collector_address.data)); @@ -10131,7 +10129,7 @@ api_set_ipfix_classify_stream (vat_main_t * vam) } } - M (SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream); + M (SET_IPFIX_CLASSIFY_STREAM, mp); mp->domain_id = htonl (domain_id); mp->src_port = htons ((u16) src_port); @@ -10191,7 +10189,7 @@ api_ipfix_classify_table_add_del (vat_main_t * vam) return -99; } - M (IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del); + M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp); mp->is_add = is_add; mp->table_id = htonl (classify_table_index); @@ -10229,7 +10227,7 @@ api_get_node_index (vat_main_t * vam) return -99; } - M (GET_NODE_INDEX, get_node_index); + M (GET_NODE_INDEX, mp); clib_memcpy (mp->node_name, name, vec_len (name)); vec_free (name); @@ -10277,7 +10275,7 @@ api_get_next_index (vat_main_t * vam) return -99; } - M (GET_NEXT_INDEX, get_next_index); + M (GET_NEXT_INDEX, mp); clib_memcpy (mp->node_name, node_name, vec_len (node_name)); clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name)); vec_free (node_name); @@ -10328,7 +10326,7 @@ api_add_node_next (vat_main_t * vam) return -99; } - M (ADD_NODE_NEXT, add_node_next); + M (ADD_NODE_NEXT, mp); clib_memcpy (mp->node_name, name, vec_len (name)); clib_memcpy (mp->next_name, next, vec_len (next)); vec_free (name); @@ -10389,7 +10387,7 @@ api_l2tpv3_create_tunnel (vat_main_t * vam) return -99; } - M (L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel); + M (L2TPV3_CREATE_TUNNEL, mp); clib_memcpy (mp->client_address, client_address.as_u8, sizeof (mp->client_address)); @@ -10440,7 +10438,7 @@ api_l2tpv3_set_tunnel_cookies (vat_main_t * vam) return -99; } - M (L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies); + M (L2TPV3_SET_TUNNEL_COOKIES, mp); mp->sw_if_index = ntohl (sw_if_index); mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie); @@ -10482,7 +10480,7 @@ api_l2tpv3_interface_enable_disable (vat_main_t * vam) return -99; } - M (L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable); + M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp); mp->sw_if_index = ntohl (sw_if_index); mp->enable_disable = enable_disable; @@ -10519,7 +10517,7 @@ api_l2tpv3_set_lookup_key (vat_main_t * vam) return -99; } - M (L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key); + M (L2TPV3_SET_LOOKUP_KEY, mp); mp->key = key; @@ -10599,13 +10597,13 @@ api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam) f64 timeout; /* Get list of l2tpv3-tunnel interfaces */ - M (SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump); + M (SW_IF_L2TPV3_TUNNEL_DUMP, mp); S; /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } W; @@ -10647,13 +10645,13 @@ api_sw_interface_tap_dump (vat_main_t * vam) print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index"); /* Get list of tap interfaces */ - M (SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump); + M (SW_INTERFACE_TAP_DUMP, mp); S; /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } W; @@ -10806,7 +10804,7 @@ api_vxlan_add_del_tunnel (vat_main_t * vam) return -99; } - M (VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel); + M (VXLAN_ADD_DEL_TUNNEL, mp); if (ipv6_set) { @@ -10922,7 +10920,7 @@ api_vxlan_tunnel_dump (vat_main_t * vam) } /* Get list of vxlan-tunnel interfaces */ - M (VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump); + M (VXLAN_TUNNEL_DUMP, mp); mp->sw_if_index = htonl (sw_if_index); @@ -10931,7 +10929,7 @@ api_vxlan_tunnel_dump (vat_main_t * vam) /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } W; @@ -10981,7 +10979,7 @@ api_gre_add_del_tunnel (vat_main_t * vam) } - M (GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel); + M (GRE_ADD_DEL_TUNNEL, mp); clib_memcpy (&mp->src_address, &src4, sizeof (src4)); clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4)); @@ -11062,7 +11060,7 @@ api_gre_tunnel_dump (vat_main_t * vam) } /* Get list of gre-tunnel interfaces */ - M (GRE_TUNNEL_DUMP, gre_tunnel_dump); + M (GRE_TUNNEL_DUMP, mp); mp->sw_if_index = htonl (sw_if_index); @@ -11071,7 +11069,7 @@ api_gre_tunnel_dump (vat_main_t * vam) /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } W; @@ -11084,7 +11082,7 @@ api_l2_fib_clear_table (vat_main_t * vam) vl_api_l2_fib_clear_table_t *mp; f64 timeout; - M (L2_FIB_CLEAR_TABLE, l2_fib_clear_table); + M (L2_FIB_CLEAR_TABLE, mp); S; W; @@ -11125,7 +11123,7 @@ api_l2_interface_efp_filter (vat_main_t * vam) return -99; } - M (L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter); + M (L2_INTERFACE_EFP_FILTER, mp); mp->sw_if_index = ntohl (sw_if_index); mp->enable_disable = enable; @@ -11191,8 +11189,8 @@ api_l2_interface_vlan_tag_rewrite (vat_main_t * vam) return -99; } - M (L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite) - mp->sw_if_index = ntohl (sw_if_index); + M (L2_INTERFACE_VLAN_TAG_REWRITE, mp); + mp->sw_if_index = ntohl (sw_if_index); mp->vtr_op = ntohl (vtr_op); mp->push_dot1q = ntohl (push_dot1q); mp->tag1 = ntohl (tag1); @@ -11252,7 +11250,7 @@ api_create_vhost_user_if (vat_main_t * vam) } vec_add1 (file_name, 0); - M (CREATE_VHOST_USER_IF, create_vhost_user_if); + M (CREATE_VHOST_USER_IF, mp); mp->is_server = is_server; clib_memcpy (mp->sock_filename, file_name, vec_len (file_name)); @@ -11324,7 +11322,7 @@ api_modify_vhost_user_if (vat_main_t * vam) } vec_add1 (file_name, 0); - M (MODIFY_VHOST_USER_IF, modify_vhost_user_if); + M (MODIFY_VHOST_USER_IF, mp); mp->sw_if_index = ntohl (sw_if_index); mp->is_server = is_server; @@ -11368,7 +11366,7 @@ api_delete_vhost_user_if (vat_main_t * vam) } - M (DELETE_VHOST_USER_IF, delete_vhost_user_if); + M (DELETE_VHOST_USER_IF, mp); mp->sw_if_index = ntohl (sw_if_index); @@ -11427,13 +11425,13 @@ api_sw_interface_vhost_user_dump (vat_main_t * vam) "Interface name idx hdr_sz features server regions filename"); /* Get list of vhost-user interfaces */ - M (SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump); + M (SW_INTERFACE_VHOST_USER_DUMP, mp); S; /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } W; @@ -11445,7 +11443,7 @@ api_show_version (vat_main_t * vam) vl_api_show_version_t *mp; f64 timeout; - M (SHOW_VERSION, show_version); + M (SHOW_VERSION, mp); S; W; @@ -11543,7 +11541,7 @@ api_vxlan_gpe_add_del_tunnel (vat_main_t * vam) return -99; } - M (VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel); + M (VXLAN_GPE_ADD_DEL_TUNNEL, mp); if (ipv6_set) @@ -11653,7 +11651,7 @@ api_vxlan_gpe_tunnel_dump (vat_main_t * vam) } /* Get list of vxlan-tunnel interfaces */ - M (VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump); + M (VXLAN_GPE_TUNNEL_DUMP, mp); mp->sw_if_index = htonl (sw_if_index); @@ -11662,7 +11660,7 @@ api_vxlan_gpe_tunnel_dump (vat_main_t * vam) /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } W; @@ -11738,7 +11736,7 @@ api_l2_fib_table_dump (vat_main_t * vam) print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI"); /* Get list of l2 fib entries */ - M (L2_FIB_TABLE_DUMP, l2_fib_table_dump); + M (L2_FIB_TABLE_DUMP, mp); mp->bd_id = ntohl (bd_id); S; @@ -11746,7 +11744,7 @@ api_l2_fib_table_dump (vat_main_t * vam) /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } W; @@ -11788,7 +11786,7 @@ api_interface_name_renumber (vat_main_t * vam) return -99; } - M (INTERFACE_NAME_RENUMBER, interface_name_renumber); + M (INTERFACE_NAME_RENUMBER, mp); mp->sw_if_index = ntohl (sw_if_index); mp->new_show_dev_instance = ntohl (new_show_dev_instance); @@ -11823,7 +11821,7 @@ api_want_ip4_arp_events (vat_main_t * vam) return -99; } - M (WANT_IP4_ARP_EVENTS, want_ip4_arp_events); + M (WANT_IP4_ARP_EVENTS, mp); mp->enable_disable = enable_disable; mp->pid = getpid (); mp->address = address.as_u32; @@ -11858,7 +11856,7 @@ api_want_ip6_nd_events (vat_main_t * vam) return -99; } - M (WANT_IP6_ND_EVENTS, want_ip6_nd_events); + M (WANT_IP6_ND_EVENTS, mp); mp->enable_disable = enable_disable; mp->pid = getpid (); clib_memcpy (mp->address, &address, sizeof (ip6_address_t)); @@ -11907,7 +11905,7 @@ api_input_acl_set_interface (vat_main_t * vam) return -99; } - M (INPUT_ACL_SET_INTERFACE, input_acl_set_interface); + M (INPUT_ACL_SET_INTERFACE, mp); mp->sw_if_index = ntohl (sw_if_index); mp->ip4_table_index = ntohl (ip4_table_index); @@ -11968,7 +11966,7 @@ api_ip_address_dump (vat_main_t * vam) vam->current_sw_if_index = sw_if_index; vam->is_ipv6 = ipv6_set; - M (IP_ADDRESS_DUMP, ip_address_dump); + M (IP_ADDRESS_DUMP, mp); mp->sw_if_index = ntohl (sw_if_index); mp->is_ipv6 = ipv6_set; S; @@ -11976,7 +11974,7 @@ api_ip_address_dump (vat_main_t * vam) /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } W; @@ -12025,14 +12023,14 @@ api_ip_dump (vat_main_t * vam) } vec_free (vam->ip_details_by_sw_if_index[is_ipv6]); - M (IP_DUMP, ip_dump); + M (IP_DUMP, mp); mp->is_ipv6 = ipv6_set; S; /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } W; @@ -12065,7 +12063,7 @@ api_ipsec_spd_add_del (vat_main_t * vam) return -99; } - M (IPSEC_SPD_ADD_DEL, ipsec_spd_add_del); + M (IPSEC_SPD_ADD_DEL, mp); mp->spd_id = ntohl (spd_id); mp->is_add = is_add; @@ -12118,7 +12116,7 @@ api_ipsec_interface_add_del_spd (vat_main_t * vam) return -99; } - M (IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd); + M (IPSEC_INTERFACE_ADD_DEL_SPD, mp); mp->spd_id = ntohl (spd_id); mp->sw_if_index = ntohl (sw_if_index); @@ -12244,7 +12242,7 @@ api_ipsec_spd_add_del_entry (vat_main_t * vam) } - M (IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry); + M (IPSEC_SPD_ADD_DEL_ENTRY, mp); mp->spd_id = ntohl (spd_id); mp->priority = ntohl (priority); @@ -12372,7 +12370,7 @@ api_ipsec_sad_add_del_entry (vat_main_t * vam) } - M (IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry); + M (IPSEC_SAD_ADD_DEL_ENTRY, mp); mp->sad_id = ntohl (sad_id); mp->is_add = is_add; @@ -12444,7 +12442,7 @@ api_ipsec_sa_set_key (vat_main_t * vam) } } - M (IPSEC_SA_SET_KEY, ipsec_set_sa_key); + M (IPSEC_SA_SET_KEY, mp); mp->sa_id = ntohl (sa_id); mp->crypto_key_length = vec_len (ck); @@ -12503,7 +12501,7 @@ api_ikev2_profile_add_del (vat_main_t * vam) return -99; } - M (IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del); + M (IKEV2_PROFILE_ADD_DEL, mp); clib_memcpy (mp->name, name, vec_len (name)); mp->is_add = is_add; @@ -12570,7 +12568,7 @@ api_ikev2_profile_set_auth (vat_main_t * vam) return -99; } - M (IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth); + M (IKEV2_PROFILE_SET_AUTH, mp); mp->is_hex = is_hex; mp->auth_method = (u8) auth_method; @@ -12650,7 +12648,7 @@ api_ikev2_profile_set_id (vat_main_t * vam) return -99; } - M (IKEV2_PROFILE_SET_ID, ikev2_profile_set_id); + M (IKEV2_PROFILE_SET_ID, mp); mp->is_local = is_local; mp->id_type = (u8) id_type; @@ -12720,7 +12718,7 @@ api_ikev2_profile_set_ts (vat_main_t * vam) return -99; } - M (IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts); + M (IKEV2_PROFILE_SET_TS, mp); mp->is_local = is_local; mp->proto = (u8) proto; @@ -12768,7 +12766,7 @@ api_ikev2_set_local_key (vat_main_t * vam) return -99; } - M (IKEV2_SET_LOCAL_KEY, ikev2_set_local_key); + M (IKEV2_SET_LOCAL_KEY, mp); clib_memcpy (mp->key_file, file, vec_len (file)); vec_free (file); @@ -12838,7 +12836,7 @@ api_map_add_domain (vat_main_t * vam) } /* Construct the API message */ - M (MAP_ADD_DOMAIN, map_add_domain); + M (MAP_ADD_DOMAIN, mp); clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix)); mp->ip4_prefix_len = ip4_prefix_len; @@ -12890,7 +12888,7 @@ api_map_del_domain (vat_main_t * vam) } /* Construct the API message */ - M (MAP_DEL_DOMAIN, map_del_domain); + M (MAP_DEL_DOMAIN, mp); mp->index = ntohl (index); @@ -12931,7 +12929,7 @@ api_map_add_del_rule (vat_main_t * vam) } /* Construct the API message */ - M (MAP_ADD_DEL_RULE, map_add_del_rule); + M (MAP_ADD_DEL_RULE, mp); mp->index = ntohl (index); mp->is_add = is_add; @@ -12952,7 +12950,7 @@ api_map_domain_dump (vat_main_t * vam) f64 timeout; /* Construct the API message */ - M (MAP_DOMAIN_DUMP, map_domain_dump); + M (MAP_DOMAIN_DUMP, mp); /* send it... */ S; @@ -12960,7 +12958,7 @@ api_map_domain_dump (vat_main_t * vam) /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } W; @@ -12989,7 +12987,7 @@ api_map_rule_dump (vat_main_t * vam) } /* Construct the API message */ - M (MAP_RULE_DUMP, map_rule_dump); + M (MAP_RULE_DUMP, mp); mp->domain_index = htonl (domain_index); @@ -12999,7 +12997,7 @@ api_map_rule_dump (vat_main_t * vam) /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } W; @@ -13069,7 +13067,7 @@ api_get_first_msg_id (vat_main_t * vam) return -99; } - M (GET_FIRST_MSG_ID, get_first_msg_id); + M (GET_FIRST_MSG_ID, mp); clib_memcpy (mp->name, name, vec_len (name)); S; W; @@ -13108,7 +13106,7 @@ api_cop_interface_enable_disable (vat_main_t * vam) } /* Construct the API message */ - M (COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable); + M (COP_INTERFACE_ENABLE_DISABLE, mp); mp->sw_if_index = ntohl (sw_if_index); mp->enable_disable = enable_disable; @@ -13154,7 +13152,7 @@ api_cop_whitelist_enable_disable (vat_main_t * vam) } /* Construct the API message */ - M (COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable); + M (COP_WHITELIST_ENABLE_DISABLE, mp); mp->sw_if_index = ntohl (sw_if_index); mp->fib_id = ntohl (fib_id); mp->ip4 = ip4; @@ -13173,7 +13171,7 @@ api_get_node_graph (vat_main_t * vam) vl_api_get_node_graph_t *mp; f64 timeout; - M (GET_NODE_GRAPH, get_node_graph); + M (GET_NODE_GRAPH, mp); /* send it... */ S; @@ -13308,7 +13306,7 @@ api_lisp_add_del_locator_set (vat_main_t * vam) data_len = sizeof (vl_api_local_locator_t) * vec_len (locators); /* Construct the API message */ - M2 (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set, data_len); + M2 (LISP_ADD_DEL_LOCATOR_SET, mp, data_len); mp->is_add = is_add; clib_memcpy (mp->locator_set_name, locator_set_name, @@ -13425,7 +13423,7 @@ api_lisp_add_del_locator (vat_main_t * vam) vec_add1 (locator_set_name, 0); /* Construct the API message */ - M (LISP_ADD_DEL_LOCATOR, lisp_add_del_locator); + M (LISP_ADD_DEL_LOCATOR, mp); mp->is_add = is_add; mp->sw_if_index = ntohl (sw_if_index); @@ -13547,7 +13545,7 @@ api_lisp_add_del_local_eid (vat_main_t * vam) vec_add1 (locator_set_name, 0); /* Construct the API message */ - M (LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid); + M (LISP_ADD_DEL_LOCAL_EID, mp); mp->is_add = is_add; lisp_eid_put_vat (mp->eid, eid->addr, eid->type); @@ -13689,7 +13687,7 @@ api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam) } /* Construct the API message */ - M2 (LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry, + M2 (LISP_GPE_ADD_DEL_FWD_ENTRY, mp, sizeof (vl_api_lisp_gpe_locator_t) * vec_len (rmt_locs) * 2); mp->is_add = is_add; @@ -13769,7 +13767,7 @@ api_lisp_add_del_map_server (vat_main_t * vam) } /* Construct the API message */ - M (LISP_ADD_DEL_MAP_SERVER, lisp_add_del_map_server); + M (LISP_ADD_DEL_MAP_SERVER, mp); mp->is_add = is_add; if (ipv6_set) @@ -13837,7 +13835,7 @@ api_lisp_add_del_map_resolver (vat_main_t * vam) } /* Construct the API message */ - M (LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver); + M (LISP_ADD_DEL_MAP_RESOLVER, mp); mp->is_add = is_add; if (ipv6_set) @@ -13894,7 +13892,7 @@ api_lisp_gpe_enable_disable (vat_main_t * vam) } /* Construct the API message */ - M (LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable); + M (LISP_GPE_ENABLE_DISABLE, mp); mp->is_en = is_en; @@ -13938,7 +13936,7 @@ api_lisp_rloc_probe_enable_disable (vat_main_t * vam) } /* Construct the API message */ - M (LISP_RLOC_PROBE_ENABLE_DISABLE, lisp_rloc_probe_enable_disable); + M (LISP_RLOC_PROBE_ENABLE_DISABLE, mp); mp->is_enabled = is_en; @@ -13982,7 +13980,7 @@ api_lisp_map_register_enable_disable (vat_main_t * vam) } /* Construct the API message */ - M (LISP_MAP_REGISTER_ENABLE_DISABLE, lisp_map_register_enable_disable); + M (LISP_MAP_REGISTER_ENABLE_DISABLE, mp); mp->is_enabled = is_en; @@ -14028,7 +14026,7 @@ api_lisp_enable_disable (vat_main_t * vam) } /* Construct the API message */ - M (LISP_ENABLE_DISABLE, lisp_enable_disable); + M (LISP_ENABLE_DISABLE, mp); mp->is_en = is_en; @@ -14048,7 +14046,7 @@ api_show_lisp_map_register_state (vat_main_t * vam) f64 timeout = ~0; vl_api_show_lisp_map_register_state_t *mp; - M (SHOW_LISP_MAP_REGISTER_STATE, show_lisp_map_register_state); + M (SHOW_LISP_MAP_REGISTER_STATE, mp); /* send */ S; @@ -14065,7 +14063,7 @@ api_show_lisp_rloc_probe_state (vat_main_t * vam) f64 timeout = ~0; vl_api_show_lisp_rloc_probe_state_t *mp; - M (SHOW_LISP_RLOC_PROBE_STATE, show_lisp_rloc_probe_state); + M (SHOW_LISP_RLOC_PROBE_STATE, mp); /* send */ S; @@ -14082,7 +14080,7 @@ api_show_lisp_map_request_mode (vat_main_t * vam) f64 timeout = ~0; vl_api_show_lisp_map_request_mode_t *mp; - M (SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode); + M (SHOW_LISP_MAP_REQUEST_MODE, mp); /* send */ S; @@ -14115,7 +14113,7 @@ api_lisp_map_request_mode (vat_main_t * vam) } } - M (LISP_MAP_REQUEST_MODE, lisp_map_request_mode); + M (LISP_MAP_REQUEST_MODE, mp); mp->mode = mode; @@ -14165,7 +14163,7 @@ api_lisp_pitr_set_locator_set (vat_main_t * vam) return -99; } - M (LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set); + M (LISP_PITR_SET_LOCATOR_SET, mp); mp->is_add = is_add; clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name)); @@ -14192,7 +14190,7 @@ api_show_lisp_pitr (vat_main_t * vam) print (vam->ofp, "%=20s", "lisp status:"); } - M (SHOW_LISP_PITR, show_lisp_pitr); + M (SHOW_LISP_PITR, mp); /* send it... */ S; @@ -14242,7 +14240,7 @@ api_lisp_eid_table_add_del_map (vat_main_t * vam) return -99; } - M (LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map); + M (LISP_EID_TABLE_ADD_DEL_MAP, mp); mp->is_add = is_add; mp->vni = htonl (vni); @@ -14388,7 +14386,7 @@ api_lisp_add_del_remote_mapping (vat_main_t * vam) data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t); - M2 (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping, data_len); + M2 (LISP_ADD_DEL_REMOTE_MAPPING, mp, data_len); mp->is_add = is_add; mp->vni = htonl (vni); mp->action = (u8) action; @@ -14506,7 +14504,7 @@ api_lisp_add_del_adjacency (vat_main_t * vam) return -99; } - M (LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency); + M (LISP_ADD_DEL_ADJACENCY, mp); mp->is_add = is_add; mp->vni = htonl (vni); mp->leid_len = leid_len; @@ -14593,7 +14591,7 @@ api_lisp_gpe_add_del_iface (vat_main_t * vam) } /* Construct the API message */ - M (LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface); + M (LISP_GPE_ADD_DEL_IFACE, mp); mp->is_add = is_add; mp->dp_table = dp_table; @@ -14657,7 +14655,7 @@ api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam) return -99; } - M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, lisp_add_del_map_request_itr_rlocs); + M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp); mp->is_add = is_add; if (is_add) { @@ -14731,7 +14729,7 @@ api_lisp_locator_dump (vat_main_t * vam) print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight"); } - M (LISP_LOCATOR_DUMP, lisp_locator_dump); + M (LISP_LOCATOR_DUMP, mp); mp->is_index_set = is_index_set; if (is_index_set) @@ -14749,7 +14747,7 @@ api_lisp_locator_dump (vat_main_t * vam) /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } /* Wait for a reply... */ @@ -14790,7 +14788,7 @@ api_lisp_locator_set_dump (vat_main_t * vam) print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name"); } - M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump); + M (LISP_LOCATOR_SET_DUMP, mp); mp->filter = filter; @@ -14800,7 +14798,7 @@ api_lisp_locator_set_dump (vat_main_t * vam) /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } /* Wait for a reply... */ @@ -14850,7 +14848,7 @@ api_lisp_eid_table_map_dump (vat_main_t * vam) print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF"); } - M (LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump); + M (LISP_EID_TABLE_MAP_DUMP, mp); mp->is_l2 = is_l2; /* send it... */ @@ -14859,7 +14857,7 @@ api_lisp_eid_table_map_dump (vat_main_t * vam) /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } /* Wait for a reply... */ @@ -14880,7 +14878,7 @@ api_lisp_eid_table_vni_dump (vat_main_t * vam) print (vam->ofp, "VNI"); } - M (LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump); + M (LISP_EID_TABLE_VNI_DUMP, mp); /* send it... */ S; @@ -14888,7 +14886,7 @@ api_lisp_eid_table_vni_dump (vat_main_t * vam) /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } /* Wait for a reply... */ @@ -14955,7 +14953,7 @@ api_lisp_eid_table_dump (vat_main_t * vam) "type", "ls_index", "ttl", "authoritative", "key_id", "key"); } - M (LISP_EID_TABLE_DUMP, lisp_eid_table_dump); + M (LISP_EID_TABLE_DUMP, mp); mp->filter = filter; if (eid_set) @@ -14988,7 +14986,7 @@ api_lisp_eid_table_dump (vat_main_t * vam) /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } @@ -15033,7 +15031,7 @@ api_lisp_gpe_fwd_entries_get (vat_main_t * vam) "leid", "reid"); } - M (LISP_GPE_FWD_ENTRIES_GET, lisp_gpe_fwd_entries_get); + M (LISP_GPE_FWD_ENTRIES_GET, mp); mp->vni = clib_host_to_net_u32 (vni); /* send it... */ @@ -15084,7 +15082,7 @@ api_lisp_adjacencies_get (vat_main_t * vam) print (vam->ofp, "%s %40s", "leid", "reid"); } - M (LISP_ADJACENCIES_GET, lisp_adjacencies_get); + M (LISP_ADJACENCIES_GET, mp); mp->vni = clib_host_to_net_u32 (vni); /* send it... */ @@ -15108,14 +15106,14 @@ api_lisp_map_server_dump (vat_main_t * vam) print (vam->ofp, "%=20s", "Map server"); } - M (LISP_MAP_SERVER_DUMP, lisp_map_server_dump); + M (LISP_MAP_SERVER_DUMP, mp); /* send it... */ S; /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } /* Wait for a reply... */ @@ -15136,14 +15134,14 @@ api_lisp_map_resolver_dump (vat_main_t * vam) print (vam->ofp, "%=20s", "Map resolver"); } - M (LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump); + M (LISP_MAP_RESOLVER_DUMP, mp); /* send it... */ S; /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } /* Wait for a reply... */ @@ -15164,7 +15162,7 @@ api_show_lisp_status (vat_main_t * vam) print (vam->ofp, "%-20s%-16s", "lisp status", "locator-set"); } - M (SHOW_LISP_STATUS, show_lisp_status); + M (SHOW_LISP_STATUS, mp); /* send it... */ S; /* Wait for a reply... */ @@ -15201,14 +15199,14 @@ api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam) print (vam->ofp, "first line"); } - M (LISP_GPE_FWD_ENTRY_PATH_DUMP, lisp_gpe_fwd_entry_path_dump); + M (LISP_GPE_FWD_ENTRY_PATH_DUMP, mp); /* send it... */ S; /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } /* Wait for a reply... */ @@ -15229,7 +15227,7 @@ api_lisp_get_map_request_itr_rlocs (vat_main_t * vam) print (vam->ofp, "%=20s", "itr-rlocs:"); } - M (LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs); + M (LISP_GET_MAP_REQUEST_ITR_RLOCS, mp); /* send it... */ S; /* Wait for a reply... */ @@ -15273,7 +15271,7 @@ api_af_packet_create (vat_main_t * vam) return -99; } - M (AF_PACKET_CREATE, af_packet_create); + M (AF_PACKET_CREATE, mp); clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name)); clib_memcpy (mp->hw_addr, hw_addr, 6); @@ -15314,7 +15312,7 @@ api_af_packet_delete (vat_main_t * vam) return -99; } - M (AF_PACKET_DELETE, af_packet_delete); + M (AF_PACKET_DELETE, mp); clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name)); vec_free (host_if_name); @@ -15399,7 +15397,7 @@ api_policer_add_del (vat_main_t * vam) return -99; } - M (POLICER_ADD_DEL, policer_add_del); + M (POLICER_ADD_DEL, mp); clib_memcpy (mp->name, name, vec_len (name)); vec_free (name); @@ -15445,7 +15443,7 @@ api_policer_dump (vat_main_t * vam) break; } - M (POLICER_DUMP, policer_dump); + M (POLICER_DUMP, mp); mp->match_name_valid = match_name_valid; clib_memcpy (mp->match_name, match_name, vec_len (match_name)); vec_free (match_name); @@ -15455,7 +15453,7 @@ api_policer_dump (vat_main_t * vam) /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } /* Wait for a reply... */ @@ -15505,7 +15503,7 @@ api_policer_classify_set_interface (vat_main_t * vam) return -99; } - M (POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface); + M (POLICER_CLASSIFY_SET_INTERFACE, mp); mp->sw_if_index = ntohl (sw_if_index); mp->ip4_table_index = ntohl (ip4_table_index); @@ -15540,7 +15538,7 @@ api_policer_classify_dump (vat_main_t * vam) print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table"); } - M (POLICER_CLASSIFY_DUMP, policer_classify_dump); + M (POLICER_CLASSIFY_DUMP, mp); mp->type = type; /* send it... */ S; @@ -15548,7 +15546,7 @@ api_policer_classify_dump (vat_main_t * vam) /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } /* Wait for a reply... */ @@ -15600,7 +15598,7 @@ api_netmap_create (vat_main_t * vam) return -99; } - M (NETMAP_CREATE, netmap_create); + M (NETMAP_CREATE, mp); clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name)); clib_memcpy (mp->hw_addr, hw_addr, 6); @@ -15643,7 +15641,7 @@ api_netmap_delete (vat_main_t * vam) return -99; } - M (NETMAP_DELETE, netmap_delete); + M (NETMAP_DELETE, mp); clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name)); vec_free (if_name); @@ -15722,14 +15720,14 @@ api_mpls_tunnel_dump (vat_main_t * vam) print (vam->ofp, " tunnel_index %d", index); - M (MPLS_TUNNEL_DUMP, mpls_tunnel_dump); + M (MPLS_TUNNEL_DUMP, mp); mp->tunnel_index = htonl (index); S; /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } W; @@ -15822,13 +15820,13 @@ api_mpls_fib_dump (vat_main_t * vam) vl_api_mpls_fib_dump_t *mp; f64 timeout; - M (MPLS_FIB_DUMP, mpls_fib_dump); + M (MPLS_FIB_DUMP, mp); S; /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } W; @@ -15923,13 +15921,13 @@ api_ip_fib_dump (vat_main_t * vam) vl_api_ip_fib_dump_t *mp; f64 timeout; - M (IP_FIB_DUMP, ip_fib_dump); + M (IP_FIB_DUMP, mp); S; /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } W; @@ -16012,7 +16010,7 @@ api_ip_neighbor_dump (vat_main_t * vam) return -99; } - M (IP_NEIGHBOR_DUMP, ip_neighbor_dump); + M (IP_NEIGHBOR_DUMP, mp); mp->is_ipv6 = (u8) is_ipv6; mp->sw_if_index = ntohl (sw_if_index); S; @@ -16020,7 +16018,7 @@ api_ip_neighbor_dump (vat_main_t * vam) /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } W; @@ -16115,13 +16113,13 @@ api_ip6_fib_dump (vat_main_t * vam) vl_api_ip6_fib_dump_t *mp; f64 timeout; - M (IP6_FIB_DUMP, ip6_fib_dump); + M (IP6_FIB_DUMP, mp); S; /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } W; @@ -16134,7 +16132,7 @@ api_classify_table_ids (vat_main_t * vam) f64 timeout; /* Construct the API message */ - M (CLASSIFY_TABLE_IDS, classify_table_ids); + M (CLASSIFY_TABLE_IDS, mp); mp->context = 0; S; @@ -16167,7 +16165,7 @@ api_classify_table_by_interface (vat_main_t * vam) } /* Construct the API message */ - M (CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface); + M (CLASSIFY_TABLE_BY_INTERFACE, mp); mp->context = 0; mp->sw_if_index = ntohl (sw_if_index); @@ -16199,7 +16197,7 @@ api_classify_table_info (vat_main_t * vam) } /* Construct the API message */ - M (CLASSIFY_TABLE_INFO, classify_table_info); + M (CLASSIFY_TABLE_INFO, mp); mp->context = 0; mp->table_id = ntohl (table_id); @@ -16231,7 +16229,7 @@ api_classify_session_dump (vat_main_t * vam) } /* Construct the API message */ - M (CLASSIFY_SESSION_DUMP, classify_session_dump); + M (CLASSIFY_SESSION_DUMP, mp); mp->context = 0; mp->table_id = ntohl (table_id); S; @@ -16239,7 +16237,7 @@ api_classify_session_dump (vat_main_t * vam) /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } W; @@ -16301,7 +16299,7 @@ api_ipfix_exporter_dump (vat_main_t * vam) f64 timeout; /* Construct the API message */ - M (IPFIX_EXPORTER_DUMP, ipfix_exporter_dump); + M (IPFIX_EXPORTER_DUMP, mp); mp->context = 0; S; @@ -16317,7 +16315,7 @@ api_ipfix_classify_stream_dump (vat_main_t * vam) f64 timeout; /* Construct the API message */ - M (IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump); + M (IPFIX_CLASSIFY_STREAM_DUMP, mp); mp->context = 0; S; @@ -16367,7 +16365,7 @@ api_ipfix_classify_table_dump (vat_main_t * vam) } /* Construct the API message */ - M (IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump); + M (IPFIX_CLASSIFY_TABLE_DUMP, mp); /* send it... */ S; @@ -16375,7 +16373,7 @@ api_ipfix_classify_table_dump (vat_main_t * vam) /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } W; @@ -16447,7 +16445,7 @@ api_sw_interface_span_enable_disable (vat_main_t * vam) break; } - M (SW_INTERFACE_SPAN_ENABLE_DISABLE, sw_interface_span_enable_disable); + M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp); mp->sw_if_index_from = htonl (src_sw_if_index); mp->sw_if_index_to = htonl (dst_sw_if_index); @@ -16546,13 +16544,13 @@ api_sw_interface_span_dump (vat_main_t * vam) vl_api_sw_interface_span_dump_t *mp; f64 timeout; - M (SW_INTERFACE_SPAN_DUMP, sw_interface_span_dump); + M (SW_INTERFACE_SPAN_DUMP, mp); S; /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } W; @@ -16580,7 +16578,7 @@ api_pg_create_interface (vat_main_t * vam) } /* Construct the API message */ - M (PG_CREATE_INTERFACE, pg_create_interface); + M (PG_CREATE_INTERFACE, mp); mp->context = 0; mp->interface_id = ntohl (if_id); @@ -16631,7 +16629,7 @@ api_pg_capture (vat_main_t * vam) u32 name_len = vec_len (pcap_file); /* Construct the API message */ - M (PG_CAPTURE, pg_capture); + M (PG_CAPTURE, mp); mp->context = 0; mp->interface_id = ntohl (if_id); mp->is_enabled = enable; @@ -16680,7 +16678,7 @@ api_pg_enable_disable (vat_main_t * vam) u32 name_len = vec_len (stream_name); /* Construct the API message */ - M (PG_ENABLE_DISABLE, pg_enable_disable); + M (PG_ENABLE_DISABLE, mp); mp->context = 0; mp->is_enabled = enable; if (stream_name_set != 0) @@ -16795,8 +16793,7 @@ api_ip_source_and_port_range_check_add_del (vat_main_t * vam) return -99; } - M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, - ip_source_and_port_range_check_add_del); + M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp); mp->is_add = is_add; @@ -16881,8 +16878,7 @@ api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam) } /* Construct the API message */ - M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, - ip_source_and_port_range_check_interface_add_del); + M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp); mp->sw_if_index = ntohl (sw_if_index); mp->is_add = is_add; @@ -16929,7 +16925,7 @@ api_ipsec_gre_add_del_tunnel (vat_main_t * vam) } } - M (IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel); + M (IPSEC_GRE_ADD_DEL_TUNNEL, mp); mp->local_sa_id = ntohl (local_sa_id); mp->remote_sa_id = ntohl (remote_sa_id); @@ -16971,7 +16967,7 @@ api_punt (vat_main_t * vam) } } - M (PUNT, punt); + M (PUNT, mp); mp->is_add = (u8) is_add; mp->ipv = (u8) ipv; @@ -17051,7 +17047,7 @@ api_ipsec_gre_tunnel_dump (vat_main_t * vam) } /* Get list of gre-tunnel interfaces */ - M (IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump); + M (IPSEC_GRE_TUNNEL_DUMP, mp); mp->sw_if_index = htonl (sw_if_index); @@ -17060,7 +17056,7 @@ api_ipsec_gre_tunnel_dump (vat_main_t * vam) /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } W; @@ -17091,7 +17087,7 @@ api_delete_subif (vat_main_t * vam) } /* Construct the API message */ - M (DELETE_SUBIF, delete_subif); + M (DELETE_SUBIF, mp); mp->sw_if_index = ntohl (sw_if_index); S; @@ -17174,7 +17170,7 @@ api_l2_interface_pbb_tag_rewrite (vat_main_t * vam) return -99; } - M (L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite); + M (L2_INTERFACE_PBB_TAG_REWRITE, mp); mp->sw_if_index = ntohl (sw_if_index); mp->vtr_op = ntohl (vtr_op); mp->outer_tag = ntohs (outer_tag); @@ -17226,7 +17222,7 @@ api_flow_classify_set_interface (vat_main_t * vam) return -99; } - M (FLOW_CLASSIFY_SET_INTERFACE, flow_classify_set_interface); + M (FLOW_CLASSIFY_SET_INTERFACE, mp); mp->sw_if_index = ntohl (sw_if_index); mp->ip4_table_index = ntohl (ip4_table_index); @@ -17260,7 +17256,7 @@ api_flow_classify_dump (vat_main_t * vam) print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table"); } - M (FLOW_CLASSIFY_DUMP, flow_classify_dump); + M (FLOW_CLASSIFY_DUMP, mp); mp->type = type; /* send it... */ S; @@ -17268,7 +17264,7 @@ api_flow_classify_dump (vat_main_t * vam) /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } /* Wait for a reply... */ @@ -17333,7 +17329,7 @@ api_feature_enable_disable (vat_main_t * vam) } /* Construct the API message */ - M (FEATURE_ENABLE_DISABLE, feature_enable_disable); + M (FEATURE_ENABLE_DISABLE, mp); mp->sw_if_index = ntohl (sw_if_index); mp->enable = enable; clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name)); @@ -17382,7 +17378,7 @@ api_sw_interface_tag_add_del (vat_main_t * vam) } /* Construct the API message */ - M (SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del); + M (SW_INTERFACE_TAG_ADD_DEL, mp); mp->sw_if_index = ntohl (sw_if_index); mp->is_add = enable; if (enable) @@ -17433,14 +17429,14 @@ api_l2_xconnect_dump (vat_main_t * vam) print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index"); } - M (L2_XCONNECT_DUMP, l2_xconnect_dump); + M (L2_XCONNECT_DUMP, mp); S; /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; - M (CONTROL_PING, control_ping); + M (CONTROL_PING, mp); S; } W; @@ -17480,7 +17476,7 @@ api_sw_interface_set_mtu (vat_main_t * vam) } /* Construct the API message */ - M (SW_INTERFACE_SET_MTU, sw_interface_set_mtu); + M (SW_INTERFACE_SET_MTU, mp); mp->sw_if_index = ntohl (sw_if_index); mp->mtu = ntohs ((u16) mtu); -- cgit 1.2.3-korg From 7bc770ceb62ede18414b7bb5788692e32477e373 Mon Sep 17 00:00:00 2001 From: Jon Loeliger Date: Tue, 31 Jan 2017 14:03:33 -0600 Subject: Convert message macro S to accept a message pointer parameter; Rather than blindly assume an unbound, fixed message parameter explicilty pass it as a paramter to the S() macro. Change-Id: Ieea1f1815cadd2eec7d9240408d69acdc3caa49a Signed-off-by: Jon Loeliger --- build-root/emacs-lisp/plugin-test-skel.el | 4 +- src/examples/sample-plugin/sample/sample_test.c | 2 +- src/plugins/acl/acl_test.c | 24 +- src/plugins/flowperpkt/flowperpkt_test.c | 2 +- .../export-vxlan-gpe/vxlan_gpe_ioam_export_test.c | 2 +- src/plugins/ioam/export/ioam_export_test.c | 2 +- src/plugins/ioam/lib-pot/pot_test.c | 12 +- src/plugins/ioam/lib-trace/trace_test.c | 6 +- src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c | 12 +- src/plugins/lb/lb_test.c | 6 +- src/plugins/snat/snat_test.c | 41 +- src/vat/api_format.c | 464 ++++++++++----------- src/vlibapi/vat_helper_macros.h | 2 +- 13 files changed, 295 insertions(+), 284 deletions(-) (limited to 'src/plugins/lb') diff --git a/build-root/emacs-lisp/plugin-test-skel.el b/build-root/emacs-lisp/plugin-test-skel.el index d69aa2ce..6d399468 100644 --- a/build-root/emacs-lisp/plugin-test-skel.el +++ b/build-root/emacs-lisp/plugin-test-skel.el @@ -128,7 +128,7 @@ do { \\ } while(0); /* S: send a message */ -#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp)) +#define S(mp) (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp)) /* W: wait for results, with timeout */ #define W \\ @@ -175,7 +175,7 @@ static int api_" plugin-name "_enable_disable (vat_main_t * vam) mp->enable_disable = enable_disable; /* send it... */ - S; + S(mp); /* Wait for a reply... */ W; diff --git a/src/examples/sample-plugin/sample/sample_test.c b/src/examples/sample-plugin/sample/sample_test.c index 5dcee809..bf7a0590 100644 --- a/src/examples/sample-plugin/sample/sample_test.c +++ b/src/examples/sample-plugin/sample/sample_test.c @@ -122,7 +122,7 @@ static int api_sample_macswap_enable_disable (vat_main_t * vam) mp->enable_disable = enable_disable; /* send it... */ - S; + S(mp); /* Wait for a reply... */ W; diff --git a/src/plugins/acl/acl_test.c b/src/plugins/acl/acl_test.c index 04683a12..70fd6959 100644 --- a/src/plugins/acl/acl_test.c +++ b/src/plugins/acl/acl_test.c @@ -276,7 +276,7 @@ static int api_acl_plugin_get_version (vat_main_t * vam) mp->client_index = vam->my_client_index; /* send it... */ - S; + S(mp); /* Wait for a reply... */ W; @@ -298,7 +298,7 @@ static int api_macip_acl_interface_get (vat_main_t * vam) mp->client_index = vam->my_client_index; /* send it... */ - S; + S(mp); /* Wait for a reply... */ W; @@ -479,7 +479,7 @@ static int api_acl_add_replace (vat_main_t * vam) mp->count = htonl(n_rules); /* send it... */ - S; + S(mp); /* Wait for a reply... */ W; @@ -502,7 +502,7 @@ static int api_acl_del (vat_main_t * vam) mp->acl_index = ntohl(acl_index); /* send it... */ - S; + S(mp); /* Wait for a reply... */ W; @@ -525,7 +525,7 @@ static int api_macip_acl_del (vat_main_t * vam) mp->acl_index = ntohl(acl_index); /* send it... */ - S; + S(mp); /* Wait for a reply... */ W; @@ -592,7 +592,7 @@ static int api_acl_interface_add_del (vat_main_t * vam) mp->is_input = is_input; /* send it... */ - S; + S(mp); /* Wait for a reply... */ W; @@ -642,7 +642,7 @@ static int api_macip_acl_interface_add_del (vat_main_t * vam) mp->is_add = is_add; /* send it... */ - S; + S(mp); /* Wait for a reply... */ W; @@ -699,7 +699,7 @@ static int api_acl_interface_set_acl_list (vat_main_t * vam) clib_memcpy(mp->acls, inacls, vec_len(inacls)*sizeof(u32)); /* send it... */ - S; + S(mp); /* Wait for a reply... */ W; @@ -728,7 +728,7 @@ static int api_acl_interface_list_dump (vat_main_t * vam) mp->sw_if_index = ntohl (sw_if_index); /* send it... */ - S; + S(mp); /* Wait for a reply... */ W; @@ -754,7 +754,7 @@ static int api_acl_dump (vat_main_t * vam) mp->acl_index = ntohl (acl_index); /* send it... */ - S; + S(mp); /* Wait for a reply... */ W; @@ -780,7 +780,7 @@ static int api_macip_acl_dump (vat_main_t * vam) mp->acl_index = ntohl (acl_index); /* send it... */ - S; + S(mp); /* Wait for a reply... */ W; @@ -912,7 +912,7 @@ static int api_macip_acl_add (vat_main_t * vam) mp->count = htonl(n_rules); /* send it... */ - S; + S(mp); /* Wait for a reply... */ W; diff --git a/src/plugins/flowperpkt/flowperpkt_test.c b/src/plugins/flowperpkt/flowperpkt_test.c index 70b4a34a..d5edc4ad 100644 --- a/src/plugins/flowperpkt/flowperpkt_test.c +++ b/src/plugins/flowperpkt/flowperpkt_test.c @@ -129,7 +129,7 @@ api_flowperpkt_tx_interface_add_del (vat_main_t * vam) mp->which = which; /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; diff --git a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c index b9f61d9a..161b5241 100644 --- a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c +++ b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c @@ -110,7 +110,7 @@ api_vxlan_gpe_ioam_export_enable_disable (vat_main_t * vam) mp->is_disable = is_disable; /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; diff --git a/src/plugins/ioam/export/ioam_export_test.c b/src/plugins/ioam/export/ioam_export_test.c index b9686058..45c4ca56 100644 --- a/src/plugins/ioam/export/ioam_export_test.c +++ b/src/plugins/ioam/export/ioam_export_test.c @@ -112,7 +112,7 @@ api_ioam_export_ip6_enable_disable (vat_main_t * vam) mp->is_disable = is_disable; /* send it... */ - S; + S(mp); /* Wait for a reply... */ W; diff --git a/src/plugins/ioam/lib-pot/pot_test.c b/src/plugins/ioam/lib-pot/pot_test.c index 48d5bd40..4f049be8 100644 --- a/src/plugins/ioam/lib-pot/pot_test.c +++ b/src/plugins/ioam/lib-pot/pot_test.c @@ -188,7 +188,8 @@ static int api_pot_profile_add (vat_main_t *vam) mp->id = id; mp->max_bits = bits; - S; W; + S(mp); + W; OUT: vec_free(name); @@ -228,7 +229,8 @@ static int api_pot_profile_activate (vat_main_t *vam) clib_memcpy(mp->list_name, name, mp->list_name_len); mp->id = id; - S; W; + S(mp); + W; OUT: vec_free(name); @@ -243,7 +245,8 @@ static int api_pot_profile_del (vat_main_t *vam) M(POT_PROFILE_DEL, mp); mp->list_name_len = 0; - S; W; + S(mp); + W; return 0; } @@ -264,7 +267,8 @@ static int api_pot_profile_show_config_dump (vat_main_t *vam) mp->id = id; - S; W; + S(mp); + W; return 0; } diff --git a/src/plugins/ioam/lib-trace/trace_test.c b/src/plugins/ioam/lib-trace/trace_test.c index a1354327..5093f330 100644 --- a/src/plugins/ioam/lib-trace/trace_test.c +++ b/src/plugins/ioam/lib-trace/trace_test.c @@ -157,7 +157,7 @@ api_trace_profile_add (vat_main_t * vam) mp->app_data = htonl (app_data); mp->num_elts = num_elts; - S; + S (mp); W; return (rv); @@ -172,7 +172,7 @@ api_trace_profile_del (vat_main_t * vam) f64 timeout; M (TRACE_PROFILE_DEL, mp); - S; + S (mp); W; return 0; } @@ -183,7 +183,7 @@ api_trace_profile_show_config (vat_main_t * vam) vl_api_trace_profile_show_config_t *mp; f64 timeout; M (TRACE_PROFILE_SHOW_CONFIG, mp); - S; + S (mp); W; return 0; } diff --git a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c index 5d36547f..ee25a874 100644 --- a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c +++ b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c @@ -132,7 +132,7 @@ api_vxlan_gpe_ioam_enable (vat_main_t * vam) mp->trace_enable = has_trace_option; - S; + S (mp); W; return (0); @@ -146,7 +146,7 @@ api_vxlan_gpe_ioam_disable (vat_main_t * vam) f64 timeout; M (VXLAN_GPE_IOAM_DISABLE, mp); - S; + S (mp); W; return 0; } @@ -240,7 +240,7 @@ api_vxlan_gpe_ioam_vni_enable (vat_main_t * vam) mp->vni = ntohl (vni); mp->is_ipv6 = ipv6_set; - S; + S (mp); W; return (0); @@ -335,7 +335,7 @@ api_vxlan_gpe_ioam_vni_disable (vat_main_t * vam) mp->vni = ntohl (vni); mp->is_ipv6 = ipv6_set; - S; + S (mp); W; return 0; @@ -405,7 +405,7 @@ api_vxlan_gpe_ioam_transit_enable (vat_main_t * vam) mp->outer_fib_index = htonl (outer_fib_index); mp->is_ipv6 = ipv6_set; - S; + S (mp); W; return (0); @@ -474,7 +474,7 @@ api_vxlan_gpe_ioam_transit_disable (vat_main_t * vam) mp->outer_fib_index = htonl (outer_fib_index); mp->is_ipv6 = ipv6_set; - S; + S (mp); W; diff --git a/src/plugins/lb/lb_test.c b/src/plugins/lb/lb_test.c index c150ea32..f553a93e 100644 --- a/src/plugins/lb/lb_test.c +++ b/src/plugins/lb/lb_test.c @@ -146,7 +146,7 @@ static int api_lb_conf (vat_main_t * vam) } M(LB_CONF, mp); - S; + S(mp); W; /* NOTREACHED */ @@ -186,7 +186,7 @@ static int api_lb_add_del_vip (vat_main_t * vam) } M(LB_ADD_DEL_VIP, mp); - S; + S(mp); W; /* NOTREACHED */ return 0; @@ -211,7 +211,7 @@ static int api_lb_add_del_as (vat_main_t * vam) } M(LB_ADD_DEL_AS, mp); - S; + S(mp); W; /* NOTREACHED */ return 0; diff --git a/src/plugins/snat/snat_test.c b/src/plugins/snat/snat_test.c index c6f9a8ff..c0913f37 100644 --- a/src/plugins/snat/snat_test.c +++ b/src/plugins/snat/snat_test.c @@ -159,7 +159,8 @@ static int api_snat_add_address_range (vat_main_t * vam) mp->is_ip4 = 1; mp->is_add = is_add; - S; W; + S(mp); + W; /* NOTREACHED */ return 0; @@ -205,7 +206,8 @@ static int api_snat_interface_add_del_feature (vat_main_t * vam) mp->is_add = is_add; mp->is_inside = is_inside; - S; W; + S(mp); + W; /* NOTREACHED */ return 0; } @@ -273,7 +275,8 @@ static int api_snat_add_static_mapping(vat_main_t * vam) memcpy (mp->local_ip_address, &local_addr, 4); memcpy (mp->external_ip_address, &external_addr, 4); - S; W; + S(mp); + W; /* NOTREACHED */ return 0; } @@ -331,12 +334,12 @@ static int api_snat_static_mapping_dump(vat_main_t * vam) "port", "vrf"); M(SNAT_STATIC_MAPPING_DUMP, mp); - S; + S(mp); /* Use a control ping for synchronization */ { vl_api_snat_control_ping_t *mp; M(SNAT_CONTROL_PING, mp); - S; + S(mp); } W; /* NOTREACHED */ @@ -386,7 +389,8 @@ static int api_snat_show_config(vat_main_t * vam) } M(SNAT_SHOW_CONFIG, mp); - S; W; + S(mp); + W; /* NOTREACHED */ return 0; } @@ -412,12 +416,12 @@ static int api_snat_address_dump(vat_main_t * vam) } M(SNAT_ADDRESS_DUMP, mp); - S; + S(mp); /* Use a control ping for synchronization */ { vl_api_snat_control_ping_t *mp; M(SNAT_CONTROL_PING, mp); - S; + S(mp); } W; /* NOTREACHED */ @@ -446,12 +450,12 @@ static int api_snat_interface_dump(vat_main_t * vam) } M(SNAT_INTERFACE_DUMP, mp); - S; + S(mp); /* Use a control ping for synchronization */ { vl_api_snat_control_ping_t *mp; M(SNAT_CONTROL_PING, mp); - S; + S(mp); } W; /* NOTREACHED */ @@ -479,7 +483,8 @@ static int api_snat_set_workers (vat_main_t * vam) M(SNAT_SET_WORKERS, mp); mp->worker_mask = clib_host_to_net_u64 (bitmap[0]); - S; W; + S(mp); + W; /* NOTREACHED */ return 0; @@ -507,12 +512,12 @@ static int api_snat_worker_dump(vat_main_t * vam) } M(SNAT_WORKER_DUMP, mp); - S; + S(mp); /* Use a control ping for synchronization */ { vl_api_snat_control_ping_t *mp; M(SNAT_CONTROL_PING, mp); - S; + S(mp); } W; /* NOTREACHED */ @@ -553,7 +558,8 @@ static int api_snat_ipfix_enable_disable (vat_main_t * vam) mp->sw_if_index = ntohl(sw_if_index); mp->is_add = is_add; - S; W; + S(mp); + W; /* NOTREACHED */ return 0; } @@ -579,12 +585,12 @@ static int api_snat_interface_addr_dump(vat_main_t * vam) } M(SNAT_INTERFACE_ADDR_DUMP, mp); - S; + S(mp); /* Use a control ping for synchronization */ { vl_api_snat_control_ping_t *mp; M(SNAT_CONTROL_PING, mp); - S; + S(mp); } W; /* NOTREACHED */ @@ -620,7 +626,8 @@ static int api_snat_add_del_interface_addr (vat_main_t * vam) mp->src_port = htons((u16) src_port); mp->enable = enable; - S; W; + S(mp); + W; /* NOTREACHED */ return 0; } diff --git a/src/vat/api_format.c b/src/vat/api_format.c index 02987eb9..b374b281 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -4608,7 +4608,7 @@ exec (vat_main_t * vam) pthread_mutex_unlock (&am->vlib_rp->mutex); mp->cmd_in_shmem = (u64) cmd; - S; + S (mp); timeout = vat_time_now (vam) + 10.0; while (vat_time_now (vam) < timeout) @@ -4667,7 +4667,7 @@ exec_inband (vat_main_t * vam) clib_memcpy (mp->cmd, vam->input->buffer, len); mp->length = htonl (len); - S; + S (mp); W2 (print (vam->ofp, "%s", vam->cmd_reply)); } @@ -4695,7 +4695,7 @@ api_create_loopback (vat_main_t * vam) if (mac_set) clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address)); - S; + S (mp); W; } @@ -4725,7 +4725,7 @@ api_delete_loopback (vat_main_t * vam) M (DELETE_LOOPBACK, mp); mp->sw_if_index = ntohl (sw_if_index); - S; + S (mp); W; } @@ -4756,7 +4756,7 @@ api_want_stats (vat_main_t * vam) M (WANT_STATS, mp); mp->enable_disable = enable; - S; + S (mp); W; } @@ -4789,7 +4789,7 @@ api_want_interface_events (vat_main_t * vam) vam->interface_event_display = enable; - S; + S (mp); W; } @@ -4833,70 +4833,70 @@ api_sw_interface_dump (vat_main_t * vam) M (SW_INTERFACE_DUMP, mp); mp->name_filter_valid = 1; strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1); - S; + S (mp); /* and local / loopback interfaces */ M (SW_INTERFACE_DUMP, mp); mp->name_filter_valid = 1; strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1); - S; + S (mp); /* and packet-generator interfaces */ M (SW_INTERFACE_DUMP, mp); mp->name_filter_valid = 1; strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1); - S; + S (mp); /* and vxlan-gpe tunnel interfaces */ M (SW_INTERFACE_DUMP, mp); mp->name_filter_valid = 1; strncpy ((char *) mp->name_filter, "vxlan_gpe", sizeof (mp->name_filter) - 1); - S; + S (mp); /* and vxlan tunnel interfaces */ M (SW_INTERFACE_DUMP, mp); mp->name_filter_valid = 1; strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1); - S; + S (mp); /* and host (af_packet) interfaces */ M (SW_INTERFACE_DUMP, mp); mp->name_filter_valid = 1; strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1); - S; + S (mp); /* and l2tpv3 tunnel interfaces */ M (SW_INTERFACE_DUMP, mp); mp->name_filter_valid = 1; strncpy ((char *) mp->name_filter, "l2tpv3_tunnel", sizeof (mp->name_filter) - 1); - S; + S (mp); /* and GRE tunnel interfaces */ M (SW_INTERFACE_DUMP, mp); mp->name_filter_valid = 1; strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1); - S; + S (mp); /* and LISP-GPE interfaces */ M (SW_INTERFACE_DUMP, mp); mp->name_filter_valid = 1; strncpy ((char *) mp->name_filter, "lisp_gpe", sizeof (mp->name_filter) - 1); - S; + S (mp); /* and IPSEC tunnel interfaces */ M (SW_INTERFACE_DUMP, mp); mp->name_filter_valid = 1; strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1); - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } W; } @@ -4944,7 +4944,7 @@ api_sw_interface_set_flags (vat_main_t * vam) mp->link_up_down = link_up; /* send it... */ - S; + S (mp); /* Wait for a reply, return the good/bad news... */ W; @@ -4979,7 +4979,7 @@ api_sw_interface_clear_stats (vat_main_t * vam) mp->sw_if_index = ~0; /* send it... */ - S; + S (mp); /* Wait for a reply, return the good/bad news... */ W; @@ -5053,7 +5053,7 @@ api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam) mp->profile = ntohl (profile); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -5134,7 +5134,7 @@ api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam) mp->tc_rate[3] = ntohl (tc_rate[3]); mp->tc_period = ntohl (tc_period); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -5201,7 +5201,7 @@ api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam) mp->tc = ntohl (tc); mp->queue = ntohl (queue); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -5279,7 +5279,7 @@ api_sw_interface_add_del_address (vat_main_t * vam) mp->address_length = address_length; /* send it... */ - S; + S (mp); /* Wait for a reply, return good/bad news */ W; @@ -5323,7 +5323,7 @@ api_sw_interface_set_mpls_enable (vat_main_t * vam) mp->enable = enable; /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -5368,7 +5368,7 @@ api_sw_interface_set_table (vat_main_t * vam) mp->vrf_id = ntohl (vrf_id); /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -5435,7 +5435,7 @@ api_sw_interface_get_table (vat_main_t * vam) mp->sw_if_index = htonl (sw_if_index); mp->is_ipv6 = is_ipv6; - S; + S (mp); W; } @@ -5477,7 +5477,7 @@ api_sw_interface_set_vpath (vat_main_t * vam) mp->enable = is_enable; /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -5527,7 +5527,7 @@ api_sw_interface_set_vxlan_bypass (vat_main_t * vam) mp->is_ipv6 = is_ipv6; /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -5600,7 +5600,7 @@ api_sw_interface_set_l2_xconnect (vat_main_t * vam) mp->tx_sw_if_index = ntohl (tx_sw_if_index); mp->enable = enable; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -5663,7 +5663,7 @@ api_sw_interface_set_l2_bridge (vat_main_t * vam) mp->bvi = bvi; mp->enable = enable; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -5688,13 +5688,13 @@ api_bridge_domain_dump (vat_main_t * vam) M (BRIDGE_DOMAIN_DUMP, mp); mp->bd_id = ntohl (bd_id); - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } W; @@ -5762,7 +5762,7 @@ api_bridge_domain_add_del (vat_main_t * vam) mp->is_add = is_add; mp->mac_age = (u8) mac_age; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -5871,7 +5871,7 @@ api_l2fib_add_del (vat_main_t * vam) } increment_mac_address (&mac); /* send it... */ - S; + S (mp); } if (count > 1) @@ -5883,7 +5883,7 @@ api_l2fib_add_del (vat_main_t * vam) vam->async_mode = 0; M (CONTROL_PING, mp); - S; + S (mp); timeout = vat_time_now (vam) + 1.0; while (vat_time_now (vam) < timeout) @@ -5964,7 +5964,7 @@ api_l2_flags (vat_main_t * vam) mp->sw_if_index = ntohl (sw_if_index); mp->feature_bitmap = ntohl (feature_bitmap); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -6016,7 +6016,7 @@ api_bridge_flags (vat_main_t * vam) mp->feature_bitmap = ntohl (flags); mp->is_set = is_set; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -6091,7 +6091,7 @@ api_bd_ip_mac_add_del (vat_main_t * vam) else clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr)); clib_memcpy (mp->mac_address, macaddr, 6); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -6184,7 +6184,7 @@ api_tap_connect (vat_main_t * vam) vec_free (tag); /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -6250,7 +6250,7 @@ api_tap_modify (vat_main_t * vam) vec_free (tap_name); /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -6288,7 +6288,7 @@ api_tap_delete (vat_main_t * vam) mp->sw_if_index = ntohl (sw_if_index); /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -6538,7 +6538,7 @@ api_ip_add_del_route (vat_main_t * vam) increment_v4_address (&v4_dst_address); } /* send it... */ - S; + S (mp); /* If we receive SIGTERM, stop now... */ if (vam->do_exit) break; @@ -6554,7 +6554,7 @@ api_ip_add_del_route (vat_main_t * vam) vam->async_mode = 0; M (CONTROL_PING, mp); - S; + S (mp); timeout = vat_time_now (vam) + 1.0; while (vat_time_now (vam) < timeout) @@ -6703,7 +6703,7 @@ api_ip_mroute_add_del (vat_main_t * vam) } /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; } @@ -6876,7 +6876,7 @@ api_mpls_route_add_del (vat_main_t * vam) local_label++; /* send it... */ - S; + S (mp); /* If we receive SIGTERM, stop now... */ if (vam->do_exit) break; @@ -6892,7 +6892,7 @@ api_mpls_route_add_del (vat_main_t * vam) vam->async_mode = 0; M (CONTROL_PING, mp); - S; + S (mp); timeout = vat_time_now (vam) + 1.0; while (vat_time_now (vam) < timeout) @@ -7006,7 +7006,7 @@ api_mpls_ip_bind_unbind (vat_main_t * vam) clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address)); /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -7052,7 +7052,7 @@ api_proxy_arp_add_del (vat_main_t * vam) clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address)); clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address)); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -7096,7 +7096,7 @@ api_proxy_arp_intfc_enable_disable (vat_main_t * vam) mp->sw_if_index = ntohl (sw_if_index); mp->enable_disable = enable; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -7182,7 +7182,7 @@ api_mpls_tunnel_add_del (vat_main_t * vam) &v6_next_hop_address, sizeof (v6_next_hop_address)); } - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -7228,7 +7228,7 @@ api_sw_interface_set_unnumbered (vat_main_t * vam) mp->unnumbered_sw_if_index = ntohl (unnum_sw_index); mp->is_add = is_add; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -7320,7 +7320,7 @@ api_ip_neighbor_add_del (vat_main_t * vam) } /* send it... */ - S; + S (mp); /* Wait for a reply, return good/bad news */ W; @@ -7363,7 +7363,7 @@ api_reset_vrf (vat_main_t * vam) mp->vrf_id = ntohl (vrf_id); mp->is_ipv6 = is_ipv6; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -7412,7 +7412,7 @@ api_create_vlan_subif (vat_main_t * vam) mp->sw_if_index = ntohl (sw_if_index); mp->vlan_id = ntohl (vlan_id); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -7497,7 +7497,7 @@ api_create_subif (vat_main_t * vam) mp->outer_vlan_id = ntohs (outer_vlan_id); mp->inner_vlan_id = ntohs (inner_vlan_id); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -7551,7 +7551,7 @@ api_oam_add_del (vat_main_t * vam) clib_memcpy (mp->src_address, &src, sizeof (mp->src_address)); clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address)); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -7591,7 +7591,7 @@ api_reset_fib (vat_main_t * vam) mp->vrf_id = ntohl (vrf_id); mp->is_ipv6 = is_ipv6; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -7684,7 +7684,7 @@ api_dhcp_proxy_config (vat_main_t * vam) } /* send it... */ - S; + S (mp); /* Wait for a reply, return good/bad news */ W; @@ -7783,7 +7783,7 @@ api_dhcp_proxy_config_2 (vat_main_t * vam) } /* send it... */ - S; + S (mp); /* Wait for a reply, return good/bad news */ W; @@ -7849,7 +7849,7 @@ api_dhcp_proxy_set_vss (vat_main_t * vam) mp->is_ipv6 = is_ipv6; mp->is_add = is_add; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -7908,7 +7908,7 @@ api_dhcp_client_config (vat_main_t * vam) mp->pid = getpid (); /* send it... */ - S; + S (mp); /* Wait for a reply, return good/bad news */ W; @@ -7974,7 +7974,7 @@ api_set_ip_flow_hash (vat_main_t * vam) mp->vrf_id = ntohl (vrf_id); mp->is_ipv6 = is_ipv6; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -8018,7 +8018,7 @@ api_sw_interface_ip6_enable_disable (vat_main_t * vam) mp->sw_if_index = ntohl (sw_if_index); mp->enable = enable; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -8066,7 +8066,7 @@ api_sw_interface_ip6_set_link_local_address (vat_main_t * vam) clib_memcpy (mp->address, &v6address, sizeof (v6address)); /* send it... */ - S; + S (mp); /* Wait for a reply, return good/bad news */ W; @@ -8156,7 +8156,7 @@ api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam) mp->pref_lifetime = ntohl (pref_lifetime); /* send it... */ - S; + S (mp); /* Wait for a reply, return good/bad news */ W; @@ -8253,7 +8253,7 @@ api_sw_interface_ip6nd_ra_config (vat_main_t * vam) mp->default_router = default_router; /* send it... */ - S; + S (mp); /* Wait for a reply, return good/bad news */ W; @@ -8296,7 +8296,7 @@ api_set_arp_neighbor_limit (vat_main_t * vam) mp->arp_neighbor_limit = ntohl (arp_nbr_limit); mp->is_ipv6 = is_ipv6; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -8367,7 +8367,7 @@ api_l2_patch_add_del (vat_main_t * vam) mp->tx_sw_if_index = ntohl (tx_sw_if_index); mp->is_add = is_add; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -8405,7 +8405,7 @@ api_ioam_enable (vat_main_t * vam) mp->pot_enable = has_pot_option; mp->trace_enable = has_trace_option; - S; + S (mp); W; return (0); @@ -8420,7 +8420,7 @@ api_ioam_disable (vat_main_t * vam) f64 timeout; M (IOAM_DISABLE, mp); - S; + S (mp); W; return 0; } @@ -8553,7 +8553,7 @@ api_sr_tunnel_add_del (vat_main_t * vam) vec_free (segments); vec_free (tags); - S; + S (mp); W; /* NOTREACHED */ } @@ -8637,7 +8637,7 @@ api_sr_policy_add_del (vat_main_t * vam) vec_free (tunnel_names); vec_free (tunnel_name); - S; + S (mp); W; /* NOTREACHED */ } @@ -8690,7 +8690,7 @@ api_sr_multicast_map_add_del (vat_main_t * vam) vec_free (policy_name); - S; + S (mp); W; /* NOTREACHED */ } @@ -9406,7 +9406,7 @@ api_classify_add_del_table (vat_main_t * vam) vec_free (mask); - S; + S (mp); W; /* NOTREACHED */ } @@ -9936,7 +9936,7 @@ api_classify_add_del_session (vat_main_t * vam) clib_memcpy (mp->match, match, vec_len (match)); vec_free (match); - S; + S (mp); W; /* NOTREACHED */ } @@ -9980,7 +9980,7 @@ api_classify_set_interface_ip_table (vat_main_t * vam) mp->table_index = ntohl (table_index); mp->is_ipv6 = is_ipv6; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -10035,7 +10035,7 @@ api_classify_set_interface_l2_tables (vat_main_t * vam) mp->other_table_index = ntohl (other_table_index); mp->is_input = (u8) is_input; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -10102,7 +10102,7 @@ api_set_ipfix_exporter (vat_main_t * vam) mp->template_interval = htonl (template_interval); mp->udp_checksum = udp_checksum; - S; + S (mp); W; /* NOTREACHED */ } @@ -10134,7 +10134,7 @@ api_set_ipfix_classify_stream (vat_main_t * vam) mp->domain_id = htonl (domain_id); mp->src_port = htons ((u16) src_port); - S; + S (mp); W; /* NOTREACHED */ } @@ -10196,7 +10196,7 @@ api_ipfix_classify_table_add_del (vat_main_t * vam) mp->ip_version = ip_version; mp->transport_protocol = transport_protocol; - S; + S (mp); W; /* NOTREACHED */ } @@ -10231,7 +10231,7 @@ api_get_node_index (vat_main_t * vam) clib_memcpy (mp->node_name, name, vec_len (name)); vec_free (name); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -10281,7 +10281,7 @@ api_get_next_index (vat_main_t * vam) vec_free (node_name); vec_free (next_node_name); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -10332,7 +10332,7 @@ api_add_node_next (vat_main_t * vam) vec_free (name); vec_free (next); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -10401,7 +10401,7 @@ api_l2tpv3_create_tunnel (vat_main_t * vam) mp->l2_sublayer_present = l2_sublayer_present; mp->is_ipv6 = 1; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -10444,7 +10444,7 @@ api_l2tpv3_set_tunnel_cookies (vat_main_t * vam) mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie); mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -10485,7 +10485,7 @@ api_l2tpv3_interface_enable_disable (vat_main_t * vam) mp->sw_if_index = ntohl (sw_if_index); mp->enable_disable = enable_disable; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -10521,7 +10521,7 @@ api_l2tpv3_set_lookup_key (vat_main_t * vam) mp->key = key; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -10598,13 +10598,13 @@ api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam) /* Get list of l2tpv3-tunnel interfaces */ M (SW_IF_L2TPV3_TUNNEL_DUMP, mp); - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } W; } @@ -10646,13 +10646,13 @@ api_sw_interface_tap_dump (vat_main_t * vam) print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index"); /* Get list of tap interfaces */ M (SW_INTERFACE_TAP_DUMP, mp); - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } W; } @@ -10823,7 +10823,7 @@ api_vxlan_add_del_tunnel (vat_main_t * vam) mp->is_add = is_add; mp->is_ipv6 = ipv6_set; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -10924,13 +10924,13 @@ api_vxlan_tunnel_dump (vat_main_t * vam) mp->sw_if_index = htonl (sw_if_index); - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } W; } @@ -10987,7 +10987,7 @@ api_gre_add_del_tunnel (vat_main_t * vam) mp->is_add = is_add; mp->teb = teb; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -11064,13 +11064,13 @@ api_gre_tunnel_dump (vat_main_t * vam) mp->sw_if_index = htonl (sw_if_index); - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } W; } @@ -11084,7 +11084,7 @@ api_l2_fib_clear_table (vat_main_t * vam) M (L2_FIB_CLEAR_TABLE, mp); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -11128,7 +11128,7 @@ api_l2_interface_efp_filter (vat_main_t * vam) mp->sw_if_index = ntohl (sw_if_index); mp->enable_disable = enable; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -11196,7 +11196,7 @@ api_l2_interface_vlan_tag_rewrite (vat_main_t * vam) mp->tag1 = ntohl (tag1); mp->tag2 = ntohl (tag2); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -11266,7 +11266,7 @@ api_create_vhost_user_if (vat_main_t * vam) strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1); vec_free (tag); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -11334,7 +11334,7 @@ api_modify_vhost_user_if (vat_main_t * vam) mp->custom_dev_instance = ntohl (custom_dev_instance); } - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -11370,7 +11370,7 @@ api_delete_vhost_user_if (vat_main_t * vam) mp->sw_if_index = ntohl (sw_if_index); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -11426,13 +11426,13 @@ api_sw_interface_vhost_user_dump (vat_main_t * vam) /* Get list of vhost-user interfaces */ M (SW_INTERFACE_VHOST_USER_DUMP, mp); - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } W; } @@ -11445,7 +11445,7 @@ api_show_version (vat_main_t * vam) M (SHOW_VERSION, mp); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -11562,7 +11562,7 @@ api_vxlan_gpe_add_del_tunnel (vat_main_t * vam) mp->is_add = is_add; mp->is_ipv6 = ipv6_set; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -11655,13 +11655,13 @@ api_vxlan_gpe_tunnel_dump (vat_main_t * vam) mp->sw_if_index = htonl (sw_if_index); - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } W; } @@ -11739,13 +11739,13 @@ api_l2_fib_table_dump (vat_main_t * vam) M (L2_FIB_TABLE_DUMP, mp); mp->bd_id = ntohl (bd_id); - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } W; } @@ -11791,7 +11791,7 @@ api_interface_name_renumber (vat_main_t * vam) mp->sw_if_index = ntohl (sw_if_index); mp->new_show_dev_instance = ntohl (new_show_dev_instance); - S; + S (mp); W; } @@ -11826,7 +11826,7 @@ api_want_ip4_arp_events (vat_main_t * vam) mp->pid = getpid (); mp->address = address.as_u32; - S; + S (mp); W; } @@ -11861,7 +11861,7 @@ api_want_ip6_nd_events (vat_main_t * vam) mp->pid = getpid (); clib_memcpy (mp->address, &address, sizeof (ip6_address_t)); - S; + S (mp); W; } @@ -11913,7 +11913,7 @@ api_input_acl_set_interface (vat_main_t * vam) mp->l2_table_index = ntohl (l2_table_index); mp->is_add = is_add; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -11969,13 +11969,13 @@ api_ip_address_dump (vat_main_t * vam) M (IP_ADDRESS_DUMP, mp); mp->sw_if_index = ntohl (sw_if_index); mp->is_ipv6 = ipv6_set; - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } W; } @@ -12025,13 +12025,13 @@ api_ip_dump (vat_main_t * vam) M (IP_DUMP, mp); mp->is_ipv6 = ipv6_set; - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } W; } @@ -12068,7 +12068,7 @@ api_ipsec_spd_add_del (vat_main_t * vam) mp->spd_id = ntohl (spd_id); mp->is_add = is_add; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -12122,7 +12122,7 @@ api_ipsec_interface_add_del_spd (vat_main_t * vam) mp->sw_if_index = ntohl (sw_if_index); mp->is_add = is_add; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -12280,7 +12280,7 @@ api_ipsec_spd_add_del_entry (vat_main_t * vam) mp->sa_id = ntohl (sa_id); mp->is_add = is_add; mp->is_ip_any = is_ip_any; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -12412,7 +12412,7 @@ api_ipsec_sad_add_del_entry (vat_main_t * vam) } } - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -12459,7 +12459,7 @@ api_ipsec_sa_set_key (vat_main_t * vam) if (ik) clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -12507,7 +12507,7 @@ api_ikev2_profile_add_del (vat_main_t * vam) mp->is_add = is_add; vec_free (name); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -12578,7 +12578,7 @@ api_ikev2_profile_set_auth (vat_main_t * vam) vec_free (name); vec_free (data); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -12658,7 +12658,7 @@ api_ikev2_profile_set_id (vat_main_t * vam) vec_free (name); vec_free (data); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -12729,7 +12729,7 @@ api_ikev2_profile_set_ts (vat_main_t * vam) clib_memcpy (mp->name, name, vec_len (name)); vec_free (name); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -12771,7 +12771,7 @@ api_ikev2_set_local_key (vat_main_t * vam) clib_memcpy (mp->key_file, file, vec_len (file)); vec_free (file); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -12854,7 +12854,7 @@ api_map_add_domain (vat_main_t * vam) mp->mtu = htons (mtu); /* send it... */ - S; + S (mp); /* Wait for a reply, return good/bad news */ W; @@ -12893,7 +12893,7 @@ api_map_del_domain (vat_main_t * vam) mp->index = ntohl (index); /* send it... */ - S; + S (mp); /* Wait for a reply, return good/bad news */ W; @@ -12937,7 +12937,7 @@ api_map_add_del_rule (vat_main_t * vam) mp->psid = ntohs (psid); /* send it... */ - S; + S (mp); /* Wait for a reply, return good/bad news */ W; @@ -12953,13 +12953,13 @@ api_map_domain_dump (vat_main_t * vam) M (MAP_DOMAIN_DUMP, mp); /* send it... */ - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } W; } @@ -12992,13 +12992,13 @@ api_map_rule_dump (vat_main_t * vam) mp->domain_index = htonl (domain_index); /* send it... */ - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } W; } @@ -13069,7 +13069,7 @@ api_get_first_msg_id (vat_main_t * vam) M (GET_FIRST_MSG_ID, mp); clib_memcpy (mp->name, name, vec_len (name)); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -13111,7 +13111,7 @@ api_cop_interface_enable_disable (vat_main_t * vam) mp->enable_disable = enable_disable; /* send it... */ - S; + S (mp); /* Wait for the reply */ W; } @@ -13160,7 +13160,7 @@ api_cop_whitelist_enable_disable (vat_main_t * vam) mp->default_cop = default_cop; /* send it... */ - S; + S (mp); /* Wait for the reply */ W; } @@ -13174,7 +13174,7 @@ api_get_node_graph (vat_main_t * vam) M (GET_NODE_GRAPH, mp); /* send it... */ - S; + S (mp); /* Wait for the reply */ W; } @@ -13319,7 +13319,7 @@ api_lisp_add_del_locator_set (vat_main_t * vam) vec_free (locators); /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -13434,7 +13434,7 @@ api_lisp_add_del_locator (vat_main_t * vam) vec_free (locator_set_name); /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -13561,7 +13561,7 @@ api_lisp_add_del_local_eid (vat_main_t * vam) vec_free (key); /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -13714,7 +13714,7 @@ api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam) vec_free (rmt_locs); /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -13782,7 +13782,7 @@ api_lisp_add_del_map_server (vat_main_t * vam) } /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -13850,7 +13850,7 @@ api_lisp_add_del_map_resolver (vat_main_t * vam) } /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -13897,7 +13897,7 @@ api_lisp_gpe_enable_disable (vat_main_t * vam) mp->is_en = is_en; /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -13941,7 +13941,7 @@ api_lisp_rloc_probe_enable_disable (vat_main_t * vam) mp->is_enabled = is_en; /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -13985,7 +13985,7 @@ api_lisp_map_register_enable_disable (vat_main_t * vam) mp->is_enabled = is_en; /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -14031,7 +14031,7 @@ api_lisp_enable_disable (vat_main_t * vam) mp->is_en = is_en; /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -14049,7 +14049,7 @@ api_show_lisp_map_register_state (vat_main_t * vam) M (SHOW_LISP_MAP_REGISTER_STATE, mp); /* send */ - S; + S (mp); /* wait for reply */ W; @@ -14066,7 +14066,7 @@ api_show_lisp_rloc_probe_state (vat_main_t * vam) M (SHOW_LISP_RLOC_PROBE_STATE, mp); /* send */ - S; + S (mp); /* wait for reply */ W; @@ -14083,7 +14083,7 @@ api_show_lisp_map_request_mode (vat_main_t * vam) M (SHOW_LISP_MAP_REQUEST_MODE, mp); /* send */ - S; + S (mp); /* wait for reply */ W; @@ -14118,7 +14118,7 @@ api_lisp_map_request_mode (vat_main_t * vam) mp->mode = mode; /* send */ - S; + S (mp); /* wait for reply */ W; @@ -14170,7 +14170,7 @@ api_lisp_pitr_set_locator_set (vat_main_t * vam) vec_free (ls_name); /* send */ - S; + S (mp); /* wait for reply */ W; @@ -14192,7 +14192,7 @@ api_show_lisp_pitr (vat_main_t * vam) M (SHOW_LISP_PITR, mp); /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -14248,7 +14248,7 @@ api_lisp_eid_table_add_del_map (vat_main_t * vam) mp->is_l2 = bd_index_set; /* send */ - S; + S (mp); /* wait for reply */ W; @@ -14403,7 +14403,7 @@ api_lisp_add_del_remote_mapping (vat_main_t * vam) vec_free (rlocs); /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -14531,7 +14531,7 @@ api_lisp_add_del_adjacency (vat_main_t * vam) } /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -14599,7 +14599,7 @@ api_lisp_gpe_add_del_iface (vat_main_t * vam) mp->vni = vni; /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -14669,7 +14669,7 @@ api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam) vec_free (locator_set_name); /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -14742,13 +14742,13 @@ api_lisp_locator_dump (vat_main_t * vam) } /* send it... */ - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } /* Wait for a reply... */ W; @@ -14793,13 +14793,13 @@ api_lisp_locator_set_dump (vat_main_t * vam) mp->filter = filter; /* send it... */ - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } /* Wait for a reply... */ W; @@ -14852,13 +14852,13 @@ api_lisp_eid_table_map_dump (vat_main_t * vam) mp->is_l2 = is_l2; /* send it... */ - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } /* Wait for a reply... */ W; @@ -14881,13 +14881,13 @@ api_lisp_eid_table_vni_dump (vat_main_t * vam) M (LISP_EID_TABLE_VNI_DUMP, mp); /* send it... */ - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } /* Wait for a reply... */ W; @@ -14981,13 +14981,13 @@ api_lisp_eid_table_dump (vat_main_t * vam) } /* send it... */ - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } /* Wait for a reply... */ @@ -15035,7 +15035,7 @@ api_lisp_gpe_fwd_entries_get (vat_main_t * vam) mp->vni = clib_host_to_net_u32 (vni); /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -15086,7 +15086,7 @@ api_lisp_adjacencies_get (vat_main_t * vam) mp->vni = clib_host_to_net_u32 (vni); /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -15108,13 +15108,13 @@ api_lisp_map_server_dump (vat_main_t * vam) M (LISP_MAP_SERVER_DUMP, mp); /* send it... */ - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } /* Wait for a reply... */ W; @@ -15136,13 +15136,13 @@ api_lisp_map_resolver_dump (vat_main_t * vam) M (LISP_MAP_RESOLVER_DUMP, mp); /* send it... */ - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } /* Wait for a reply... */ W; @@ -15164,7 +15164,7 @@ api_show_lisp_status (vat_main_t * vam) M (SHOW_LISP_STATUS, mp); /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -15202,12 +15202,12 @@ api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam) M (LISP_GPE_FWD_ENTRY_PATH_DUMP, mp); /* send it... */ - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } /* Wait for a reply... */ W; @@ -15229,7 +15229,7 @@ api_lisp_get_map_request_itr_rlocs (vat_main_t * vam) M (LISP_GET_MAP_REQUEST_ITR_RLOCS, mp); /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -15278,7 +15278,7 @@ api_af_packet_create (vat_main_t * vam) mp->use_random_hw_addr = random_hw_addr; vec_free (host_if_name); - S; + S (mp); W2 (fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index)); /* NOTREACHED */ return 0; @@ -15317,7 +15317,7 @@ api_af_packet_delete (vat_main_t * vam) clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name)); vec_free (host_if_name); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -15417,7 +15417,7 @@ api_policer_add_del (vat_main_t * vam) mp->violate_dscp = violate_action.dscp; mp->color_aware = color_aware; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -15448,13 +15448,13 @@ api_policer_dump (vat_main_t * vam) clib_memcpy (mp->match_name, match_name, vec_len (match_name)); vec_free (match_name); /* send it... */ - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } /* Wait for a reply... */ W; @@ -15511,7 +15511,7 @@ api_policer_classify_set_interface (vat_main_t * vam) mp->l2_table_index = ntohl (l2_table_index); mp->is_add = is_add; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -15541,13 +15541,13 @@ api_policer_classify_dump (vat_main_t * vam) M (POLICER_CLASSIFY_DUMP, mp); mp->type = type; /* send it... */ - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } /* Wait for a reply... */ W; @@ -15607,7 +15607,7 @@ api_netmap_create (vat_main_t * vam) mp->is_master = is_master; vec_free (if_name); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -15646,7 +15646,7 @@ api_netmap_delete (vat_main_t * vam) clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name)); vec_free (if_name); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -15722,13 +15722,13 @@ api_mpls_tunnel_dump (vat_main_t * vam) M (MPLS_TUNNEL_DUMP, mp); mp->tunnel_index = htonl (index); - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } W; } @@ -15821,13 +15821,13 @@ api_mpls_fib_dump (vat_main_t * vam) f64 timeout; M (MPLS_FIB_DUMP, mp); - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } W; } @@ -15922,13 +15922,13 @@ api_ip_fib_dump (vat_main_t * vam) f64 timeout; M (IP_FIB_DUMP, mp); - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } W; } @@ -16013,13 +16013,13 @@ api_ip_neighbor_dump (vat_main_t * vam) M (IP_NEIGHBOR_DUMP, mp); mp->is_ipv6 = (u8) is_ipv6; mp->sw_if_index = ntohl (sw_if_index); - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } W; } @@ -16114,13 +16114,13 @@ api_ip6_fib_dump (vat_main_t * vam) f64 timeout; M (IP6_FIB_DUMP, mp); - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } W; } @@ -16135,7 +16135,7 @@ api_classify_table_ids (vat_main_t * vam) M (CLASSIFY_TABLE_IDS, mp); mp->context = 0; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -16169,7 +16169,7 @@ api_classify_table_by_interface (vat_main_t * vam) mp->context = 0; mp->sw_if_index = ntohl (sw_if_index); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -16201,7 +16201,7 @@ api_classify_table_info (vat_main_t * vam) mp->context = 0; mp->table_id = ntohl (table_id); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -16232,13 +16232,13 @@ api_classify_session_dump (vat_main_t * vam) M (CLASSIFY_SESSION_DUMP, mp); mp->context = 0; mp->table_id = ntohl (table_id); - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } W; /* NOTREACHED */ @@ -16302,7 +16302,7 @@ api_ipfix_exporter_dump (vat_main_t * vam) M (IPFIX_EXPORTER_DUMP, mp); mp->context = 0; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -16318,7 +16318,7 @@ api_ipfix_classify_stream_dump (vat_main_t * vam) M (IPFIX_CLASSIFY_STREAM_DUMP, mp); mp->context = 0; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -16368,13 +16368,13 @@ api_ipfix_classify_table_dump (vat_main_t * vam) M (IPFIX_CLASSIFY_TABLE_DUMP, mp); /* send it... */ - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } W; } @@ -16451,7 +16451,7 @@ api_sw_interface_span_enable_disable (vat_main_t * vam) mp->sw_if_index_to = htonl (dst_sw_if_index); mp->state = state; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -16545,13 +16545,13 @@ api_sw_interface_span_dump (vat_main_t * vam) f64 timeout; M (SW_INTERFACE_SPAN_DUMP, mp); - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } W; } @@ -16582,7 +16582,7 @@ api_pg_create_interface (vat_main_t * vam) mp->context = 0; mp->interface_id = ntohl (if_id); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -16641,7 +16641,7 @@ api_pg_capture (vat_main_t * vam) } vec_free (pcap_file); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -16688,7 +16688,7 @@ api_pg_enable_disable (vat_main_t * vam) } vec_free (stream_name); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -16819,7 +16819,7 @@ api_ip_source_and_port_range_check_add_del (vat_main_t * vam) mp->vrf_id = ntohl (vrf_id); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -16888,7 +16888,7 @@ api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam) mp->udp_in_vrf_id = ntohl (udp_in_vrf_id); /* send it... */ - S; + S (mp); /* Wait for a reply... */ W; @@ -16933,7 +16933,7 @@ api_ipsec_gre_add_del_tunnel (vat_main_t * vam) clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address)); mp->is_add = is_add; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -16974,7 +16974,7 @@ api_punt (vat_main_t * vam) mp->l4_protocol = (u8) protocol; mp->l4_port = htons ((u16) port); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -17051,13 +17051,13 @@ api_ipsec_gre_tunnel_dump (vat_main_t * vam) mp->sw_if_index = htonl (sw_if_index); - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } W; } @@ -17090,7 +17090,7 @@ api_delete_subif (vat_main_t * vam) M (DELETE_SUBIF, mp); mp->sw_if_index = ntohl (sw_if_index); - S; + S (mp); W; } @@ -17179,7 +17179,7 @@ api_l2_interface_pbb_tag_rewrite (vat_main_t * vam) mp->b_vlanid = ntohs (vlanid); mp->i_sid = ntohl (sid); - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -17229,7 +17229,7 @@ api_flow_classify_set_interface (vat_main_t * vam) mp->ip6_table_index = ntohl (ip6_table_index); mp->is_add = is_add; - S; + S (mp); W; /* NOTREACHED */ return 0; @@ -17259,13 +17259,13 @@ api_flow_classify_dump (vat_main_t * vam) M (FLOW_CLASSIFY_DUMP, mp); mp->type = type; /* send it... */ - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } /* Wait for a reply... */ W; @@ -17337,7 +17337,7 @@ api_feature_enable_disable (vat_main_t * vam) vec_free (arc_name); vec_free (feature_name); - S; + S (mp); W; } @@ -17385,7 +17385,7 @@ api_sw_interface_tag_add_del (vat_main_t * vam) strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1); vec_free (tag); - S; + S (mp); W; } @@ -17431,13 +17431,13 @@ api_l2_xconnect_dump (vat_main_t * vam) M (L2_XCONNECT_DUMP, mp); - S; + S (mp); /* Use a control ping for synchronization */ { vl_api_control_ping_t *mp; M (CONTROL_PING, mp); - S; + S (mp); } W; } @@ -17480,7 +17480,7 @@ api_sw_interface_set_mtu (vat_main_t * vam) mp->sw_if_index = ntohl (sw_if_index); mp->mtu = ntohs ((u16) mtu); - S; + S (mp); W; } diff --git a/src/vlibapi/vat_helper_macros.h b/src/vlibapi/vat_helper_macros.h index b2fbb86d..172fe2db 100644 --- a/src/vlibapi/vat_helper_macros.h +++ b/src/vlibapi/vat_helper_macros.h @@ -39,7 +39,7 @@ do { \ } while(0); /* S: send a message */ -#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp)) +#define S(mp) (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp)) /* W: wait for results, with timeout */ #define W \ -- cgit 1.2.3-korg From 1f9191f6efa5f2e0284c194f920093201b27ef81 Mon Sep 17 00:00:00 2001 From: Jon Loeliger Date: Tue, 31 Jan 2017 15:27:19 -0600 Subject: Localize the timeout variable within the W message macro. Rather than rely on an unbound variable, explicitly introduce the timeout variable within the 'do { ... } while (0)' construct as a block-local variable. Change-Id: I6e78635290f9b5ab3f56b7f116c5fa762c88c9e9 Signed-off-by: Jon Loeliger --- build-root/emacs-lisp/plugin-test-skel.el | 3 +- src/plugins/acl/acl_test.c | 12 -- src/plugins/flowperpkt/flowperpkt_test.c | 1 - .../export-vxlan-gpe/vxlan_gpe_ioam_export_test.c | 1 - src/plugins/ioam/export/ioam_export_test.c | 1 - src/plugins/ioam/lib-pot/pot_test.c | 4 - src/plugins/ioam/lib-trace/trace_test.c | 4 +- src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c | 6 - src/plugins/lb/lb_test.c | 3 - src/plugins/snat/snat_test.c | 12 -- src/vat/api_format.c | 186 +-------------------- src/vlibapi/vat_helper_macros.h | 4 +- 12 files changed, 6 insertions(+), 231 deletions(-) (limited to 'src/plugins/lb') diff --git a/build-root/emacs-lisp/plugin-test-skel.el b/build-root/emacs-lisp/plugin-test-skel.el index 6d399468..116c420a 100644 --- a/build-root/emacs-lisp/plugin-test-skel.el +++ b/build-root/emacs-lisp/plugin-test-skel.el @@ -133,7 +133,7 @@ do { \\ /* W: wait for results, with timeout */ #define W \\ do { \\ - timeout = vat_time_now (vam) + 1.0; \\ + f64 timeout = vat_time_now (vam) + 1.0; \\ \\ while (vat_time_now (vam) < timeout) { \\ if (vam->result_ready == 1) { \\ @@ -147,7 +147,6 @@ static int api_" plugin-name "_enable_disable (vat_main_t * vam) { " plugin-name "_test_main_t * sm = &" plugin-name "_test_main; unformat_input_t * i = vam->input; - f64 timeout; int enable_disable = 1; u32 sw_if_index = ~0; vl_api_" plugin-name "_enable_disable_t * mp; diff --git a/src/plugins/acl/acl_test.c b/src/plugins/acl/acl_test.c index 70fd6959..39d7e1c4 100644 --- a/src/plugins/acl/acl_test.c +++ b/src/plugins/acl/acl_test.c @@ -267,7 +267,6 @@ static int api_acl_plugin_get_version (vat_main_t * vam) acl_test_main_t * sm = &acl_test_main; vl_api_acl_plugin_get_version_t * mp; u32 msg_size = sizeof(*mp); - f64 timeout; vam->result_ready = 0; mp = vl_msg_api_alloc_as_if_client(msg_size); @@ -289,7 +288,6 @@ static int api_macip_acl_interface_get (vat_main_t * vam) acl_test_main_t * sm = &acl_test_main; vl_api_acl_plugin_get_version_t * mp; u32 msg_size = sizeof(*mp); - f64 timeout; vam->result_ready = 0; mp = vl_msg_api_alloc_as_if_client(msg_size); @@ -321,7 +319,6 @@ static int api_acl_add_replace (vat_main_t * vam) { acl_test_main_t * sm = &acl_test_main; unformat_input_t * i = vam->input; - f64 timeout; vl_api_acl_add_replace_t * mp; u32 acl_index = ~0; u32 msg_size = sizeof (*mp); /* without the rules */ @@ -488,7 +485,6 @@ static int api_acl_add_replace (vat_main_t * vam) static int api_acl_del (vat_main_t * vam) { unformat_input_t * i = vam->input; - f64 timeout; vl_api_acl_del_t * mp; u32 acl_index = ~0; @@ -511,7 +507,6 @@ static int api_acl_del (vat_main_t * vam) static int api_macip_acl_del (vat_main_t * vam) { unformat_input_t * i = vam->input; - f64 timeout; vl_api_acl_del_t * mp; u32 acl_index = ~0; @@ -534,7 +529,6 @@ static int api_macip_acl_del (vat_main_t * vam) static int api_acl_interface_add_del (vat_main_t * vam) { unformat_input_t * i = vam->input; - f64 timeout; vl_api_acl_interface_add_del_t * mp; u32 sw_if_index = ~0; u32 acl_index = ~0; @@ -601,7 +595,6 @@ static int api_acl_interface_add_del (vat_main_t * vam) static int api_macip_acl_interface_add_del (vat_main_t * vam) { unformat_input_t * i = vam->input; - f64 timeout; vl_api_macip_acl_interface_add_del_t * mp; u32 sw_if_index = ~0; u32 acl_index = ~0; @@ -651,7 +644,6 @@ static int api_macip_acl_interface_add_del (vat_main_t * vam) static int api_acl_interface_set_acl_list (vat_main_t * vam) { unformat_input_t * i = vam->input; - f64 timeout; vl_api_acl_interface_set_acl_list_t * mp; u32 sw_if_index = ~0; u32 acl_index = ~0; @@ -709,7 +701,6 @@ static int api_acl_interface_set_acl_list (vat_main_t * vam) static int api_acl_interface_list_dump (vat_main_t * vam) { unformat_input_t * i = vam->input; - f64 timeout; u32 sw_if_index = ~0; vl_api_acl_interface_list_dump_t * mp; @@ -737,7 +728,6 @@ static int api_acl_interface_list_dump (vat_main_t * vam) static int api_acl_dump (vat_main_t * vam) { unformat_input_t * i = vam->input; - f64 timeout; u32 acl_index = ~0; vl_api_acl_dump_t * mp; @@ -763,7 +753,6 @@ static int api_acl_dump (vat_main_t * vam) static int api_macip_acl_dump (vat_main_t * vam) { unformat_input_t * i = vam->input; - f64 timeout; u32 acl_index = ~0; vl_api_acl_dump_t * mp; @@ -799,7 +788,6 @@ static int api_macip_acl_add (vat_main_t * vam) { acl_test_main_t * sm = &acl_test_main; unformat_input_t * i = vam->input; - f64 timeout; vl_api_macip_acl_add_t * mp; u32 msg_size = sizeof (*mp); /* without the rules */ diff --git a/src/plugins/flowperpkt/flowperpkt_test.c b/src/plugins/flowperpkt/flowperpkt_test.c index d5edc4ad..4cc1cfb7 100644 --- a/src/plugins/flowperpkt/flowperpkt_test.c +++ b/src/plugins/flowperpkt/flowperpkt_test.c @@ -95,7 +95,6 @@ static int api_flowperpkt_tx_interface_add_del (vat_main_t * vam) { unformat_input_t *i = vam->input; - f64 timeout; int enable_disable = 1; u8 which = 0; /* ipv4 by default */ u32 sw_if_index = ~0; diff --git a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c index 161b5241..a7938219 100644 --- a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c +++ b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c @@ -92,7 +92,6 @@ static int api_vxlan_gpe_ioam_export_enable_disable (vat_main_t * vam) { unformat_input_t *i = vam->input; - f64 timeout; int is_disable = 0; vl_api_vxlan_gpe_ioam_export_enable_disable_t *mp; diff --git a/src/plugins/ioam/export/ioam_export_test.c b/src/plugins/ioam/export/ioam_export_test.c index 45c4ca56..2cb036a5 100644 --- a/src/plugins/ioam/export/ioam_export_test.c +++ b/src/plugins/ioam/export/ioam_export_test.c @@ -94,7 +94,6 @@ static int api_ioam_export_ip6_enable_disable (vat_main_t * vam) { unformat_input_t *i = vam->input; - f64 timeout; int is_disable = 0; vl_api_ioam_export_ip6_enable_disable_t *mp; diff --git a/src/plugins/ioam/lib-pot/pot_test.c b/src/plugins/ioam/lib-pot/pot_test.c index 4f049be8..d896eb2f 100644 --- a/src/plugins/ioam/lib-pot/pot_test.c +++ b/src/plugins/ioam/lib-pot/pot_test.c @@ -132,7 +132,6 @@ static int api_pot_profile_add (vat_main_t *vam) u64 secret_key = 0; u32 bits = MAX_BITS; u64 lpc = 0, poly2 = 0; - f64 timeout; u8 id = 0; int rv = 0; @@ -204,7 +203,6 @@ static int api_pot_profile_activate (vat_main_t *vam) u8 *name = NULL; u8 id = 0; int rv = 0; - f64 timeout; while (unformat_check_input(input) != UNFORMAT_END_OF_INPUT) { @@ -241,7 +239,6 @@ OUT: static int api_pot_profile_del (vat_main_t *vam) { vl_api_pot_profile_del_t *mp; - f64 timeout; M(POT_PROFILE_DEL, mp); mp->list_name_len = 0; @@ -254,7 +251,6 @@ static int api_pot_profile_show_config_dump (vat_main_t *vam) { unformat_input_t *input = vam->input; vl_api_pot_profile_show_config_dump_t *mp; - f64 timeout; u8 id = 0; while(unformat_check_input(input) != UNFORMAT_END_OF_INPUT) diff --git a/src/plugins/ioam/lib-trace/trace_test.c b/src/plugins/ioam/lib-trace/trace_test.c index 5093f330..d1fb7205 100644 --- a/src/plugins/ioam/lib-trace/trace_test.c +++ b/src/plugins/ioam/lib-trace/trace_test.c @@ -129,7 +129,6 @@ api_trace_profile_add (vat_main_t * vam) u32 node_id = 0; u32 app_data = 0; u8 trace_tsp = 0; - f64 timeout; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { @@ -169,7 +168,6 @@ static int api_trace_profile_del (vat_main_t * vam) { vl_api_trace_profile_del_t *mp; - f64 timeout; M (TRACE_PROFILE_DEL, mp); S (mp); @@ -181,7 +179,7 @@ static int api_trace_profile_show_config (vat_main_t * vam) { vl_api_trace_profile_show_config_t *mp; - f64 timeout; + M (TRACE_PROFILE_SHOW_CONFIG, mp); S (mp); W; diff --git a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c index ee25a874..3e7300f5 100644 --- a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c +++ b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c @@ -104,7 +104,6 @@ api_vxlan_gpe_ioam_enable (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_vxlan_gpe_ioam_enable_t *mp; - f64 timeout; u32 id = 0; int has_trace_option = 0; int has_pow_option = 0; @@ -143,7 +142,6 @@ static int api_vxlan_gpe_ioam_disable (vat_main_t * vam) { vl_api_vxlan_gpe_ioam_disable_t *mp; - f64 timeout; M (VXLAN_GPE_IOAM_DISABLE, mp); S (mp); @@ -163,7 +161,6 @@ api_vxlan_gpe_ioam_vni_enable (vat_main_t * vam) u8 remote_set = 0; u32 vni; u8 vni_set = 0; - f64 timeout; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) @@ -258,7 +255,6 @@ api_vxlan_gpe_ioam_vni_disable (vat_main_t * vam) u8 remote_set = 0; u32 vni; u8 vni_set = 0; - f64 timeout; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) @@ -351,7 +347,6 @@ api_vxlan_gpe_ioam_transit_enable (vat_main_t * vam) u8 ipv4_set = 0, ipv6_set = 0; u8 local_set = 0; u32 outer_fib_index = 0; - f64 timeout; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) @@ -421,7 +416,6 @@ api_vxlan_gpe_ioam_transit_disable (vat_main_t * vam) u8 ipv4_set = 0, ipv6_set = 0; u8 local_set = 0; u32 outer_fib_index = 0; - f64 timeout; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) diff --git a/src/plugins/lb/lb_test.c b/src/plugins/lb/lb_test.c index f553a93e..a811079e 100644 --- a/src/plugins/lb/lb_test.c +++ b/src/plugins/lb/lb_test.c @@ -133,7 +133,6 @@ foreach_standard_reply_retval_handler; static int api_lb_conf (vat_main_t * vam) { unformat_input_t *i = vam->input; - f64 timeout; vl_api_lb_conf_t mps, *mp; if (!unformat(i, "%U %U %u %u", @@ -156,7 +155,6 @@ static int api_lb_conf (vat_main_t * vam) static int api_lb_add_del_vip (vat_main_t * vam) { unformat_input_t * i = vam->input; - f64 timeout; vl_api_lb_add_del_vip_t mps, *mp; mps.is_del = 0; mps.is_gre4 = 0; @@ -195,7 +193,6 @@ static int api_lb_add_del_vip (vat_main_t * vam) static int api_lb_add_del_as (vat_main_t * vam) { unformat_input_t * i = vam->input; - f64 timeout; vl_api_lb_add_del_as_t mps, *mp; mps.is_del = 0; diff --git a/src/plugins/snat/snat_test.c b/src/plugins/snat/snat_test.c index c0913f37..8bab00c1 100644 --- a/src/plugins/snat/snat_test.c +++ b/src/plugins/snat/snat_test.c @@ -109,7 +109,6 @@ _(SNAT_IPFIX_ENABLE_DISABLE_REPLY, \ static int api_snat_add_address_range (vat_main_t * vam) { unformat_input_t * i = vam->input; - f64 timeout; ip4_address_t start_addr, end_addr; u32 start_host_order, end_host_order; vl_api_snat_add_address_range_t * mp; @@ -169,7 +168,6 @@ static int api_snat_add_address_range (vat_main_t * vam) static int api_snat_interface_add_del_feature (vat_main_t * vam) { unformat_input_t * i = vam->input; - f64 timeout; vl_api_snat_interface_add_del_feature_t * mp; u32 sw_if_index; u8 sw_if_index_set = 0; @@ -215,7 +213,6 @@ static int api_snat_interface_add_del_feature (vat_main_t * vam) static int api_snat_add_static_mapping(vat_main_t * vam) { unformat_input_t * i = vam->input; - f64 timeout; vl_api_snat_add_static_mapping_t * mp; u8 external_addr_set = 0; u8 local_addr_set; @@ -320,7 +317,6 @@ static void vl_api_snat_static_mapping_details_t_handler static int api_snat_static_mapping_dump(vat_main_t * vam) { - f64 timeout; vl_api_snat_static_mapping_dump_t * mp; if (vam->json_output) @@ -379,7 +375,6 @@ static void vl_api_snat_show_config_reply_t_handler static int api_snat_show_config(vat_main_t * vam) { - f64 timeout; vl_api_snat_show_config_t * mp; if (vam->json_output) @@ -406,7 +401,6 @@ static void vl_api_snat_address_details_t_handler static int api_snat_address_dump(vat_main_t * vam) { - f64 timeout; vl_api_snat_address_dump_t * mp; if (vam->json_output) @@ -440,7 +434,6 @@ static void vl_api_snat_interface_details_t_handler static int api_snat_interface_dump(vat_main_t * vam) { - f64 timeout; vl_api_snat_interface_dump_t * mp; if (vam->json_output) @@ -465,7 +458,6 @@ static int api_snat_interface_dump(vat_main_t * vam) static int api_snat_set_workers (vat_main_t * vam) { unformat_input_t * i = vam->input; - f64 timeout; vl_api_snat_set_workers_t * mp; uword *bitmap; @@ -502,7 +494,6 @@ static void vl_api_snat_worker_details_t_handler static int api_snat_worker_dump(vat_main_t * vam) { - f64 timeout; vl_api_snat_worker_dump_t * mp; if (vam->json_output) @@ -527,7 +518,6 @@ static int api_snat_worker_dump(vat_main_t * vam) static int api_snat_ipfix_enable_disable (vat_main_t * vam) { unformat_input_t * i = vam->input; - f64 timeout; vl_api_snat_add_del_interface_addr_t * mp; u32 sw_if_index; u8 sw_if_index_set = 0; @@ -575,7 +565,6 @@ static void vl_api_snat_interface_addr_details_t_handler static int api_snat_interface_addr_dump(vat_main_t * vam) { - f64 timeout; vl_api_snat_interface_addr_dump_t * mp; if (vam->json_output) @@ -600,7 +589,6 @@ static int api_snat_interface_addr_dump(vat_main_t * vam) static int api_snat_add_del_interface_addr (vat_main_t * vam) { unformat_input_t * i = vam->input; - f64 timeout; vl_api_snat_ipfix_enable_disable_t * mp; u32 domain_id = 0; u32 src_port = 0; diff --git a/src/vat/api_format.c b/src/vat/api_format.c index b374b281..8caa94f0 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -4640,7 +4640,6 @@ static int exec_inband (vat_main_t * vam) { vl_api_cli_inband_t *mp; - f64 timeout; unformat_input_t *i = vam->input; if (vec_len (i->buffer) == 0) @@ -4676,7 +4675,6 @@ api_create_loopback (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_create_loopback_t *mp; - f64 timeout; u8 mac_address[6]; u8 mac_set = 0; @@ -4704,7 +4702,6 @@ api_delete_loopback (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_delete_loopback_t *mp; - f64 timeout; u32 sw_if_index = ~0; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -4734,7 +4731,6 @@ api_want_stats (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_want_stats_t *mp; - f64 timeout; int enable = -1; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -4765,7 +4761,6 @@ api_want_interface_events (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_want_interface_events_t *mp; - f64 timeout; int enable = -1; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -4799,7 +4794,6 @@ int api_sw_interface_dump (vat_main_t * vam) { vl_api_sw_interface_dump_t *mp; - f64 timeout; hash_pair_t *p; name_sort_t *nses = 0, *ns; sw_interface_subif_t *sub = NULL; @@ -4906,7 +4900,6 @@ api_sw_interface_set_flags (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_sw_interface_set_flags_t *mp; - f64 timeout; u32 sw_if_index; u8 sw_if_index_set = 0; u8 admin_up = 0, link_up = 0; @@ -4955,7 +4948,6 @@ api_sw_interface_clear_stats (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_sw_interface_clear_stats_t *mp; - f64 timeout; u32 sw_if_index; u8 sw_if_index_set = 0; @@ -4991,7 +4983,6 @@ api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp; - f64 timeout; u32 sw_if_index; u8 sw_if_index_set = 0; u32 subport; @@ -5064,7 +5055,6 @@ api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_sw_interface_set_dpdk_hqos_subport_t *mp; - f64 timeout; u32 sw_if_index; u8 sw_if_index_set = 0; u32 subport; @@ -5145,7 +5135,6 @@ api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp; - f64 timeout; u32 sw_if_index; u8 sw_if_index_set = 0; u8 entry_set = 0; @@ -5213,7 +5202,6 @@ api_sw_interface_add_del_address (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_sw_interface_add_del_address_t *mp; - f64 timeout; u32 sw_if_index; u8 sw_if_index_set = 0; u8 is_add = 1, del_all = 0; @@ -5290,7 +5278,6 @@ api_sw_interface_set_mpls_enable (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_sw_interface_set_mpls_enable_t *mp; - f64 timeout; u32 sw_if_index; u8 sw_if_index_set = 0; u8 enable = 1; @@ -5334,7 +5321,6 @@ api_sw_interface_set_table (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_sw_interface_set_table_t *mp; - f64 timeout; u32 sw_if_index, vrf_id = 0; u8 sw_if_index_set = 0; u8 is_ipv6 = 0; @@ -5411,7 +5397,6 @@ api_sw_interface_get_table (vat_main_t * vam) u32 sw_if_index; u8 sw_if_index_set = 0; u8 is_ipv6 = 0; - f64 timeout; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -5444,7 +5429,6 @@ api_sw_interface_set_vpath (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_sw_interface_set_vpath_t *mp; - f64 timeout; u32 sw_if_index = 0; u8 sw_if_index_set = 0; u8 is_enable = 0; @@ -5488,7 +5472,6 @@ api_sw_interface_set_vxlan_bypass (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_sw_interface_set_vxlan_bypass_t *mp; - f64 timeout; u32 sw_if_index = 0; u8 sw_if_index_set = 0; u8 is_enable = 1; @@ -5538,7 +5521,6 @@ api_sw_interface_set_l2_xconnect (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_sw_interface_set_l2_xconnect_t *mp; - f64 timeout; u32 rx_sw_if_index; u8 rx_sw_if_index_set = 0; u32 tx_sw_if_index; @@ -5611,7 +5593,6 @@ api_sw_interface_set_l2_bridge (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_sw_interface_set_l2_bridge_t *mp; - f64 timeout; u32 rx_sw_if_index; u8 rx_sw_if_index_set = 0; u32 bd_id; @@ -5674,7 +5655,6 @@ api_bridge_domain_dump (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_bridge_domain_dump_t *mp; - f64 timeout; u32 bd_id = ~0; /* Parse args required to build the message */ @@ -5707,7 +5687,6 @@ api_bridge_domain_add_del (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_bridge_domain_add_del_t *mp; - f64 timeout; u32 bd_id = ~0; u8 is_add = 1; u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0; @@ -5920,7 +5899,6 @@ api_l2_flags (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_l2_flags_t *mp; - f64 timeout; u32 sw_if_index; u32 feature_bitmap = 0; u8 sw_if_index_set = 0; @@ -5975,7 +5953,6 @@ api_bridge_flags (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_bridge_flags_t *mp; - f64 timeout; u32 bd_id; u8 bd_id_set = 0; u8 is_set = 1; @@ -6027,7 +6004,6 @@ api_bd_ip_mac_add_del (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_bd_ip_mac_add_del_t *mp; - f64 timeout; u32 bd_id; u8 is_ipv6 = 0; u8 is_add = 1; @@ -6102,7 +6078,6 @@ api_tap_connect (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_tap_connect_t *mp; - f64 timeout; u8 mac_address[6]; u8 random_mac = 1; u8 name_set = 0; @@ -6195,7 +6170,6 @@ api_tap_modify (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_tap_modify_t *mp; - f64 timeout; u8 mac_address[6]; u8 random_mac = 1; u8 name_set = 0; @@ -6261,7 +6235,6 @@ api_tap_delete (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_tap_delete_t *mp; - f64 timeout; u32 sw_if_index = ~0; u8 sw_if_index_set = 0; @@ -6299,7 +6272,6 @@ api_ip_add_del_route (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_ip_add_del_route_t *mp; - f64 timeout; u32 sw_if_index = ~0, vrf_id = 0; u8 is_ipv6 = 0; u8 is_local = 0, is_drop = 0; @@ -6549,6 +6521,7 @@ api_ip_add_del_route (vat_main_t * vam) { vl_api_control_ping_t *mp; f64 after; + f64 timeout; /* Shut off async mode */ vam->async_mode = 0; @@ -6596,7 +6569,6 @@ api_ip_mroute_add_del (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_ip_mroute_add_del_t *mp; - f64 timeout; u32 sw_if_index = ~0, vrf_id = 0; u8 is_ipv6 = 0; u8 is_local = 0; @@ -6713,7 +6685,6 @@ api_mpls_route_add_del (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_mpls_route_add_del_t *mp; - f64 timeout; u32 sw_if_index = ~0, table_id = 0; u8 create_table_if_needed = 0; u8 is_add = 1; @@ -6887,6 +6858,7 @@ api_mpls_route_add_del (vat_main_t * vam) { vl_api_control_ping_t *mp; f64 after; + f64 timeout; /* Shut off async mode */ vam->async_mode = 0; @@ -6934,7 +6906,6 @@ api_mpls_ip_bind_unbind (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_mpls_ip_bind_unbind_t *mp; - f64 timeout; u32 ip_table_id = 0; u8 create_table_if_needed = 0; u8 is_bind = 1; @@ -7017,7 +6988,6 @@ api_proxy_arp_add_del (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_proxy_arp_add_del_t *mp; - f64 timeout; u32 vrf_id = 0; u8 is_add = 1; ip4_address_t lo, hi; @@ -7063,7 +7033,6 @@ api_proxy_arp_intfc_enable_disable (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_proxy_arp_intfc_enable_disable_t *mp; - f64 timeout; u32 sw_if_index; u8 enable = 1; u8 sw_if_index_set = 0; @@ -7107,7 +7076,6 @@ api_mpls_tunnel_add_del (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_mpls_tunnel_add_del_t *mp; - f64 timeout; u8 is_add = 1; u8 l2_only = 0; @@ -7193,7 +7161,6 @@ api_sw_interface_set_unnumbered (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_sw_interface_set_unnumbered_t *mp; - f64 timeout; u32 sw_if_index; u32 unnum_sw_index = ~0; u8 is_add = 1; @@ -7239,7 +7206,6 @@ api_ip_neighbor_add_del (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_ip_neighbor_add_del_t *mp; - f64 timeout; u32 sw_if_index; u8 sw_if_index_set = 0; u32 vrf_id = 0; @@ -7334,7 +7300,6 @@ api_reset_vrf (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_reset_vrf_t *mp; - f64 timeout; u32 vrf_id = 0; u8 is_ipv6 = 0; u8 vrf_id_set = 0; @@ -7374,7 +7339,6 @@ api_create_vlan_subif (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_create_vlan_subif_t *mp; - f64 timeout; u32 sw_if_index; u8 sw_if_index_set = 0; u32 vlan_id; @@ -7433,7 +7397,6 @@ api_create_subif (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_create_subif_t *mp; - f64 timeout; u32 sw_if_index; u8 sw_if_index_set = 0; u32 sub_id; @@ -7508,7 +7471,6 @@ api_oam_add_del (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_oam_add_del_t *mp; - f64 timeout; u32 vrf_id = 0; u8 is_add = 1; ip4_address_t src, dst; @@ -7562,7 +7524,6 @@ api_reset_fib (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_reset_fib_t *mp; - f64 timeout; u32 vrf_id = 0; u8 is_ipv6 = 0; u8 vrf_id_set = 0; @@ -7602,7 +7563,6 @@ api_dhcp_proxy_config (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_dhcp_proxy_config_t *mp; - f64 timeout; u32 vrf_id = 0; u8 is_add = 1; u8 insert_cid = 1; @@ -7697,7 +7657,6 @@ api_dhcp_proxy_config_2 (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_dhcp_proxy_config_2_t *mp; - f64 timeout; u32 rx_vrf_id = 0; u32 server_vrf_id = 0; u8 is_add = 1; @@ -7796,7 +7755,6 @@ api_dhcp_proxy_set_vss (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_dhcp_proxy_set_vss_t *mp; - f64 timeout; u8 is_ipv6 = 0; u8 is_add = 1; u32 tbl_id; @@ -7860,7 +7818,6 @@ api_dhcp_client_config (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_dhcp_client_config_t *mp; - f64 timeout; u32 sw_if_index; u8 sw_if_index_set = 0; u8 is_add = 1; @@ -7921,7 +7878,6 @@ api_set_ip_flow_hash (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_set_ip_flow_hash_t *mp; - f64 timeout; u32 vrf_id = 0; u8 is_ipv6 = 0; u8 vrf_id_set = 0; @@ -7985,7 +7941,6 @@ api_sw_interface_ip6_enable_disable (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_sw_interface_ip6_enable_disable_t *mp; - f64 timeout; u32 sw_if_index; u8 sw_if_index_set = 0; u8 enable = 0; @@ -8029,7 +7984,6 @@ api_sw_interface_ip6_set_link_local_address (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_sw_interface_ip6_set_link_local_address_t *mp; - f64 timeout; u32 sw_if_index; u8 sw_if_index_set = 0; u8 v6_address_set = 0; @@ -8081,7 +8035,6 @@ api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_sw_interface_ip6nd_ra_prefix_t *mp; - f64 timeout; u32 sw_if_index; u8 sw_if_index_set = 0; u32 address_length = 0; @@ -8170,7 +8123,6 @@ api_sw_interface_ip6nd_ra_config (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_sw_interface_ip6nd_ra_config_t *mp; - f64 timeout; u32 sw_if_index; u8 sw_if_index_set = 0; u8 suppress = 0; @@ -8267,7 +8219,6 @@ api_set_arp_neighbor_limit (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_set_arp_neighbor_limit_t *mp; - f64 timeout; u32 arp_nbr_limit; u8 limit_set = 0; u8 is_ipv6 = 0; @@ -8307,7 +8258,6 @@ api_l2_patch_add_del (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_l2_patch_add_del_t *mp; - f64 timeout; u32 rx_sw_if_index; u8 rx_sw_if_index_set = 0; u32 tx_sw_if_index; @@ -8378,7 +8328,6 @@ api_ioam_enable (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_ioam_enable_t *mp; - f64 timeout; u32 id = 0; int has_trace_option = 0; int has_pot_option = 0; @@ -8417,7 +8366,6 @@ static int api_ioam_disable (vat_main_t * vam) { vl_api_ioam_disable_t *mp; - f64 timeout; M (IOAM_DISABLE, mp); S (mp); @@ -8430,7 +8378,6 @@ api_sr_tunnel_add_del (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_sr_tunnel_add_del_t *mp; - f64 timeout; int is_del = 0; int pl_index; ip6_address_t src_address; @@ -8563,7 +8510,6 @@ api_sr_policy_add_del (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_sr_policy_add_del_t *mp; - f64 timeout; int is_del = 0; u8 *name = 0; u8 *tunnel_name = 0; @@ -8647,7 +8593,6 @@ api_sr_multicast_map_add_del (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_sr_multicast_map_add_del_t *mp; - f64 timeout; int is_del = 0; ip6_address_t multicast_address; u8 *policy_name = 0; @@ -9320,7 +9265,6 @@ api_classify_add_del_table (vat_main_t * vam) u32 miss_next_index = ~0; u32 memory_size = 32 << 20; u8 *mask = 0; - f64 timeout; u32 current_data_flag = 0; int current_data_offset = 0; @@ -9858,7 +9802,6 @@ api_classify_add_del_session (vat_main_t * vam) u32 opaque_index = ~0; u8 *match = 0; i32 advance = 0; - f64 timeout; u32 skip_n_vectors = 0; u32 match_n_vectors = 0; u32 action = 0; @@ -9946,7 +9889,6 @@ api_classify_set_interface_ip_table (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_classify_set_interface_ip_table_t *mp; - f64 timeout; u32 sw_if_index; int sw_if_index_set; u32 table_index = ~0; @@ -9991,7 +9933,6 @@ api_classify_set_interface_l2_tables (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_classify_set_interface_l2_tables_t *mp; - f64 timeout; u32 sw_if_index; int sw_if_index_set; u32 ip4_table_index = ~0; @@ -10055,7 +9996,6 @@ api_set_ipfix_exporter (vat_main_t * vam) u32 path_mtu = ~0; u32 template_interval = ~0; u8 udp_checksum = 0; - f64 timeout; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -10114,7 +10054,6 @@ api_set_ipfix_classify_stream (vat_main_t * vam) vl_api_set_ipfix_classify_stream_t *mp; u32 domain_id = 0; u32 src_port = UDP_DST_PORT_ipfix; - f64 timeout; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -10148,7 +10087,6 @@ api_ipfix_classify_table_add_del (vat_main_t * vam) u32 classify_table_index = ~0; u8 ip_version = 0; u8 transport_protocol = 255; - f64 timeout; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -10206,7 +10144,6 @@ api_get_node_index (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_get_node_index_t *mp; - f64 timeout; u8 *name = 0; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -10242,7 +10179,6 @@ api_get_next_index (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_get_next_index_t *mp; - f64 timeout; u8 *node_name = 0, *next_node_name = 0; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -10292,7 +10228,6 @@ api_add_node_next (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_add_node_next_t *mp; - f64 timeout; u8 *name = 0; u8 *next = 0; @@ -10351,7 +10286,6 @@ api_l2tpv3_create_tunnel (vat_main_t * vam) u64 remote_cookie = 0; u8 l2_sublayer_present = 0; vl_api_l2tpv3_create_tunnel_t *mp; - f64 timeout; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -10416,7 +10350,6 @@ api_l2tpv3_set_tunnel_cookies (vat_main_t * vam) u64 new_local_cookie = 0; u64 new_remote_cookie = 0; vl_api_l2tpv3_set_tunnel_cookies_t *mp; - f64 timeout; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -10455,7 +10388,6 @@ api_l2tpv3_interface_enable_disable (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_l2tpv3_interface_enable_disable_t *mp; - f64 timeout; u32 sw_if_index; u8 sw_if_index_set = 0; u8 enable_disable = 1; @@ -10496,7 +10428,6 @@ api_l2tpv3_set_lookup_key (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_l2tpv3_set_lookup_key_t *mp; - f64 timeout; u8 key = ~0; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -10594,7 +10525,6 @@ static int api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam) { vl_api_sw_if_l2tpv3_tunnel_dump_t *mp; - f64 timeout; /* Get list of l2tpv3-tunnel interfaces */ M (SW_IF_L2TPV3_TUNNEL_DUMP, mp); @@ -10641,7 +10571,6 @@ static int api_sw_interface_tap_dump (vat_main_t * vam) { vl_api_sw_interface_tap_dump_t *mp; - f64 timeout; print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index"); /* Get list of tap interfaces */ @@ -10677,7 +10606,6 @@ api_vxlan_add_del_tunnel (vat_main_t * vam) { unformat_input_t *line_input = vam->input; vl_api_vxlan_add_del_tunnel_t *mp; - f64 timeout; ip46_address_t src, dst; u8 is_add = 1; u8 ipv4_set = 0, ipv6_set = 0; @@ -10894,7 +10822,6 @@ api_vxlan_tunnel_dump (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_vxlan_tunnel_dump_t *mp; - f64 timeout; u32 sw_if_index; u8 sw_if_index_set = 0; @@ -10940,7 +10867,6 @@ api_gre_add_del_tunnel (vat_main_t * vam) { unformat_input_t *line_input = vam->input; vl_api_gre_add_del_tunnel_t *mp; - f64 timeout; ip4_address_t src4, dst4; u8 is_add = 1; u8 teb = 0; @@ -11034,7 +10960,6 @@ api_gre_tunnel_dump (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_gre_tunnel_dump_t *mp; - f64 timeout; u32 sw_if_index; u8 sw_if_index_set = 0; @@ -11080,7 +11005,6 @@ api_l2_fib_clear_table (vat_main_t * vam) { // unformat_input_t * i = vam->input; vl_api_l2_fib_clear_table_t *mp; - f64 timeout; M (L2_FIB_CLEAR_TABLE, mp); @@ -11095,7 +11019,6 @@ api_l2_interface_efp_filter (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_l2_interface_efp_filter_t *mp; - f64 timeout; u32 sw_if_index; u8 enable = 1; u8 sw_if_index_set = 0; @@ -11150,7 +11073,6 @@ api_l2_interface_vlan_tag_rewrite (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_l2_interface_vlan_tag_rewrite_t *mp; - f64 timeout; u32 sw_if_index; u8 sw_if_index_set = 0; u8 vtr_op_set = 0; @@ -11207,7 +11129,6 @@ api_create_vhost_user_if (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_create_vhost_user_if_t *mp; - f64 timeout; u8 *file_name; u8 is_server = 0; u8 file_name_set = 0; @@ -11277,7 +11198,6 @@ api_modify_vhost_user_if (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_modify_vhost_user_if_t *mp; - f64 timeout; u8 *file_name; u8 is_server = 0; u8 file_name_set = 0; @@ -11345,7 +11265,6 @@ api_delete_vhost_user_if (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_delete_vhost_user_if_t *mp; - f64 timeout; u32 sw_if_index = ~0; u8 sw_if_index_set = 0; @@ -11420,7 +11339,6 @@ static int api_sw_interface_vhost_user_dump (vat_main_t * vam) { vl_api_sw_interface_vhost_user_dump_t *mp; - f64 timeout; print (vam->ofp, "Interface name idx hdr_sz features server regions filename"); @@ -11441,7 +11359,6 @@ static int api_show_version (vat_main_t * vam) { vl_api_show_version_t *mp; - f64 timeout; M (SHOW_VERSION, mp); @@ -11457,7 +11374,6 @@ api_vxlan_gpe_add_del_tunnel (vat_main_t * vam) { unformat_input_t *line_input = vam->input; vl_api_vxlan_gpe_add_del_tunnel_t *mp; - f64 timeout; ip4_address_t local4, remote4; ip6_address_t local6, remote6; u8 is_add = 1; @@ -11625,7 +11541,6 @@ api_vxlan_gpe_tunnel_dump (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_vxlan_gpe_tunnel_dump_t *mp; - f64 timeout; u32 sw_if_index; u8 sw_if_index_set = 0; @@ -11714,7 +11629,6 @@ api_l2_fib_table_dump (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_l2_fib_table_dump_t *mp; - f64 timeout; u32 bd_id; u8 bd_id_set = 0; @@ -11757,7 +11671,6 @@ api_interface_name_renumber (vat_main_t * vam) unformat_input_t *line_input = vam->input; vl_api_interface_name_renumber_t *mp; u32 sw_if_index = ~0; - f64 timeout; u32 new_show_dev_instance = ~0; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) @@ -11800,7 +11713,6 @@ api_want_ip4_arp_events (vat_main_t * vam) { unformat_input_t *line_input = vam->input; vl_api_want_ip4_arp_events_t *mp; - f64 timeout; ip4_address_t address; int address_set = 0; u32 enable_disable = 1; @@ -11835,7 +11747,6 @@ api_want_ip6_nd_events (vat_main_t * vam) { unformat_input_t *line_input = vam->input; vl_api_want_ip6_nd_events_t *mp; - f64 timeout; ip6_address_t address; int address_set = 0; u32 enable_disable = 1; @@ -11870,7 +11781,6 @@ api_input_acl_set_interface (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_input_acl_set_interface_t *mp; - f64 timeout; u32 sw_if_index; int sw_if_index_set; u32 ip4_table_index = ~0; @@ -11928,7 +11838,6 @@ api_ip_address_dump (vat_main_t * vam) u8 sw_if_index_set = 0; u8 ipv4_set = 0; u8 ipv6_set = 0; - f64 timeout; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -11988,7 +11897,6 @@ api_ip_dump (vat_main_t * vam) int ipv4_set = 0; int ipv6_set = 0; int is_ipv6; - f64 timeout; int i; while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT) @@ -12041,7 +11949,6 @@ api_ipsec_spd_add_del (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_ipsec_spd_add_del_t *mp; - f64 timeout; u32 spd_id = ~0; u8 is_add = 1; @@ -12079,7 +11986,6 @@ api_ipsec_interface_add_del_spd (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_ipsec_interface_add_del_spd_t *mp; - f64 timeout; u32 sw_if_index; u8 sw_if_index_set = 0; u32 spd_id = (u32) ~ 0; @@ -12133,7 +12039,6 @@ api_ipsec_spd_add_del_entry (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_ipsec_spd_add_del_entry_t *mp; - f64 timeout; u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1; u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0; i32 priority = 0; @@ -12291,7 +12196,6 @@ api_ipsec_sad_add_del_entry (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_ipsec_sad_add_del_entry_t *mp; - f64 timeout; u32 sad_id = 0, spi = 0; u8 *ck = 0, *ik = 0; u8 is_add = 1; @@ -12423,7 +12327,6 @@ api_ipsec_sa_set_key (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_ipsec_sa_set_key_t *mp; - f64 timeout; u32 sa_id; u8 *ck = 0, *ik = 0; @@ -12470,7 +12373,6 @@ api_ikev2_profile_add_del (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_ikev2_profile_add_del_t *mp; - f64 timeout; u8 is_add = 1; u8 *name = 0; @@ -12518,7 +12420,6 @@ api_ikev2_profile_set_auth (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_ikev2_profile_set_auth_t *mp; - f64 timeout; u8 *name = 0; u8 *data = 0; u32 auth_method = 0; @@ -12589,7 +12490,6 @@ api_ikev2_profile_set_id (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_ikev2_profile_set_id_t *mp; - f64 timeout; u8 *name = 0; u8 *data = 0; u8 is_local = 0; @@ -12669,7 +12569,6 @@ api_ikev2_profile_set_ts (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_ikev2_profile_set_ts_t *mp; - f64 timeout; u8 *name = 0; u8 is_local = 0; u32 proto = 0, start_port = 0, end_port = (u32) ~ 0; @@ -12740,7 +12639,6 @@ api_ikev2_set_local_key (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_ikev2_set_local_key_t *mp; - f64 timeout; u8 *file = 0; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -12785,7 +12683,6 @@ api_map_add_domain (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_map_add_domain_t *mp; - f64 timeout; ip4_address_t ip4_prefix; ip6_address_t ip6_prefix; @@ -12865,7 +12762,6 @@ api_map_del_domain (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_map_del_domain_t *mp; - f64 timeout; u32 num_m_args = 0; u32 index; @@ -12904,7 +12800,6 @@ api_map_add_del_rule (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_map_add_del_rule_t *mp; - f64 timeout; u8 is_add = 1; ip6_address_t ip6_dst; u32 num_m_args = 0, index, psid = 0; @@ -12947,7 +12842,6 @@ static int api_map_domain_dump (vat_main_t * vam) { vl_api_map_domain_dump_t *mp; - f64 timeout; /* Construct the API message */ M (MAP_DOMAIN_DUMP, mp); @@ -12969,7 +12863,6 @@ api_map_rule_dump (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_map_rule_dump_t *mp; - f64 timeout; u32 domain_index = ~0; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -13041,7 +12934,6 @@ static int api_get_first_msg_id (vat_main_t * vam) { vl_api_get_first_msg_id_t *mp; - f64 timeout; unformat_input_t *i = vam->input; u8 *name; u8 name_set = 0; @@ -13080,7 +12972,6 @@ api_cop_interface_enable_disable (vat_main_t * vam) { unformat_input_t *line_input = vam->input; vl_api_cop_interface_enable_disable_t *mp; - f64 timeout; u32 sw_if_index = ~0; u8 enable_disable = 1; @@ -13121,7 +13012,6 @@ api_cop_whitelist_enable_disable (vat_main_t * vam) { unformat_input_t *line_input = vam->input; vl_api_cop_whitelist_enable_disable_t *mp; - f64 timeout; u32 sw_if_index = ~0; u8 ip4 = 0, ip6 = 0, default_cop = 0; u32 fib_id = 0; @@ -13169,7 +13059,6 @@ static int api_get_node_graph (vat_main_t * vam) { vl_api_get_node_graph_t *mp; - f64 timeout; M (GET_NODE_GRAPH, mp); @@ -13246,7 +13135,6 @@ api_lisp_add_del_locator_set (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_lisp_add_del_locator_set_t *mp; - f64 timeout = ~0; u8 is_add = 1; u8 *locator_set_name = NULL; u8 locator_set_name_set = 0; @@ -13333,7 +13221,6 @@ api_lisp_add_del_locator (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_lisp_add_del_locator_t *mp; - f64 timeout = ~0; u32 tmp_if_index = ~0; u32 sw_if_index = ~0; u8 sw_if_index_set = 0; @@ -13473,7 +13360,6 @@ api_lisp_add_del_local_eid (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_lisp_add_del_local_eid_t *mp; - f64 timeout = ~0; u8 is_add = 1; u8 eid_set = 0; lisp_eid_vat_t _eid, *eid = &_eid; @@ -13587,7 +13473,6 @@ api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam) u32 dp_table = 0, vni = 0;; unformat_input_t *input = vam->input; vl_api_lisp_gpe_add_del_fwd_entry_t *mp; - f64 timeout = ~0; u8 is_add = 1; lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid; lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid; @@ -13728,7 +13613,6 @@ api_lisp_add_del_map_server (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_lisp_add_del_map_server_t *mp; - f64 timeout = ~0; u8 is_add = 1; u8 ipv4_set = 0; u8 ipv6_set = 0; @@ -13796,7 +13680,6 @@ api_lisp_add_del_map_resolver (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_lisp_add_del_map_resolver_t *mp; - f64 timeout = ~0; u8 is_add = 1; u8 ipv4_set = 0; u8 ipv6_set = 0; @@ -13864,7 +13747,6 @@ api_lisp_gpe_enable_disable (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_lisp_gpe_enable_disable_t *mp; - f64 timeout = ~0; u8 is_set = 0; u8 is_en = 1; @@ -13911,7 +13793,6 @@ api_lisp_rloc_probe_enable_disable (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_lisp_rloc_probe_enable_disable_t *mp; - f64 timeout = ~0; u8 is_set = 0; u8 is_en = 0; @@ -13955,7 +13836,6 @@ api_lisp_map_register_enable_disable (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_lisp_map_register_enable_disable_t *mp; - f64 timeout = ~0; u8 is_set = 0; u8 is_en = 0; @@ -13999,7 +13879,6 @@ api_lisp_enable_disable (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_lisp_enable_disable_t *mp; - f64 timeout = ~0; u8 is_set = 0; u8 is_en = 0; @@ -14043,7 +13922,6 @@ api_lisp_enable_disable (vat_main_t * vam) static int api_show_lisp_map_register_state (vat_main_t * vam) { - f64 timeout = ~0; vl_api_show_lisp_map_register_state_t *mp; M (SHOW_LISP_MAP_REGISTER_STATE, mp); @@ -14060,7 +13938,6 @@ api_show_lisp_map_register_state (vat_main_t * vam) static int api_show_lisp_rloc_probe_state (vat_main_t * vam) { - f64 timeout = ~0; vl_api_show_lisp_rloc_probe_state_t *mp; M (SHOW_LISP_RLOC_PROBE_STATE, mp); @@ -14077,7 +13954,6 @@ api_show_lisp_rloc_probe_state (vat_main_t * vam) static int api_show_lisp_map_request_mode (vat_main_t * vam) { - f64 timeout = ~0; vl_api_show_lisp_map_request_mode_t *mp; M (SHOW_LISP_MAP_REQUEST_MODE, mp); @@ -14094,7 +13970,6 @@ api_show_lisp_map_request_mode (vat_main_t * vam) static int api_lisp_map_request_mode (vat_main_t * vam) { - f64 timeout = ~0; unformat_input_t *input = vam->input; vl_api_lisp_map_request_mode_t *mp; u8 mode = 0; @@ -14136,7 +14011,6 @@ api_lisp_map_request_mode (vat_main_t * vam) static int api_lisp_pitr_set_locator_set (vat_main_t * vam) { - f64 timeout = ~0; u8 ls_name_set = 0; unformat_input_t *input = vam->input; vl_api_lisp_pitr_set_locator_set_t *mp; @@ -14183,7 +14057,6 @@ static int api_show_lisp_pitr (vat_main_t * vam) { vl_api_show_lisp_pitr_t *mp; - f64 timeout = ~0; if (!vam->json_output) { @@ -14207,7 +14080,6 @@ api_show_lisp_pitr (vat_main_t * vam) static int api_lisp_eid_table_add_del_map (vat_main_t * vam) { - f64 timeout = ~0; unformat_input_t *input = vam->input; vl_api_lisp_eid_table_add_del_map_t *mp; u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0; @@ -14297,7 +14169,6 @@ api_lisp_add_del_remote_mapping (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_lisp_add_del_remote_mapping_t *mp; - f64 timeout = ~0; u32 vni = 0; lisp_eid_vat_t _eid, *eid = &_eid; lisp_eid_vat_t _seid, *seid = &_seid; @@ -14424,7 +14295,6 @@ api_lisp_add_del_adjacency (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_lisp_add_del_adjacency_t *mp; - f64 timeout = ~0; u32 vni = 0; ip4_address_t leid4, reid4; ip6_address_t leid6, reid6; @@ -14545,7 +14415,6 @@ api_lisp_gpe_add_del_iface (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_lisp_gpe_add_del_iface_t *mp; - f64 timeout = ~0; u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0; u32 dp_table = 0, vni = 0; @@ -14619,7 +14488,6 @@ api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_lisp_add_del_map_request_itr_rlocs_t *mp; - f64 timeout = ~0; u8 *locator_set_name = 0; u8 locator_set_name_set = 0; u8 is_add = 1; @@ -14683,7 +14551,6 @@ api_lisp_locator_dump (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_lisp_locator_dump_t *mp; - f64 timeout = ~0; u8 is_index_set = 0, is_name_set = 0; u8 *ls_name = 0; u32 ls_index = ~0; @@ -14762,7 +14629,6 @@ api_lisp_locator_set_dump (vat_main_t * vam) { vl_api_lisp_locator_set_dump_t *mp; unformat_input_t *input = vam->input; - f64 timeout = ~0; u8 filter = 0; /* Parse args required to build the message */ @@ -14815,7 +14681,6 @@ api_lisp_eid_table_map_dump (vat_main_t * vam) u8 mode_set = 0; unformat_input_t *input = vam->input; vl_api_lisp_eid_table_map_dump_t *mp; - f64 timeout = ~0; /* Parse args required to build the message */ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -14871,7 +14736,6 @@ static int api_lisp_eid_table_vni_dump (vat_main_t * vam) { vl_api_lisp_eid_table_vni_dump_t *mp; - f64 timeout = ~0; if (!vam->json_output) { @@ -14901,7 +14765,6 @@ api_lisp_eid_table_dump (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_lisp_eid_table_dump_t *mp; - f64 timeout = ~0; struct in_addr ip4; struct in6_addr ip6; u8 mac[6]; @@ -15002,7 +14865,6 @@ api_lisp_gpe_fwd_entries_get (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_lisp_gpe_fwd_entries_get_t *mp; - f64 timeout = ~0; u8 vni_set = 0; u32 vni = ~0; @@ -15054,7 +14916,6 @@ api_lisp_adjacencies_get (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_lisp_adjacencies_get_t *mp; - f64 timeout = ~0; u8 vni_set = 0; u32 vni = ~0; @@ -15099,7 +14960,6 @@ static int api_lisp_map_server_dump (vat_main_t * vam) { vl_api_lisp_map_server_dump_t *mp; - f64 timeout = ~0; if (!vam->json_output) { @@ -15127,7 +14987,6 @@ static int api_lisp_map_resolver_dump (vat_main_t * vam) { vl_api_lisp_map_resolver_dump_t *mp; - f64 timeout = ~0; if (!vam->json_output) { @@ -15155,7 +15014,6 @@ static int api_show_lisp_status (vat_main_t * vam) { vl_api_show_lisp_status_t *mp; - f64 timeout = ~0; if (!vam->json_output) { @@ -15176,7 +15034,6 @@ static int api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam) { vl_api_lisp_gpe_fwd_entry_path_dump_t *mp; - f64 timeout = ~0; unformat_input_t *i = vam->input; u32 fwd_entry_index = ~0; @@ -15220,7 +15077,6 @@ static int api_lisp_get_map_request_itr_rlocs (vat_main_t * vam) { vl_api_lisp_get_map_request_itr_rlocs_t *mp; - f64 timeout = ~0; if (!vam->json_output) { @@ -15242,7 +15098,6 @@ api_af_packet_create (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_af_packet_create_t *mp; - f64 timeout; u8 *host_if_name = 0; u8 hw_addr[6]; u8 random_hw_addr = 1; @@ -15289,7 +15144,6 @@ api_af_packet_delete (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_af_packet_delete_t *mp; - f64 timeout; u8 *host_if_name = 0; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -15328,7 +15182,6 @@ api_policer_add_del (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_policer_add_del_t *mp; - f64 timeout; u8 is_add = 1; u8 *name = 0; u32 cir = 0; @@ -15428,7 +15281,6 @@ api_policer_dump (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_policer_dump_t *mp; - f64 timeout = ~0; u8 *match_name = 0; u8 match_name_valid = 0; @@ -15468,7 +15320,6 @@ api_policer_classify_set_interface (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_policer_classify_set_interface_t *mp; - f64 timeout; u32 sw_if_index; int sw_if_index_set; u32 ip4_table_index = ~0; @@ -15522,7 +15373,6 @@ api_policer_classify_dump (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_policer_classify_dump_t *mp; - f64 timeout = ~0; u8 type = POLICER_CLASSIFY_N_TABLES; if (unformat (i, "type %U", unformat_policer_classify_table_type, &type)) @@ -15561,7 +15411,6 @@ api_netmap_create (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_netmap_create_t *mp; - f64 timeout; u8 *if_name = 0; u8 hw_addr[6]; u8 random_hw_addr = 1; @@ -15618,7 +15467,6 @@ api_netmap_delete (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_netmap_delete_t *mp; - f64 timeout; u8 *if_name = 0; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -15705,7 +15553,6 @@ static int api_mpls_tunnel_dump (vat_main_t * vam) { vl_api_mpls_tunnel_dump_t *mp; - f64 timeout; i32 index = -1; /* Parse args required to build the message */ @@ -15818,7 +15665,6 @@ static int api_mpls_fib_dump (vat_main_t * vam) { vl_api_mpls_fib_dump_t *mp; - f64 timeout; M (MPLS_FIB_DUMP, mp); S (mp); @@ -15919,7 +15765,6 @@ static int api_ip_fib_dump (vat_main_t * vam) { vl_api_ip_fib_dump_t *mp; - f64 timeout; M (IP_FIB_DUMP, mp); S (mp); @@ -15987,7 +15832,6 @@ api_ip_neighbor_dump (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_ip_neighbor_dump_t *mp; - f64 timeout; u8 is_ipv6 = 0; u32 sw_if_index = ~0; @@ -16111,7 +15955,6 @@ static int api_ip6_fib_dump (vat_main_t * vam) { vl_api_ip6_fib_dump_t *mp; - f64 timeout; M (IP6_FIB_DUMP, mp); S (mp); @@ -16129,7 +15972,6 @@ int api_classify_table_ids (vat_main_t * vam) { vl_api_classify_table_ids_t *mp; - f64 timeout; /* Construct the API message */ M (CLASSIFY_TABLE_IDS, mp); @@ -16146,7 +15988,6 @@ api_classify_table_by_interface (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_classify_table_by_interface_t *mp; - f64 timeout; u32 sw_if_index = ~0; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -16180,7 +16021,6 @@ api_classify_table_info (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_classify_table_info_t *mp; - f64 timeout; u32 table_id = ~0; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -16212,7 +16052,6 @@ api_classify_session_dump (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_classify_session_dump_t *mp; - f64 timeout; u32 table_id = ~0; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -16296,7 +16135,6 @@ int api_ipfix_exporter_dump (vat_main_t * vam) { vl_api_ipfix_exporter_dump_t *mp; - f64 timeout; /* Construct the API message */ M (IPFIX_EXPORTER_DUMP, mp); @@ -16312,7 +16150,6 @@ static int api_ipfix_classify_stream_dump (vat_main_t * vam) { vl_api_ipfix_classify_stream_dump_t *mp; - f64 timeout; /* Construct the API message */ M (IPFIX_CLASSIFY_STREAM_DUMP, mp); @@ -16356,7 +16193,6 @@ static int api_ipfix_classify_table_dump (vat_main_t * vam) { vl_api_ipfix_classify_table_dump_t *mp; - f64 timeout; if (!vam->json_output) { @@ -16415,7 +16251,6 @@ api_sw_interface_span_enable_disable (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_sw_interface_span_enable_disable_t *mp; - f64 timeout; u32 src_sw_if_index = ~0; u32 dst_sw_if_index = ~0; u8 state = 3; @@ -16542,7 +16377,6 @@ static int api_sw_interface_span_dump (vat_main_t * vam) { vl_api_sw_interface_span_dump_t *mp; - f64 timeout; M (SW_INTERFACE_SPAN_DUMP, mp); S (mp); @@ -16561,7 +16395,6 @@ api_pg_create_interface (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_pg_create_interface_t *mp; - f64 timeout; u32 if_id = ~0; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -16593,7 +16426,6 @@ api_pg_capture (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_pg_capture_t *mp; - f64 timeout; u32 if_id = ~0; u8 enable = 1; @@ -16652,7 +16484,6 @@ api_pg_enable_disable (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_pg_enable_disable_t *mp; - f64 timeout; u8 enable = 1; u8 stream_name_set = 0; @@ -16699,7 +16530,6 @@ api_ip_source_and_port_range_check_add_del (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_ip_source_and_port_range_check_add_del_t *mp; - f64 timeout; u16 *low_ports = 0; u16 *high_ports = 0; @@ -16830,7 +16660,6 @@ api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_ip_source_and_port_range_check_interface_add_del_t *mp; - f64 timeout; u32 sw_if_index = ~0; int vrf_set = 0; u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0; @@ -16899,7 +16728,6 @@ api_ipsec_gre_add_del_tunnel (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_ipsec_gre_add_del_tunnel_t *mp; - f64 timeout; u32 local_sa_id = 0; u32 remote_sa_id = 0; ip4_address_t src_address; @@ -16944,7 +16772,6 @@ api_punt (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_punt_t *mp; - f64 timeout; u32 ipv = ~0; u32 protocol = ~0; u32 port = ~0; @@ -17021,7 +16848,6 @@ api_ipsec_gre_tunnel_dump (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_ipsec_gre_tunnel_dump_t *mp; - f64 timeout; u32 sw_if_index; u8 sw_if_index_set = 0; @@ -17067,7 +16893,6 @@ api_delete_subif (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_delete_subif_t *mp; - f64 timeout; u32 sw_if_index = ~0; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -17104,7 +16929,6 @@ api_l2_interface_pbb_tag_rewrite (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_l2_interface_pbb_tag_rewrite_t *mp; - f64 timeout; u32 sw_if_index = ~0, vtr_op = ~0; u16 outer_tag = ~0; u8 dmac[6], smac[6]; @@ -17190,7 +17014,6 @@ api_flow_classify_set_interface (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_flow_classify_set_interface_t *mp; - f64 timeout; u32 sw_if_index; int sw_if_index_set; u32 ip4_table_index = ~0; @@ -17240,7 +17063,6 @@ api_flow_classify_dump (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_flow_classify_dump_t *mp; - f64 timeout = ~0; u8 type = FLOW_CLASSIFY_N_TABLES; if (unformat (i, "type %U", unformat_flow_classify_table_type, &type)) @@ -17279,7 +17101,6 @@ api_feature_enable_disable (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_feature_enable_disable_t *mp; - f64 timeout; u8 *arc_name = 0; u8 *feature_name = 0; u32 sw_if_index = ~0; @@ -17346,7 +17167,6 @@ api_sw_interface_tag_add_del (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_sw_interface_tag_add_del_t *mp; - f64 timeout; u32 sw_if_index = ~0; u8 *tag = 0; u8 enable = 1; @@ -17422,7 +17242,6 @@ static int api_l2_xconnect_dump (vat_main_t * vam) { vl_api_l2_xconnect_dump_t *mp; - f64 timeout; if (!vam->json_output) { @@ -17447,7 +17266,6 @@ api_sw_interface_set_mtu (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_sw_interface_set_mtu_t *mp; - f64 timeout; u32 sw_if_index = ~0; u32 mtu = 0; diff --git a/src/vlibapi/vat_helper_macros.h b/src/vlibapi/vat_helper_macros.h index 172fe2db..ffb74fe3 100644 --- a/src/vlibapi/vat_helper_macros.h +++ b/src/vlibapi/vat_helper_macros.h @@ -44,7 +44,7 @@ do { \ /* W: wait for results, with timeout */ #define W \ do { \ - timeout = vat_time_now (vam) + 1.0; \ + f64 timeout = vat_time_now (vam) + 1.0; \ \ while (vat_time_now (vam) < timeout) { \ if (vam->result_ready == 1) { \ @@ -58,7 +58,7 @@ do { \ /* W2: wait for results, with timeout */ #define W2(body) \ do { \ - timeout = vat_time_now (vam) + 1.0; \ + f64 timeout = vat_time_now (vam) + 1.0; \ \ while (vat_time_now (vam) < timeout) { \ if (vam->result_ready == 1) { \ -- cgit 1.2.3-korg From 56c7b01e163c233030359781d7e60f4553e90c51 Mon Sep 17 00:00:00 2001 From: Jon Loeliger Date: Wed, 1 Feb 2017 12:31:41 -0600 Subject: Refactor fragile msg macro W and W2 to not burry return control flow. Instead, have them accept and assign a return paramter leaving the return control flow up to the caller. Clean up otherwise misleading returns present even after "NOT REACHED" comments. Change-Id: I0861921f73ab65d55b95eabd27514f0129152723 Signed-off-by: Jon Loeliger --- build-root/emacs-lisp/plugin-test-skel.el | 4 +- src/examples/sample-plugin/sample/sample_test.c | 4 +- src/plugins/acl/acl_test.c | 52 +- src/plugins/flowperpkt/flowperpkt_test.c | 4 +- .../export-vxlan-gpe/vxlan_gpe_ioam_export_test.c | 4 +- src/plugins/ioam/export/ioam_export_test.c | 4 +- src/plugins/ioam/lib-pot/pot_test.c | 18 +- src/plugins/ioam/lib-trace/trace_test.c | 17 +- src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c | 36 +- src/plugins/lb/lb_test.c | 19 +- src/plugins/snat/snat_test.c | 74 +- src/vat/api_format.c | 1028 +++++++++++--------- src/vlibapi/vat_helper_macros.h | 12 +- 13 files changed, 699 insertions(+), 577 deletions(-) (limited to 'src/plugins/lb') diff --git a/build-root/emacs-lisp/plugin-test-skel.el b/build-root/emacs-lisp/plugin-test-skel.el index 116c420a..b546747f 100644 --- a/build-root/emacs-lisp/plugin-test-skel.el +++ b/build-root/emacs-lisp/plugin-test-skel.el @@ -150,6 +150,7 @@ static int api_" plugin-name "_enable_disable (vat_main_t * vam) int enable_disable = 1; u32 sw_if_index = ~0; vl_api_" plugin-name "_enable_disable_t * mp; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -177,7 +178,8 @@ static int api_" plugin-name "_enable_disable (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } /* diff --git a/src/examples/sample-plugin/sample/sample_test.c b/src/examples/sample-plugin/sample/sample_test.c index bf7a0590..6dd3a3e8 100644 --- a/src/examples/sample-plugin/sample/sample_test.c +++ b/src/examples/sample-plugin/sample/sample_test.c @@ -98,6 +98,7 @@ static int api_sample_macswap_enable_disable (vat_main_t * vam) int enable_disable = 1; u32 sw_if_index = ~0; vl_api_sample_macswap_enable_disable_t * mp; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -125,7 +126,8 @@ static int api_sample_macswap_enable_disable (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } /* diff --git a/src/plugins/acl/acl_test.c b/src/plugins/acl/acl_test.c index 39d7e1c4..23dc6bc0 100644 --- a/src/plugins/acl/acl_test.c +++ b/src/plugins/acl/acl_test.c @@ -267,6 +267,7 @@ static int api_acl_plugin_get_version (vat_main_t * vam) acl_test_main_t * sm = &acl_test_main; vl_api_acl_plugin_get_version_t * mp; u32 msg_size = sizeof(*mp); + int ret; vam->result_ready = 0; mp = vl_msg_api_alloc_as_if_client(msg_size); @@ -278,9 +279,8 @@ static int api_acl_plugin_get_version (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; - - return 0; + W (ret); + return ret; } static int api_macip_acl_interface_get (vat_main_t * vam) @@ -288,6 +288,7 @@ static int api_macip_acl_interface_get (vat_main_t * vam) acl_test_main_t * sm = &acl_test_main; vl_api_acl_plugin_get_version_t * mp; u32 msg_size = sizeof(*mp); + int ret; vam->result_ready = 0; mp = vl_msg_api_alloc_as_if_client(msg_size); @@ -299,9 +300,8 @@ static int api_macip_acl_interface_get (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; - - return 0; + W (ret); + return ret; } #define vec_validate_acl_rules(v, idx) \ @@ -335,6 +335,7 @@ static int api_acl_add_replace (vat_main_t * vam) ip4_address_t src_v4address, dst_v4address; ip6_address_t src_v6address, dst_v6address; u8 *tag = 0; + int ret; if (!unformat (i, "%d", &acl_index)) { /* Just assume -1 */ @@ -479,7 +480,8 @@ static int api_acl_add_replace (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } static int api_acl_del (vat_main_t * vam) @@ -487,6 +489,7 @@ static int api_acl_del (vat_main_t * vam) unformat_input_t * i = vam->input; vl_api_acl_del_t * mp; u32 acl_index = ~0; + int ret; if (!unformat (i, "%d", &acl_index)) { errmsg ("missing acl index\n"); @@ -501,7 +504,8 @@ static int api_acl_del (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } static int api_macip_acl_del (vat_main_t * vam) @@ -509,6 +513,7 @@ static int api_macip_acl_del (vat_main_t * vam) unformat_input_t * i = vam->input; vl_api_acl_del_t * mp; u32 acl_index = ~0; + int ret; if (!unformat (i, "%d", &acl_index)) { errmsg ("missing acl index\n"); @@ -523,7 +528,8 @@ static int api_macip_acl_del (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } static int api_acl_interface_add_del (vat_main_t * vam) @@ -534,6 +540,7 @@ static int api_acl_interface_add_del (vat_main_t * vam) u32 acl_index = ~0; u8 is_input = 0; u8 is_add = 0; + int ret; // acl_interface_add_del | sw_if_index acl_index [out] [del] @@ -589,7 +596,8 @@ static int api_acl_interface_add_del (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } static int api_macip_acl_interface_add_del (vat_main_t * vam) @@ -599,6 +607,7 @@ static int api_macip_acl_interface_add_del (vat_main_t * vam) u32 sw_if_index = ~0; u32 acl_index = ~0; u8 is_add = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -638,7 +647,8 @@ static int api_macip_acl_interface_add_del (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } static int api_acl_interface_set_acl_list (vat_main_t * vam) @@ -650,6 +660,7 @@ static int api_acl_interface_set_acl_list (vat_main_t * vam) u32 *inacls = 0; u32 *outacls = 0; u8 is_input = 0; + int ret; // acl_interface_set_acl_list | sw_if_index input [acl-idx list] output [acl-idx list] @@ -694,7 +705,8 @@ static int api_acl_interface_set_acl_list (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } @@ -703,6 +715,7 @@ static int api_acl_interface_list_dump (vat_main_t * vam) unformat_input_t * i = vam->input; u32 sw_if_index = ~0; vl_api_acl_interface_list_dump_t * mp; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -722,7 +735,8 @@ static int api_acl_interface_list_dump (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } static int api_acl_dump (vat_main_t * vam) @@ -730,6 +744,7 @@ static int api_acl_dump (vat_main_t * vam) unformat_input_t * i = vam->input; u32 acl_index = ~0; vl_api_acl_dump_t * mp; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -747,7 +762,8 @@ static int api_acl_dump (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } static int api_macip_acl_dump (vat_main_t * vam) @@ -755,6 +771,7 @@ static int api_macip_acl_dump (vat_main_t * vam) unformat_input_t * i = vam->input; u32 acl_index = ~0; vl_api_acl_dump_t * mp; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -772,7 +789,8 @@ static int api_macip_acl_dump (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } #define vec_validate_macip_acl_rules(v, idx) \ @@ -801,6 +819,7 @@ static int api_macip_acl_add (vat_main_t * vam) u8 src_mac[6]; u8 *tag = 0; u8 mac_mask_all_1[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -903,7 +922,8 @@ static int api_macip_acl_add (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } /* diff --git a/src/plugins/flowperpkt/flowperpkt_test.c b/src/plugins/flowperpkt/flowperpkt_test.c index 4cc1cfb7..972a3b07 100644 --- a/src/plugins/flowperpkt/flowperpkt_test.c +++ b/src/plugins/flowperpkt/flowperpkt_test.c @@ -99,6 +99,7 @@ api_flowperpkt_tx_interface_add_del (vat_main_t * vam) u8 which = 0; /* ipv4 by default */ u32 sw_if_index = ~0; vl_api_flowperpkt_tx_interface_add_del_t *mp; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -131,7 +132,8 @@ api_flowperpkt_tx_interface_add_del (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } /* diff --git a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c index a7938219..17d31c95 100644 --- a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c +++ b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c @@ -94,6 +94,7 @@ api_vxlan_gpe_ioam_export_enable_disable (vat_main_t * vam) unformat_input_t *i = vam->input; int is_disable = 0; vl_api_vxlan_gpe_ioam_export_enable_disable_t *mp; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -112,7 +113,8 @@ api_vxlan_gpe_ioam_export_enable_disable (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } /* diff --git a/src/plugins/ioam/export/ioam_export_test.c b/src/plugins/ioam/export/ioam_export_test.c index 2cb036a5..5023afd7 100644 --- a/src/plugins/ioam/export/ioam_export_test.c +++ b/src/plugins/ioam/export/ioam_export_test.c @@ -96,6 +96,7 @@ api_ioam_export_ip6_enable_disable (vat_main_t * vam) unformat_input_t *i = vam->input; int is_disable = 0; vl_api_ioam_export_ip6_enable_disable_t *mp; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -114,7 +115,8 @@ api_ioam_export_ip6_enable_disable (vat_main_t * vam) S(mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } /* diff --git a/src/plugins/ioam/lib-pot/pot_test.c b/src/plugins/ioam/lib-pot/pot_test.c index d896eb2f..1c6dd02d 100644 --- a/src/plugins/ioam/lib-pot/pot_test.c +++ b/src/plugins/ioam/lib-pot/pot_test.c @@ -134,6 +134,7 @@ static int api_pot_profile_add (vat_main_t *vam) u64 lpc = 0, poly2 = 0; u8 id = 0; int rv = 0; + int ret; while (unformat_check_input(input) != UNFORMAT_END_OF_INPUT) { @@ -188,7 +189,8 @@ static int api_pot_profile_add (vat_main_t *vam) mp->max_bits = bits; S(mp); - W; + W (ret); + return ret; OUT: vec_free(name); @@ -203,6 +205,7 @@ static int api_pot_profile_activate (vat_main_t *vam) u8 *name = NULL; u8 id = 0; int rv = 0; + int ret; while (unformat_check_input(input) != UNFORMAT_END_OF_INPUT) { @@ -228,7 +231,8 @@ static int api_pot_profile_activate (vat_main_t *vam) mp->id = id; S(mp); - W; + W (ret); + return ret; OUT: vec_free(name); @@ -239,12 +243,13 @@ OUT: static int api_pot_profile_del (vat_main_t *vam) { vl_api_pot_profile_del_t *mp; + int ret; M(POT_PROFILE_DEL, mp); mp->list_name_len = 0; S(mp); - W; - return 0; + W (ret); + return ret; } static int api_pot_profile_show_config_dump (vat_main_t *vam) @@ -252,6 +257,7 @@ static int api_pot_profile_show_config_dump (vat_main_t *vam) unformat_input_t *input = vam->input; vl_api_pot_profile_show_config_dump_t *mp; u8 id = 0; + int ret; while(unformat_check_input(input) != UNFORMAT_END_OF_INPUT) { @@ -264,8 +270,8 @@ static int api_pot_profile_show_config_dump (vat_main_t *vam) mp->id = id; S(mp); - W; - return 0; + W (ret); + return ret; } /* diff --git a/src/plugins/ioam/lib-trace/trace_test.c b/src/plugins/ioam/lib-trace/trace_test.c index d1fb7205..1e287dee 100644 --- a/src/plugins/ioam/lib-trace/trace_test.c +++ b/src/plugins/ioam/lib-trace/trace_test.c @@ -125,10 +125,10 @@ api_trace_profile_add (vat_main_t * vam) vl_api_trace_profile_add_t *mp; u8 trace_type = 0; u8 num_elts = 0; - int rv = 0; u32 node_id = 0; u32 app_data = 0; u8 trace_tsp = 0; + int ret; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { @@ -157,9 +157,8 @@ api_trace_profile_add (vat_main_t * vam) mp->num_elts = num_elts; S (mp); - W; - - return (rv); + W (ret); + return ret; } @@ -168,22 +167,24 @@ static int api_trace_profile_del (vat_main_t * vam) { vl_api_trace_profile_del_t *mp; + int ret; M (TRACE_PROFILE_DEL, mp); S (mp); - W; - return 0; + W (ret); + return ret; } static int api_trace_profile_show_config (vat_main_t * vam) { vl_api_trace_profile_show_config_t *mp; + int ret; M (TRACE_PROFILE_SHOW_CONFIG, mp); S (mp); - W; - return 0; + W (ret); + return ret; } /* diff --git a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c index 3e7300f5..80e65644 100644 --- a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c +++ b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c @@ -108,6 +108,7 @@ api_vxlan_gpe_ioam_enable (vat_main_t * vam) int has_trace_option = 0; int has_pow_option = 0; int has_ppc_option = 0; + int ret; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { @@ -132,9 +133,8 @@ api_vxlan_gpe_ioam_enable (vat_main_t * vam) S (mp); - W; - - return (0); + W (ret); + return ret; } @@ -142,11 +142,12 @@ static int api_vxlan_gpe_ioam_disable (vat_main_t * vam) { vl_api_vxlan_gpe_ioam_disable_t *mp; + int ret; M (VXLAN_GPE_IOAM_DISABLE, mp); S (mp); - W; - return 0; + W (ret); + return ret; } static int @@ -161,6 +162,7 @@ api_vxlan_gpe_ioam_vni_enable (vat_main_t * vam) u8 remote_set = 0; u32 vni; u8 vni_set = 0; + int ret; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) @@ -238,9 +240,8 @@ api_vxlan_gpe_ioam_vni_enable (vat_main_t * vam) mp->is_ipv6 = ipv6_set; S (mp); - W; - - return (0); + W (ret); + return ret; } static int @@ -255,6 +256,7 @@ api_vxlan_gpe_ioam_vni_disable (vat_main_t * vam) u8 remote_set = 0; u32 vni; u8 vni_set = 0; + int ret; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) @@ -332,9 +334,8 @@ api_vxlan_gpe_ioam_vni_disable (vat_main_t * vam) mp->is_ipv6 = ipv6_set; S (mp); - W; - - return 0; + W (ret); + return ret; } static int @@ -347,6 +348,7 @@ api_vxlan_gpe_ioam_transit_enable (vat_main_t * vam) u8 ipv4_set = 0, ipv6_set = 0; u8 local_set = 0; u32 outer_fib_index = 0; + int ret; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) @@ -401,9 +403,8 @@ api_vxlan_gpe_ioam_transit_enable (vat_main_t * vam) mp->is_ipv6 = ipv6_set; S (mp); - W; - - return (0); + W (ret); + return ret; } static int @@ -416,6 +417,7 @@ api_vxlan_gpe_ioam_transit_disable (vat_main_t * vam) u8 ipv4_set = 0, ipv6_set = 0; u8 local_set = 0; u32 outer_fib_index = 0; + int ret; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) @@ -469,10 +471,8 @@ api_vxlan_gpe_ioam_transit_disable (vat_main_t * vam) mp->is_ipv6 = ipv6_set; S (mp); - W; - - - return (0); + W (ret); + return ret; } /* diff --git a/src/plugins/lb/lb_test.c b/src/plugins/lb/lb_test.c index a811079e..9b30c18d 100644 --- a/src/plugins/lb/lb_test.c +++ b/src/plugins/lb/lb_test.c @@ -134,6 +134,7 @@ static int api_lb_conf (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_lb_conf_t mps, *mp; + int ret; if (!unformat(i, "%U %U %u %u", unformat_ip4_address, &mps.ip4_src_address, @@ -146,16 +147,15 @@ static int api_lb_conf (vat_main_t * vam) M(LB_CONF, mp); S(mp); - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int api_lb_add_del_vip (vat_main_t * vam) { unformat_input_t * i = vam->input; vl_api_lb_add_del_vip_t mps, *mp; + int ret; mps.is_del = 0; mps.is_gre4 = 0; @@ -185,15 +185,15 @@ static int api_lb_add_del_vip (vat_main_t * vam) M(LB_ADD_DEL_VIP, mp); S(mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int api_lb_add_del_as (vat_main_t * vam) { unformat_input_t * i = vam->input; vl_api_lb_add_del_as_t mps, *mp; + int ret; mps.is_del = 0; if (!unformat(i, "%U %U", @@ -209,9 +209,8 @@ static int api_lb_add_del_as (vat_main_t * vam) M(LB_ADD_DEL_AS, mp); S(mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } /* diff --git a/src/plugins/snat/snat_test.c b/src/plugins/snat/snat_test.c index 8bab00c1..086059a3 100644 --- a/src/plugins/snat/snat_test.c +++ b/src/plugins/snat/snat_test.c @@ -114,6 +114,7 @@ static int api_snat_add_address_range (vat_main_t * vam) vl_api_snat_add_address_range_t * mp; u8 is_add = 1; int count; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -159,10 +160,8 @@ static int api_snat_add_address_range (vat_main_t * vam) mp->is_add = is_add; S(mp); - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int api_snat_interface_add_del_feature (vat_main_t * vam) @@ -173,6 +172,7 @@ static int api_snat_interface_add_del_feature (vat_main_t * vam) u8 sw_if_index_set = 0; u8 is_inside = 1; u8 is_add = 1; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -205,9 +205,8 @@ static int api_snat_interface_add_del_feature (vat_main_t * vam) mp->is_inside = is_inside; S(mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int api_snat_add_static_mapping(vat_main_t * vam) @@ -222,6 +221,7 @@ static int api_snat_add_static_mapping(vat_main_t * vam) u32 local_port = 0, external_port = 0, vrf_id = ~0; u32 sw_if_index = ~0; u8 sw_if_index_set = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -273,9 +273,8 @@ static int api_snat_add_static_mapping(vat_main_t * vam) memcpy (mp->external_ip_address, &external_addr, 4); S(mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static void vl_api_snat_control_ping_reply_t_handler @@ -318,6 +317,7 @@ static void vl_api_snat_static_mapping_details_t_handler static int api_snat_static_mapping_dump(vat_main_t * vam) { vl_api_snat_static_mapping_dump_t * mp; + int ret; if (vam->json_output) { @@ -337,9 +337,8 @@ static int api_snat_static_mapping_dump(vat_main_t * vam) M(SNAT_CONTROL_PING, mp); S(mp); } - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static void vl_api_snat_show_config_reply_t_handler @@ -376,6 +375,7 @@ static void vl_api_snat_show_config_reply_t_handler static int api_snat_show_config(vat_main_t * vam) { vl_api_snat_show_config_t * mp; + int ret; if (vam->json_output) { @@ -385,9 +385,8 @@ static int api_snat_show_config(vat_main_t * vam) M(SNAT_SHOW_CONFIG, mp); S(mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static void vl_api_snat_address_details_t_handler @@ -402,6 +401,7 @@ static void vl_api_snat_address_details_t_handler static int api_snat_address_dump(vat_main_t * vam) { vl_api_snat_address_dump_t * mp; + int ret; if (vam->json_output) { @@ -417,9 +417,8 @@ static int api_snat_address_dump(vat_main_t * vam) M(SNAT_CONTROL_PING, mp); S(mp); } - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static void vl_api_snat_interface_details_t_handler @@ -435,6 +434,7 @@ static void vl_api_snat_interface_details_t_handler static int api_snat_interface_dump(vat_main_t * vam) { vl_api_snat_interface_dump_t * mp; + int ret; if (vam->json_output) { @@ -450,9 +450,8 @@ static int api_snat_interface_dump(vat_main_t * vam) M(SNAT_CONTROL_PING, mp); S(mp); } - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int api_snat_set_workers (vat_main_t * vam) @@ -460,6 +459,7 @@ static int api_snat_set_workers (vat_main_t * vam) unformat_input_t * i = vam->input; vl_api_snat_set_workers_t * mp; uword *bitmap; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -476,10 +476,8 @@ static int api_snat_set_workers (vat_main_t * vam) mp->worker_mask = clib_host_to_net_u64 (bitmap[0]); S(mp); - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static void vl_api_snat_worker_details_t_handler @@ -495,6 +493,7 @@ static void vl_api_snat_worker_details_t_handler static int api_snat_worker_dump(vat_main_t * vam) { vl_api_snat_worker_dump_t * mp; + int ret; if (vam->json_output) { @@ -510,9 +509,8 @@ static int api_snat_worker_dump(vat_main_t * vam) M(SNAT_CONTROL_PING, mp); S(mp); } - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int api_snat_ipfix_enable_disable (vat_main_t * vam) @@ -522,6 +520,7 @@ static int api_snat_ipfix_enable_disable (vat_main_t * vam) u32 sw_if_index; u8 sw_if_index_set = 0; u8 is_add = 1; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -549,9 +548,8 @@ static int api_snat_ipfix_enable_disable (vat_main_t * vam) mp->is_add = is_add; S(mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static void vl_api_snat_interface_addr_details_t_handler @@ -566,6 +564,7 @@ static void vl_api_snat_interface_addr_details_t_handler static int api_snat_interface_addr_dump(vat_main_t * vam) { vl_api_snat_interface_addr_dump_t * mp; + int ret; if (vam->json_output) { @@ -581,9 +580,8 @@ static int api_snat_interface_addr_dump(vat_main_t * vam) M(SNAT_CONTROL_PING, mp); S(mp); } - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int api_snat_add_del_interface_addr (vat_main_t * vam) @@ -593,6 +591,7 @@ static int api_snat_add_del_interface_addr (vat_main_t * vam) u32 domain_id = 0; u32 src_port = 0; u8 enable = 1; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -615,9 +614,8 @@ static int api_snat_add_del_interface_addr (vat_main_t * vam) mp->enable = enable; S(mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } /* diff --git a/src/vat/api_format.c b/src/vat/api_format.c index 8caa94f0..db5478ca 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -4641,6 +4641,7 @@ exec_inband (vat_main_t * vam) { vl_api_cli_inband_t *mp; unformat_input_t *i = vam->input; + int ret; if (vec_len (i->buffer) == 0) return -1; @@ -4667,7 +4668,8 @@ exec_inband (vat_main_t * vam) mp->length = htonl (len); S (mp); - W2 (print (vam->ofp, "%s", vam->cmd_reply)); + W2 (ret, print (vam->ofp, "%s", vam->cmd_reply)); + return ret; } static int @@ -4677,6 +4679,7 @@ api_create_loopback (vat_main_t * vam) vl_api_create_loopback_t *mp; u8 mac_address[6]; u8 mac_set = 0; + int ret; memset (mac_address, 0, sizeof (mac_address)); @@ -4694,7 +4697,8 @@ api_create_loopback (vat_main_t * vam) clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address)); S (mp); - W; + W (ret); + return ret; } static int @@ -4703,6 +4707,7 @@ api_delete_loopback (vat_main_t * vam) unformat_input_t *i = vam->input; vl_api_delete_loopback_t *mp; u32 sw_if_index = ~0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -4723,7 +4728,8 @@ api_delete_loopback (vat_main_t * vam) mp->sw_if_index = ntohl (sw_if_index); S (mp); - W; + W (ret); + return ret; } static int @@ -4732,6 +4738,7 @@ api_want_stats (vat_main_t * vam) unformat_input_t *i = vam->input; vl_api_want_stats_t *mp; int enable = -1; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -4753,7 +4760,8 @@ api_want_stats (vat_main_t * vam) mp->enable_disable = enable; S (mp); - W; + W (ret); + return ret; } static int @@ -4762,6 +4770,7 @@ api_want_interface_events (vat_main_t * vam) unformat_input_t *i = vam->input; vl_api_want_interface_events_t *mp; int enable = -1; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -4785,7 +4794,8 @@ api_want_interface_events (vat_main_t * vam) vam->interface_event_display = enable; S (mp); - W; + W (ret); + return ret; } @@ -4797,6 +4807,7 @@ api_sw_interface_dump (vat_main_t * vam) hash_pair_t *p; name_sort_t *nses = 0, *ns; sw_interface_subif_t *sub = NULL; + int ret; /* Toss the old name table */ /* *INDENT-OFF* */ @@ -4892,7 +4903,8 @@ api_sw_interface_dump (vat_main_t * vam) M (CONTROL_PING, mp); S (mp); } - W; + W (ret); + return ret; } static int @@ -4903,6 +4915,7 @@ api_sw_interface_set_flags (vat_main_t * vam) u32 sw_if_index; u8 sw_if_index_set = 0; u8 admin_up = 0, link_up = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -4940,7 +4953,8 @@ api_sw_interface_set_flags (vat_main_t * vam) S (mp); /* Wait for a reply, return the good/bad news... */ - W; + W (ret); + return ret; } static int @@ -4950,6 +4964,7 @@ api_sw_interface_clear_stats (vat_main_t * vam) vl_api_sw_interface_clear_stats_t *mp; u32 sw_if_index; u8 sw_if_index_set = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -4974,7 +4989,8 @@ api_sw_interface_clear_stats (vat_main_t * vam) S (mp); /* Wait for a reply, return the good/bad news... */ - W; + W (ret); + return ret; } #if DPDK >0 @@ -4991,6 +5007,7 @@ api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam) u8 pipe_set = 0; u32 profile; u8 profile_set = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -5045,9 +5062,8 @@ api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam) S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -5063,6 +5079,7 @@ api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam) u32 tb_size = 1000000; u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 }; u32 tc_period = 10; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -5125,9 +5142,8 @@ api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam) mp->tc_period = ntohl (tc_period); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -5141,6 +5157,7 @@ api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam) u8 tc_set = 0; u8 queue_set = 0; u32 entry, tc, queue; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -5191,9 +5208,8 @@ api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam) mp->queue = ntohl (queue); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } #endif @@ -5210,6 +5226,7 @@ api_sw_interface_add_del_address (vat_main_t * vam) u8 v6_address_set = 0; ip4_address_t v4address; ip6_address_t v6address; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -5270,7 +5287,8 @@ api_sw_interface_add_del_address (vat_main_t * vam) S (mp); /* Wait for a reply, return good/bad news */ - W; + W (ret); + return ret; } static int @@ -5281,6 +5299,7 @@ api_sw_interface_set_mpls_enable (vat_main_t * vam) u32 sw_if_index; u8 sw_if_index_set = 0; u8 enable = 1; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -5313,7 +5332,8 @@ api_sw_interface_set_mpls_enable (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } static int @@ -5324,6 +5344,7 @@ api_sw_interface_set_table (vat_main_t * vam) u32 sw_if_index, vrf_id = 0; u8 sw_if_index_set = 0; u8 is_ipv6 = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -5357,7 +5378,8 @@ api_sw_interface_set_table (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } static void vl_api_sw_interface_get_table_reply_t_handler @@ -5397,6 +5419,7 @@ api_sw_interface_get_table (vat_main_t * vam) u32 sw_if_index; u8 sw_if_index_set = 0; u8 is_ipv6 = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -5421,7 +5444,8 @@ api_sw_interface_get_table (vat_main_t * vam) mp->is_ipv6 = is_ipv6; S (mp); - W; + W (ret); + return ret; } static int @@ -5432,6 +5456,7 @@ api_sw_interface_set_vpath (vat_main_t * vam) u32 sw_if_index = 0; u8 sw_if_index_set = 0; u8 is_enable = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -5464,7 +5489,8 @@ api_sw_interface_set_vpath (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } static int @@ -5476,6 +5502,7 @@ api_sw_interface_set_vxlan_bypass (vat_main_t * vam) u8 sw_if_index_set = 0; u8 is_enable = 1; u8 is_ipv6 = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -5513,7 +5540,8 @@ api_sw_interface_set_vxlan_bypass (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } static int @@ -5526,6 +5554,7 @@ api_sw_interface_set_l2_xconnect (vat_main_t * vam) u32 tx_sw_if_index; u8 tx_sw_if_index_set = 0; u8 enable = 1; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -5583,9 +5612,8 @@ api_sw_interface_set_l2_xconnect (vat_main_t * vam) mp->enable = enable; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -5600,6 +5628,7 @@ api_sw_interface_set_l2_bridge (vat_main_t * vam) u8 bvi = 0; u32 shg = 0; u8 enable = 1; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -5645,9 +5674,8 @@ api_sw_interface_set_l2_bridge (vat_main_t * vam) mp->enable = enable; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -5656,6 +5684,7 @@ api_bridge_domain_dump (vat_main_t * vam) unformat_input_t *i = vam->input; vl_api_bridge_domain_dump_t *mp; u32 bd_id = ~0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -5677,9 +5706,8 @@ api_bridge_domain_dump (vat_main_t * vam) S (mp); } - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -5691,6 +5719,7 @@ api_bridge_domain_add_del (vat_main_t * vam) u8 is_add = 1; u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0; u32 mac_age = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -5742,9 +5771,8 @@ api_bridge_domain_add_del (vat_main_t * vam) mp->mac_age = (u8) mac_age; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -5887,8 +5915,11 @@ api_l2fib_add_del (vat_main_t * vam) } else { + int ret; + /* Wait for a reply... */ - W; + W (ret); + return ret; } /* Return the good/bad news */ return (vam->retval); @@ -5902,6 +5933,7 @@ api_l2_flags (vat_main_t * vam) u32 sw_if_index; u32 feature_bitmap = 0; u8 sw_if_index_set = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -5943,9 +5975,8 @@ api_l2_flags (vat_main_t * vam) mp->feature_bitmap = ntohl (feature_bitmap); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -5957,6 +5988,7 @@ api_bridge_flags (vat_main_t * vam) u8 bd_id_set = 0; u8 is_set = 1; u32 flags = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -5994,9 +6026,8 @@ api_bridge_flags (vat_main_t * vam) mp->is_set = is_set; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -6013,6 +6044,7 @@ api_bd_ip_mac_add_del (vat_main_t * vam) ip4_address_t v4addr; ip6_address_t v6addr; u8 macaddr[6]; + int ret; /* Parse args required to build the message */ @@ -6068,9 +6100,8 @@ api_bd_ip_mac_add_del (vat_main_t * vam) clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr)); clib_memcpy (mp->mac_address, macaddr, 6); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -6089,6 +6120,7 @@ api_tap_connect (vat_main_t * vam) ip6_address_t ip6_address; u32 ip6_mask_width; int ip6_address_set = 0; + int ret; memset (mac_address, 0, sizeof (mac_address)); @@ -6162,7 +6194,8 @@ api_tap_connect (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } static int @@ -6176,6 +6209,7 @@ api_tap_modify (vat_main_t * vam) u8 *tap_name; u32 sw_if_index = ~0; u8 sw_if_index_set = 0; + int ret; memset (mac_address, 0, sizeof (mac_address)); @@ -6227,7 +6261,8 @@ api_tap_modify (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } static int @@ -6237,6 +6272,7 @@ api_tap_delete (vat_main_t * vam) vl_api_tap_delete_t *mp; u32 sw_if_index = ~0; u8 sw_if_index_set = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -6264,7 +6300,8 @@ api_tap_delete (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } static int @@ -6556,8 +6593,11 @@ api_ip_add_del_route (vat_main_t * vam) } else { + int ret; + /* Wait for a reply... */ - W; + W (ret); + return ret; } /* Return the good/bad news */ @@ -6580,6 +6620,7 @@ api_ip_mroute_add_del (vat_main_t * vam) ip6_address_t v6_grp_address, v6_src_address; mfib_itf_flags_t iflags = 0; mfib_entry_flags_t eflags = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -6677,7 +6718,8 @@ api_ip_mroute_add_del (vat_main_t * vam) /* send it... */ S (mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } static int @@ -6893,8 +6935,11 @@ api_mpls_route_add_del (vat_main_t * vam) } else { + int ret; + /* Wait for a reply... */ - W; + W (ret); + return ret; } /* Return the good/bad news */ @@ -6915,6 +6960,7 @@ api_mpls_ip_bind_unbind (vat_main_t * vam) u32 address_length; u8 address_set = 0; mpls_label_t local_label = MPLS_LABEL_INVALID; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -6980,7 +7026,8 @@ api_mpls_ip_bind_unbind (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } static int @@ -6992,6 +7039,7 @@ api_proxy_arp_add_del (vat_main_t * vam) u8 is_add = 1; ip4_address_t lo, hi; u8 range_set = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -7023,9 +7071,8 @@ api_proxy_arp_add_del (vat_main_t * vam) clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address)); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -7036,6 +7083,7 @@ api_proxy_arp_intfc_enable_disable (vat_main_t * vam) u32 sw_if_index; u8 enable = 1; u8 sw_if_index_set = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -7066,9 +7114,8 @@ api_proxy_arp_intfc_enable_disable (vat_main_t * vam) mp->enable_disable = enable; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -7089,6 +7136,7 @@ api_mpls_tunnel_add_del (vat_main_t * vam) }; ip6_address_t v6_next_hop_address = { {0} }; mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -7151,9 +7199,8 @@ api_mpls_tunnel_add_del (vat_main_t * vam) } S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -7165,6 +7212,7 @@ api_sw_interface_set_unnumbered (vat_main_t * vam) u32 unnum_sw_index = ~0; u8 is_add = 1; u8 sw_if_index_set = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -7196,9 +7244,8 @@ api_sw_interface_set_unnumbered (vat_main_t * vam) mp->is_add = is_add; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -7217,6 +7264,7 @@ api_ip_neighbor_add_del (vat_main_t * vam) u8 v6_address_set = 0; ip4_address_t v4address; ip6_address_t v6address; + int ret; memset (mac_address, 0, sizeof (mac_address)); @@ -7289,10 +7337,8 @@ api_ip_neighbor_add_del (vat_main_t * vam) S (mp); /* Wait for a reply, return good/bad news */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -7303,6 +7349,7 @@ api_reset_vrf (vat_main_t * vam) u32 vrf_id = 0; u8 is_ipv6 = 0; u8 vrf_id_set = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -7329,9 +7376,8 @@ api_reset_vrf (vat_main_t * vam) mp->is_ipv6 = is_ipv6; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -7343,6 +7389,7 @@ api_create_vlan_subif (vat_main_t * vam) u8 sw_if_index_set = 0; u32 vlan_id; u8 vlan_id_set = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -7377,9 +7424,8 @@ api_create_vlan_subif (vat_main_t * vam) mp->vlan_id = ntohl (vlan_id); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } #define foreach_create_subif_bit \ @@ -7412,6 +7458,7 @@ api_create_subif (vat_main_t * vam) u32 tmp; u16 outer_vlan_id = 0; u16 inner_vlan_id = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -7461,9 +7508,8 @@ api_create_subif (vat_main_t * vam) mp->inner_vlan_id = ntohs (inner_vlan_id); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -7476,6 +7522,7 @@ api_oam_add_del (vat_main_t * vam) ip4_address_t src, dst; u8 src_set = 0; u8 dst_set = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -7514,9 +7561,8 @@ api_oam_add_del (vat_main_t * vam) clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address)); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -7528,6 +7574,7 @@ api_reset_fib (vat_main_t * vam) u8 is_ipv6 = 0; u8 vrf_id_set = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { if (unformat (i, "vrf %d", &vrf_id)) @@ -7553,9 +7600,8 @@ api_reset_fib (vat_main_t * vam) mp->is_ipv6 = is_ipv6; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -7574,6 +7620,7 @@ api_dhcp_proxy_config (vat_main_t * vam) u8 v6_src_address_set = 0; ip4_address_t v4srcaddress; ip6_address_t v6srcaddress; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -7647,9 +7694,8 @@ api_dhcp_proxy_config (vat_main_t * vam) S (mp); /* Wait for a reply, return good/bad news */ - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -7669,6 +7715,7 @@ api_dhcp_proxy_config_2 (vat_main_t * vam) u8 v6_src_address_set = 0; ip4_address_t v4srcaddress; ip6_address_t v6srcaddress; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -7745,9 +7792,8 @@ api_dhcp_proxy_config_2 (vat_main_t * vam) S (mp); /* Wait for a reply, return good/bad news */ - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -7763,6 +7809,7 @@ api_dhcp_proxy_set_vss (vat_main_t * vam) u8 oui_set = 0; u32 fib_id; u8 fib_id_set = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -7808,9 +7855,8 @@ api_dhcp_proxy_set_vss (vat_main_t * vam) mp->is_add = is_add; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -7823,6 +7869,7 @@ api_dhcp_client_config (vat_main_t * vam) u8 is_add = 1; u8 *hostname = 0; u8 disable_event = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -7868,9 +7915,8 @@ api_dhcp_client_config (vat_main_t * vam) S (mp); /* Wait for a reply, return good/bad news */ - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -7887,6 +7933,7 @@ api_set_ip_flow_hash (vat_main_t * vam) u8 dport = 0; u8 proto = 0; u8 reverse = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -7931,9 +7978,8 @@ api_set_ip_flow_hash (vat_main_t * vam) mp->is_ipv6 = is_ipv6; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -7944,6 +7990,7 @@ api_sw_interface_ip6_enable_disable (vat_main_t * vam) u32 sw_if_index; u8 sw_if_index_set = 0; u8 enable = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -7974,9 +8021,8 @@ api_sw_interface_ip6_enable_disable (vat_main_t * vam) mp->enable = enable; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -7988,6 +8034,7 @@ api_sw_interface_ip6_set_link_local_address (vat_main_t * vam) u8 sw_if_index_set = 0; u8 v6_address_set = 0; ip6_address_t v6address; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -8023,10 +8070,8 @@ api_sw_interface_ip6_set_link_local_address (vat_main_t * vam) S (mp); /* Wait for a reply, return good/bad news */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } @@ -8048,6 +8093,7 @@ api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam) u8 is_no = 0; u32 val_lifetime = 0; u32 pref_lifetime = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -8112,10 +8158,8 @@ api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam) S (mp); /* Wait for a reply, return good/bad news */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -8138,6 +8182,7 @@ api_sw_interface_ip6nd_ra_config (vat_main_t * vam) u32 lifetime = 0; u32 initial_count = 0; u32 initial_interval = 0; + int ret; /* Parse args required to build the message */ @@ -8208,10 +8253,8 @@ api_sw_interface_ip6nd_ra_config (vat_main_t * vam) S (mp); /* Wait for a reply, return good/bad news */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -8222,6 +8265,7 @@ api_set_arp_neighbor_limit (vat_main_t * vam) u32 arp_nbr_limit; u8 limit_set = 0; u8 is_ipv6 = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -8248,9 +8292,8 @@ api_set_arp_neighbor_limit (vat_main_t * vam) mp->is_ipv6 = is_ipv6; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -8263,6 +8306,7 @@ api_l2_patch_add_del (vat_main_t * vam) u32 tx_sw_if_index; u8 tx_sw_if_index_set = 0; u8 is_add = 1; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -8318,9 +8362,8 @@ api_l2_patch_add_del (vat_main_t * vam) mp->is_add = is_add; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -8333,6 +8376,7 @@ api_ioam_enable (vat_main_t * vam) int has_pot_option = 0; int has_seqno_option = 0; int has_analyse_option = 0; + int ret; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { @@ -8355,10 +8399,8 @@ api_ioam_enable (vat_main_t * vam) mp->trace_enable = has_trace_option; S (mp); - W; - - return (0); - + W (ret); + return ret; } @@ -8366,11 +8408,12 @@ static int api_ioam_disable (vat_main_t * vam) { vl_api_ioam_disable_t *mp; + int ret; M (IOAM_DISABLE, mp); S (mp); - W; - return 0; + W (ret); + return ret; } static int @@ -8395,6 +8438,7 @@ api_sr_tunnel_add_del (vat_main_t * vam) ip6_address_t next_address, tag; u8 *name = 0; u8 *policy_name = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -8501,8 +8545,8 @@ api_sr_tunnel_add_del (vat_main_t * vam) vec_free (tags); S (mp); - W; - /* NOTREACHED */ + W (ret); + return ret; } static int @@ -8520,6 +8564,7 @@ api_sr_policy_add_del (vat_main_t * vam) int j = 0; int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM) + int ret; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { @@ -8584,8 +8629,8 @@ api_sr_policy_add_del (vat_main_t * vam) vec_free (tunnel_name); S (mp); - W; - /* NOTREACHED */ + W (ret); + return ret; } static int @@ -8597,6 +8642,7 @@ api_sr_multicast_map_add_del (vat_main_t * vam) ip6_address_t multicast_address; u8 *policy_name = 0; int multicast_address_set = 0; + int ret; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { @@ -8636,8 +8682,8 @@ api_sr_multicast_map_add_del (vat_main_t * vam) vec_free (policy_name); S (mp); - W; - /* NOTREACHED */ + W (ret); + return ret; } @@ -9267,6 +9313,7 @@ api_classify_add_del_table (vat_main_t * vam) u8 *mask = 0; u32 current_data_flag = 0; int current_data_offset = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -9351,8 +9398,8 @@ api_classify_add_del_table (vat_main_t * vam) vec_free (mask); S (mp); - W; - /* NOTREACHED */ + W (ret); + return ret; } uword @@ -9806,6 +9853,7 @@ api_classify_add_del_session (vat_main_t * vam) u32 match_n_vectors = 0; u32 action = 0; u32 metadata = 0; + int ret; /* * Warning: you have to supply skip_n and match_n @@ -9880,8 +9928,8 @@ api_classify_add_del_session (vat_main_t * vam) vec_free (match); S (mp); - W; - /* NOTREACHED */ + W (ret); + return ret; } static int @@ -9893,6 +9941,7 @@ api_classify_set_interface_ip_table (vat_main_t * vam) int sw_if_index_set; u32 table_index = ~0; u8 is_ipv6 = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -9923,9 +9972,8 @@ api_classify_set_interface_ip_table (vat_main_t * vam) mp->is_ipv6 = is_ipv6; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -9939,6 +9987,7 @@ api_classify_set_interface_l2_tables (vat_main_t * vam) u32 ip6_table_index = ~0; u32 other_table_index = ~0; u32 is_input = 1; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -9977,9 +10026,8 @@ api_classify_set_interface_l2_tables (vat_main_t * vam) mp->is_input = (u8) is_input; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -9996,6 +10044,7 @@ api_set_ipfix_exporter (vat_main_t * vam) u32 path_mtu = ~0; u32 template_interval = ~0; u8 udp_checksum = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -10043,8 +10092,8 @@ api_set_ipfix_exporter (vat_main_t * vam) mp->udp_checksum = udp_checksum; S (mp); - W; - /* NOTREACHED */ + W (ret); + return ret; } static int @@ -10054,6 +10103,7 @@ api_set_ipfix_classify_stream (vat_main_t * vam) vl_api_set_ipfix_classify_stream_t *mp; u32 domain_id = 0; u32 src_port = UDP_DST_PORT_ipfix; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -10074,8 +10124,8 @@ api_set_ipfix_classify_stream (vat_main_t * vam) mp->src_port = htons ((u16) src_port); S (mp); - W; - /* NOTREACHED */ + W (ret); + return ret; } static int @@ -10087,6 +10137,7 @@ api_ipfix_classify_table_add_del (vat_main_t * vam) u32 classify_table_index = ~0; u8 ip_version = 0; u8 transport_protocol = 255; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -10135,8 +10186,8 @@ api_ipfix_classify_table_add_del (vat_main_t * vam) mp->transport_protocol = transport_protocol; S (mp); - W; - /* NOTREACHED */ + W (ret); + return ret; } static int @@ -10145,6 +10196,7 @@ api_get_node_index (vat_main_t * vam) unformat_input_t *i = vam->input; vl_api_get_node_index_t *mp; u8 *name = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -10169,9 +10221,8 @@ api_get_node_index (vat_main_t * vam) vec_free (name); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -10180,6 +10231,7 @@ api_get_next_index (vat_main_t * vam) unformat_input_t *i = vam->input; vl_api_get_next_index_t *mp; u8 *node_name = 0, *next_node_name = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -10218,9 +10270,8 @@ api_get_next_index (vat_main_t * vam) vec_free (next_node_name); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -10230,6 +10281,7 @@ api_add_node_next (vat_main_t * vam) vl_api_add_node_next_t *mp; u8 *name = 0; u8 *next = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -10268,9 +10320,8 @@ api_add_node_next (vat_main_t * vam) vec_free (next); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -10286,6 +10337,7 @@ api_l2tpv3_create_tunnel (vat_main_t * vam) u64 remote_cookie = 0; u8 l2_sublayer_present = 0; vl_api_l2tpv3_create_tunnel_t *mp; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -10336,9 +10388,8 @@ api_l2tpv3_create_tunnel (vat_main_t * vam) mp->is_ipv6 = 1; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -10350,6 +10401,7 @@ api_l2tpv3_set_tunnel_cookies (vat_main_t * vam) u64 new_local_cookie = 0; u64 new_remote_cookie = 0; vl_api_l2tpv3_set_tunnel_cookies_t *mp; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -10378,9 +10430,8 @@ api_l2tpv3_set_tunnel_cookies (vat_main_t * vam) mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -10391,6 +10442,7 @@ api_l2tpv3_interface_enable_disable (vat_main_t * vam) u32 sw_if_index; u8 sw_if_index_set = 0; u8 enable_disable = 1; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -10418,9 +10470,8 @@ api_l2tpv3_interface_enable_disable (vat_main_t * vam) mp->enable_disable = enable_disable; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -10429,6 +10480,7 @@ api_l2tpv3_set_lookup_key (vat_main_t * vam) unformat_input_t *i = vam->input; vl_api_l2tpv3_set_lookup_key_t *mp; u8 key = ~0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -10453,9 +10505,8 @@ api_l2tpv3_set_lookup_key (vat_main_t * vam) mp->key = key; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler @@ -10525,6 +10576,7 @@ static int api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam) { vl_api_sw_if_l2tpv3_tunnel_dump_t *mp; + int ret; /* Get list of l2tpv3-tunnel interfaces */ M (SW_IF_L2TPV3_TUNNEL_DUMP, mp); @@ -10536,7 +10588,8 @@ api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam) M (CONTROL_PING, mp); S (mp); } - W; + W (ret); + return ret; } @@ -10571,6 +10624,7 @@ static int api_sw_interface_tap_dump (vat_main_t * vam) { vl_api_sw_interface_tap_dump_t *mp; + int ret; print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index"); /* Get list of tap interfaces */ @@ -10583,7 +10637,8 @@ api_sw_interface_tap_dump (vat_main_t * vam) M (CONTROL_PING, mp); S (mp); } - W; + W (ret); + return ret; } static uword unformat_vxlan_decap_next @@ -10616,6 +10671,7 @@ api_vxlan_add_del_tunnel (vat_main_t * vam) u32 encap_vrf_id = 0; u32 decap_next_index = ~0; u32 vni = 0; + int ret; /* Can't "universally zero init" (={0}) due to GCC bug 53119 */ memset (&src, 0, sizeof src); @@ -10752,9 +10808,8 @@ api_vxlan_add_del_tunnel (vat_main_t * vam) mp->is_ipv6 = ipv6_set; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static void vl_api_vxlan_tunnel_details_t_handler @@ -10824,6 +10879,7 @@ api_vxlan_tunnel_dump (vat_main_t * vam) vl_api_vxlan_tunnel_dump_t *mp; u32 sw_if_index; u8 sw_if_index_set = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -10859,7 +10915,8 @@ api_vxlan_tunnel_dump (vat_main_t * vam) M (CONTROL_PING, mp); S (mp); } - W; + W (ret); + return ret; } static int @@ -10873,6 +10930,7 @@ api_gre_add_del_tunnel (vat_main_t * vam) u8 src_set = 0; u8 dst_set = 0; u32 outer_fib_id = 0; + int ret; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { @@ -10914,9 +10972,8 @@ api_gre_add_del_tunnel (vat_main_t * vam) mp->teb = teb; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static void vl_api_gre_tunnel_details_t_handler @@ -10962,6 +11019,7 @@ api_gre_tunnel_dump (vat_main_t * vam) vl_api_gre_tunnel_dump_t *mp; u32 sw_if_index; u8 sw_if_index_set = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -10997,7 +11055,8 @@ api_gre_tunnel_dump (vat_main_t * vam) M (CONTROL_PING, mp); S (mp); } - W; + W (ret); + return ret; } static int @@ -11005,13 +11064,13 @@ api_l2_fib_clear_table (vat_main_t * vam) { // unformat_input_t * i = vam->input; vl_api_l2_fib_clear_table_t *mp; + int ret; M (L2_FIB_CLEAR_TABLE, mp); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -11022,6 +11081,7 @@ api_l2_interface_efp_filter (vat_main_t * vam) u32 sw_if_index; u8 enable = 1; u8 sw_if_index_set = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -11052,9 +11112,8 @@ api_l2_interface_efp_filter (vat_main_t * vam) mp->enable_disable = enable; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } #define foreach_vtr_op \ @@ -11080,6 +11139,7 @@ api_l2_interface_vlan_tag_rewrite (vat_main_t * vam) u32 push_dot1q = 1; u32 tag1 = ~0; u32 tag2 = ~0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -11119,9 +11179,8 @@ api_l2_interface_vlan_tag_rewrite (vat_main_t * vam) mp->tag2 = ntohl (tag2); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -11136,6 +11195,7 @@ api_create_vhost_user_if (vat_main_t * vam) u8 hwaddr[6]; u8 use_custom_mac = 0; u8 *tag = 0; + int ret; /* Shut up coverity */ memset (hwaddr, 0, sizeof (hwaddr)); @@ -11188,9 +11248,8 @@ api_create_vhost_user_if (vat_main_t * vam) vec_free (tag); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -11204,6 +11263,7 @@ api_modify_vhost_user_if (vat_main_t * vam) u32 custom_dev_instance = ~0; u8 sw_if_index_set = 0; u32 sw_if_index = (u32) ~ 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -11255,9 +11315,8 @@ api_modify_vhost_user_if (vat_main_t * vam) } S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -11267,6 +11326,7 @@ api_delete_vhost_user_if (vat_main_t * vam) vl_api_delete_vhost_user_if_t *mp; u32 sw_if_index = ~0; u8 sw_if_index_set = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -11290,9 +11350,8 @@ api_delete_vhost_user_if (vat_main_t * vam) mp->sw_if_index = ntohl (sw_if_index); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static void vl_api_sw_interface_vhost_user_details_t_handler @@ -11339,6 +11398,7 @@ static int api_sw_interface_vhost_user_dump (vat_main_t * vam) { vl_api_sw_interface_vhost_user_dump_t *mp; + int ret; print (vam->ofp, "Interface name idx hdr_sz features server regions filename"); @@ -11352,20 +11412,21 @@ api_sw_interface_vhost_user_dump (vat_main_t * vam) M (CONTROL_PING, mp); S (mp); } - W; + W (ret); + return ret; } static int api_show_version (vat_main_t * vam) { vl_api_show_version_t *mp; + int ret; M (SHOW_VERSION, mp); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } @@ -11385,6 +11446,7 @@ api_vxlan_gpe_add_del_tunnel (vat_main_t * vam) u8 protocol = ~0; u32 vni; u8 vni_set = 0; + int ret; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { @@ -11479,9 +11541,8 @@ api_vxlan_gpe_add_del_tunnel (vat_main_t * vam) mp->is_ipv6 = ipv6_set; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static void vl_api_vxlan_gpe_tunnel_details_t_handler @@ -11543,6 +11604,7 @@ api_vxlan_gpe_tunnel_dump (vat_main_t * vam) vl_api_vxlan_gpe_tunnel_dump_t *mp; u32 sw_if_index; u8 sw_if_index_set = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -11578,7 +11640,8 @@ api_vxlan_gpe_tunnel_dump (vat_main_t * vam) M (CONTROL_PING, mp); S (mp); } - W; + W (ret); + return ret; } u8 * @@ -11631,6 +11694,7 @@ api_l2_fib_table_dump (vat_main_t * vam) vl_api_l2_fib_table_dump_t *mp; u32 bd_id; u8 bd_id_set = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -11661,7 +11725,8 @@ api_l2_fib_table_dump (vat_main_t * vam) M (CONTROL_PING, mp); S (mp); } - W; + W (ret); + return ret; } @@ -11672,6 +11737,7 @@ api_interface_name_renumber (vat_main_t * vam) vl_api_interface_name_renumber_t *mp; u32 sw_if_index = ~0; u32 new_show_dev_instance = ~0; + int ret; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { @@ -11705,7 +11771,8 @@ api_interface_name_renumber (vat_main_t * vam) mp->new_show_dev_instance = ntohl (new_show_dev_instance); S (mp); - W; + W (ret); + return ret; } static int @@ -11716,6 +11783,7 @@ api_want_ip4_arp_events (vat_main_t * vam) ip4_address_t address; int address_set = 0; u32 enable_disable = 1; + int ret; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { @@ -11739,7 +11807,8 @@ api_want_ip4_arp_events (vat_main_t * vam) mp->address = address.as_u32; S (mp); - W; + W (ret); + return ret; } static int @@ -11750,6 +11819,7 @@ api_want_ip6_nd_events (vat_main_t * vam) ip6_address_t address; int address_set = 0; u32 enable_disable = 1; + int ret; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { @@ -11773,7 +11843,8 @@ api_want_ip6_nd_events (vat_main_t * vam) clib_memcpy (mp->address, &address, sizeof (ip6_address_t)); S (mp); - W; + W (ret); + return ret; } static int @@ -11787,6 +11858,7 @@ api_input_acl_set_interface (vat_main_t * vam) u32 ip6_table_index = ~0; u32 l2_table_index = ~0; u8 is_add = 1; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -11824,9 +11896,8 @@ api_input_acl_set_interface (vat_main_t * vam) mp->is_add = is_add; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -11838,6 +11909,7 @@ api_ip_address_dump (vat_main_t * vam) u8 sw_if_index_set = 0; u8 ipv4_set = 0; u8 ipv6_set = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -11886,7 +11958,8 @@ api_ip_address_dump (vat_main_t * vam) M (CONTROL_PING, mp); S (mp); } - W; + W (ret); + return ret; } static int @@ -11898,6 +11971,7 @@ api_ip_dump (vat_main_t * vam) int ipv6_set = 0; int is_ipv6; int i; + int ret; while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT) { @@ -11941,7 +12015,8 @@ api_ip_dump (vat_main_t * vam) M (CONTROL_PING, mp); S (mp); } - W; + W (ret); + return ret; } static int @@ -11951,6 +12026,7 @@ api_ipsec_spd_add_del (vat_main_t * vam) vl_api_ipsec_spd_add_del_t *mp; u32 spd_id = ~0; u8 is_add = 1; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -11976,9 +12052,8 @@ api_ipsec_spd_add_del (vat_main_t * vam) mp->is_add = is_add; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -11990,6 +12065,7 @@ api_ipsec_interface_add_del_spd (vat_main_t * vam) u8 sw_if_index_set = 0; u32 spd_id = (u32) ~ 0; u8 is_add = 1; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -12029,9 +12105,8 @@ api_ipsec_interface_add_del_spd (vat_main_t * vam) mp->is_add = is_add; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -12046,6 +12121,7 @@ api_ipsec_spd_add_del_entry (vat_main_t * vam) u32 lport_start = 0, lport_stop = (u32) ~ 0; ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop; ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop; + int ret; laddr4_start.as_u32 = raddr4_start.as_u32 = 0; laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0; @@ -12186,9 +12262,8 @@ api_ipsec_spd_add_del_entry (vat_main_t * vam) mp->is_add = is_add; mp->is_ip_any = is_ip_any; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -12207,6 +12282,7 @@ api_ipsec_sad_add_del_entry (vat_main_t * vam) ip4_address_t tun_dst4; ip6_address_t tun_src6; ip6_address_t tun_dst6; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -12317,9 +12393,8 @@ api_ipsec_sad_add_del_entry (vat_main_t * vam) } S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -12329,6 +12404,7 @@ api_ipsec_sa_set_key (vat_main_t * vam) vl_api_ipsec_sa_set_key_t *mp; u32 sa_id; u8 *ck = 0, *ik = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -12363,9 +12439,8 @@ api_ipsec_sa_set_key (vat_main_t * vam) clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -12375,6 +12450,7 @@ api_ikev2_profile_add_del (vat_main_t * vam) vl_api_ikev2_profile_add_del_t *mp; u8 is_add = 1; u8 *name = 0; + int ret; const char *valid_chars = "a-zA-Z0-9_"; @@ -12410,9 +12486,8 @@ api_ikev2_profile_add_del (vat_main_t * vam) vec_free (name); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -12424,6 +12499,7 @@ api_ikev2_profile_set_auth (vat_main_t * vam) u8 *data = 0; u32 auth_method = 0; u8 is_hex = 0; + int ret; const char *valid_chars = "a-zA-Z0-9_"; @@ -12480,9 +12556,8 @@ api_ikev2_profile_set_auth (vat_main_t * vam) vec_free (data); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -12495,6 +12570,7 @@ api_ikev2_profile_set_id (vat_main_t * vam) u8 is_local = 0; u32 id_type = 0; ip4_address_t ip4; + int ret; const char *valid_chars = "a-zA-Z0-9_"; @@ -12559,9 +12635,8 @@ api_ikev2_profile_set_id (vat_main_t * vam) vec_free (data); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -12575,6 +12650,7 @@ api_ikev2_profile_set_ts (vat_main_t * vam) ip4_address_t start_addr, end_addr; const char *valid_chars = "a-zA-Z0-9_"; + int ret; start_addr.as_u32 = 0; end_addr.as_u32 = (u32) ~ 0; @@ -12629,9 +12705,8 @@ api_ikev2_profile_set_ts (vat_main_t * vam) vec_free (name); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -12640,6 +12715,7 @@ api_ikev2_set_local_key (vat_main_t * vam) unformat_input_t *i = vam->input; vl_api_ikev2_set_local_key_t *mp; u8 *file = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -12670,9 +12746,8 @@ api_ikev2_set_local_key (vat_main_t * vam) vec_free (file); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } /* @@ -12693,6 +12768,7 @@ api_map_add_domain (vat_main_t * vam) u8 is_translation = 0; u32 mtu = 0; u32 ip6_src_len = 128; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -12754,7 +12830,8 @@ api_map_add_domain (vat_main_t * vam) S (mp); /* Wait for a reply, return good/bad news */ - W; + W (ret); + return ret; } static int @@ -12765,6 +12842,7 @@ api_map_del_domain (vat_main_t * vam) u32 num_m_args = 0; u32 index; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -12792,7 +12870,8 @@ api_map_del_domain (vat_main_t * vam) S (mp); /* Wait for a reply, return good/bad news */ - W; + W (ret); + return ret; } static int @@ -12803,6 +12882,7 @@ api_map_add_del_rule (vat_main_t * vam) u8 is_add = 1; ip6_address_t ip6_dst; u32 num_m_args = 0, index, psid = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -12835,13 +12915,15 @@ api_map_add_del_rule (vat_main_t * vam) S (mp); /* Wait for a reply, return good/bad news */ - W; + W (ret); + return ret; } static int api_map_domain_dump (vat_main_t * vam) { vl_api_map_domain_dump_t *mp; + int ret; /* Construct the API message */ M (MAP_DOMAIN_DUMP, mp); @@ -12855,7 +12937,8 @@ api_map_domain_dump (vat_main_t * vam) M (CONTROL_PING, mp); S (mp); } - W; + W (ret); + return ret; } static int @@ -12864,6 +12947,7 @@ api_map_rule_dump (vat_main_t * vam) unformat_input_t *i = vam->input; vl_api_map_rule_dump_t *mp; u32 domain_index = ~0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -12893,7 +12977,8 @@ api_map_rule_dump (vat_main_t * vam) M (CONTROL_PING, mp); S (mp); } - W; + W (ret); + return ret; } static void vl_api_map_add_domain_reply_t_handler @@ -12937,6 +13022,7 @@ api_get_first_msg_id (vat_main_t * vam) unformat_input_t *i = vam->input; u8 *name; u8 name_set = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -12962,9 +13048,8 @@ api_get_first_msg_id (vat_main_t * vam) M (GET_FIRST_MSG_ID, mp); clib_memcpy (mp->name, name, vec_len (name)); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -12974,6 +13059,7 @@ api_cop_interface_enable_disable (vat_main_t * vam) vl_api_cop_interface_enable_disable_t *mp; u32 sw_if_index = ~0; u8 enable_disable = 1; + int ret; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { @@ -13004,7 +13090,8 @@ api_cop_interface_enable_disable (vat_main_t * vam) /* send it... */ S (mp); /* Wait for the reply */ - W; + W (ret); + return ret; } static int @@ -13015,6 +13102,7 @@ api_cop_whitelist_enable_disable (vat_main_t * vam) u32 sw_if_index = ~0; u8 ip4 = 0, ip6 = 0, default_cop = 0; u32 fib_id = 0; + int ret; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { @@ -13052,20 +13140,23 @@ api_cop_whitelist_enable_disable (vat_main_t * vam) /* send it... */ S (mp); /* Wait for the reply */ - W; + W (ret); + return ret; } static int api_get_node_graph (vat_main_t * vam) { vl_api_get_node_graph_t *mp; + int ret; M (GET_NODE_GRAPH, mp); /* send it... */ S (mp); /* Wait for the reply */ - W; + W (ret); + return ret; } /* *INDENT-OFF* */ @@ -13142,6 +13233,7 @@ api_lisp_add_del_locator_set (vat_main_t * vam) u32 sw_if_index, priority, weight; u32 data_len = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { @@ -13210,10 +13302,8 @@ api_lisp_add_del_locator_set (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -13232,6 +13322,7 @@ api_lisp_add_del_locator (vat_main_t * vam) u8 is_add = 1; u8 *locator_set_name = NULL; u8 locator_set_name_set = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -13324,10 +13415,8 @@ api_lisp_add_del_locator (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } uword @@ -13368,6 +13457,7 @@ api_lisp_add_del_local_eid (vat_main_t * vam) u32 vni = 0; u16 key_id = 0; u8 *key = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -13450,10 +13540,8 @@ api_lisp_add_del_local_eid (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } /* *INDENT-OFF* */ @@ -13482,6 +13570,7 @@ api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam) ip6_address_t rmt_rloc6, lcl_rloc6; vl_api_lisp_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0; + int ret; memset (&rloc, 0, sizeof (rloc)); @@ -13602,10 +13691,8 @@ api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -13618,6 +13705,7 @@ api_lisp_add_del_map_server (vat_main_t * vam) u8 ipv6_set = 0; ip4_address_t ipv4; ip6_address_t ipv6; + int ret; /* Parse args required to build the message */ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -13669,10 +13757,8 @@ api_lisp_add_del_map_server (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -13685,6 +13771,7 @@ api_lisp_add_del_map_resolver (vat_main_t * vam) u8 ipv6_set = 0; ip4_address_t ipv4; ip6_address_t ipv6; + int ret; /* Parse args required to build the message */ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -13736,10 +13823,8 @@ api_lisp_add_del_map_resolver (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -13749,6 +13834,7 @@ api_lisp_gpe_enable_disable (vat_main_t * vam) vl_api_lisp_gpe_enable_disable_t *mp; u8 is_set = 0; u8 is_en = 1; + int ret; /* Parse args required to build the message */ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -13782,10 +13868,8 @@ api_lisp_gpe_enable_disable (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -13795,6 +13879,7 @@ api_lisp_rloc_probe_enable_disable (vat_main_t * vam) vl_api_lisp_rloc_probe_enable_disable_t *mp; u8 is_set = 0; u8 is_en = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -13825,10 +13910,8 @@ api_lisp_rloc_probe_enable_disable (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -13838,6 +13921,7 @@ api_lisp_map_register_enable_disable (vat_main_t * vam) vl_api_lisp_map_register_enable_disable_t *mp; u8 is_set = 0; u8 is_en = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -13868,10 +13952,8 @@ api_lisp_map_register_enable_disable (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -13881,6 +13963,7 @@ api_lisp_enable_disable (vat_main_t * vam) vl_api_lisp_enable_disable_t *mp; u8 is_set = 0; u8 is_en = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -13913,16 +13996,15 @@ api_lisp_enable_disable (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int api_show_lisp_map_register_state (vat_main_t * vam) { vl_api_show_lisp_map_register_state_t *mp; + int ret; M (SHOW_LISP_MAP_REGISTER_STATE, mp); @@ -13930,15 +14012,15 @@ api_show_lisp_map_register_state (vat_main_t * vam) S (mp); /* wait for reply */ - W; - - return 0; + W (ret); + return ret; } static int api_show_lisp_rloc_probe_state (vat_main_t * vam) { vl_api_show_lisp_rloc_probe_state_t *mp; + int ret; M (SHOW_LISP_RLOC_PROBE_STATE, mp); @@ -13946,15 +14028,15 @@ api_show_lisp_rloc_probe_state (vat_main_t * vam) S (mp); /* wait for reply */ - W; - - return 0; + W (ret); + return ret; } static int api_show_lisp_map_request_mode (vat_main_t * vam) { vl_api_show_lisp_map_request_mode_t *mp; + int ret; M (SHOW_LISP_MAP_REQUEST_MODE, mp); @@ -13962,9 +14044,8 @@ api_show_lisp_map_request_mode (vat_main_t * vam) S (mp); /* wait for reply */ - W; - - return 0; + W (ret); + return ret; } static int @@ -13973,6 +14054,7 @@ api_lisp_map_request_mode (vat_main_t * vam) unformat_input_t *input = vam->input; vl_api_lisp_map_request_mode_t *mp; u8 mode = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -13996,10 +14078,8 @@ api_lisp_map_request_mode (vat_main_t * vam) S (mp); /* wait for reply */ - W; - - /* notreached */ - return 0; + W (ret); + return ret; } /** @@ -14016,6 +14096,7 @@ api_lisp_pitr_set_locator_set (vat_main_t * vam) vl_api_lisp_pitr_set_locator_set_t *mp; u8 is_add = 1; u8 *ls_name = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -14047,16 +14128,15 @@ api_lisp_pitr_set_locator_set (vat_main_t * vam) S (mp); /* wait for reply */ - W; - - /* notreached */ - return 0; + W (ret); + return ret; } static int api_show_lisp_pitr (vat_main_t * vam) { vl_api_show_lisp_pitr_t *mp; + int ret; if (!vam->json_output) { @@ -14068,10 +14148,8 @@ api_show_lisp_pitr (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } /** @@ -14084,6 +14162,7 @@ api_lisp_eid_table_add_del_map (vat_main_t * vam) vl_api_lisp_eid_table_add_del_map_t *mp; u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0; u32 vni, vrf, bd_index; + int ret; /* Parse args required to build the message */ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -14123,10 +14202,8 @@ api_lisp_eid_table_add_del_map (vat_main_t * vam) S (mp); /* wait for reply */ - W; - - /* notreached */ - return 0; + W (ret); + return ret; } uword @@ -14177,6 +14254,7 @@ api_lisp_add_del_remote_mapping (vat_main_t * vam) ip4_address_t rloc4; ip6_address_t rloc6; vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0; + int ret; memset (&rloc, 0, sizeof (rloc)); @@ -14277,10 +14355,8 @@ api_lisp_add_del_remote_mapping (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } /** @@ -14303,6 +14379,7 @@ api_lisp_add_del_adjacency (vat_main_t * vam) u8 reid_type, leid_type; u32 leid_len = 0, reid_len = 0, len; u8 is_add = 1; + int ret; leid_type = reid_type = (u8) ~ 0; @@ -14404,10 +14481,8 @@ api_lisp_add_del_adjacency (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -14417,6 +14492,7 @@ api_lisp_gpe_add_del_iface (vat_main_t * vam) vl_api_lisp_gpe_add_del_iface_t *mp; u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0; u32 dp_table = 0, vni = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -14471,10 +14547,8 @@ api_lisp_gpe_add_del_iface (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } /** @@ -14491,6 +14565,7 @@ api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam) u8 *locator_set_name = 0; u8 locator_set_name_set = 0; u8 is_add = 1; + int ret; /* Parse args required to build the message */ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -14540,10 +14615,8 @@ api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -14554,6 +14627,7 @@ api_lisp_locator_dump (vat_main_t * vam) u8 is_index_set = 0, is_name_set = 0; u8 *ls_name = 0; u32 ls_index = ~0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -14618,10 +14692,8 @@ api_lisp_locator_dump (vat_main_t * vam) S (mp); } /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -14630,6 +14702,7 @@ api_lisp_locator_set_dump (vat_main_t * vam) vl_api_lisp_locator_set_dump_t *mp; unformat_input_t *input = vam->input; u8 filter = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -14668,10 +14741,8 @@ api_lisp_locator_set_dump (vat_main_t * vam) S (mp); } /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -14681,6 +14752,7 @@ api_lisp_eid_table_map_dump (vat_main_t * vam) u8 mode_set = 0; unformat_input_t *input = vam->input; vl_api_lisp_eid_table_map_dump_t *mp; + int ret; /* Parse args required to build the message */ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -14726,16 +14798,15 @@ api_lisp_eid_table_map_dump (vat_main_t * vam) S (mp); } /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int api_lisp_eid_table_vni_dump (vat_main_t * vam) { vl_api_lisp_eid_table_vni_dump_t *mp; + int ret; if (!vam->json_output) { @@ -14754,10 +14825,8 @@ api_lisp_eid_table_vni_dump (vat_main_t * vam) S (mp); } /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -14771,6 +14840,7 @@ api_lisp_eid_table_dump (vat_main_t * vam) u8 eid_type = ~0, eid_set = 0; u32 prefix_length = ~0, t, vni = 0; u8 filter = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -14854,10 +14924,8 @@ api_lisp_eid_table_dump (vat_main_t * vam) } /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -14867,6 +14935,7 @@ api_lisp_gpe_fwd_entries_get (vat_main_t * vam) vl_api_lisp_gpe_fwd_entries_get_t *mp; u8 vni_set = 0; u32 vni = ~0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -14900,10 +14969,8 @@ api_lisp_gpe_fwd_entries_get (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } #define vl_api_lisp_gpe_fwd_entries_get_reply_t_endian vl_noop_handler @@ -14918,6 +14985,7 @@ api_lisp_adjacencies_get (vat_main_t * vam) vl_api_lisp_adjacencies_get_t *mp; u8 vni_set = 0; u32 vni = ~0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -14950,16 +15018,15 @@ api_lisp_adjacencies_get (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int api_lisp_map_server_dump (vat_main_t * vam) { vl_api_lisp_map_server_dump_t *mp; + int ret; if (!vam->json_output) { @@ -14977,16 +15044,15 @@ api_lisp_map_server_dump (vat_main_t * vam) S (mp); } /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int api_lisp_map_resolver_dump (vat_main_t * vam) { vl_api_lisp_map_resolver_dump_t *mp; + int ret; if (!vam->json_output) { @@ -15004,16 +15070,15 @@ api_lisp_map_resolver_dump (vat_main_t * vam) S (mp); } /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int api_show_lisp_status (vat_main_t * vam) { vl_api_show_lisp_status_t *mp; + int ret; if (!vam->json_output) { @@ -15024,10 +15089,8 @@ api_show_lisp_status (vat_main_t * vam) /* send it... */ S (mp); /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -15036,6 +15099,7 @@ api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam) vl_api_lisp_gpe_fwd_entry_path_dump_t *mp; unformat_input_t *i = vam->input; u32 fwd_entry_index = ~0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -15067,16 +15131,15 @@ api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam) S (mp); } /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int api_lisp_get_map_request_itr_rlocs (vat_main_t * vam) { vl_api_lisp_get_map_request_itr_rlocs_t *mp; + int ret; if (!vam->json_output) { @@ -15087,10 +15150,8 @@ api_lisp_get_map_request_itr_rlocs (vat_main_t * vam) /* send it... */ S (mp); /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -15101,6 +15162,7 @@ api_af_packet_create (vat_main_t * vam) u8 *host_if_name = 0; u8 hw_addr[6]; u8 random_hw_addr = 1; + int ret; memset (hw_addr, 0, sizeof (hw_addr)); @@ -15134,9 +15196,8 @@ api_af_packet_create (vat_main_t * vam) vec_free (host_if_name); S (mp); - W2 (fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index)); - /* NOTREACHED */ - return 0; + W2 (ret, fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index)); + return ret; } static int @@ -15145,6 +15206,7 @@ api_af_packet_delete (vat_main_t * vam) unformat_input_t *i = vam->input; vl_api_af_packet_delete_t *mp; u8 *host_if_name = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -15172,9 +15234,8 @@ api_af_packet_delete (vat_main_t * vam) vec_free (host_if_name); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -15193,6 +15254,7 @@ api_policer_add_del (vat_main_t * vam) u8 type = 0; u8 color_aware = 0; sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action; + int ret; conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT; conform_action.dscp = 0; @@ -15271,9 +15333,8 @@ api_policer_add_del (vat_main_t * vam) mp->color_aware = color_aware; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -15283,6 +15344,7 @@ api_policer_dump (vat_main_t * vam) vl_api_policer_dump_t *mp; u8 *match_name = 0; u8 match_name_valid = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -15309,10 +15371,8 @@ api_policer_dump (vat_main_t * vam) S (mp); } /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -15326,6 +15386,7 @@ api_policer_classify_set_interface (vat_main_t * vam) u32 ip6_table_index = ~0; u32 l2_table_index = ~0; u8 is_add = 1; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -15363,9 +15424,8 @@ api_policer_classify_set_interface (vat_main_t * vam) mp->is_add = is_add; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -15374,6 +15434,7 @@ api_policer_classify_dump (vat_main_t * vam) unformat_input_t *i = vam->input; vl_api_policer_classify_dump_t *mp; u8 type = POLICER_CLASSIFY_N_TABLES; + int ret; if (unformat (i, "type %U", unformat_policer_classify_table_type, &type)) ; @@ -15400,10 +15461,8 @@ api_policer_classify_dump (vat_main_t * vam) S (mp); } /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -15416,6 +15475,7 @@ api_netmap_create (vat_main_t * vam) u8 random_hw_addr = 1; u8 is_pipe = 0; u8 is_master = 0; + int ret; memset (hw_addr, 0, sizeof (hw_addr)); @@ -15457,9 +15517,8 @@ api_netmap_create (vat_main_t * vam) vec_free (if_name); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -15468,6 +15527,7 @@ api_netmap_delete (vat_main_t * vam) unformat_input_t *i = vam->input; vl_api_netmap_delete_t *mp; u8 *if_name = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -15495,9 +15555,8 @@ api_netmap_delete (vat_main_t * vam) vec_free (if_name); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static void vl_api_mpls_tunnel_details_t_handler @@ -15554,6 +15613,7 @@ api_mpls_tunnel_dump (vat_main_t * vam) { vl_api_mpls_tunnel_dump_t *mp; i32 index = -1; + int ret; /* Parse args required to build the message */ while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT) @@ -15577,7 +15637,8 @@ api_mpls_tunnel_dump (vat_main_t * vam) M (CONTROL_PING, mp); S (mp); } - W; + W (ret); + return ret; } #define vl_api_mpls_fib_details_t_endian vl_noop_handler @@ -15665,6 +15726,7 @@ static int api_mpls_fib_dump (vat_main_t * vam) { vl_api_mpls_fib_dump_t *mp; + int ret; M (MPLS_FIB_DUMP, mp); S (mp); @@ -15675,7 +15737,8 @@ api_mpls_fib_dump (vat_main_t * vam) M (CONTROL_PING, mp); S (mp); } - W; + W (ret); + return ret; } #define vl_api_ip_fib_details_t_endian vl_noop_handler @@ -15765,6 +15828,7 @@ static int api_ip_fib_dump (vat_main_t * vam) { vl_api_ip_fib_dump_t *mp; + int ret; M (IP_FIB_DUMP, mp); S (mp); @@ -15775,7 +15839,8 @@ api_ip_fib_dump (vat_main_t * vam) M (CONTROL_PING, mp); S (mp); } - W; + W (ret); + return ret; } static void vl_api_ip_neighbor_details_t_handler @@ -15834,6 +15899,7 @@ api_ip_neighbor_dump (vat_main_t * vam) vl_api_ip_neighbor_dump_t *mp; u8 is_ipv6 = 0; u32 sw_if_index = ~0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -15865,7 +15931,8 @@ api_ip_neighbor_dump (vat_main_t * vam) M (CONTROL_PING, mp); S (mp); } - W; + W (ret); + return ret; } #define vl_api_ip6_fib_details_t_endian vl_noop_handler @@ -15955,6 +16022,7 @@ static int api_ip6_fib_dump (vat_main_t * vam) { vl_api_ip6_fib_dump_t *mp; + int ret; M (IP6_FIB_DUMP, mp); S (mp); @@ -15965,22 +16033,23 @@ api_ip6_fib_dump (vat_main_t * vam) M (CONTROL_PING, mp); S (mp); } - W; + W (ret); + return ret; } int api_classify_table_ids (vat_main_t * vam) { vl_api_classify_table_ids_t *mp; + int ret; /* Construct the API message */ M (CLASSIFY_TABLE_IDS, mp); mp->context = 0; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } int @@ -15990,6 +16059,7 @@ api_classify_table_by_interface (vat_main_t * vam) vl_api_classify_table_by_interface_t *mp; u32 sw_if_index = ~0; + int ret; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) @@ -16011,9 +16081,8 @@ api_classify_table_by_interface (vat_main_t * vam) mp->sw_if_index = ntohl (sw_if_index); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } int @@ -16023,6 +16092,7 @@ api_classify_table_info (vat_main_t * vam) vl_api_classify_table_info_t *mp; u32 table_id = ~0; + int ret; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { if (unformat (input, "table_id %d", &table_id)) @@ -16042,9 +16112,8 @@ api_classify_table_info (vat_main_t * vam) mp->table_id = ntohl (table_id); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } int @@ -16054,6 +16123,7 @@ api_classify_session_dump (vat_main_t * vam) vl_api_classify_session_dump_t *mp; u32 table_id = ~0; + int ret; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { if (unformat (input, "table_id %d", &table_id)) @@ -16079,9 +16149,8 @@ api_classify_session_dump (vat_main_t * vam) M (CONTROL_PING, mp); S (mp); } - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static void @@ -16135,28 +16204,30 @@ int api_ipfix_exporter_dump (vat_main_t * vam) { vl_api_ipfix_exporter_dump_t *mp; + int ret; /* Construct the API message */ M (IPFIX_EXPORTER_DUMP, mp); mp->context = 0; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int api_ipfix_classify_stream_dump (vat_main_t * vam) { vl_api_ipfix_classify_stream_dump_t *mp; + int ret; /* Construct the API message */ M (IPFIX_CLASSIFY_STREAM_DUMP, mp); mp->context = 0; S (mp); - W; + W (ret); + return ret; /* NOTREACHED */ return 0; } @@ -16193,6 +16264,7 @@ static int api_ipfix_classify_table_dump (vat_main_t * vam) { vl_api_ipfix_classify_table_dump_t *mp; + int ret; if (!vam->json_output) { @@ -16212,7 +16284,8 @@ api_ipfix_classify_table_dump (vat_main_t * vam) M (CONTROL_PING, mp); S (mp); } - W; + W (ret); + return ret; } static void @@ -16254,6 +16327,7 @@ api_sw_interface_span_enable_disable (vat_main_t * vam) u32 src_sw_if_index = ~0; u32 dst_sw_if_index = ~0; u8 state = 3; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -16287,9 +16361,8 @@ api_sw_interface_span_enable_disable (vat_main_t * vam) mp->state = state; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static void @@ -16377,6 +16450,7 @@ static int api_sw_interface_span_dump (vat_main_t * vam) { vl_api_sw_interface_span_dump_t *mp; + int ret; M (SW_INTERFACE_SPAN_DUMP, mp); S (mp); @@ -16387,7 +16461,8 @@ api_sw_interface_span_dump (vat_main_t * vam) M (CONTROL_PING, mp); S (mp); } - W; + W (ret); + return ret; } int @@ -16397,6 +16472,7 @@ api_pg_create_interface (vat_main_t * vam) vl_api_pg_create_interface_t *mp; u32 if_id = ~0; + int ret; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { if (unformat (input, "if_id %d", &if_id)) @@ -16416,9 +16492,8 @@ api_pg_create_interface (vat_main_t * vam) mp->interface_id = ntohl (if_id); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } int @@ -16432,6 +16507,7 @@ api_pg_capture (vat_main_t * vam) u32 count = 1; u8 pcap_file_set = 0; u8 *pcap_file = 0; + int ret; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { if (unformat (input, "if_id %d", &if_id)) @@ -16474,9 +16550,8 @@ api_pg_capture (vat_main_t * vam) vec_free (pcap_file); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } int @@ -16488,6 +16563,7 @@ api_pg_enable_disable (vat_main_t * vam) u8 enable = 1; u8 stream_name_set = 0; u8 *stream_name = 0; + int ret; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { if (unformat (input, "stream %s", &stream_name)) @@ -16520,9 +16596,8 @@ api_pg_enable_disable (vat_main_t * vam) vec_free (stream_name); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } int @@ -16543,6 +16618,7 @@ api_ip_source_and_port_range_check_add_del (vat_main_t * vam) u32 vrf_id = ~0; u8 is_add = 1; u8 is_ipv6 = 0; + int ret; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { @@ -16650,9 +16726,8 @@ api_ip_source_and_port_range_check_add_del (vat_main_t * vam) mp->vrf_id = ntohl (vrf_id); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } int @@ -16665,6 +16740,7 @@ api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam) u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0; u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0; u8 is_add = 1; + int ret; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { @@ -16720,7 +16796,8 @@ api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam) S (mp); /* Wait for a reply... */ - W; + W (ret); + return ret; } static int @@ -16733,6 +16810,7 @@ api_ipsec_gre_add_del_tunnel (vat_main_t * vam) ip4_address_t src_address; ip4_address_t dst_address; u8 is_add = 1; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -16762,9 +16840,8 @@ api_ipsec_gre_add_del_tunnel (vat_main_t * vam) mp->is_add = is_add; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -16776,6 +16853,7 @@ api_punt (vat_main_t * vam) u32 protocol = ~0; u32 port = ~0; int is_add = 1; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -16802,9 +16880,8 @@ api_punt (vat_main_t * vam) mp->l4_port = htons ((u16) port); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static void vl_api_ipsec_gre_tunnel_details_t_handler @@ -16850,6 +16927,7 @@ api_ipsec_gre_tunnel_dump (vat_main_t * vam) vl_api_ipsec_gre_tunnel_dump_t *mp; u32 sw_if_index; u8 sw_if_index_set = 0; + int ret; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -16885,7 +16963,8 @@ api_ipsec_gre_tunnel_dump (vat_main_t * vam) M (CONTROL_PING, mp); S (mp); } - W; + W (ret); + return ret; } static int @@ -16894,6 +16973,7 @@ api_delete_subif (vat_main_t * vam) unformat_input_t *i = vam->input; vl_api_delete_subif_t *mp; u32 sw_if_index = ~0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -16916,7 +16996,8 @@ api_delete_subif (vat_main_t * vam) mp->sw_if_index = ntohl (sw_if_index); S (mp); - W; + W (ret); + return ret; } #define foreach_pbb_vtr_op \ @@ -16936,6 +17017,7 @@ api_l2_interface_pbb_tag_rewrite (vat_main_t * vam) u16 vlanid = 0; u32 sid = ~0; u32 tmp; + int ret; /* Shut up coverity */ memset (dmac, 0, sizeof (dmac)); @@ -17004,9 +17086,8 @@ api_l2_interface_pbb_tag_rewrite (vat_main_t * vam) mp->i_sid = ntohl (sid); S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -17019,6 +17100,7 @@ api_flow_classify_set_interface (vat_main_t * vam) u32 ip4_table_index = ~0; u32 ip6_table_index = ~0; u8 is_add = 1; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -17053,9 +17135,8 @@ api_flow_classify_set_interface (vat_main_t * vam) mp->is_add = is_add; S (mp); - W; - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -17064,6 +17145,7 @@ api_flow_classify_dump (vat_main_t * vam) unformat_input_t *i = vam->input; vl_api_flow_classify_dump_t *mp; u8 type = FLOW_CLASSIFY_N_TABLES; + int ret; if (unformat (i, "type %U", unformat_flow_classify_table_type, &type)) ; @@ -17090,10 +17172,8 @@ api_flow_classify_dump (vat_main_t * vam) S (mp); } /* Wait for a reply... */ - W; - - /* NOTREACHED */ - return 0; + W (ret); + return ret; } static int @@ -17105,6 +17185,7 @@ api_feature_enable_disable (vat_main_t * vam) u8 *feature_name = 0; u32 sw_if_index = ~0; u8 enable = 1; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -17159,7 +17240,8 @@ api_feature_enable_disable (vat_main_t * vam) vec_free (feature_name); S (mp); - W; + W (ret); + return ret; } static int @@ -17170,6 +17252,7 @@ api_sw_interface_tag_add_del (vat_main_t * vam) u32 sw_if_index = ~0; u8 *tag = 0; u8 enable = 1; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -17206,7 +17289,8 @@ api_sw_interface_tag_add_del (vat_main_t * vam) vec_free (tag); S (mp); - W; + W (ret); + return ret; } static void vl_api_l2_xconnect_details_t_handler @@ -17242,6 +17326,7 @@ static int api_l2_xconnect_dump (vat_main_t * vam) { vl_api_l2_xconnect_dump_t *mp; + int ret; if (!vam->json_output) { @@ -17258,7 +17343,8 @@ api_l2_xconnect_dump (vat_main_t * vam) M (CONTROL_PING, mp); S (mp); } - W; + W (ret); + return ret; } static int @@ -17268,6 +17354,7 @@ api_sw_interface_set_mtu (vat_main_t * vam) vl_api_sw_interface_set_mtu_t *mp; u32 sw_if_index = ~0; u32 mtu = 0; + int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { @@ -17299,7 +17386,8 @@ api_sw_interface_set_mtu (vat_main_t * vam) mp->mtu = ntohs ((u16) mtu); S (mp); - W; + W (ret); + return ret; } diff --git a/src/vlibapi/vat_helper_macros.h b/src/vlibapi/vat_helper_macros.h index ffb74fe3..57722338 100644 --- a/src/vlibapi/vat_helper_macros.h +++ b/src/vlibapi/vat_helper_macros.h @@ -42,32 +42,32 @@ do { \ #define S(mp) (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp)) /* W: wait for results, with timeout */ -#define W \ +#define W(ret) \ do { \ f64 timeout = vat_time_now (vam) + 1.0; \ \ while (vat_time_now (vam) < timeout) { \ if (vam->result_ready == 1) { \ - return (vam->retval); \ + ret = vam->retval; \ } \ vat_suspend (vam->vlib_main, 1e-5); \ } \ - return -99; \ + ret = -99; \ } while(0); /* W2: wait for results, with timeout */ -#define W2(body) \ +#define W2(ret, body) \ do { \ f64 timeout = vat_time_now (vam) + 1.0; \ \ while (vat_time_now (vam) < timeout) { \ if (vam->result_ready == 1) { \ (body); \ - return (vam->retval); \ + ret = vam->retval; \ } \ vat_suspend (vam->vlib_main, 1e-5); \ } \ - return -99; \ + ret = -99; \ } while(0); -- cgit 1.2.3-korg From 3b46cba8f4e909bc363403c6c92215159abb2f11 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Mon, 23 Jan 2017 21:13:45 +0100 Subject: Plugin infrastructure improvements This patch replaces requirement for vlib_plugin_register function in the plugin so file and introduces new macro: VLIB_PLUGIN_REGISTER () = { .version = "version string", .version_required = "requred version", .default_disabled = 1, .early_init = "early_init_function_name", }; Plugin will nor be loaded if .default_disabled is set to 1 unless explicitely enabled in startup.conf. If .verstion_required is set, plugin will not be loaded if there is version mismatch between plugin and vpp. This can be bypassed by setting "skip-version-check" for specific plugin. If .early-init string is present, plugin loader will try to resolve this specific symbol in the plugin namespace and make a function call. Following startup.conf configuration is added: plugins { path /path/to/plugin/directory plugin ila_plugin.so { enable skip-version-check } plugin acl_plugin.so { disable } } Change-Id: I706c691dd34d94ffe9e02b59831af8859a95f061 Signed-off-by: Damjan Marion --- src/plugins/acl/acl.c | 29 +-- src/plugins/acl/acl.h | 2 - src/plugins/acl/l2sess.c | 13 -- src/plugins/acl/l2sess.h | 1 - src/plugins/flowperpkt/flowperpkt.c | 32 +-- src/plugins/ila/ila.c | 14 +- src/plugins/ioam/encap/ip6_ioam_trace.c | 18 +- src/plugins/lb/lb.c | 15 +- src/plugins/sixrd/sixrd.c | 23 +-- src/plugins/snat/snat.c | 27 +-- src/plugins/snat/snat.h | 1 - src/vlib/unix/main.c | 8 + src/vlib/unix/plugin.c | 339 ++++++++++++++++++++++++++------ src/vlib/unix/plugin.h | 31 ++- src/vnet/plugin/plugin.h | 9 +- src/vpp/vnet/main.c | 15 +- 16 files changed, 367 insertions(+), 210 deletions(-) (limited to 'src/plugins/lb') diff --git a/src/plugins/acl/acl.c b/src/plugins/acl/acl.c index f4db2013..85c9113b 100644 --- a/src/plugins/acl/acl.c +++ b/src/plugins/acl/acl.c @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -128,29 +129,11 @@ _(MACIP_ACL_INTERFACE_ADD_DEL, macip_acl_interface_add_del) \ _(MACIP_ACL_DUMP, macip_acl_dump) \ _(MACIP_ACL_INTERFACE_GET, macip_acl_interface_get) -/* - * This routine exists to convince the vlib plugin framework that - * we haven't accidentally copied a random .dll into the plugin directory. - * - * Also collects global variable pointers passed from the vpp engine - */ - -clib_error_t * -vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h, - int from_early_init) -{ - acl_main_t *am = &acl_main; - clib_error_t *error = 0; - - am->vlib_main = vm; - am->vnet_main = h->vnet_main; - am->ethernet_main = h->ethernet_main; - - l2sess_vlib_plugin_register(vm, h, from_early_init); - - return error; -} - +/* *INDENT-OFF* */ +VLIB_PLUGIN_REGISTER () = { + .version = VPP_BUILD_VER, +}; +/* *INDENT-ON* */ static void vl_api_acl_plugin_get_version_t_handler (vl_api_acl_plugin_get_version_t * mp) diff --git a/src/plugins/acl/acl.h b/src/plugins/acl/acl.h index afc9b289..62046788 100644 --- a/src/plugins/acl/acl.h +++ b/src/plugins/acl/acl.h @@ -17,7 +17,6 @@ #include #include -#include #include @@ -139,7 +138,6 @@ typedef struct { /* convenience */ vlib_main_t * vlib_main; vnet_main_t * vnet_main; - ethernet_main_t * ethernet_main; } acl_main_t; extern acl_main_t acl_main; diff --git a/src/plugins/acl/l2sess.c b/src/plugins/acl/l2sess.c index cc9bde44..b0385be1 100644 --- a/src/plugins/acl/l2sess.c +++ b/src/plugins/acl/l2sess.c @@ -30,19 +30,6 @@ #include #include -void -l2sess_vlib_plugin_register (vlib_main_t * vm, void* hh, - int from_early_init) -{ - l2sess_main_t *sm = &l2sess_main; - vnet_plugin_handoff_t * h = hh; - memset (sm, 0, sizeof (*sm)); - - sm->vlib_main = vm; - sm->vnet_main = h->vnet_main; - sm->ethernet_main = h->ethernet_main; -} - void l2sess_init_next_features_input (vlib_main_t * vm, l2sess_main_t * sm) { diff --git a/src/plugins/acl/l2sess.h b/src/plugins/acl/l2sess.h index db899917..888b5301 100644 --- a/src/plugins/acl/l2sess.h +++ b/src/plugins/acl/l2sess.h @@ -132,7 +132,6 @@ foreach_l2sess_node /* convenience */ vlib_main_t * vlib_main; vnet_main_t * vnet_main; - ethernet_main_t * ethernet_main; /* Counter(s) */ u64 counter_attempted_delete_free_session; diff --git a/src/plugins/flowperpkt/flowperpkt.c b/src/plugins/flowperpkt/flowperpkt.c index cc351599..6b292eef 100644 --- a/src/plugins/flowperpkt/flowperpkt.c +++ b/src/plugins/flowperpkt/flowperpkt.c @@ -24,6 +24,7 @@ */ #include +#include #include #include @@ -479,30 +480,11 @@ static void *vl_api_flowperpkt_tx_interface_add_del_t_print #define foreach_flowperpkt_plugin_api_msg \ _(FLOWPERPKT_TX_INTERFACE_ADD_DEL, flowperpkt_tx_interface_add_del) -/** - * @brief plugin-api required function - * @param vm vlib_main_t * vlib main data structure pointer - * @param h vlib_plugin_handoff_t * handoff structure - * @param from_early_init int notused - * - * Notes: - * This routine exists to convince the vlib plugin framework that - * we haven't accidentally copied a random .dll into the plugin directory. - * - * Also collects global variable pointers passed from the vpp engine - */ -clib_error_t * -vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h, - int from_early_init) -{ - flowperpkt_main_t *fm = &flowperpkt_main; - clib_error_t *error = 0; - - fm->vlib_main = vm; - fm->vnet_main = h->vnet_main; - - return error; -} +/* *INDENT-OFF* */ +VLIB_PLUGIN_REGISTER () = { + .version = VPP_BUILD_VER, +}; +/* *INDENT-ON* */ static clib_error_t * flowperpkt_tx_interface_add_del_feature_command_fn (vlib_main_t * vm, @@ -627,6 +609,8 @@ flowperpkt_init (vlib_main_t * vm) u32 num_threads; u8 *name; + fm->vnet_main = vnet_get_main (); + /* Construct the API name */ name = format (0, "flowperpkt_%08x%c", api_version, 0); diff --git a/src/plugins/ila/ila.c b/src/plugins/ila/ila.c index 336f4cf5..e0f3907f 100644 --- a/src/plugins/ila/ila.c +++ b/src/plugins/ila/ila.c @@ -18,6 +18,7 @@ #include #include #include +#include static ila_main_t ila_main; @@ -821,14 +822,11 @@ ila_interface (u32 sw_if_index, u8 disable) return 0; } -clib_error_t * -vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h, - int from_early_init) -{ - clib_error_t *error = 0; - - return error; -} +/* *INDENT-OFF* */ +VLIB_PLUGIN_REGISTER () = { + .version = VPP_BUILD_VER, +}; +/* *INDENT-ON* */ u8 *format_ila_dpo (u8 * s, va_list * va) { diff --git a/src/plugins/ioam/encap/ip6_ioam_trace.c b/src/plugins/ioam/encap/ip6_ioam_trace.c index 3a6758cd..a836dfe8 100644 --- a/src/plugins/ioam/encap/ip6_ioam_trace.c +++ b/src/plugins/ioam/encap/ip6_ioam_trace.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -349,18 +350,11 @@ VLIB_CLI_COMMAND (ip6_show_ioam_trace_cmd, static) = { }; /* *INDENT-ON* */ -/* - * This routine exists to convince the vlib plugin framework that - * we haven't accidentally copied a random .dll into the plugin directory. - * - * Also collects global variable pointers passed from the vpp engine - */ -clib_error_t * -vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h, - int from_early_init) -{ - return 0; -} +/* *INDENT-OFF* */ +VLIB_PLUGIN_REGISTER () = { + .version = VPP_BUILD_VER, +}; +/* *INDENT-ON* */ static clib_error_t * ip6_hop_by_hop_ioam_trace_init (vlib_main_t * vm) diff --git a/src/plugins/lb/lb.c b/src/plugins/lb/lb.c index 1d9b9870..dc3f5be1 100644 --- a/src/plugins/lb/lb.c +++ b/src/plugins/lb/lb.c @@ -15,6 +15,7 @@ #include #include +#include #include //GC runs at most once every so many seconds @@ -730,15 +731,11 @@ int lb_vip_del(u32 vip_index) return 0; } -clib_error_t * -vlib_plugin_register (vlib_main_t * vm, - vnet_plugin_handoff_t * h, - int from_early_init) -{ - clib_error_t *error = 0; - return error; -} - +/* *INDENT-OFF* */ +VLIB_PLUGIN_REGISTER () = { + .version = VPP_BUILD_VER, +}; +/* *INDENT-ON* */ u8 *format_lb_dpo (u8 * s, va_list * va) { diff --git a/src/plugins/sixrd/sixrd.c b/src/plugins/sixrd/sixrd.c index 66e631a2..71fc181f 100644 --- a/src/plugins/sixrd/sixrd.c +++ b/src/plugins/sixrd/sixrd.c @@ -19,6 +19,7 @@ #include #include #include +#include /* * This code supports the following sixrd modes: @@ -340,27 +341,19 @@ VLIB_CLI_COMMAND(show_sixrd_stats_command, static) = { .function = show_sixrd_stats_command_fn, }; -/* - * This routine exists to convince the vlib plugin framework that - * we haven't accidentally copied a random .dll into the plugin directory. - * - * Also collects global variable pointers passed from the vpp engine - */ -clib_error_t * -vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h, - int from_early_init) +/* *INDENT-OFF* */ +VLIB_PLUGIN_REGISTER () = { + .version = VPP_BUILD_VER, +}; +/* *INDENT-ON* */ + +static clib_error_t * sixrd_init (vlib_main_t * vm) { - clib_error_t * error = 0; sixrd_main_t *mm = &sixrd_main; mm->vnet_main = vnet_get_main(); mm->vlib_main = vm; - return error; -} - -static clib_error_t * sixrd_init (vlib_main_t * vm) -{ sixrd_dpo_module_init (); return (NULL); diff --git a/src/plugins/snat/snat.c b/src/plugins/snat/snat.c index 0fcd6ce8..750cc925 100644 --- a/src/plugins/snat/snat.c +++ b/src/plugins/snat/snat.c @@ -28,6 +28,7 @@ #include #include #include +#include snat_main_t snat_main; @@ -129,27 +130,11 @@ VNET_FEATURE_INIT (ip4_snat_out2in_fast, static) = { .runs_before = VNET_FEATURES ("ip4-lookup"), }; - -/* - * This routine exists to convince the vlib plugin framework that - * we haven't accidentally copied a random .dll into the plugin directory. - * - * Also collects global variable pointers passed from the vpp engine - */ - -clib_error_t * -vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h, - int from_early_init) -{ - snat_main_t * sm = &snat_main; - clib_error_t * error = 0; - - sm->vlib_main = vm; - sm->vnet_main = h->vnet_main; - sm->ethernet_main = h->ethernet_main; - - return error; -} +/* *INDENT-OFF* */ +VLIB_PLUGIN_REGISTER () = { + .version = VPP_BUILD_VER, +}; +/* *INDENT-ON* */ /*$$$$$ move to an installed header file */ #if (1 || CLIB_DEBUG > 0) /* "trust, but verify" */ diff --git a/src/plugins/snat/snat.h b/src/plugins/snat/snat.h index 32dc9f9e..39cbd3f8 100644 --- a/src/plugins/snat/snat.h +++ b/src/plugins/snat/snat.h @@ -233,7 +233,6 @@ typedef struct { vnet_main_t * vnet_main; ip4_main_t * ip4_main; ip_lookup_main_t * ip4_lookup_main; - ethernet_main_t * ethernet_main; api_main_t * api_main; } snat_main_t; diff --git a/src/vlib/unix/main.c b/src/vlib/unix/main.c index 562778e0..a04d9f9c 100644 --- a/src/vlib/unix/main.c +++ b/src/vlib/unix/main.c @@ -503,6 +503,14 @@ vlib_unix_main (int argc, char *argv[]) vm->heap_base = clib_mem_get_heap (); ASSERT (vm->heap_base); + unformat_init_command_line (&input, (char **) vm->argv); + if ((e = vlib_plugin_config (vm, &input))) + { + clib_error_report (e); + return 1; + } + unformat_free (&input); + i = vlib_plugin_early_init (vm); if (i) return i; diff --git a/src/vlib/unix/plugin.c b/src/vlib/unix/plugin.c index 40399090..4aba95c8 100644 --- a/src/vlib/unix/plugin.c +++ b/src/vlib/unix/plugin.c @@ -16,29 +16,16 @@ */ #include +#include #include #include plugin_main_t vlib_plugin_main; -void -vlib_set_get_handoff_structure_cb (void *cb) -{ - plugin_main_t *pm = &vlib_plugin_main; - pm->handoff_structure_get_cb = cb; -} - -static void * -vnet_get_handoff_structure (void) -{ - void *(*fp) (void); - - fp = vlib_plugin_main.handoff_structure_get_cb; - if (fp == 0) - return 0; - else - return (*fp) (); -} +char *vlib_plugin_path __attribute__ ((weak)); +char *vlib_plugin_path = ""; +char *vlib_plugin_app_version __attribute__ ((weak)); +char *vlib_plugin_app_version = ""; void * vlib_get_plugin_symbol (char *plugin_name, char *symbol_name) @@ -54,13 +41,99 @@ vlib_get_plugin_symbol (char *plugin_name, char *symbol_name) return dlsym (pi->handle, symbol_name); } +static char * +str_array_to_vec (char *array, int len) +{ + char c, *r = 0; + int n = 0; + + do + { + c = array[n]; + vec_add1 (r, c); + } + while (c && ++n < len); + + if (c) + vec_add1 (r, 0); + + return r; +} + static int load_one_plugin (plugin_main_t * pm, plugin_info_t * pi, int from_early_init) { - void *handle, *register_handle; - clib_error_t *(*fp) (vlib_main_t *, void *, int); + void *handle; clib_error_t *error; - void *handoff_structure; + elf_main_t em = { 0 }; + elf_section_t *section; + u8 *data; + char *version_required; + vlib_plugin_registration_t *reg; + plugin_config_t *pc = 0; + uword *p; + + if (elf_read_file (&em, (char *) pi->filename)) + return -1; + + error = elf_get_section_by_name (&em, ".vlib_plugin_registration", + §ion); + if (error) + { + clib_warning ("Not a plugin: %s\n", (char *) pi->name); + return -1; + } + + data = elf_get_section_contents (&em, section->index, 1); + reg = (vlib_plugin_registration_t *) data; + + if (vec_len (data) != sizeof (*reg)) + { + clib_warning ("vlib_plugin_registration size mismatch in plugin %s\n", + (char *) pi->name); + goto error; + } + + p = hash_get_mem (pm->config_index_by_name, pi->name); + if (p) + { + pc = vec_elt_at_index (pm->configs, p[0]); + if (pc->is_disabled) + { + clib_warning ("Plugin disabled: %s", pi->name); + goto error; + } + if (reg->default_disabled && pc->is_enabled == 0) + { + clib_warning ("Plugin disabled: %s (default)", pi->name); + goto error; + } + } + else if (reg->default_disabled) + { + clib_warning ("Plugin disabled: %s (default)", pi->name); + goto error; + } + + version_required = str_array_to_vec ((char *) ®->version_required, + sizeof (reg->version_required)); + + if ((strlen (version_required) > 0) && + (strncmp (vlib_plugin_app_version, version_required, + strlen (version_required)))) + { + clib_warning ("Plugin %s version mismatch: %s != %s", + pi->name, vlib_plugin_app_version, reg->version_required); + if (!(pc && pc->skip_version_check == 1)) + { + vec_free (version_required); + goto error; + } + } + + vec_free (version_required); + vec_free (data); + elf_main_free (&em); handle = dlopen ((char *) pi->filename, RTLD_LAZY); @@ -77,35 +150,47 @@ load_one_plugin (plugin_main_t * pm, plugin_info_t * pi, int from_early_init) pi->handle = handle; + reg = dlsym (pi->handle, "vlib_plugin_registration"); - register_handle = dlsym (pi->handle, "vlib_plugin_register"); - if (register_handle == 0) + if (reg == 0) { - dlclose (handle); - clib_warning ("Plugin missing vlib_plugin_register: %s\n", - (char *) pi->name); - return 1; + /* This should never happen unless somebody chagnes registration macro */ + clib_warning ("Missing plugin registration in plugin '%s'", pi->name); + os_exit (1); } - fp = register_handle; - - handoff_structure = vnet_get_handoff_structure (); + pi->reg = reg; + pi->version = str_array_to_vec ((char *) ®->version, + sizeof (reg->version)); - if (handoff_structure == 0) - error = clib_error_return (0, "handoff structure callback returned 0"); - else - error = (*fp) (pm->vlib_main, handoff_structure, from_early_init); - - if (error) + if (reg && reg->early_init) { - clib_error_report (error); - dlclose (handle); - return 1; + clib_error_t *(*ei) (vlib_main_t *); + void *h; + + h = dlsym (pi->handle, reg->early_init); + if (h) + { + ei = h; + error = (*ei) (pm->vlib_main); + if (error) + { + clib_error_report (error); + os_exit (1); + } + } + else + clib_warning ("Plugin %s: early init function %s set but not found", + (char *) pi->name, reg->early_init); } clib_warning ("Loaded plugin: %s", pi->name); return 0; +error: + vec_free (data); + elf_main_free (&em); + return -1; } static u8 ** @@ -215,23 +300,16 @@ vlib_load_new_plugins (plugin_main_t * pm, int from_early_init) return 0; } -char *vlib_plugin_path __attribute__ ((weak)); -char *vlib_plugin_path = ""; -char *vlib_plugin_name_filter __attribute__ ((weak)); -char *vlib_plugin_name_filter = 0; - int vlib_plugin_early_init (vlib_main_t * vm) { plugin_main_t *pm = &vlib_plugin_main; - pm->plugin_path = format (0, "%s%c", vlib_plugin_path, 0); + if (pm->plugin_path == 0) + pm->plugin_path = format (0, "%s%c", vlib_plugin_path, 0); clib_warning ("plugin path %s", pm->plugin_path); - if (vlib_plugin_name_filter) - pm->plugin_name_filter = format (0, "%s%c", vlib_plugin_name_filter, 0); - pm->plugin_by_name_hash = hash_create_string (0, sizeof (uword)); pm->vlib_main = vm; @@ -245,19 +323,24 @@ vlib_plugins_show_cmd_fn (vlib_main_t * vm, plugin_main_t *pm = &vlib_plugin_main; u8 *s = 0; u8 *key = 0; - uword *value = 0; + uword value = 0; int index = 1; + plugin_info_t *pi; - s = format (s, " Plugin path is: %s\n", pm->plugin_path); - if (vlib_plugin_name_filter) - s = format (s, " Plugin filter: %s\n", vlib_plugin_name_filter); + s = format (s, " Plugin path is: %s\n\n", pm->plugin_path); + s = format (s, " %-41s%s\n", "Plugin", "Version"); - s = format (s, " Plugins loaded: \n"); + /* *INDENT-OFF* */ hash_foreach_mem (key, value, pm->plugin_by_name_hash, - { - if (key != 0) - s = format (s, " %d.%s\n", index, key); index++;} - ); + { + if (key != 0) + { + pi = vec_elt_at_index (pm->plugin_info, value); + s = format (s, "%3d. %-40s %s\n", index, key, pi->version); + index++; + } + }); + /* *INDENT-ON* */ vlib_cli_output (vm, "%v", s); vec_free (s); @@ -273,6 +356,148 @@ VLIB_CLI_COMMAND (plugins_show_cmd, static) = }; /* *INDENT-ON* */ +static clib_error_t * +config_one_plugin (vlib_main_t * vm, char *name, unformat_input_t * input) +{ + plugin_main_t *pm = &vlib_plugin_main; + plugin_config_t *pc; + clib_error_t *error = 0; + uword *p; + int is_enable = 0; + int is_disable = 0; + int skip_version_check = 0; + + if (pm->config_index_by_name == 0) + pm->config_index_by_name = hash_create_string (0, sizeof (uword)); + + p = hash_get_mem (pm->config_index_by_name, name); + + if (p) + { + error = clib_error_return (0, "plugin '%s' already configured", name); + goto done; + } + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "enable")) + is_enable = 1; + else if (unformat (input, "disable")) + is_disable = 1; + else if (unformat (input, "skip-version-check")) + skip_version_check = 1; + else + { + error = clib_error_return (0, "unknown input '%U'", + format_unformat_error, input); + goto done; + } + } + + if (is_enable && is_disable) + { + error = clib_error_return (0, "please specify either enable or disable" + " for plugin '%s'", name); + goto done; + } + + vec_add2 (pm->configs, pc, 1); + hash_set_mem (pm->config_index_by_name, name, pc - pm->configs); + pc->is_enabled = is_enable; + pc->is_disabled = is_disable; + pc->skip_version_check = skip_version_check; + pc->name = name; + +done: + return error; +} + +clib_error_t * +vlib_plugin_config (vlib_main_t * vm, unformat_input_t * input) +{ + plugin_main_t *pm = &vlib_plugin_main; + clib_error_t *error = 0; + unformat_input_t in; + + unformat_init (&in, 0, 0); + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + u8 *s, *v; + if (unformat (input, "%s %v", &s, &v)) + { + if (strncmp ((const char *) s, "plugins", 8) == 0) + { + if (vec_len (in.buffer) > 0) + vec_add1 (in.buffer, ' '); + vec_add (in.buffer, v, vec_len (v)); + } + } + else + { + error = clib_error_return (0, "unknown input '%U'", + format_unformat_error, input); + goto done; + } + + vec_free (v); + vec_free (s); + } +done: + input = ∈ + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + unformat_input_t sub_input; + u8 *s = 0; + if (unformat (input, "path %s", &s)) + pm->plugin_path = s; + else if (unformat (input, "plugin %s %U", &s, + unformat_vlib_cli_sub_input, &sub_input)) + { + error = config_one_plugin (vm, (char *) s, &sub_input); + unformat_free (&sub_input); + if (error) + goto done2; + } + else + { + error = clib_error_return (0, "unknown input '%U'", + format_unformat_error, input); + { + vec_free (s); + goto done2; + } + } + } + +done2: + unformat_free (&in); + return error; +} + +/* discard whole 'plugins' section, as it is already consumed prior to + plugin load */ +static clib_error_t * +plugins_config (vlib_main_t * vm, unformat_input_t * input) +{ + u8 *junk; + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "%s", &junk)) + { + vec_free (junk); + return 0; + } + else + return clib_error_return (0, "unknown input '%U'", + format_unformat_error, input); + } + return 0; +} + +VLIB_CONFIG_FUNCTION (plugins_config, "plugins"); + /* * fd.io coding-style-patch-verification: ON * diff --git a/src/vlib/unix/plugin.h b/src/vlib/unix/plugin.h index 1c74cdd2..01fec356 100644 --- a/src/vlib/unix/plugin.h +++ b/src/vlib/unix/plugin.h @@ -56,7 +56,14 @@ * vlib_load_new_plugins(). */ - +/* *INDENT-OFF* */ +typedef CLIB_PACKED(struct { + u8 default_disabled; + const char version[32]; + const char version_required[32]; + const char *early_init; +}) vlib_plugin_registration_t; +/* *INDENT-ON* */ typedef struct { @@ -64,8 +71,20 @@ typedef struct u8 *filename; struct stat file_info; void *handle; + + /* plugin registration */ + vlib_plugin_registration_t *reg; + char *version; } plugin_info_t; +typedef struct +{ + char *name; + u8 is_disabled; + u8 is_enabled; + u8 skip_version_check; +} plugin_config_t; + typedef struct { /* loaded plugin info */ @@ -76,8 +95,9 @@ typedef struct u8 *plugin_path; u8 *plugin_name_filter; - /* handoff structure get callback */ - void *handoff_structure_get_cb; + /* plugin configs and hash by name */ + plugin_config_t *configs; + uword *config_index_by_name; /* usual */ vlib_main_t *vlib_main; @@ -85,10 +105,15 @@ typedef struct extern plugin_main_t vlib_plugin_main; +clib_error_t *vlib_plugin_config (vlib_main_t * vm, unformat_input_t * input); int vlib_plugin_early_init (vlib_main_t * vm); int vlib_load_new_plugins (plugin_main_t * pm, int from_early_init); void *vlib_get_plugin_symbol (char *plugin_name, char *symbol_name); +#define VLIB_PLUGIN_REGISTER() \ + vlib_plugin_registration_t vlib_plugin_registration \ + __attribute__((__section__(".vlib_plugin_registration"))) + #endif /* __included_plugin_h__ */ /* diff --git a/src/vnet/plugin/plugin.h b/src/vnet/plugin/plugin.h index a14a5932..6e1a3264 100644 --- a/src/vnet/plugin/plugin.h +++ b/src/vnet/plugin/plugin.h @@ -20,13 +20,6 @@ #include #include #include - -/* Pointers to Genuine Vnet data structures handed to plugin .dll's */ -typedef struct { - vnet_main_t * vnet_main; - ethernet_main_t * ethernet_main; -} vnet_plugin_handoff_t; - -void * vnet_get_handoff_structure (void); +#include #endif /* included_vnet_plugin_h */ diff --git a/src/vpp/vnet/main.c b/src/vpp/vnet/main.c index a252b846..4a96ca94 100644 --- a/src/vpp/vnet/main.c +++ b/src/vpp/vnet/main.c @@ -18,7 +18,7 @@ #include #include #include - +#include #include @@ -39,16 +39,7 @@ vpe_main_init (vlib_main_t * vm) * Load plugins from /usr/lib/vpp_plugins by default */ char *vlib_plugin_path = "/usr/lib/vpp_plugins"; - -void * -vnet_get_handoff_structure (void) -{ - static vnet_plugin_handoff_t _rv, *rv = &_rv; - - rv->vnet_main = vnet_get_main (); - rv->ethernet_main = ðernet_main; - return (void *) rv; -} +char *vlib_plugin_app_version = VPP_BUILD_VER; int main (int argc, char *argv[]) @@ -59,7 +50,6 @@ main (int argc, char *argv[]) uword main_heap_size = (1ULL << 30); u8 *sizep; u32 size; - void vlib_set_get_handoff_structure_cb (void *cb); #if __x86_64__ CLIB_UNUSED (const char *msg) @@ -206,7 +196,6 @@ defaulted: #if DPDK == 0 unix_physmem_init (vm, 0 /* fail_if_physical_memory_not_present */ ); #endif - vlib_set_get_handoff_structure_cb (&vnet_get_handoff_structure); return vlib_unix_main (argc, argv); } else -- cgit 1.2.3-korg From a9a20e7f69f4a91a4d5267ab5ce14125bdc7d6c6 Mon Sep 17 00:00:00 2001 From: Billy McFall Date: Wed, 15 Feb 2017 11:39:12 -0500 Subject: VPP-635: CLI Memory leak with invalid parameter In the CLI parsing, below is a common pattern: /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) return 0; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { if (unformat (line_input, "x")) x = 1; : else return clib_error_return (0, "unknown input `%U'", format_unformat_error, line_input); } unformat_free (line_input); The 'else' returns if an unknown string is encountered. There a memory leak because the 'unformat_free(line_input)' is not called. There is a large number of instances of this pattern. Replaced the previous pattern with: /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) return 0; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { if (unformat (line_input, "x")) x = 1; : else { error = clib_error_return (0, "unknown input `%U'", format_unformat_error, line_input); goto done: } } /* ...Remaining code... */ done: unformat_free (line_input); return error; } In multiple files, 'unformat_free (line_input);' was never called, so there was a memory leak whether an invalid string was entered or not. Also, there were multiple instance where: error = clib_error_return (0, "unknown input `%U'", format_unformat_error, line_input); used 'input' as the last parameter instead of 'line_input'. The result is that output did not contain the substring in error, instead just an empty string. Fixed all of those as well. There are a lot of file, and very mind numbing work, so tried to keep it to a pattern to avoid mistakes. Change-Id: I8902f0c32a47dd7fb3bb3471a89818571702f1d2 Signed-off-by: Billy McFall Signed-off-by: Dave Barach --- build-root/emacs-lisp/tunnel-c-skel.el | 19 ++- src/plugins/ila/ila.c | 25 ++- src/plugins/lb/cli.c | 99 ++++++----- src/plugins/sixrd/sixrd.c | 42 +++-- src/plugins/snat/snat.c | 139 +++++++++++----- src/vlib/threads_cli.c | 79 ++++++--- src/vlib/trace.c | 13 +- src/vlib/unix/cli.c | 22 ++- src/vnet/devices/af_packet/cli.c | 56 +++++-- src/vnet/devices/dpdk/cli.c | 290 +++++++++++++++++++++++---------- src/vnet/devices/dpdk/ipsec/cli.c | 15 +- src/vnet/devices/netmap/cli.c | 54 ++++-- src/vnet/devices/virtio/vhost-user.c | 62 +++++-- src/vnet/gre/interface.c | 35 ++-- src/vnet/ip/ip4_source_check.c | 6 +- src/vnet/ip/ip4_test.c | 15 +- src/vnet/ip/ip6_neighbor.c | 27 ++- src/vnet/ip/lookup.c | 34 ++-- src/vnet/ipsec-gre/interface.c | 34 ++-- src/vnet/ipsec/ipsec_cli.c | 177 +++++++++++++------- src/vnet/l2/l2_patch.c | 26 ++- src/vnet/l2/l2_xcrw.c | 34 +++- src/vnet/l2tp/l2tp.c | 39 +++-- src/vnet/lisp-cp/lisp_cli.c | 139 ++++++++++++---- src/vnet/lisp-gpe/interface.c | 58 +++++-- src/vnet/lisp-gpe/lisp_gpe.c | 13 +- src/vnet/map/map.c | 186 +++++++++++++++------ src/vnet/mpls/mpls.c | 2 + src/vnet/mpls/mpls_tunnel.c | 19 ++- src/vnet/pg/cli.c | 39 +++-- src/vnet/policer/node_funcs.c | 19 ++- src/vnet/policer/policer.c | 13 +- src/vnet/unix/tapcli.c | 57 +++++-- src/vnet/vxlan-gpe/vxlan_gpe.c | 62 +++++-- src/vnet/vxlan/vxlan.c | 81 ++++++--- src/vpp/app/l2t.c | 9 +- src/vpp/app/vpe_cli.c | 24 ++- 37 files changed, 1487 insertions(+), 576 deletions(-) (limited to 'src/plugins/lb') diff --git a/build-root/emacs-lisp/tunnel-c-skel.el b/build-root/emacs-lisp/tunnel-c-skel.el index aa260e53..a1b1757d 100644 --- a/build-root/emacs-lisp/tunnel-c-skel.el +++ b/build-root/emacs-lisp/tunnel-c-skel.el @@ -288,6 +288,7 @@ static clib_error_t * vlib_cli_command_t * cmd) { unformat_input_t _line_input, * line_input = &_line_input; + clib_error_t *error = 0; ip4_address_t src, dst; u8 is_add = 1; u8 src_set = 0; @@ -322,13 +323,19 @@ static clib_error_t * { encap_fib_index = fib_index_from_fib_id (tmp); if (encap_fib_index == ~0) - return clib_error_return (0, \"nonexistent encap fib id %d\", tmp); + { + unformat_free (line_input); + return clib_error_return (0, \"nonexistent encap fib id %d\", tmp); + } } else if (unformat (line_input, \"decap-vrf-id %d\", &tmp)) { decap_fib_index = fib_index_from_fib_id (tmp); if (decap_fib_index == ~0) - return clib_error_return (0, \"nonexistent decap fib id %d\", tmp); + { + unformat_free (line_input); + return clib_error_return (0, \"nonexistent decap fib id %d\", tmp); + } } else if (unformat (line_input, \"decap-next %U\", unformat_decap_next, &decap_next_index)) @@ -346,8 +353,12 @@ static clib_error_t * * in the " ENCAP_STACK " header */ else - return clib_error_return (0, \"parse error: '%U'\", - format_unformat_error, line_input); + { + error = clib_error_return (0, \"parse error: '%U'\", + format_unformat_error, line_input); + unformat_free (line_input); + return error; + } } unformat_free (line_input); diff --git a/src/plugins/ila/ila.c b/src/plugins/ila/ila.c index e0f3907f..52c7ea55 100644 --- a/src/plugins/ila/ila.c +++ b/src/plugins/ila/ila.c @@ -949,6 +949,7 @@ ila_entry_command_fn (vlib_main_t * vm, ila_add_del_entry_args_t args = { 0 }; u8 next_hop_set = 0; int ret; + clib_error_t *error = 0; args.type = ILA_TYPE_IID; args.csum_mode = ILA_CSUM_MODE_NO_ACTION; @@ -986,19 +987,29 @@ ila_entry_command_fn (vlib_main_t * vm, else if (unformat (line_input, "del")) args.is_del = 1; else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); - if (!next_hop_set) - return clib_error_return (0, "Specified a next hop"); + { + error = clib_error_return (0, "Specified a next hop"); + goto done; + } if ((ret = ila_add_del_entry (&args))) - return clib_error_return (0, "ila_add_del_entry returned error %d", ret); + { + error = clib_error_return (0, "ila_add_del_entry returned error %d", ret); + goto done; + } - return NULL; +done: + unformat_free (line_input); + + return error; } VLIB_CLI_COMMAND (ila_entry_command, static) = diff --git a/src/plugins/lb/cli.c b/src/plugins/lb/cli.c index b59c6426..6452a875 100644 --- a/src/plugins/lb/cli.c +++ b/src/plugins/lb/cli.c @@ -28,13 +28,16 @@ lb_vip_command_fn (vlib_main_t * vm, int ret; u32 gre4 = 0; lb_vip_type_t type; + clib_error_t *error = 0; if (!unformat_user (input, unformat_line_input, line_input)) return 0; - if (!unformat(line_input, "%U", unformat_ip46_prefix, &prefix, &plen, IP46_TYPE_ANY, &plen)) - return clib_error_return (0, "invalid vip prefix: '%U'", - format_unformat_error, line_input); + if (!unformat(line_input, "%U", unformat_ip46_prefix, &prefix, &plen, IP46_TYPE_ANY, &plen)) { + error = clib_error_return (0, "invalid vip prefix: '%U'", + format_unformat_error, line_input); + goto done; + } while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { @@ -46,13 +49,13 @@ lb_vip_command_fn (vlib_main_t * vm, gre4 = 1; else if (unformat(line_input, "encap gre6")) gre4 = 0; - else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + else { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); - if (ip46_prefix_is_ip4(&prefix, plen)) { type = (gre4)?LB_VIP_TYPE_IP4_GRE4:LB_VIP_TYPE_IP4_GRE6; @@ -65,17 +68,25 @@ lb_vip_command_fn (vlib_main_t * vm, u32 index; if (!del) { if ((ret = lb_vip_add(&prefix, plen, type, new_len, &index))) { - return clib_error_return (0, "lb_vip_add error %d", ret); + error = clib_error_return (0, "lb_vip_add error %d", ret); + goto done; } else { vlib_cli_output(vm, "lb_vip_add ok %d", index); } } else { - if ((ret = lb_vip_find_index(&prefix, plen, &index))) - return clib_error_return (0, "lb_vip_find_index error %d", ret); - else if ((ret = lb_vip_del(index))) - return clib_error_return (0, "lb_vip_del error %d", ret); + if ((ret = lb_vip_find_index(&prefix, plen, &index))) { + error = clib_error_return (0, "lb_vip_find_index error %d", ret); + goto done; + } else if ((ret = lb_vip_del(index))) { + error = clib_error_return (0, "lb_vip_del error %d", ret); + goto done; + } } - return NULL; + +done: + unformat_free (line_input); + + return error; } VLIB_CLI_COMMAND (lb_vip_command, static) = @@ -96,16 +107,21 @@ lb_as_command_fn (vlib_main_t * vm, u32 vip_index; u8 del = 0; int ret; + clib_error_t *error = 0; if (!unformat_user (input, unformat_line_input, line_input)) return 0; - if (!unformat(line_input, "%U", unformat_ip46_prefix, &vip_prefix, &vip_plen, IP46_TYPE_ANY)) - return clib_error_return (0, "invalid as address: '%U'", - format_unformat_error, line_input); + if (!unformat(line_input, "%U", unformat_ip46_prefix, &vip_prefix, &vip_plen, IP46_TYPE_ANY)) { + error = clib_error_return (0, "invalid as address: '%U'", + format_unformat_error, line_input); + goto done; + } - if ((ret = lb_vip_find_index(&vip_prefix, vip_plen, &vip_index))) - return clib_error_return (0, "lb_vip_find_index error %d", ret); + if ((ret = lb_vip_find_index(&vip_prefix, vip_plen, &vip_index))) { + error = clib_error_return (0, "lb_vip_find_index error %d", ret); + goto done; + } while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { @@ -114,15 +130,15 @@ lb_as_command_fn (vlib_main_t * vm, } else if (unformat(line_input, "del")) { del = 1; } else { - vec_free(as_array); - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; } } if (!vec_len(as_array)) { - vec_free(as_array); - return clib_error_return (0, "No AS address provided"); + error = clib_error_return (0, "No AS address provided"); + goto done; } lb_garbage_collection(); @@ -130,18 +146,21 @@ lb_as_command_fn (vlib_main_t * vm, if (del) { if ((ret = lb_vip_del_ass(vip_index, as_array, vec_len(as_array)))) { - vec_free(as_array); - return clib_error_return (0, "lb_vip_del_ass error %d", ret); + error = clib_error_return (0, "lb_vip_del_ass error %d", ret); + goto done; } } else { if ((ret = lb_vip_add_ass(vip_index, as_array, vec_len(as_array)))) { - vec_free(as_array); - return clib_error_return (0, "lb_vip_add_ass error %d", ret); + error = clib_error_return (0, "lb_vip_add_ass error %d", ret); + goto done; } } +done: + unformat_free (line_input); vec_free(as_array); - return 0; + + return error; } VLIB_CLI_COMMAND (lb_as_command, static) = @@ -163,6 +182,7 @@ lb_conf_command_fn (vlib_main_t * vm, u32 per_cpu_sticky_buckets_log2 = 0; u32 flow_timeout = lbm->flow_timeout; int ret; + clib_error_t *error = 0; if (!unformat_user (input, unformat_line_input, line_input)) return 0; @@ -181,19 +201,24 @@ lb_conf_command_fn (vlib_main_t * vm, per_cpu_sticky_buckets = 1 << per_cpu_sticky_buckets_log2; } else if (unformat(line_input, "timeout %d", &flow_timeout)) ; - else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + else { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); - lb_garbage_collection(); - if ((ret = lb_conf(&ip4, &ip6, per_cpu_sticky_buckets, flow_timeout))) - return clib_error_return (0, "lb_conf error %d", ret); + if ((ret = lb_conf(&ip4, &ip6, per_cpu_sticky_buckets, flow_timeout))) { + error = clib_error_return (0, "lb_conf error %d", ret); + goto done; + } - return NULL; +done: + unformat_free (line_input); + + return error; } VLIB_CLI_COMMAND (lb_conf_command, static) = diff --git a/src/plugins/sixrd/sixrd.c b/src/plugins/sixrd/sixrd.c index 71fc181f..67a9a3ad 100644 --- a/src/plugins/sixrd/sixrd.c +++ b/src/plugins/sixrd/sixrd.c @@ -192,6 +192,7 @@ sixrd_add_domain_command_fn (vlib_main_t *vm, u32 num_m_args = 0; /* Optional arguments */ u32 mtu = 0; + clib_error_t *error = 0; /* Get a line of input. */ if (!unformat_user(input, unformat_line_input, line_input)) @@ -205,19 +206,25 @@ sixrd_add_domain_command_fn (vlib_main_t *vm, num_m_args++; else if (unformat(line_input, "mtu %d", &mtu)) num_m_args++; - else - return clib_error_return(0, "unknown input `%U'", - format_unformat_error, input); + else { + error = clib_error_return(0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free(line_input); - if (num_m_args < 3) - return clib_error_return(0, "mandatory argument(s) missing"); + if (num_m_args < 3) { + error = clib_error_return(0, "mandatory argument(s) missing"); + goto done; + } sixrd_create_domain(&ip6_prefix, ip6_prefix_len, &ip4_prefix, ip4_prefix_len, &ip4_src, &sixrd_domain_index, mtu); - return 0; +done: + unformat_free (line_input); + + return error; } static clib_error_t * @@ -228,6 +235,7 @@ sixrd_del_domain_command_fn (vlib_main_t *vm, unformat_input_t _line_input, *line_input = &_line_input; u32 num_m_args = 0; u32 sixrd_domain_index; + clib_error_t *error = 0; /* Get a line of input. */ if (! unformat_user(input, unformat_line_input, line_input)) @@ -236,18 +244,24 @@ sixrd_del_domain_command_fn (vlib_main_t *vm, while (unformat_check_input(line_input) != UNFORMAT_END_OF_INPUT) { if (unformat(line_input, "index %d", &sixrd_domain_index)) num_m_args++; - else - return clib_error_return(0, "unknown input `%U'", - format_unformat_error, input); + else { + error = clib_error_return(0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free(line_input); - if (num_m_args != 1) - return clib_error_return(0, "mandatory argument(s) missing"); + if (num_m_args != 1) { + error = clib_error_return(0, "mandatory argument(s) missing"); + goto done; + } sixrd_delete_domain(sixrd_domain_index); - return 0; +done: + unformat_free (line_input); + + return error; } static u8 * diff --git a/src/plugins/snat/snat.c b/src/plugins/snat/snat.c index 73854a7a..8c2bacdb 100644 --- a/src/plugins/snat/snat.c +++ b/src/plugins/snat/snat.c @@ -1705,6 +1705,7 @@ add_address_command_fn (vlib_main_t * vm, int i, count; int is_add = 1; int rv = 0; + clib_error_t *error = 0; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -1721,19 +1722,27 @@ add_address_command_fn (vlib_main_t * vm, else if (unformat (line_input, "del")) is_add = 0; else - return clib_error_return (0, "unknown input '%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); if (sm->static_mapping_only) - return clib_error_return (0, "static mapping only mode"); + { + error = clib_error_return (0, "static mapping only mode"); + goto done; + } start_host_order = clib_host_to_net_u32 (start_addr.as_u32); end_host_order = clib_host_to_net_u32 (end_addr.as_u32); if (end_host_order < start_host_order) - return clib_error_return (0, "end address less than start address"); + { + error = clib_error_return (0, "end address less than start address"); + goto done; + } count = (end_host_order - start_host_order) + 1; @@ -1755,11 +1764,11 @@ add_address_command_fn (vlib_main_t * vm, switch (rv) { case VNET_API_ERROR_NO_SUCH_ENTRY: - return clib_error_return (0, "S-NAT address not exist."); - break; + error = clib_error_return (0, "S-NAT address not exist."); + goto done; case VNET_API_ERROR_UNSPECIFIED: - return clib_error_return (0, "S-NAT address used in static mapping."); - break; + error = clib_error_return (0, "S-NAT address used in static mapping."); + goto done; default: break; } @@ -1767,7 +1776,10 @@ add_address_command_fn (vlib_main_t * vm, increment_v4_address (&this_addr); } - return 0; +done: + unformat_free (line_input); + + return error; } VLIB_CLI_COMMAND (add_address_command, static) = { @@ -1807,10 +1819,12 @@ snat_feature_command_fn (vlib_main_t * vm, else if (unformat (line_input, "del")) is_del = 1; else - return clib_error_return (0, "unknown input '%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); if (vec_len (inside_sw_if_indices)) { @@ -1830,6 +1844,8 @@ snat_feature_command_fn (vlib_main_t * vm, } } +done: + unformat_free (line_input); vec_free (inside_sw_if_indices); vec_free (outside_sw_if_indices); @@ -1923,13 +1939,18 @@ add_static_mapping_command_fn (vlib_main_t * vm, else if (unformat (line_input, "del")) is_add = 0; else - return clib_error_return (0, "unknown input: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "unknown input: '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); if (!addr_only && !proto_set) - return clib_error_return (0, "missing protocol"); + { + error = clib_error_return (0, "missing protocol"); + goto done; + } rv = snat_add_static_mapping(l_addr, e_addr, (u16) l_port, (u16) e_port, vrf_id, addr_only, sw_if_index, proto, is_add); @@ -1937,22 +1958,27 @@ add_static_mapping_command_fn (vlib_main_t * vm, switch (rv) { case VNET_API_ERROR_INVALID_VALUE: - return clib_error_return (0, "External port already in use."); - break; + error = clib_error_return (0, "External port already in use."); + goto done; case VNET_API_ERROR_NO_SUCH_ENTRY: if (is_add) - return clib_error_return (0, "External addres must be allocated."); + error = clib_error_return (0, "External addres must be allocated."); else - return clib_error_return (0, "Mapping not exist."); - break; + error = clib_error_return (0, "Mapping not exist."); + goto done; case VNET_API_ERROR_NO_SUCH_FIB: - return clib_error_return (0, "No such VRF id."); + error = clib_error_return (0, "No such VRF id."); + goto done; case VNET_API_ERROR_VALUE_EXIST: - return clib_error_return (0, "Mapping already exist."); + error = clib_error_return (0, "Mapping already exist."); + goto done; default: break; } +done: + unformat_free (line_input); + return error; } @@ -1985,6 +2011,7 @@ set_workers_command_fn (vlib_main_t * vm, unformat_input_t _line_input, *line_input = &_line_input; uword *bitmap = 0; int rv = 0; + clib_error_t *error = 0; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -1995,13 +2022,18 @@ set_workers_command_fn (vlib_main_t * vm, if (unformat (line_input, "%U", unformat_bitmap_list, &bitmap)) ; else - return clib_error_return (0, "unknown input '%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); if (bitmap == 0) - return clib_error_return (0, "List of workers must be specified."); + { + error = clib_error_return (0, "List of workers must be specified."); + goto done; + } rv = snat_set_workers(bitmap); @@ -2010,17 +2042,20 @@ set_workers_command_fn (vlib_main_t * vm, switch (rv) { case VNET_API_ERROR_INVALID_WORKER: - return clib_error_return (0, "Invalid worker(s)."); - break; + error = clib_error_return (0, "Invalid worker(s)."); + goto done; case VNET_API_ERROR_FEATURE_DISABLED: - return clib_error_return (0, + error = clib_error_return (0, "Supported only if 2 or more workes available."); - break; + goto done; default: break; } - return 0; +done: + unformat_free (line_input); + + return error; } /*? @@ -2047,6 +2082,7 @@ snat_ipfix_logging_enable_disable_command_fn (vlib_main_t * vm, u32 src_port = 0; u8 enable = 1; int rv = 0; + clib_error_t *error = 0; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -2061,17 +2097,25 @@ snat_ipfix_logging_enable_disable_command_fn (vlib_main_t * vm, else if (unformat (line_input, "disable")) enable = 0; else - return clib_error_return (0, "unknown input '%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); rv = snat_ipfix_logging_enable_disable (enable, domain_id, (u16) src_port); if (rv) - return clib_error_return (0, "ipfix logging enable failed"); + { + error = clib_error_return (0, "ipfix logging enable failed"); + goto done; + } - return 0; +done: + unformat_free (line_input); + + return error; } /*? @@ -2604,6 +2648,7 @@ snat_add_interface_address_command_fn (vlib_main_t * vm, u32 sw_if_index; int rv; int is_del = 0; + clib_error_t *error = 0; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -2617,8 +2662,11 @@ snat_add_interface_address_command_fn (vlib_main_t * vm, else if (unformat (line_input, "del")) is_del = 1; else - return clib_error_return (0, "unknown input '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "unknown input '%U'", + format_unformat_error, line_input); + goto done; + } } rv = snat_add_interface_address (sm, sw_if_index, is_del); @@ -2629,10 +2677,15 @@ snat_add_interface_address_command_fn (vlib_main_t * vm, break; default: - return clib_error_return (0, "snat_add_interface_address returned %d", - rv); + error = clib_error_return (0, "snat_add_interface_address returned %d", + rv); + goto done; } - return 0; + +done: + unformat_free (line_input); + + return error; } VLIB_CLI_COMMAND (snat_add_interface_address_command, static) = { diff --git a/src/vlib/threads_cli.c b/src/vlib/threads_cli.c index 54cc1aed..36f8109e 100644 --- a/src/vlib/threads_cli.c +++ b/src/vlib/threads_cli.c @@ -163,21 +163,31 @@ trace_frame_queue (vlib_main_t * vm, unformat_input_t * input, else if (unformat (line_input, "index %u", &index)) ; else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); - if (enable > 1) - return clib_error_return (0, "expecting on or off"); + { + error = clib_error_return (0, "expecting on or off"); + goto done; + } if (vec_len (tm->frame_queue_mains) == 0) - return clib_error_return (0, "no worker handoffs exist"); + { + error = clib_error_return (0, "no worker handoffs exist"); + goto done; + } if (index > vec_len (tm->frame_queue_mains) - 1) - return clib_error_return (0, - "expecting valid worker handoff queue index"); + { + error = clib_error_return (0, + "expecting valid worker handoff queue index"); + goto done; + } fqm = vec_elt_at_index (tm->frame_queue_mains, index); @@ -185,7 +195,7 @@ trace_frame_queue (vlib_main_t * vm, unformat_input_t * input, if (num_fq == 0) { vlib_cli_output (vm, "No frame queues exist\n"); - return error; + goto done; } // Allocate storage for trace if necessary @@ -204,6 +214,10 @@ trace_frame_queue (vlib_main_t * vm, unformat_input_t * input, memset (fqh, 0, sizeof (*fqh)); fqm->vlib_frame_queues[fqix]->trace = enable; } + +done: + unformat_free (line_input); + return error; } @@ -432,28 +446,33 @@ test_frame_queue_nelts (vlib_main_t * vm, unformat_input_t * input, else if (unformat (line_input, "index %u", &index)) ; else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); - if (index > vec_len (tm->frame_queue_mains) - 1) - return clib_error_return (0, - "expecting valid worker handoff queue index"); + { + error = clib_error_return (0, + "expecting valid worker handoff queue index"); + goto done; + } fqm = vec_elt_at_index (tm->frame_queue_mains, index); if ((nelts != 4) && (nelts != 8) && (nelts != 16) && (nelts != 32)) { - return clib_error_return (0, "expecting 4,8,16,32"); + error = clib_error_return (0, "expecting 4,8,16,32"); + goto done; } num_fq = vec_len (fqm->vlib_frame_queues); if (num_fq == 0) { vlib_cli_output (vm, "No frame queues exist\n"); - return error; + goto done; } for (fqix = 0; fqix < num_fq; fqix++) @@ -461,6 +480,9 @@ test_frame_queue_nelts (vlib_main_t * vm, unformat_input_t * input, fqm->vlib_frame_queues[fqix]->nelts = nelts; } +done: + unformat_free (line_input); + return error; } @@ -499,15 +521,19 @@ test_frame_queue_threshold (vlib_main_t * vm, unformat_input_t * input, else if (unformat (line_input, "index %u", &index)) ; else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); - if (index > vec_len (tm->frame_queue_mains) - 1) - return clib_error_return (0, - "expecting valid worker handoff queue index"); + { + error = clib_error_return (0, + "expecting valid worker handoff queue index"); + goto done; + } fqm = vec_elt_at_index (tm->frame_queue_mains, index); @@ -515,7 +541,7 @@ test_frame_queue_threshold (vlib_main_t * vm, unformat_input_t * input, if (threshold == ~(u32) 0) { vlib_cli_output (vm, "expecting threshold value\n"); - return error; + goto done; } if (threshold == 0) @@ -525,7 +551,7 @@ test_frame_queue_threshold (vlib_main_t * vm, unformat_input_t * input, if (num_fq == 0) { vlib_cli_output (vm, "No frame queues exist\n"); - return error; + goto done; } for (fqix = 0; fqix < num_fq; fqix++) @@ -533,6 +559,9 @@ test_frame_queue_threshold (vlib_main_t * vm, unformat_input_t * input, fqm->vlib_frame_queues[fqix]->vector_threshold = threshold; } +done: + unformat_free (line_input); + return error; } diff --git a/src/vlib/trace.c b/src/vlib/trace.c index dcdb837f..6d487ae1 100644 --- a/src/vlib/trace.c +++ b/src/vlib/trace.c @@ -372,6 +372,7 @@ cli_add_trace_buffer (vlib_main_t * vm, vlib_trace_node_t *tn; u32 node_index, add; u8 verbose = 0; + clib_error_t *error = 0; if (!unformat_user (input, unformat_line_input, line_input)) return 0; @@ -384,8 +385,11 @@ cli_add_trace_buffer (vlib_main_t * vm, else if (unformat (line_input, "verbose")) verbose = 1; else - return clib_error_create ("expected NODE COUNT, got `%U'", - format_unformat_error, line_input); + { + error = clib_error_create ("expected NODE COUNT, got `%U'", + format_unformat_error, line_input); + goto done; + } } /* *INDENT-OFF* */ @@ -403,7 +407,10 @@ cli_add_trace_buffer (vlib_main_t * vm, })); /* *INDENT-ON* */ - return 0; +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ diff --git a/src/vlib/unix/cli.c b/src/vlib/unix/cli.c index 69fca6ec..88e2453c 100644 --- a/src/vlib/unix/cli.c +++ b/src/vlib/unix/cli.c @@ -2835,6 +2835,7 @@ unix_cli_set_terminal_pager (vlib_main_t * vm, unix_cli_main_t *cm = &unix_cli_main; unix_cli_file_t *cf; unformat_input_t _line_input, *line_input = &_line_input; + clib_error_t *error = 0; if (!unformat_user (input, unformat_line_input, line_input)) return 0; @@ -2852,13 +2853,17 @@ unix_cli_set_terminal_pager (vlib_main_t * vm, "Pager limit set to %u lines; note, this is global.\n", um->cli_pager_buffer_limit); else - return clib_error_return (0, "unknown parameter: `%U`", - format_unformat_error, line_input); + { + error = clib_error_return (0, "unknown parameter: `%U`", + format_unformat_error, line_input); + goto done; + } } +done: unformat_free (line_input); - return 0; + return error; } /*? @@ -2886,6 +2891,7 @@ unix_cli_set_terminal_history (vlib_main_t * vm, unix_cli_file_t *cf; unformat_input_t _line_input, *line_input = &_line_input; u32 limit; + clib_error_t *error = 0; if (!unformat_user (input, unformat_line_input, line_input)) return 0; @@ -2901,8 +2907,11 @@ unix_cli_set_terminal_history (vlib_main_t * vm, else if (unformat (line_input, "limit %u", &cf->history_limit)) ; else - return clib_error_return (0, "unknown parameter: `%U`", - format_unformat_error, line_input); + { + error = clib_error_return (0, "unknown parameter: `%U`", + format_unformat_error, line_input); + goto done; + } /* If we reduced history size, or turned it off, purge the history */ limit = cf->has_history ? cf->history_limit : 0; @@ -2914,9 +2923,10 @@ unix_cli_set_terminal_history (vlib_main_t * vm, } } +done: unformat_free (line_input); - return 0; + return error; } /*? diff --git a/src/vnet/devices/af_packet/cli.c b/src/vnet/devices/af_packet/cli.c index 6baa26e1..d4aa7016 100644 --- a/src/vnet/devices/af_packet/cli.c +++ b/src/vnet/devices/af_packet/cli.c @@ -49,6 +49,7 @@ af_packet_create_command_fn (vlib_main_t * vm, unformat_input_t * input, u8 *hw_addr_ptr = 0; u32 sw_if_index; int r; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -63,29 +64,47 @@ af_packet_create_command_fn (vlib_main_t * vm, unformat_input_t * input, (line_input, "hw-addr %U", unformat_ethernet_address, hwaddr)) hw_addr_ptr = hwaddr; else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); if (host_if_name == NULL) - return clib_error_return (0, "missing host interface name"); + { + error = clib_error_return (0, "missing host interface name"); + goto done; + } r = af_packet_create_if (vm, host_if_name, hw_addr_ptr, &sw_if_index); - vec_free (host_if_name); if (r == VNET_API_ERROR_SYSCALL_ERROR_1) - return clib_error_return (0, "%s (errno %d)", strerror (errno), errno); + { + error = clib_error_return (0, "%s (errno %d)", strerror (errno), errno); + goto done; + } if (r == VNET_API_ERROR_INVALID_INTERFACE) - return clib_error_return (0, "Invalid interface name"); + { + error = clib_error_return (0, "Invalid interface name"); + goto done; + } if (r == VNET_API_ERROR_SUBIF_ALREADY_EXISTS) - return clib_error_return (0, "Interface elready exists"); + { + error = clib_error_return (0, "Interface elready exists"); + goto done; + } vlib_cli_output (vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main (), sw_if_index); - return 0; + +done: + vec_free (host_if_name); + unformat_free (line_input); + + return error; } /*? @@ -124,6 +143,7 @@ af_packet_delete_command_fn (vlib_main_t * vm, unformat_input_t * input, { unformat_input_t _line_input, *line_input = &_line_input; u8 *host_if_name = NULL; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -134,18 +154,26 @@ af_packet_delete_command_fn (vlib_main_t * vm, unformat_input_t * input, if (unformat (line_input, "name %s", &host_if_name)) ; else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); if (host_if_name == NULL) - return clib_error_return (0, "missing host interface name"); + { + error = clib_error_return (0, "missing host interface name"); + goto done; + } af_packet_delete_if (vm, host_if_name); + +done: vec_free (host_if_name); + unformat_free (line_input); - return 0; + return error; } /*? diff --git a/src/vnet/devices/dpdk/cli.c b/src/vnet/devices/dpdk/cli.c index d133cfd9..1fc665ac 100644 --- a/src/vnet/devices/dpdk/cli.c +++ b/src/vnet/devices/dpdk/cli.c @@ -398,7 +398,7 @@ set_dpdk_if_desc (vlib_main_t * vm, unformat_input_t * input, u32 hw_if_index = (u32) ~ 0; u32 nb_rx_desc = (u32) ~ 0; u32 nb_tx_desc = (u32) ~ 0; - clib_error_t *rv; + clib_error_t *error = NULL; if (!unformat_user (input, unformat_line_input, line_input)) return 0; @@ -414,25 +414,37 @@ set_dpdk_if_desc (vlib_main_t * vm, unformat_input_t * input, else if (unformat (line_input, "rx %d", &nb_rx_desc)) ; else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); - if (hw_if_index == (u32) ~ 0) - return clib_error_return (0, "please specify valid interface name"); + { + error = clib_error_return (0, "please specify valid interface name"); + goto done; + } hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index); xd = vec_elt_at_index (dm->devices, hw->dev_instance); if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0) - return clib_error_return (0, "number of descriptors can be set only for " - "physical devices"); + { + error = + clib_error_return (0, + "number of descriptors can be set only for " + "physical devices"); + goto done; + } if ((nb_rx_desc == (u32) ~ 0 || nb_rx_desc == xd->nb_rx_desc) && (nb_tx_desc == (u32) ~ 0 || nb_tx_desc == xd->nb_tx_desc)) - return clib_error_return (0, "nothing changed"); + { + error = clib_error_return (0, "nothing changed"); + goto done; + } if (nb_rx_desc != (u32) ~ 0) xd->nb_rx_desc = nb_rx_desc; @@ -440,9 +452,12 @@ set_dpdk_if_desc (vlib_main_t * vm, unformat_input_t * input, if (nb_tx_desc != (u32) ~ 0) xd->nb_tx_desc = nb_tx_desc; - rv = dpdk_port_setup (dm, xd); + error = dpdk_port_setup (dm, xd); + +done: + unformat_free (line_input); - return rv; + return error; } /* *INDENT-OFF* */ @@ -523,6 +538,7 @@ set_dpdk_if_placement (vlib_main_t * vm, unformat_input_t * input, u32 queue = (u32) 0; u32 cpu = (u32) ~ 0; int i; + clib_error_t *error = NULL; if (!unformat_user (input, unformat_line_input, line_input)) return 0; @@ -538,18 +554,25 @@ set_dpdk_if_placement (vlib_main_t * vm, unformat_input_t * input, else if (unformat (line_input, "thread %d", &cpu)) ; else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); - if (hw_if_index == (u32) ~ 0) - return clib_error_return (0, "please specify valid interface name"); + { + error = clib_error_return (0, "please specify valid interface name"); + goto done; + } if (cpu < dm->input_cpu_first_index || cpu >= (dm->input_cpu_first_index + dm->input_cpu_count)) - return clib_error_return (0, "please specify valid thread id"); + { + error = clib_error_return (0, "please specify valid thread id"); + goto done; + } hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index); xd = vec_elt_at_index (dm->devices, hw->dev_instance); @@ -563,7 +586,7 @@ set_dpdk_if_placement (vlib_main_t * vm, unformat_input_t * input, queue == dq->queue_id) { if (cpu == i) /* nothing to do */ - return 0; + goto done; vec_del1(dm->devices_by_cpu[i], dq - dm->devices_by_cpu[i]); vec_add2(dm->devices_by_cpu[cpu], dq, 1); @@ -586,13 +609,18 @@ set_dpdk_if_placement (vlib_main_t * vm, unformat_input_t * input, vlib_node_set_state (vlib_mains[cpu], dpdk_input_node.index, VLIB_NODE_STATE_POLLING); - return 0; + goto done; } } /* *INDENT-ON* */ } - return clib_error_return (0, "not found"); + error = clib_error_return (0, "not found"); + +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ @@ -653,6 +681,7 @@ set_dpdk_if_hqos_placement (vlib_main_t * vm, unformat_input_t * input, u32 hw_if_index = (u32) ~ 0; u32 cpu = (u32) ~ 0; int i; + clib_error_t *error = NULL; if (!unformat_user (input, unformat_line_input, line_input)) return 0; @@ -666,18 +695,22 @@ set_dpdk_if_hqos_placement (vlib_main_t * vm, unformat_input_t * input, else if (unformat (line_input, "thread %d", &cpu)) ; else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); - if (hw_if_index == (u32) ~ 0) return clib_error_return (0, "please specify valid interface name"); if (cpu < dm->hqos_cpu_first_index || cpu >= (dm->hqos_cpu_first_index + dm->hqos_cpu_count)) - return clib_error_return (0, "please specify valid thread id"); + { + error = clib_error_return (0, "please specify valid thread id"); + goto done; + } hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index); xd = vec_elt_at_index (dm->devices, hw->dev_instance); @@ -689,7 +722,7 @@ set_dpdk_if_hqos_placement (vlib_main_t * vm, unformat_input_t * input, if (hw_if_index == dm->devices[dq->device].vlib_hw_if_index) { if (cpu == i) /* nothing to do */ - return 0; + goto done; vec_del1 (dm->devices_by_hqos_cpu[i], dq - dm->devices_by_hqos_cpu[i]); @@ -703,12 +736,17 @@ set_dpdk_if_hqos_placement (vlib_main_t * vm, unformat_input_t * input, vec_sort_with_function (dm->devices_by_hqos_cpu[cpu], dpdk_device_queue_sort); - return 0; + goto done; } } } - return clib_error_return (0, "not found"); + error = clib_error_return (0, "not found"); + +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ @@ -732,6 +770,7 @@ set_dpdk_if_hqos_pipe (vlib_main_t * vm, unformat_input_t * input, u32 pipe_id = (u32) ~ 0; u32 profile_id = (u32) ~ 0; int rv; + clib_error_t *error = NULL; if (!unformat_user (input, unformat_line_input, line_input)) return 0; @@ -749,14 +788,18 @@ set_dpdk_if_hqos_pipe (vlib_main_t * vm, unformat_input_t * input, else if (unformat (line_input, "profile %d", &profile_id)) ; else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); - if (hw_if_index == (u32) ~ 0) - return clib_error_return (0, "please specify valid interface name"); + { + error = clib_error_return (0, "please specify valid interface name"); + goto done; + } hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index); xd = vec_elt_at_index (dm->devices, hw->dev_instance); @@ -765,9 +808,15 @@ set_dpdk_if_hqos_pipe (vlib_main_t * vm, unformat_input_t * input, rte_sched_pipe_config (xd->hqos_ht->hqos, subport_id, pipe_id, profile_id); if (rv) - return clib_error_return (0, "pipe configuration failed"); + { + error = clib_error_return (0, "pipe configuration failed"); + goto done; + } - return 0; +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ @@ -797,6 +846,7 @@ set_dpdk_if_hqos_subport (vlib_main_t * vm, unformat_input_t * input, .tc_period = 10, }; int rv; + clib_error_t *error = NULL; if (!unformat_user (input, unformat_line_input, line_input)) return 0; @@ -829,23 +879,33 @@ set_dpdk_if_hqos_subport (vlib_main_t * vm, unformat_input_t * input, else if (unformat (line_input, "period %d", &p.tc_period)) ; else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); - if (hw_if_index == (u32) ~ 0) - return clib_error_return (0, "please specify valid interface name"); + { + error = clib_error_return (0, "please specify valid interface name"); + goto done; + } hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index); xd = vec_elt_at_index (dm->devices, hw->dev_instance); rv = rte_sched_subport_config (xd->hqos_ht->hqos, subport_id, &p); if (rv) - return clib_error_return (0, "subport configuration failed"); + { + error = clib_error_return (0, "subport configuration failed"); + goto done; + } - return 0; +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ @@ -872,6 +932,7 @@ set_dpdk_if_hqos_tctbl (vlib_main_t * vm, unformat_input_t * input, u32 queue = (u32) ~ 0; u32 entry = (u32) ~ 0; u32 val, i; + clib_error_t *error = NULL; if (!unformat_user (input, unformat_line_input, line_input)) return 0; @@ -889,20 +950,33 @@ set_dpdk_if_hqos_tctbl (vlib_main_t * vm, unformat_input_t * input, else if (unformat (line_input, "queue %d", &queue)) ; else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); - if (hw_if_index == (u32) ~ 0) - return clib_error_return (0, "please specify valid interface name"); + { + error = clib_error_return (0, "please specify valid interface name"); + goto done; + } if (entry >= 64) - return clib_error_return (0, "invalid entry"); + { + error = clib_error_return (0, "invalid entry"); + goto done; + } if (tc >= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE) - return clib_error_return (0, "invalid traffic class"); + { + error = clib_error_return (0, "invalid traffic class"); + goto done; + } if (queue >= RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS) - return clib_error_return (0, "invalid traffic class"); + { + error = clib_error_return (0, "invalid traffic class"); + goto done; + } hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index); xd = vec_elt_at_index (dm->devices, hw->dev_instance); @@ -911,7 +985,10 @@ set_dpdk_if_hqos_tctbl (vlib_main_t * vm, unformat_input_t * input, uword *p = hash_get_mem (tm->thread_registrations_by_name, "workers"); /* Should never happen, shut up Coverity warning */ if (p == 0) - return clib_error_return (0, "no worker registrations?"); + { + error = clib_error_return (0, "no worker registrations?"); + goto done; + } vlib_thread_registration_t *tr = (vlib_thread_registration_t *) p[0]; int worker_thread_first = tr->first_index; @@ -921,7 +998,10 @@ set_dpdk_if_hqos_tctbl (vlib_main_t * vm, unformat_input_t * input, for (i = 0; i < worker_thread_count; i++) xd->hqos_wt[worker_thread_first + i].hqos_tc_table[entry] = val; - return 0; +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ @@ -939,6 +1019,7 @@ set_dpdk_if_hqos_pktfield (vlib_main_t * vm, unformat_input_t * input, unformat_input_t _line_input, *line_input = &_line_input; vlib_thread_main_t *tm = vlib_get_thread_main (); dpdk_main_t *dm = &dpdk_main; + clib_error_t *error = NULL; /* Device specific data */ struct rte_eth_dev_info dev_info; @@ -984,15 +1065,19 @@ set_dpdk_if_hqos_pktfield (vlib_main_t * vm, unformat_input_t * input, else if (unformat (line_input, "mask %llx", &mask)) ; else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); - /* Get interface */ if (hw_if_index == (u32) ~ 0) - return clib_error_return (0, "please specify valid interface name"); + { + error = clib_error_return (0, "please specify valid interface name"); + goto done; + } hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index); xd = vec_elt_at_index (dm->devices, hw->dev_instance); @@ -1019,7 +1104,7 @@ set_dpdk_if_hqos_pktfield (vlib_main_t * vm, unformat_input_t * input, if (devconf->hqos_enabled == 0) { vlib_cli_output (vm, "HQoS disabled for this interface"); - return 0; + goto done; } n_subports_per_port = devconf->hqos.port.n_subports_per_port; @@ -1028,27 +1113,39 @@ set_dpdk_if_hqos_pktfield (vlib_main_t * vm, unformat_input_t * input, /* Validate packet field configuration: id, offset and mask */ if (id >= 3) - return clib_error_return (0, "invalid packet field id"); + { + error = clib_error_return (0, "invalid packet field id"); + goto done; + } switch (id) { case 0: if (dpdk_hqos_validate_mask (mask, n_subports_per_port) != 0) - return clib_error_return (0, "invalid subport ID mask " - "(n_subports_per_port = %u)", - n_subports_per_port); + { + error = clib_error_return (0, "invalid subport ID mask " + "(n_subports_per_port = %u)", + n_subports_per_port); + goto done; + } break; case 1: if (dpdk_hqos_validate_mask (mask, n_pipes_per_subport) != 0) - return clib_error_return (0, "invalid pipe ID mask " - "(n_pipes_per_subport = %u)", - n_pipes_per_subport); + { + error = clib_error_return (0, "invalid pipe ID mask " + "(n_pipes_per_subport = %u)", + n_pipes_per_subport); + goto done; + } break; case 2: default: if (dpdk_hqos_validate_mask (mask, tctbl_size) != 0) - return clib_error_return (0, "invalid TC table index mask " - "(TC table size = %u)", tctbl_size); + { + error = clib_error_return (0, "invalid TC table index mask " + "(TC table size = %u)", tctbl_size); + goto done; + } } /* Propagate packet field configuration to all workers */ @@ -1075,7 +1172,10 @@ set_dpdk_if_hqos_pktfield (vlib_main_t * vm, unformat_input_t * input, __builtin_ctzll (mask); } - return 0; +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ @@ -1106,6 +1206,7 @@ show_dpdk_if_hqos (vlib_main_t * vm, unformat_input_t * input, dpdk_device_config_t *devconf = 0; vlib_thread_registration_t *tr; uword *p = 0; + clib_error_t *error = NULL; if (!unformat_user (input, unformat_line_input, line_input)) return 0; @@ -1117,14 +1218,18 @@ show_dpdk_if_hqos (vlib_main_t * vm, unformat_input_t * input, &hw_if_index)) ; else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); - if (hw_if_index == (u32) ~ 0) - return clib_error_return (0, "please specify interface name!!"); + { + error = clib_error_return (0, "please specify interface name!!"); + goto done; + } hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index); xd = vec_elt_at_index (dm->devices, hw->dev_instance); @@ -1151,7 +1256,7 @@ show_dpdk_if_hqos (vlib_main_t * vm, unformat_input_t * input, if (devconf->hqos_enabled == 0) { vlib_cli_output (vm, "HQoS disabled for this interface"); - return 0; + goto done; } /* Detect the set of worker threads */ @@ -1159,7 +1264,10 @@ show_dpdk_if_hqos (vlib_main_t * vm, unformat_input_t * input, /* Should never happen, shut up Coverity warning */ if (p == 0) - return clib_error_return (0, "no worker registrations?"); + { + error = clib_error_return (0, "no worker registrations?"); + goto done; + } tr = (vlib_thread_registration_t *) p[0]; @@ -1284,7 +1392,10 @@ show_dpdk_if_hqos (vlib_main_t * vm, unformat_input_t * input, } #endif - return 0; +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ @@ -1315,6 +1426,7 @@ show_dpdk_hqos_queue_stats (vlib_main_t * vm, unformat_input_t * input, u32 qindex; struct rte_sched_queue_stats stats; u16 qlen; + clib_error_t *error = NULL; if (!unformat_user (input, unformat_line_input, line_input)) return 0; @@ -1339,14 +1451,18 @@ show_dpdk_hqos_queue_stats (vlib_main_t * vm, unformat_input_t * input, ; else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); - if (hw_if_index == (u32) ~ 0) - return clib_error_return (0, "please specify interface name!!"); + { + error = clib_error_return (0, "please specify interface name!!"); + goto done; + } hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index); xd = vec_elt_at_index (dm->devices, hw->dev_instance); @@ -1373,7 +1489,7 @@ show_dpdk_hqos_queue_stats (vlib_main_t * vm, unformat_input_t * input, if (devconf->hqos_enabled == 0) { vlib_cli_output (vm, "HQoS disabled for this interface"); - return 0; + goto done; } /* @@ -1386,7 +1502,10 @@ show_dpdk_hqos_queue_stats (vlib_main_t * vm, unformat_input_t * input, if (rte_sched_queue_read_stats (xd->hqos_ht->hqos, qindex, &stats, &qlen) != 0) - return clib_error_return (0, "failed to read stats"); + { + error = clib_error_return (0, "failed to read stats"); + goto done; + } vlib_cli_output (vm, "%=24s%=16s", "Stats Parameter", "Value"); vlib_cli_output (vm, "%=24s%=16d", "Packets", stats.n_pkts); @@ -1399,7 +1518,10 @@ show_dpdk_hqos_queue_stats (vlib_main_t * vm, unformat_input_t * input, vlib_cli_output (vm, "%=24s%=16d", "Bytes dropped", stats.n_bytes_dropped); - return 0; +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ diff --git a/src/vnet/devices/dpdk/ipsec/cli.c b/src/vnet/devices/dpdk/ipsec/cli.c index 93df4a64..f9d3a5d0 100644 --- a/src/vnet/devices/dpdk/ipsec/cli.c +++ b/src/vnet/devices/dpdk/ipsec/cli.c @@ -111,6 +111,7 @@ lcore_cryptodev_map_fn (vlib_main_t * vm, unformat_input_t * input, { unformat_input_t _line_input, *line_input = &_line_input; u16 detail = 0; + clib_error_t *error = NULL; if (!unformat_user (input, unformat_line_input, line_input)) return 0; @@ -120,15 +121,19 @@ lcore_cryptodev_map_fn (vlib_main_t * vm, unformat_input_t * input, if (unformat (line_input, "verbose")) detail = 1; else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); - dpdk_ipsec_show_mapping (vm, detail); - return 0; +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ diff --git a/src/vnet/devices/netmap/cli.c b/src/vnet/devices/netmap/cli.c index 6157f27c..71363294 100644 --- a/src/vnet/devices/netmap/cli.c +++ b/src/vnet/devices/netmap/cli.c @@ -37,6 +37,7 @@ netmap_create_command_fn (vlib_main_t * vm, unformat_input_t * input, u8 is_pipe = 0; u8 is_master = 0; u32 sw_if_index = ~0; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -57,30 +58,48 @@ netmap_create_command_fn (vlib_main_t * vm, unformat_input_t * input, else if (unformat (line_input, "slave")) is_master = 0; else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); if (host_if_name == NULL) - return clib_error_return (0, "missing host interface name"); + { + error = clib_error_return (0, "missing host interface name"); + goto done; + } r = netmap_create_if (vm, host_if_name, hw_addr_ptr, is_pipe, is_master, &sw_if_index); if (r == VNET_API_ERROR_SYSCALL_ERROR_1) - return clib_error_return (0, "%s (errno %d)", strerror (errno), errno); + { + error = clib_error_return (0, "%s (errno %d)", strerror (errno), errno); + goto done; + } if (r == VNET_API_ERROR_INVALID_INTERFACE) - return clib_error_return (0, "Invalid interface name"); + { + error = clib_error_return (0, "Invalid interface name"); + goto done; + } if (r == VNET_API_ERROR_SUBIF_ALREADY_EXISTS) - return clib_error_return (0, "Interface already exists"); + { + error = clib_error_return (0, "Interface already exists"); + goto done; + } vlib_cli_output (vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main (), sw_if_index); - return 0; + +done: + unformat_free (line_input); + + return error; } /*? @@ -144,6 +163,7 @@ netmap_delete_command_fn (vlib_main_t * vm, unformat_input_t * input, { unformat_input_t _line_input, *line_input = &_line_input; u8 *host_if_name = NULL; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -154,17 +174,25 @@ netmap_delete_command_fn (vlib_main_t * vm, unformat_input_t * input, if (unformat (line_input, "name %s", &host_if_name)) ; else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); if (host_if_name == NULL) - return clib_error_return (0, "missing host interface name"); + { + error = clib_error_return (0, "missing host interface name"); + goto done; + } netmap_delete_if (vm, host_if_name); - return 0; +done: + unformat_free (line_input); + + return error; } /*? diff --git a/src/vnet/devices/virtio/vhost-user.c b/src/vnet/devices/virtio/vhost-user.c index 315daa77..c43f6e67 100644 --- a/src/vnet/devices/virtio/vhost-user.c +++ b/src/vnet/devices/virtio/vhost-user.c @@ -2682,6 +2682,7 @@ vhost_user_connect_command_fn (vlib_main_t * vm, u32 custom_dev_instance = ~0; u8 hwaddr[6]; u8 *hw = NULL; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -2704,10 +2705,12 @@ vhost_user_connect_command_fn (vlib_main_t * vm, renumber = 1; } else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); vnet_main_t *vnm = vnet_get_main (); @@ -2716,14 +2719,18 @@ vhost_user_connect_command_fn (vlib_main_t * vm, is_server, &sw_if_index, feature_mask, renumber, custom_dev_instance, hw))) { - vec_free (sock_filename); - return clib_error_return (0, "vhost_user_create_if returned %d", rv); + error = clib_error_return (0, "vhost_user_create_if returned %d", rv); + goto done; } - vec_free (sock_filename); vlib_cli_output (vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main (), sw_if_index); - return 0; + +done: + vec_free (sock_filename); + unformat_free (line_input); + + return error; } clib_error_t * @@ -2734,6 +2741,7 @@ vhost_user_delete_command_fn (vlib_main_t * vm, unformat_input_t _line_input, *line_input = &_line_input; u32 sw_if_index = ~0; vnet_main_t *vnm = vnet_get_main (); + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -2751,15 +2759,25 @@ vhost_user_delete_command_fn (vlib_main_t * vm, vnet_get_sup_hw_interface (vnm, sw_if_index); if (hwif == NULL || vhost_user_dev_class.index != hwif->dev_class_index) - return clib_error_return (0, "Not a vhost interface"); + { + error = clib_error_return (0, "Not a vhost interface"); + goto done; + } } else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); + vhost_user_delete_if (vnm, vm, sw_if_index); - return 0; + +done: + unformat_free (line_input); + + return error; } int @@ -3286,6 +3304,7 @@ vhost_thread_command_fn (vlib_main_t * vm, u32 sw_if_index; u8 del = 0; int rv; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -3295,9 +3314,9 @@ vhost_thread_command_fn (vlib_main_t * vm, (line_input, "%U %d", unformat_vnet_sw_interface, vnet_get_main (), &sw_if_index, &worker_thread_index)) { - unformat_free (line_input); - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, input); + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; } if (unformat (line_input, "del")) @@ -3305,9 +3324,16 @@ vhost_thread_command_fn (vlib_main_t * vm, if ((rv = vhost_user_thread_placement (sw_if_index, worker_thread_index, del))) - return clib_error_return (0, "vhost_user_thread_placement returned %d", - rv); - return 0; + { + error = clib_error_return (0, "vhost_user_thread_placement returned %d", + rv); + goto done; + } + +done: + unformat_free (line_input); + + return error; } diff --git a/src/vnet/gre/interface.c b/src/vnet/gre/interface.c index d624587d..d4476ac4 100644 --- a/src/vnet/gre/interface.c +++ b/src/vnet/gre/interface.c @@ -491,6 +491,7 @@ create_gre_tunnel_command_fn (vlib_main_t * vm, u32 num_m_args = 0; u8 is_add = 1; u32 sw_if_index; + clib_error_t *error = NULL; /* Get a line of input. */ if (! unformat_user (input, unformat_line_input, line_input)) @@ -508,16 +509,24 @@ create_gre_tunnel_command_fn (vlib_main_t * vm, else if (unformat (line_input, "teb")) teb = 1; else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); if (num_m_args < 2) - return clib_error_return (0, "mandatory argument(s) missing"); + { + error = clib_error_return (0, "mandatory argument(s) missing"); + goto done; + } if (memcmp (&src, &dst, sizeof(src)) == 0) - return clib_error_return (0, "src and dst are identical"); + { + error = clib_error_return (0, "src and dst are identical"); + goto done; + } memset (a, 0, sizeof (*a)); a->outer_fib_id = outer_fib_id; @@ -536,15 +545,21 @@ create_gre_tunnel_command_fn (vlib_main_t * vm, vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(), sw_if_index); break; case VNET_API_ERROR_INVALID_VALUE: - return clib_error_return (0, "GRE tunnel already exists..."); + error = clib_error_return (0, "GRE tunnel already exists..."); + goto done; case VNET_API_ERROR_NO_SUCH_FIB: - return clib_error_return (0, "outer fib ID %d doesn't exist\n", - outer_fib_id); + error = clib_error_return (0, "outer fib ID %d doesn't exist\n", + outer_fib_id); + goto done; default: - return clib_error_return (0, "vnet_gre_add_del_tunnel returned %d", rv); + error = clib_error_return (0, "vnet_gre_add_del_tunnel returned %d", rv); + goto done; } - return 0; +done: + unformat_free (line_input); + + return error; } VLIB_CLI_COMMAND (create_gre_tunnel_command, static) = { diff --git a/src/vnet/ip/ip4_source_check.c b/src/vnet/ip/ip4_source_check.c index d461cc88..3af32f2e 100644 --- a/src/vnet/ip/ip4_source_check.c +++ b/src/vnet/ip/ip4_source_check.c @@ -399,6 +399,8 @@ set_ip_source_check (vlib_main_t * vm, vnet_feature_enable_disable ("ip4-unicast", feature_name, sw_if_index, is_del == 0, &config, sizeof (config)); done: + unformat_free (line_input); + return error; } @@ -531,7 +533,9 @@ ip_source_check_accept (vlib_main_t * vm, } done: - return (error); + unformat_free (line_input); + + return error; } /*? diff --git a/src/vnet/ip/ip4_test.c b/src/vnet/ip/ip4_test.c index 45d17113..73dabfdc 100644 --- a/src/vnet/ip/ip4_test.c +++ b/src/vnet/ip/ip4_test.c @@ -143,8 +143,11 @@ thrash (vlib_main_t * vm, else if (unformat (line_input, "verbose")) verbose = 1; else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } } @@ -178,7 +181,7 @@ thrash (vlib_main_t * vm, if (p == 0) { vlib_cli_output (vm, "Couldn't map fib id %d to fib index\n", table_id); - return 0; + goto done; } table_index = p[0]; @@ -294,7 +297,11 @@ thrash (vlib_main_t * vm, pool_free (tm->route_pool); } - return 0; + +done: + unformat_free (line_input); + + return error; } /*? diff --git a/src/vnet/ip/ip6_neighbor.c b/src/vnet/ip/ip6_neighbor.c index 7229591e..6b53137f 100644 --- a/src/vnet/ip/ip6_neighbor.c +++ b/src/vnet/ip/ip6_neighbor.c @@ -2923,7 +2923,10 @@ ip6_neighbor_cmd (vlib_main_t * vm, unformat_input_t * main_input, else if (unformat (line_input, "ra-lifetime")) { if (!unformat (line_input, "%d", &ra_lifetime)) - return (error = unformat_parse_error (line_input)); + { + error = unformat_parse_error (line_input); + goto done; + } use_lifetime = 1; break; } @@ -2931,13 +2934,19 @@ ip6_neighbor_cmd (vlib_main_t * vm, unformat_input_t * main_input, { if (!unformat (line_input, "%d %d", &ra_initial_count, &ra_initial_interval)) - return (error = unformat_parse_error (line_input)); + { + error = unformat_parse_error (line_input); + goto done; + } break; } else if (unformat (line_input, "ra-interval")) { if (!unformat (line_input, "%d", &ra_max_interval)) - return (error = unformat_parse_error (line_input)); + { + error = unformat_parse_error (line_input); + goto done; + } if (!unformat (line_input, "%d", &ra_min_interval)) ra_min_interval = 0; @@ -2949,7 +2958,10 @@ ip6_neighbor_cmd (vlib_main_t * vm, unformat_input_t * main_input, break; } else - return (unformat_parse_error (line_input)); + { + error = unformat_parse_error (line_input); + goto done; + } } if (add_radv_info) @@ -3006,7 +3018,10 @@ ip6_neighbor_cmd (vlib_main_t * vm, unformat_input_t * main_input, else if (unformat (line_input, "no-onlink")) no_onlink = 1; else - return (unformat_parse_error (line_input)); + { + error = unformat_parse_error (line_input); + goto done; + } } ip6_neighbor_ra_prefix (vm, sw_if_index, @@ -3018,9 +3033,9 @@ ip6_neighbor_cmd (vlib_main_t * vm, unformat_input_t * main_input, off_link, no_autoconfig, no_onlink, is_no); } +done: unformat_free (line_input); -done: return error; } diff --git a/src/vnet/ip/lookup.c b/src/vnet/ip/lookup.c index 0ef0e7a6..807b87b6 100644 --- a/src/vnet/ip/lookup.c +++ b/src/vnet/ip/lookup.c @@ -568,8 +568,6 @@ vnet_ip_route_cmd (vlib_main_t * vm, } } - unformat_free (line_input); - if (vec_len (prefixs) == 0) { error = @@ -704,6 +702,7 @@ done: vec_free (dpos); vec_free (prefixs); vec_free (rpaths); + unformat_free (line_input); return error; } @@ -872,8 +871,6 @@ vnet_ip_mroute_cmd (vlib_main_t * vm, } } - unformat_free (line_input); - if (~0 == table_id) { /* @@ -970,6 +967,8 @@ vnet_ip_mroute_cmd (vlib_main_t * vm, (scount * gcount) / (timet[1] - timet[0])); done: + unformat_free (line_input); + return error; } @@ -1149,24 +1148,37 @@ probe_neighbor_address (vlib_main_t * vm, is_ip4 = 0; } else - return clib_error_return (0, "unknown input '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "unknown input '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); - if (sw_if_index == ~0) - return clib_error_return (0, "Interface required, not set."); + { + error = clib_error_return (0, "Interface required, not set."); + goto done; + } if (address_set == 0) - return clib_error_return (0, "ip address required, not set."); + { + error = clib_error_return (0, "ip address required, not set."); + goto done; + } if (address_set > 1) - return clib_error_return (0, "Multiple ip addresses not supported."); + { + error = clib_error_return (0, "Multiple ip addresses not supported."); + goto done; + } if (is_ip4) error = ip4_probe_neighbor_wait (vm, &a4, sw_if_index, retry_count); else error = ip6_probe_neighbor_wait (vm, &a6, sw_if_index, retry_count); +done: + unformat_free (line_input); + return error; } diff --git a/src/vnet/ipsec-gre/interface.c b/src/vnet/ipsec-gre/interface.c index 3b6e4ac2..0772ce73 100644 --- a/src/vnet/ipsec-gre/interface.c +++ b/src/vnet/ipsec-gre/interface.c @@ -232,6 +232,7 @@ create_ipsec_gre_tunnel_command_fn (vlib_main_t * vm, vnet_ipsec_gre_add_del_tunnel_args_t _a, *a = &_a; int rv; u32 sw_if_index; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -250,16 +251,24 @@ create_ipsec_gre_tunnel_command_fn (vlib_main_t * vm, else if (unformat (line_input, "remote-sa %d", &rsa)) num_m_args++; else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); if (num_m_args < 4) - return clib_error_return (0, "mandatory argument(s) missing"); + { + error = clib_error_return (0, "mandatory argument(s) missing"); + goto done; + } if (memcmp (&src, &dst, sizeof (src)) == 0) - return clib_error_return (0, "src and dst are identical"); + { + error = clib_error_return (0, "src and dst are identical"); + goto done; + } memset (a, 0, sizeof (*a)); a->is_add = is_add; @@ -277,14 +286,19 @@ create_ipsec_gre_tunnel_command_fn (vlib_main_t * vm, vnet_get_main (), sw_if_index); break; case VNET_API_ERROR_INVALID_VALUE: - return clib_error_return (0, "GRE tunnel already exists..."); + error = clib_error_return (0, "GRE tunnel already exists..."); + goto done; default: - return clib_error_return (0, - "vnet_ipsec_gre_add_del_tunnel returned %d", - rv); + error = clib_error_return (0, + "vnet_ipsec_gre_add_del_tunnel returned %d", + rv); + goto done; } - return 0; +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ diff --git a/src/vnet/ipsec/ipsec_cli.c b/src/vnet/ipsec/ipsec_cli.c index 3c1e26f2..0e034402 100644 --- a/src/vnet/ipsec/ipsec_cli.c +++ b/src/vnet/ipsec/ipsec_cli.c @@ -32,6 +32,7 @@ set_interface_spd_command_fn (vlib_main_t * vm, u32 sw_if_index = (u32) ~ 0; u32 spd_id; int is_add = 1; + clib_error_t *error = NULL; if (!unformat_user (input, unformat_line_input, line_input)) return 0; @@ -43,14 +44,18 @@ set_interface_spd_command_fn (vlib_main_t * vm, else if (unformat (line_input, "del")) is_add = 0; else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); - - unformat_free (line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } ipsec_set_interface_spd (vm, sw_if_index, spd_id, is_add); - return 0; +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ @@ -72,7 +77,7 @@ ipsec_sa_add_del_command_fn (vlib_main_t * vm, ipsec_sa_t sa; int is_add = ~0; u8 *ck = 0, *ik = 0; - clib_error_t *err = 0; + clib_error_t *error = NULL; memset (&sa, 0, sizeof (sa)); @@ -90,8 +95,11 @@ ipsec_sa_add_del_command_fn (vlib_main_t * vm, else if (unformat (line_input, "esp")) sa.protocol = IPSEC_PROTOCOL_ESP; else if (unformat (line_input, "ah")) - //sa.protocol = IPSEC_PROTOCOL_AH; - return clib_error_return (0, "unsupported security protocol 'AH'"); + { + //sa.protocol = IPSEC_PROTOCOL_AH; + error = clib_error_return (0, "unsupported security protocol 'AH'"); + goto done; + } else if (unformat (line_input, "crypto-key %U", unformat_hex_string, &ck)) sa.crypto_key_len = vec_len (ck); @@ -102,8 +110,12 @@ ipsec_sa_add_del_command_fn (vlib_main_t * vm, { if (sa.crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 || sa.crypto_alg >= IPSEC_CRYPTO_N_ALG) - return clib_error_return (0, "unsupported crypto-alg: '%U'", - format_ipsec_crypto_alg, sa.crypto_alg); + { + error = clib_error_return (0, "unsupported crypto-alg: '%U'", + format_ipsec_crypto_alg, + sa.crypto_alg); + goto done; + } } else if (unformat (line_input, "integ-key %U", unformat_hex_string, &ik)) @@ -113,8 +125,12 @@ ipsec_sa_add_del_command_fn (vlib_main_t * vm, { if (sa.integ_alg < IPSEC_INTEG_ALG_SHA1_96 || sa.integ_alg >= IPSEC_INTEG_N_ALG) - return clib_error_return (0, "unsupported integ-alg: '%U'", - format_ipsec_integ_alg, sa.integ_alg); + { + error = clib_error_return (0, "unsupported integ-alg: '%U'", + format_ipsec_integ_alg, + sa.integ_alg); + goto done; + } } else if (unformat (line_input, "tunnel-src %U", unformat_ip4_address, &sa.tunnel_src_addr.ip4)) @@ -135,12 +151,13 @@ ipsec_sa_add_del_command_fn (vlib_main_t * vm, sa.is_tunnel_ip6 = 1; } else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); - if (sa.crypto_key_len > sizeof (sa.crypto_key)) sa.crypto_key_len = sizeof (sa.crypto_key); @@ -156,14 +173,17 @@ ipsec_sa_add_del_command_fn (vlib_main_t * vm, if (is_add) { ASSERT (im->cb.check_support_cb); - err = im->cb.check_support_cb (&sa); - if (err) - return err; + error = im->cb.check_support_cb (&sa); + if (error) + goto done; } ipsec_add_del_sa (vm, &sa, is_add); - return 0; +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ @@ -183,6 +203,7 @@ ipsec_spd_add_del_command_fn (vlib_main_t * vm, unformat_input_t _line_input, *line_input = &_line_input; u32 spd_id = ~0; int is_add = ~0; + clib_error_t *error = NULL; if (!unformat_user (input, unformat_line_input, line_input)) return 0; @@ -196,18 +217,25 @@ ipsec_spd_add_del_command_fn (vlib_main_t * vm, else if (unformat (line_input, "%u", &spd_id)) ; else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); - if (spd_id == ~0) - return clib_error_return (0, "please specify SPD ID"); + { + error = clib_error_return (0, "please specify SPD ID"); + goto done; + } ipsec_add_del_spd (vm, spd_id, is_add); - return 0; +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ @@ -230,6 +258,7 @@ ipsec_policy_add_del_command_fn (vlib_main_t * vm, int is_add = 0; int is_ip_any = 1; u32 tmp, tmp2; + clib_error_t *error = NULL; memset (&p, 0, sizeof (p)); p.lport.stop = p.rport.stop = ~0; @@ -262,7 +291,10 @@ ipsec_policy_add_del_command_fn (vlib_main_t * vm, &p.policy)) { if (p.policy == IPSEC_POLICY_ACTION_RESOLVE) - return clib_error_return (0, "unsupported action: 'resolve'"); + { + error = clib_error_return (0, "unsupported action: 'resolve'"); + goto done; + } } else if (unformat (line_input, "sa %u", &p.sa_id)) ; @@ -300,19 +332,24 @@ ipsec_policy_add_del_command_fn (vlib_main_t * vm, p.rport.stop = tmp2; } else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); - ipsec_add_del_policy (vm, &p, is_add); if (is_ip_any) { p.is_ipv6 = 1; ipsec_add_del_policy (vm, &p, is_add); } - return 0; + +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ @@ -332,6 +369,7 @@ set_ipsec_sa_key_command_fn (vlib_main_t * vm, unformat_input_t _line_input, *line_input = &_line_input; ipsec_sa_t sa; u8 *ck = 0, *ik = 0; + clib_error_t *error = NULL; memset (&sa, 0, sizeof (sa)); @@ -349,12 +387,13 @@ set_ipsec_sa_key_command_fn (vlib_main_t * vm, if (unformat (line_input, "integ-key %U", unformat_hex_string, &ik)) sa.integ_key_len = vec_len (ik); else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); - if (sa.crypto_key_len > sizeof (sa.crypto_key)) sa.crypto_key_len = sizeof (sa.crypto_key); @@ -369,7 +408,10 @@ set_ipsec_sa_key_command_fn (vlib_main_t * vm, ipsec_set_sa_key (vm, &sa); - return 0; +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ @@ -649,6 +691,7 @@ create_ipsec_tunnel_command_fn (vlib_main_t * vm, ipsec_add_del_tunnel_args_t a; int rv; u32 num_m_args = 0; + clib_error_t *error = NULL; memset (&a, 0, sizeof (a)); a.is_add = 1; @@ -673,13 +716,18 @@ create_ipsec_tunnel_command_fn (vlib_main_t * vm, else if (unformat (line_input, "del")) a.is_add = 0; else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); if (num_m_args < 4) - return clib_error_return (0, "mandatory argument(s) missing"); + { + error = clib_error_return (0, "mandatory argument(s) missing"); + goto done; + } rv = ipsec_add_del_tunnel_if (&a); @@ -689,16 +737,21 @@ create_ipsec_tunnel_command_fn (vlib_main_t * vm, break; case VNET_API_ERROR_INVALID_VALUE: if (a.is_add) - return clib_error_return (0, - "IPSec tunnel interface already exists..."); + error = clib_error_return (0, + "IPSec tunnel interface already exists..."); else - return clib_error_return (0, "IPSec tunnel interface not exists..."); + error = clib_error_return (0, "IPSec tunnel interface not exists..."); + goto done; default: - return clib_error_return (0, "ipsec_register_interface returned %d", - rv); + error = clib_error_return (0, "ipsec_register_interface returned %d", + rv); + goto done; } - return 0; +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ @@ -720,6 +773,7 @@ set_interface_key_command_fn (vlib_main_t * vm, u32 hw_if_index = (u32) ~ 0; u32 alg; u8 *key = 0; + clib_error_t *error = NULL; if (!unformat_user (input, unformat_line_input, line_input)) return 0; @@ -748,25 +802,38 @@ set_interface_key_command_fn (vlib_main_t * vm, else if (unformat (line_input, "%U", unformat_hex_string, &key)) ; else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); - if (type == IPSEC_IF_SET_KEY_TYPE_NONE) - return clib_error_return (0, "unknown key type"); + { + error = clib_error_return (0, "unknown key type"); + goto done; + } if (alg > 0 && vec_len (key) == 0) - return clib_error_return (0, "key is not specified"); + { + error = clib_error_return (0, "key is not specified"); + goto done; + } if (hw_if_index == (u32) ~ 0) - return clib_error_return (0, "interface not specified"); + { + error = clib_error_return (0, "interface not specified"); + goto done; + } ipsec_set_interface_key (im->vnet_main, hw_if_index, type, alg, key); + +done: vec_free (key); + unformat_free (line_input); - return 0; + return error; } /* *INDENT-OFF* */ diff --git a/src/vnet/l2/l2_patch.c b/src/vnet/l2/l2_patch.c index 5e4691f4..ff3d2f3a 100644 --- a/src/vnet/l2/l2_patch.c +++ b/src/vnet/l2/l2_patch.c @@ -315,6 +315,7 @@ test_patch_command_fn (vlib_main_t * vm, int rx_set = 0; int tx_set = 0; int is_add = 1; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -335,10 +336,16 @@ test_patch_command_fn (vlib_main_t * vm, } if (rx_set == 0) - return clib_error_return (0, "rx interface not set"); + { + error = clib_error_return (0, "rx interface not set"); + goto done; + } if (tx_set == 0) - return clib_error_return (0, "tx interface not set"); + { + error = clib_error_return (0, "tx interface not set"); + goto done; + } rv = vnet_l2_patch_add_del (rx_sw_if_index, tx_sw_if_index, is_add); @@ -348,17 +355,24 @@ test_patch_command_fn (vlib_main_t * vm, break; case VNET_API_ERROR_INVALID_SW_IF_INDEX: - return clib_error_return (0, "rx interface not a physical port"); + error = clib_error_return (0, "rx interface not a physical port"); + goto done; case VNET_API_ERROR_INVALID_SW_IF_INDEX_2: - return clib_error_return (0, "tx interface not a physical port"); + error = clib_error_return (0, "tx interface not a physical port"); + goto done; default: - return clib_error_return + error = clib_error_return (0, "WARNING: vnet_l2_patch_add_del returned %d", rv); + goto done; } - return 0; + +done: + unformat_free (line_input); + + return error; } /*? diff --git a/src/vnet/l2/l2_xcrw.c b/src/vnet/l2/l2_xcrw.c index 70610a85..d08a5d8f 100644 --- a/src/vnet/l2/l2_xcrw.c +++ b/src/vnet/l2/l2_xcrw.c @@ -409,6 +409,7 @@ set_l2_xcrw_command_fn (vlib_main_t * vm, u8 *rw = 0; vnet_main_t *vnm = vnet_get_main (); int rv; + clib_error_t *error = NULL; if (!unformat_user (input, unformat_line_input, line_input)) @@ -416,8 +417,11 @@ set_l2_xcrw_command_fn (vlib_main_t * vm, if (!unformat (line_input, "%U", unformat_vnet_sw_interface, vnm, &l2_sw_if_index)) - return clib_error_return (0, "unknown input '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "unknown input '%U'", + format_unformat_error, line_input); + goto done; + } while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { @@ -436,7 +440,10 @@ set_l2_xcrw_command_fn (vlib_main_t * vm, } if (next_node_index == ~0) - return clib_error_return (0, "next node not specified"); + { + error = clib_error_return (0, "next node not specified"); + goto done; + } if (tx_fib_id != ~0) { @@ -448,7 +455,11 @@ set_l2_xcrw_command_fn (vlib_main_t * vm, p = hash_get (ip4_main.fib_index_by_table_id, tx_fib_id); if (p == 0) - return clib_error_return (0, "nonexistent tx_fib_id %d", tx_fib_id); + { + error = + clib_error_return (0, "nonexistent tx_fib_id %d", tx_fib_id); + goto done; + } tx_fib_index = p[0]; } @@ -463,16 +474,21 @@ set_l2_xcrw_command_fn (vlib_main_t * vm, break; case VNET_API_ERROR_INVALID_SW_IF_INDEX: - return clib_error_return (0, "%U not cross-connected", - format_vnet_sw_if_index_name, - vnm, l2_sw_if_index); + error = clib_error_return (0, "%U not cross-connected", + format_vnet_sw_if_index_name, + vnm, l2_sw_if_index); + goto done; + default: - return clib_error_return (0, "vnet_configure_l2_xcrw returned %d", rv); + error = clib_error_return (0, "vnet_configure_l2_xcrw returned %d", rv); + goto done; } +done: vec_free (rw); + unformat_free (line_input); - return 0; + return error; } /*? diff --git a/src/vnet/l2tp/l2tp.c b/src/vnet/l2tp/l2tp.c index a4531dab..2d323397 100644 --- a/src/vnet/l2tp/l2tp.c +++ b/src/vnet/l2tp/l2tp.c @@ -427,6 +427,7 @@ create_l2tpv3_tunnel_command_fn (vlib_main_t * vm, u32 sw_if_index; u32 encap_fib_id = ~0; u32 encap_fib_index = ~0; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -455,18 +456,22 @@ create_l2tpv3_tunnel_command_fn (vlib_main_t * vm, else if (unformat (line_input, "l2-sublayer-present")) l2_sublayer_present = 1; else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); - if (encap_fib_id != ~0) { uword *p; ip6_main_t *im = &ip6_main; if (!(p = hash_get (im->fib_index_by_table_id, encap_fib_id))) - return clib_error_return (0, "No fib with id %d", encap_fib_id); + { + error = clib_error_return (0, "No fib with id %d", encap_fib_id); + goto done; + } encap_fib_index = p[0]; } else @@ -475,9 +480,15 @@ create_l2tpv3_tunnel_command_fn (vlib_main_t * vm, } if (our_address_set == 0) - return clib_error_return (0, "our address not specified"); + { + error = clib_error_return (0, "our address not specified"); + goto done; + } if (client_address_set == 0) - return clib_error_return (0, "client address not specified"); + { + error = clib_error_return (0, "client address not specified"); + goto done; + } rv = create_l2tpv3_ipv6_tunnel (lm, &client_address, &our_address, local_session_id, remote_session_id, @@ -491,16 +502,22 @@ create_l2tpv3_tunnel_command_fn (vlib_main_t * vm, vnet_get_main (), sw_if_index); break; case VNET_API_ERROR_INVALID_VALUE: - return clib_error_return (0, "session already exists..."); + error = clib_error_return (0, "session already exists..."); + goto done; case VNET_API_ERROR_NO_SUCH_ENTRY: - return clib_error_return (0, "session does not exist..."); + error = clib_error_return (0, "session does not exist..."); + goto done; default: - return clib_error_return (0, "l2tp_session_add_del returned %d", rv); + error = clib_error_return (0, "l2tp_session_add_del returned %d", rv); + goto done; } - return 0; +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ diff --git a/src/vnet/lisp-cp/lisp_cli.c b/src/vnet/lisp-cp/lisp_cli.c index 25d11c61..05df9fb6 100644 --- a/src/vnet/lisp-cp/lisp_cli.c +++ b/src/vnet/lisp-cp/lisp_cli.c @@ -25,6 +25,7 @@ lisp_show_adjacencies_command_fn (vlib_main_t * vm, vlib_cli_output (vm, "%s %40s\n", "leid", "reid"); unformat_input_t _line_input, *line_input = &_line_input; u32 vni = ~0; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -38,14 +39,14 @@ lisp_show_adjacencies_command_fn (vlib_main_t * vm, { vlib_cli_output (vm, "parse error: '%U'", format_unformat_error, line_input); - return 0; + goto done; } } if (~0 == vni) { vlib_cli_output (vm, "error: no vni specified!"); - return 0; + goto done; } adjs = vnet_lisp_adjacencies_get_by_vni (vni); @@ -57,7 +58,10 @@ lisp_show_adjacencies_command_fn (vlib_main_t * vm, } vec_free (adjs); - return 0; +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ @@ -77,6 +81,7 @@ lisp_add_del_map_server_command_fn (vlib_main_t * vm, u8 is_add = 1, ip_set = 0; ip_address_t ip; unformat_input_t _line_input, *line_input = &_line_input; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -94,14 +99,14 @@ lisp_add_del_map_server_command_fn (vlib_main_t * vm, { vlib_cli_output (vm, "parse error: '%U'", format_unformat_error, line_input); - return 0; + goto done; } } if (!ip_set) { vlib_cli_output (vm, "map-server ip address not set!"); - return 0; + goto done; } rv = vnet_lisp_add_del_map_server (&ip, is_add); @@ -109,7 +114,10 @@ lisp_add_del_map_server_command_fn (vlib_main_t * vm, vlib_cli_output (vm, "failed to %s map-server!", is_add ? "add" : "delete"); - return 0; +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ @@ -191,7 +199,7 @@ lisp_add_del_local_eid_command_fn (vlib_main_t * vm, unformat_input_t * input, if (key && (0 == key_id)) { vlib_cli_output (vm, "invalid key_id!"); - return 0; + goto done;; } gid_address_copy (&a->eid, &eid); @@ -213,6 +221,8 @@ done: vec_free (locator_set_name); gid_address_free (&a->eid); vec_free (a->key); + unformat_free (line_input); + return error; } @@ -233,6 +243,7 @@ lisp_eid_table_map_command_fn (vlib_main_t * vm, u8 is_add = 1, is_l2 = 0; u32 vni = 0, dp_id = 0; unformat_input_t _line_input, *line_input = &_line_input; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -250,11 +261,16 @@ lisp_eid_table_map_command_fn (vlib_main_t * vm, is_l2 = 1; else { - return unformat_parse_error (line_input); + error = unformat_parse_error (line_input); + goto done; } } vnet_lisp_eid_table_map (vni, dp_id, is_l2, is_add); - return 0; + +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ @@ -479,7 +495,7 @@ lisp_add_del_adjacency_command_fn (vlib_main_t * vm, unformat_input_t * input, != ip_prefix_version (leid_ippref))) { clib_warning ("remote and local EIDs are of different types!"); - return error; + goto done; } memset (a, 0, sizeof (a[0])); @@ -512,6 +528,7 @@ lisp_map_request_mode_command_fn (vlib_main_t * vm, { unformat_input_t _i, *i = &_i; map_request_mode_t mr_mode = _MR_MODE_MAX; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, i)) @@ -533,12 +550,15 @@ lisp_map_request_mode_command_fn (vlib_main_t * vm, if (_MR_MODE_MAX == mr_mode) { clib_warning ("No LISP map request mode entered!"); - return 0; + goto done; } vnet_lisp_set_map_request_mode (mr_mode); + done: - return 0; + unformat_free (i); + + return error; } /* *INDENT-OFF* */ @@ -630,7 +650,10 @@ lisp_pitr_set_locator_set_command_fn (vlib_main_t * vm, else if (unformat (line_input, "disable")) is_add = 0; else - return clib_error_return (0, "parse error"); + { + error = clib_error_return (0, "parse error"); + goto done; + } } if (!locator_name_set) @@ -648,6 +671,8 @@ lisp_pitr_set_locator_set_command_fn (vlib_main_t * vm, done: if (locator_set_name) vec_free (locator_set_name); + unformat_free (line_input); + return error; } @@ -771,6 +796,7 @@ lisp_show_eid_table_command_fn (vlib_main_t * vm, gid_address_t eid; u8 print_all = 1; u8 filter = 0; + clib_error_t *error = NULL; memset (&eid, 0, sizeof (eid)); @@ -787,8 +813,11 @@ lisp_show_eid_table_command_fn (vlib_main_t * vm, else if (unformat (line_input, "remote")) filter = 2; else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } vlib_cli_output (vm, "%-35s%-20s%-30s%-20s%-s", @@ -818,7 +847,7 @@ lisp_show_eid_table_command_fn (vlib_main_t * vm, { mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, &eid); if ((u32) ~ 0 == mi) - return 0; + goto done; mapit = pool_elt_at_index (lcm->mapping_pool, mi); locator_set_t *ls = pool_elt_at_index (lcm->locator_set_pool, @@ -827,14 +856,17 @@ lisp_show_eid_table_command_fn (vlib_main_t * vm, if (filter && !((1 == filter && ls->local) || (2 == filter && !ls->local))) { - return 0; + goto done; } vlib_cli_output (vm, "%U,", format_eid_entry, lcm->vnet_main, lcm, mapit, ls); } - return 0; +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ @@ -853,6 +885,7 @@ lisp_enable_disable_command_fn (vlib_main_t * vm, unformat_input_t * input, unformat_input_t _line_input, *line_input = &_line_input; u8 is_enabled = 0; u8 is_set = 0; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -869,16 +902,24 @@ lisp_enable_disable_command_fn (vlib_main_t * vm, unformat_input_t * input, is_set = 1; else { - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; } } if (!is_set) - return clib_error_return (0, "state not set"); + { + error = clib_error_return (0, "state not set"); + goto done; + } vnet_lisp_enable_disable (is_enabled); - return 0; + +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ @@ -897,6 +938,7 @@ lisp_map_register_enable_disable_command_fn (vlib_main_t * vm, unformat_input_t _line_input, *line_input = &_line_input; u8 is_enabled = 0; u8 is_set = 0; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -915,18 +957,22 @@ lisp_map_register_enable_disable_command_fn (vlib_main_t * vm, { vlib_cli_output (vm, "parse error: '%U'", format_unformat_error, line_input); - return 0; + goto done; } } if (!is_set) { vlib_cli_output (vm, "state not set!"); - return 0; + goto done; } vnet_lisp_map_register_enable_disable (is_enabled); - return 0; + +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ @@ -945,6 +991,7 @@ lisp_rloc_probe_enable_disable_command_fn (vlib_main_t * vm, unformat_input_t _line_input, *line_input = &_line_input; u8 is_enabled = 0; u8 is_set = 0; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -963,18 +1010,22 @@ lisp_rloc_probe_enable_disable_command_fn (vlib_main_t * vm, { vlib_cli_output (vm, "parse error: '%U'", format_unformat_error, line_input); - return 0; + goto done; } } if (!is_set) { vlib_cli_output (vm, "state not set!"); - return 0; + goto done; } vnet_lisp_rloc_probe_enable_disable (is_enabled); - return 0; + +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ @@ -1022,6 +1073,7 @@ lisp_show_eid_table_map_command_fn (vlib_main_t * vm, lisp_cp_main_t *lcm = vnet_lisp_cp_get_main (); uword *vni_table = 0; u8 is_l2 = 0; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -1040,14 +1092,17 @@ lisp_show_eid_table_map_command_fn (vlib_main_t * vm, is_l2 = 0; } else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } if (!vni_table) { vlib_cli_output (vm, "Error: expected l2|l3 param!\n"); - return 0; + goto done; } vlib_cli_output (vm, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF"); @@ -1059,7 +1114,10 @@ lisp_show_eid_table_map_command_fn (vlib_main_t * vm, })); /* *INDENT-ON* */ - return 0; +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ @@ -1131,6 +1189,8 @@ done: vec_free (locators); if (locator_set_name) vec_free (locator_set_name); + unformat_free (line_input); + return error; } @@ -1205,6 +1265,8 @@ lisp_add_del_locator_in_set_command_fn (vlib_main_t * vm, done: vec_free (locators); vec_free (locator_set_name); + unformat_free (line_input); + return error; } @@ -1322,6 +1384,8 @@ lisp_add_del_map_resolver_command_fn (vlib_main_t * vm, } done: + unformat_free (line_input); + return error; } @@ -1372,11 +1436,11 @@ lisp_add_del_mreq_itr_rlocs_command_fn (vlib_main_t * vm, is_add ? "add" : "delete"); } +done: vec_free (locator_set_name); + unformat_free (line_input); -done: return error; - } /* *INDENT-OFF* */ @@ -1438,7 +1502,10 @@ lisp_use_petr_set_locator_set_command_fn (vlib_main_t * vm, else if (unformat (line_input, "disable")) is_add = 0; else - return clib_error_return (0, "parse error"); + { + error = clib_error_return (0, "parse error"); + goto done; + } } if (!ip_set) @@ -1454,6 +1521,8 @@ lisp_use_petr_set_locator_set_command_fn (vlib_main_t * vm, } done: + unformat_free (line_input); + return error; } diff --git a/src/vnet/lisp-gpe/interface.c b/src/vnet/lisp-gpe/interface.c index 2142e095..19ac22e7 100644 --- a/src/vnet/lisp-gpe/interface.c +++ b/src/vnet/lisp-gpe/interface.c @@ -794,6 +794,7 @@ lisp_gpe_add_del_iface_command_fn (vlib_main_t * vm, unformat_input_t * input, u32 table_id, vni, bd_id; u8 vni_is_set = 0, vrf_is_set = 0, bd_index_is_set = 0; u8 nsh_iface = 0; + clib_error_t *error = NULL; if (vnet_lisp_gpe_enable_disable_status () == 0) { @@ -828,8 +829,9 @@ lisp_gpe_add_del_iface_command_fn (vlib_main_t * vm, unformat_input_t * input, } else { - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; } } @@ -839,7 +841,8 @@ lisp_gpe_add_del_iface_command_fn (vlib_main_t * vm, unformat_input_t * input, { if (~0 == lisp_gpe_add_nsh_iface (&lisp_gpe_main)) { - return clib_error_return (0, "NSH interface not created"); + error = clib_error_return (0, "NSH interface not created"); + goto done; } } else @@ -850,21 +853,34 @@ lisp_gpe_add_del_iface_command_fn (vlib_main_t * vm, unformat_input_t * input, } if (vrf_is_set && bd_index_is_set) - return clib_error_return (0, - "Cannot set both vrf and brdige domain index!"); + { + error = clib_error_return + (0, "Cannot set both vrf and brdige domain index!"); + goto done; + } if (!vni_is_set) - return clib_error_return (0, "vni must be set!"); + { + error = clib_error_return (0, "vni must be set!"); + goto done; + } if (!vrf_is_set && !bd_index_is_set) - return clib_error_return (0, "vrf or bridge domain index must be set!"); + { + error = + clib_error_return (0, "vrf or bridge domain index must be set!"); + goto done; + } if (bd_index_is_set) { if (is_add) { if (~0 == lisp_gpe_tenant_l2_iface_add_or_lock (vni, bd_id)) - return clib_error_return (0, "L2 interface not created"); + { + error = clib_error_return (0, "L2 interface not created"); + goto done; + } } else lisp_gpe_tenant_l2_iface_unlock (vni); @@ -874,13 +890,35 @@ lisp_gpe_add_del_iface_command_fn (vlib_main_t * vm, unformat_input_t * input, if (is_add) { if (~0 == lisp_gpe_tenant_l3_iface_add_or_lock (vni, table_id)) - return clib_error_return (0, "L3 interface not created"); + { + error = clib_error_return (0, "L3 interface not created"); + goto done; + } } else lisp_gpe_tenant_l3_iface_unlock (vni); } - return (NULL); + if (nsh_iface) + { + if (is_add) + { + if (~0 == lisp_gpe_add_nsh_iface (&lisp_gpe_main)) + { + error = clib_error_return (0, "NSH interface not created"); + goto done; + } + else + { + lisp_gpe_del_nsh_iface (&lisp_gpe_main); + } + } + } + +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ diff --git a/src/vnet/lisp-gpe/lisp_gpe.c b/src/vnet/lisp-gpe/lisp_gpe.c index 1f8afdae..f2fbcbd5 100644 --- a/src/vnet/lisp-gpe/lisp_gpe.c +++ b/src/vnet/lisp-gpe/lisp_gpe.c @@ -218,6 +218,7 @@ lisp_gpe_enable_disable_command_fn (vlib_main_t * vm, unformat_input_t _line_input, *line_input = &_line_input; u8 is_en = 1; vnet_lisp_gpe_enable_disable_args_t _a, *a = &_a; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -231,12 +232,18 @@ lisp_gpe_enable_disable_command_fn (vlib_main_t * vm, is_en = 0; else { - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; } } a->is_en = is_en; - return vnet_lisp_gpe_enable_disable (a); + error = vnet_lisp_gpe_enable_disable (a); + +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ diff --git a/src/vnet/map/map.c b/src/vnet/map/map.c index aeec6a94..a2d28118 100644 --- a/src/vnet/map/map.c +++ b/src/vnet/map/map.c @@ -465,6 +465,8 @@ map_security_check_command_fn (vlib_main_t * vm, { unformat_input_t _line_input, *line_input = &_line_input; map_main_t *mm = &map_main; + clib_error_t *error = NULL; + /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) return 0; @@ -476,11 +478,17 @@ map_security_check_command_fn (vlib_main_t * vm, else if (unformat (line_input, "on")) mm->sec_check = true; else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } + +done: unformat_free (line_input); - return 0; + + return error; } static clib_error_t * @@ -490,6 +498,8 @@ map_security_check_frag_command_fn (vlib_main_t * vm, { unformat_input_t _line_input, *line_input = &_line_input; map_main_t *mm = &map_main; + clib_error_t *error = NULL; + /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) return 0; @@ -501,11 +511,17 @@ map_security_check_frag_command_fn (vlib_main_t * vm, else if (unformat (line_input, "on")) mm->sec_check_frag = true; else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } + +done: unformat_free (line_input); - return 0; + + return error; } static clib_error_t * @@ -523,6 +539,7 @@ map_add_domain_command_fn (vlib_main_t * vm, u32 mtu = 0; u8 flags = 0; ip6_src_len = 128; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -559,20 +576,28 @@ map_add_domain_command_fn (vlib_main_t * vm, else if (unformat (line_input, "map-t")) flags |= MAP_DOMAIN_TRANSLATION; else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); if (num_m_args < 3) - return clib_error_return (0, "mandatory argument(s) missing"); + { + error = clib_error_return (0, "mandatory argument(s) missing"); + goto done; + } map_create_domain (&ip4_prefix, ip4_prefix_len, &ip6_prefix, ip6_prefix_len, &ip6_src, ip6_src_len, ea_bits_len, psid_offset, psid_length, &map_domain_index, mtu, flags); - return 0; +done: + unformat_free (line_input); + + return error; } static clib_error_t * @@ -582,6 +607,7 @@ map_del_domain_command_fn (vlib_main_t * vm, unformat_input_t _line_input, *line_input = &_line_input; u32 num_m_args = 0; u32 map_domain_index; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -592,17 +618,25 @@ map_del_domain_command_fn (vlib_main_t * vm, if (unformat (line_input, "index %d", &map_domain_index)) num_m_args++; else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); if (num_m_args != 1) - return clib_error_return (0, "mandatory argument(s) missing"); + { + error = clib_error_return (0, "mandatory argument(s) missing"); + goto done; + } map_delete_domain (map_domain_index); - return 0; +done: + unformat_free (line_input); + + return error; } static clib_error_t * @@ -613,6 +647,7 @@ map_add_rule_command_fn (vlib_main_t * vm, ip6_address_t tep; u32 num_m_args = 0; u32 psid = 0, map_domain_index; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -628,19 +663,29 @@ map_add_rule_command_fn (vlib_main_t * vm, if (unformat (line_input, "ip6-dst %U", unformat_ip6_address, &tep)) num_m_args++; else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); if (num_m_args != 3) - return clib_error_return (0, "mandatory argument(s) missing"); + { + error = clib_error_return (0, "mandatory argument(s) missing"); + goto done; + } if (map_add_del_psid (map_domain_index, psid, &tep, 1) != 0) { - return clib_error_return (0, "Failing to add Mapping Rule"); + error = clib_error_return (0, "Failing to add Mapping Rule"); + goto done; } - return 0; + +done: + unformat_free (line_input); + + return error; } #if MAP_SKIP_IP6_LOOKUP @@ -653,6 +698,7 @@ map_pre_resolve_command_fn (vlib_main_t * vm, ip4_address_t ip4nh; ip6_address_t ip6nh; map_main_t *mm = &map_main; + clib_error_t *error = NULL; memset (&ip4nh, 0, sizeof (ip4nh)); memset (&ip6nh, 0, sizeof (ip6nh)); @@ -669,14 +715,19 @@ map_pre_resolve_command_fn (vlib_main_t * vm, if (unformat (line_input, "ip6-nh %U", unformat_ip6_address, &ip6nh)) mm->preresolve_ip6 = ip6nh; else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); map_pre_resolve (&ip4nh, &ip6nh); - return 0; +done: + unformat_free (line_input); + + return error; } #endif @@ -688,6 +739,7 @@ map_icmp_relay_source_address_command_fn (vlib_main_t * vm, unformat_input_t _line_input, *line_input = &_line_input; ip4_address_t icmp_src_address; map_main_t *mm = &map_main; + clib_error_t *error = NULL; mm->icmp4_src_address.as_u32 = 0; @@ -701,12 +753,17 @@ map_icmp_relay_source_address_command_fn (vlib_main_t * vm, (line_input, "%U", unformat_ip4_address, &icmp_src_address)) mm->icmp4_src_address = icmp_src_address; else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } + +done: unformat_free (line_input); - return 0; + return error; } static clib_error_t * @@ -717,6 +774,7 @@ map_icmp_unreachables_command_fn (vlib_main_t * vm, unformat_input_t _line_input, *line_input = &_line_input; map_main_t *mm = &map_main; int num_m_args = 0; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -730,16 +788,21 @@ map_icmp_unreachables_command_fn (vlib_main_t * vm, else if (unformat (line_input, "off")) mm->icmp6_enabled = false; else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); if (num_m_args != 1) - return clib_error_return (0, "mandatory argument(s) missing"); + error = clib_error_return (0, "mandatory argument(s) missing"); - return 0; +done: + unformat_free (line_input); + + return error; } static clib_error_t * @@ -748,6 +811,7 @@ map_fragment_command_fn (vlib_main_t * vm, { unformat_input_t _line_input, *line_input = &_line_input; map_main_t *mm = &map_main; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -760,12 +824,17 @@ map_fragment_command_fn (vlib_main_t * vm, else if (unformat (line_input, "outer")) mm->frag_inner = false; else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } + +done: unformat_free (line_input); - return 0; + return error; } static clib_error_t * @@ -775,6 +844,7 @@ map_fragment_df_command_fn (vlib_main_t * vm, { unformat_input_t _line_input, *line_input = &_line_input; map_main_t *mm = &map_main; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -787,12 +857,17 @@ map_fragment_df_command_fn (vlib_main_t * vm, else if (unformat (line_input, "off")) mm->frag_ignore_df = false; else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } + +done: unformat_free (line_input); - return 0; + return error; } static clib_error_t * @@ -803,6 +878,7 @@ map_traffic_class_command_fn (vlib_main_t * vm, unformat_input_t _line_input, *line_input = &_line_input; map_main_t *mm = &map_main; u32 tc = 0; + clib_error_t *error = NULL; mm->tc_copy = false; @@ -817,12 +893,17 @@ map_traffic_class_command_fn (vlib_main_t * vm, else if (unformat (line_input, "%x", &tc)) mm->tc = tc & 0xff; else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } + +done: unformat_free (line_input); - return 0; + return error; } static u8 * @@ -922,6 +1003,7 @@ show_map_domain_command_fn (vlib_main_t * vm, unformat_input_t * input, map_domain_t *d; bool counters = false; u32 map_domain_index = ~0; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -934,10 +1016,12 @@ show_map_domain_command_fn (vlib_main_t * vm, unformat_input_t * input, else if (unformat (line_input, "index %d", &map_domain_index)) ; else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, input); + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); if (pool_elts (mm->domains) == 0) vlib_cli_output (vm, "No MAP domains are configured..."); @@ -952,15 +1036,19 @@ show_map_domain_command_fn (vlib_main_t * vm, unformat_input_t * input, { if (pool_is_free_index (mm->domains, map_domain_index)) { - return clib_error_return (0, "MAP domain does not exists %d", - map_domain_index); + error = clib_error_return (0, "MAP domain does not exists %d", + map_domain_index); + goto done; } d = pool_elt_at_index (mm->domains, map_domain_index); vlib_cli_output (vm, "%U", format_map_domain, d, counters); } - return 0; +done: + unformat_free (line_input); + + return error; } static clib_error_t * diff --git a/src/vnet/mpls/mpls.c b/src/vnet/mpls/mpls.c index 0e610e17..7ae4aa00 100644 --- a/src/vnet/mpls/mpls.c +++ b/src/vnet/mpls/mpls.c @@ -470,6 +470,8 @@ vnet_mpls_local_label (vlib_main_t * vm, } done: + unformat_free (line_input); + return error; } diff --git a/src/vnet/mpls/mpls_tunnel.c b/src/vnet/mpls/mpls_tunnel.c index 8d1e30a3..e488271d 100644 --- a/src/vnet/mpls/mpls_tunnel.c +++ b/src/vnet/mpls/mpls_tunnel.c @@ -535,6 +535,7 @@ vnet_create_mpls_tunnel_command_fn (vlib_main_t * vm, fib_route_path_t rpath, *rpaths = NULL; mpls_label_t out_label = MPLS_LABEL_INVALID, *labels = NULL; u32 sw_if_index; + clib_error_t *error = NULL; memset(&rpath, 0, sizeof(rpath)); @@ -595,8 +596,11 @@ vnet_create_mpls_tunnel_command_fn (vlib_main_t * vm, else if (unformat (line_input, "l2-only")) l2_only = 1; else - return clib_error_return (0, "unknown input '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "unknown input '%U'", + format_unformat_error, line_input); + goto done; + } } if (is_del) @@ -606,17 +610,22 @@ vnet_create_mpls_tunnel_command_fn (vlib_main_t * vm, else { if (0 == vec_len(labels)) - return clib_error_return (0, "No Output Labels '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "No Output Labels '%U'", + format_unformat_error, line_input); + goto done; + } vec_add1(rpaths, rpath); vnet_mpls_tunnel_add(rpaths, labels, l2_only, &sw_if_index); } +done: vec_free(labels); vec_free(rpaths); + unformat_free (line_input); - return (NULL); + return error; } /*? diff --git a/src/vnet/pg/cli.c b/src/vnet/pg/cli.c index f5896b43..3c249a7b 100644 --- a/src/vnet/pg/cli.c +++ b/src/vnet/pg/cli.c @@ -547,21 +547,30 @@ pg_capture_cmd_fn (vlib_main_t * vm, else { error = clib_error_create ("unknown input `%U'", - format_unformat_error, input); - return error; + format_unformat_error, line_input); + goto done; } } if (!hi) - return clib_error_return (0, "Please specify interface name"); + { + error = clib_error_return (0, "Please specify interface name"); + goto done; + } if (hi->dev_class_index != pg_dev_class.index) - return clib_error_return (0, "Please specify packet-generator interface"); + { + error = + clib_error_return (0, "Please specify packet-generator interface"); + goto done; + } if (!pcap_file_name && is_disable == 0) - return clib_error_return (0, "Please specify pcap file name"); + { + error = clib_error_return (0, "Please specify pcap file name"); + goto done; + } - unformat_free (line_input); pg_capture_args_t _a, *a = &_a; @@ -572,6 +581,10 @@ pg_capture_cmd_fn (vlib_main_t * vm, a->count = count; error = pg_capture (a); + +done: + unformat_free (line_input); + return error; } @@ -590,6 +603,7 @@ create_pg_if_cmd_fn (vlib_main_t * vm, pg_main_t *pg = &pg_main; unformat_input_t _line_input, *line_input = &_line_input; u32 if_id; + clib_error_t *error = NULL; if (!unformat_user (input, unformat_line_input, line_input)) return 0; @@ -600,14 +614,19 @@ create_pg_if_cmd_fn (vlib_main_t * vm, ; else - return clib_error_create ("unknown input `%U'", - format_unformat_error, input); + { + error = clib_error_create ("unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } + pg_interface_add_or_get (pg, if_id); + +done: unformat_free (line_input); - pg_interface_add_or_get (pg, if_id); - return 0; + return error; } /* *INDENT-OFF* */ diff --git a/src/vnet/policer/node_funcs.c b/src/vnet/policer/node_funcs.c index 1f4997ff..457dd09f 100644 --- a/src/vnet/policer/node_funcs.c +++ b/src/vnet/policer/node_funcs.c @@ -447,6 +447,7 @@ test_policer_command_fn (vlib_main_t * vm, int rx_set = 0; int is_add = 1; int is_show = 0; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -468,7 +469,10 @@ test_policer_command_fn (vlib_main_t * vm, } if (rx_set == 0) - return clib_error_return (0, "interface not set"); + { + error = clib_error_return (0, "interface not set"); + goto done; + } if (is_show) { @@ -477,12 +481,13 @@ test_policer_command_fn (vlib_main_t * vm, policer = pool_elt_at_index (pm->policers, pi); vlib_cli_output (vm, "%U", format_policer_instance, policer); - return 0; + goto done; } if (is_add && config_name == 0) { - return clib_error_return (0, "policer config name required"); + error = clib_error_return (0, "policer config name required"); + goto done; } rv = test_policer_add_del (rx_sw_if_index, config_name, is_add); @@ -493,11 +498,15 @@ test_policer_command_fn (vlib_main_t * vm, break; default: - return clib_error_return + error = clib_error_return (0, "WARNING: vnet_vnet_policer_add_del returned %d", rv); + goto done; } - return 0; +done: + unformat_free (line_input); + + return error; } /* *INDENT-OFF* */ diff --git a/src/vnet/policer/policer.c b/src/vnet/policer/policer.c index 290a6af5..cd754e29 100644 --- a/src/vnet/policer/policer.c +++ b/src/vnet/policer/policer.c @@ -413,6 +413,7 @@ configure_policer_command_fn (vlib_main_t * vm, u8 is_add = 1; u8 *name = 0; u32 pi; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -433,13 +434,19 @@ configure_policer_command_fn (vlib_main_t * vm, foreach_config_param #undef _ else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } + error = policer_add_del (vm, name, &c, &pi, is_add); + +done: unformat_free (line_input); - return policer_add_del (vm, name, &c, &pi, is_add); + return error; } /* *INDENT-OFF* */ diff --git a/src/vnet/unix/tapcli.c b/src/vnet/unix/tapcli.c index 48e81b50..25c930c6 100644 --- a/src/vnet/unix/tapcli.c +++ b/src/vnet/unix/tapcli.c @@ -1308,6 +1308,7 @@ tap_connect_command_fn (vlib_main_t * vm, int ip6_address_set = 0; u32 ip4_mask_width = 0; u32 ip6_mask_width = 0; + clib_error_t *error = NULL; if (tm->is_disabled) return clib_error_return (0, "device disabled..."); @@ -1336,12 +1337,18 @@ tap_connect_command_fn (vlib_main_t * vm, else if (unformat (line_input, "%s", &intfc_name)) ; else - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } } if (intfc_name == 0) - return clib_error_return (0, "interface name must be specified"); + { + error = clib_error_return (0, "interface name must be specified"); + goto done; + } memset (ap, 0, sizeof (*ap)); @@ -1367,48 +1374,64 @@ tap_connect_command_fn (vlib_main_t * vm, switch (rv) { case VNET_API_ERROR_SYSCALL_ERROR_1: - return clib_error_return (0, "Couldn't open /dev/net/tun"); + error = clib_error_return (0, "Couldn't open /dev/net/tun"); + goto done; case VNET_API_ERROR_SYSCALL_ERROR_2: - return clib_error_return (0, "Error setting flags on '%s'", intfc_name); - + error = clib_error_return (0, "Error setting flags on '%s'", intfc_name); + goto done; + case VNET_API_ERROR_SYSCALL_ERROR_3: - return clib_error_return (0, "Couldn't open provisioning socket"); + error = clib_error_return (0, "Couldn't open provisioning socket"); + goto done; case VNET_API_ERROR_SYSCALL_ERROR_4: - return clib_error_return (0, "Couldn't get if_index"); + error = clib_error_return (0, "Couldn't get if_index"); + goto done; case VNET_API_ERROR_SYSCALL_ERROR_5: - return clib_error_return (0, "Couldn't bind provisioning socket"); + error = clib_error_return (0, "Couldn't bind provisioning socket"); + goto done; case VNET_API_ERROR_SYSCALL_ERROR_6: - return clib_error_return (0, "Couldn't set device non-blocking flag"); + error = clib_error_return (0, "Couldn't set device non-blocking flag"); + goto done; case VNET_API_ERROR_SYSCALL_ERROR_7: - return clib_error_return (0, "Couldn't set device MTU"); + error = clib_error_return (0, "Couldn't set device MTU"); + goto done; case VNET_API_ERROR_SYSCALL_ERROR_8: - return clib_error_return (0, "Couldn't get interface flags"); + error = clib_error_return (0, "Couldn't get interface flags"); + goto done; case VNET_API_ERROR_SYSCALL_ERROR_9: - return clib_error_return (0, "Couldn't set intfc admin state up"); + error = clib_error_return (0, "Couldn't set intfc admin state up"); + goto done; case VNET_API_ERROR_SYSCALL_ERROR_10: - return clib_error_return (0, "Couldn't set intfc address/mask"); + error = clib_error_return (0, "Couldn't set intfc address/mask"); + goto done; case VNET_API_ERROR_INVALID_REGISTRATION: - return clib_error_return (0, "Invalid registration"); + error = clib_error_return (0, "Invalid registration"); + goto done; case 0: break; default: - return clib_error_return (0, "Unknown error: %d", rv); + error = clib_error_return (0, "Unknown error: %d", rv); + goto done; } vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(), sw_if_index); - return 0; + +done: + unformat_free (line_input); + + return error; } VLIB_CLI_COMMAND (tap_connect_command, static) = { diff --git a/src/vnet/vxlan-gpe/vxlan_gpe.c b/src/vnet/vxlan-gpe/vxlan_gpe.c index b97510c4..2cba596f 100644 --- a/src/vnet/vxlan-gpe/vxlan_gpe.c +++ b/src/vnet/vxlan-gpe/vxlan_gpe.c @@ -454,6 +454,7 @@ vxlan_gpe_add_del_tunnel_command_fn (vlib_main_t * vm, u32 tmp; vnet_vxlan_gpe_add_del_tunnel_args_t _a, * a = &_a; u32 sw_if_index; + clib_error_t *error = NULL; /* Get a line of input. */ if (! unformat_user (input, unformat_line_input, line_input)) @@ -494,7 +495,10 @@ vxlan_gpe_add_del_tunnel_command_fn (vlib_main_t * vm, encap_fib_index = ip4_fib_index_from_table_id (tmp); if (encap_fib_index == ~0) - return clib_error_return (0, "nonexistent encap fib id %d", tmp); + { + error = clib_error_return (0, "nonexistent encap fib id %d", tmp); + goto done; + } } else if (unformat (line_input, "decap-vrf-id %d", &tmp)) { @@ -504,7 +508,10 @@ vxlan_gpe_add_del_tunnel_command_fn (vlib_main_t * vm, decap_fib_index = ip4_fib_index_from_table_id (tmp); if (decap_fib_index == ~0) - return clib_error_return (0, "nonexistent decap fib id %d", tmp); + { + error = clib_error_return (0, "nonexistent decap fib id %d", tmp); + goto done; + } } else if (unformat (line_input, "vni %d", &vni)) vni_set = 1; @@ -517,27 +524,43 @@ vxlan_gpe_add_del_tunnel_command_fn (vlib_main_t * vm, else if (unformat(line_input, "next-nsh")) protocol = VXLAN_GPE_PROTOCOL_NSH; else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); - if (local_set == 0) - return clib_error_return (0, "tunnel local address not specified"); + { + error = clib_error_return (0, "tunnel local address not specified"); + goto done; + } if (remote_set == 0) - return clib_error_return (0, "tunnel remote address not specified"); + { + error = clib_error_return (0, "tunnel remote address not specified"); + goto done; + } if (ipv4_set && ipv6_set) - return clib_error_return (0, "both IPv4 and IPv6 addresses specified"); + { + error = clib_error_return (0, "both IPv4 and IPv6 addresses specified"); + goto done; + } if ((ipv4_set && memcmp(&local.ip4, &remote.ip4, sizeof(local.ip4)) == 0) || (ipv6_set && memcmp(&local.ip6, &remote.ip6, sizeof(local.ip6)) == 0)) - return clib_error_return (0, "src and dst addresses are identical"); + { + error = clib_error_return (0, "src and dst addresses are identical"); + goto done; + } if (vni_set == 0) - return clib_error_return (0, "vni not specified"); + { + error = clib_error_return (0, "vni not specified"); + goto done; + } memset (a, 0, sizeof (*a)); @@ -558,20 +581,27 @@ vxlan_gpe_add_del_tunnel_command_fn (vlib_main_t * vm, vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(), sw_if_index); break; case VNET_API_ERROR_INVALID_DECAP_NEXT: - return clib_error_return (0, "invalid decap-next..."); + error = clib_error_return (0, "invalid decap-next..."); + goto done; case VNET_API_ERROR_TUNNEL_EXIST: - return clib_error_return (0, "tunnel already exists..."); + error = clib_error_return (0, "tunnel already exists..."); + goto done; case VNET_API_ERROR_NO_SUCH_ENTRY: - return clib_error_return (0, "tunnel does not exist..."); + error = clib_error_return (0, "tunnel does not exist..."); + goto done; default: - return clib_error_return + error = clib_error_return (0, "vnet_vxlan_gpe_add_del_tunnel returned %d", rv); + goto done; } - return 0; +done: + unformat_free (line_input); + + return error; } VLIB_CLI_COMMAND (create_vxlan_gpe_tunnel_command, static) = { diff --git a/src/vnet/vxlan/vxlan.c b/src/vnet/vxlan/vxlan.c index 849fc25d..eedc16f8 100644 --- a/src/vnet/vxlan/vxlan.c +++ b/src/vnet/vxlan/vxlan.c @@ -657,6 +657,7 @@ vxlan_add_del_tunnel_command_fn (vlib_main_t * vm, int rv; vnet_vxlan_add_del_tunnel_args_t _a, * a = &_a; u32 tunnel_sw_if_index; + clib_error_t *error = NULL; /* Cant "universally zero init" (={0}) due to GCC bug 53119 */ memset(&src, 0, sizeof src); @@ -715,7 +716,10 @@ vxlan_add_del_tunnel_command_fn (vlib_main_t * vm, { encap_fib_index = fib_table_find (fib_ip_proto (ipv6_set), tmp); if (encap_fib_index == ~0) - return clib_error_return (0, "nonexistent encap-vrf-id %d", tmp); + { + error = clib_error_return (0, "nonexistent encap-vrf-id %d", tmp); + goto done; + } } else if (unformat (line_input, "decap-next %U", unformat_decap_next, &decap_next_index, ipv4_set)) @@ -723,41 +727,72 @@ vxlan_add_del_tunnel_command_fn (vlib_main_t * vm, else if (unformat (line_input, "vni %d", &vni)) { if (vni >> 24) - return clib_error_return (0, "vni %d out of range", vni); + { + error = clib_error_return (0, "vni %d out of range", vni); + goto done; + } } else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + goto done; + } } - unformat_free (line_input); - if (src_set == 0) - return clib_error_return (0, "tunnel src address not specified"); + { + error = clib_error_return (0, "tunnel src address not specified"); + goto done; + } if (dst_set == 0) - return clib_error_return (0, "tunnel dst address not specified"); + { + error = clib_error_return (0, "tunnel dst address not specified"); + goto done; + } if (grp_set && !ip46_address_is_multicast(&dst)) - return clib_error_return (0, "tunnel group address not multicast"); + { + error = clib_error_return (0, "tunnel group address not multicast"); + goto done; + } if (grp_set == 0 && ip46_address_is_multicast(&dst)) - return clib_error_return (0, "dst address must be unicast"); + { + error = clib_error_return (0, "dst address must be unicast"); + goto done; + } if (grp_set && mcast_sw_if_index == ~0) - return clib_error_return (0, "tunnel nonexistent multicast device"); + { + error = clib_error_return (0, "tunnel nonexistent multicast device"); + goto done; + } if (ipv4_set && ipv6_set) - return clib_error_return (0, "both IPv4 and IPv6 addresses specified"); + { + error = clib_error_return (0, "both IPv4 and IPv6 addresses specified"); + goto done; + } if (ip46_address_cmp(&src, &dst) == 0) - return clib_error_return (0, "src and dst addresses are identical"); + { + error = clib_error_return (0, "src and dst addresses are identical"); + goto done; + } if (decap_next_index == ~0) - return clib_error_return (0, "next node not found"); + { + error = clib_error_return (0, "next node not found"); + goto done; + } if (vni == 0) - return clib_error_return (0, "vni not specified"); + { + error = clib_error_return (0, "vni not specified"); + goto done; + } memset (a, 0, sizeof (*a)); @@ -779,17 +814,23 @@ vxlan_add_del_tunnel_command_fn (vlib_main_t * vm, break; case VNET_API_ERROR_TUNNEL_EXIST: - return clib_error_return (0, "tunnel already exists..."); + error = clib_error_return (0, "tunnel already exists..."); + goto done; case VNET_API_ERROR_NO_SUCH_ENTRY: - return clib_error_return (0, "tunnel does not exist..."); + error = clib_error_return (0, "tunnel does not exist..."); + goto done; default: - return clib_error_return + error = clib_error_return (0, "vnet_vxlan_add_del_tunnel returned %d", rv); + goto done; } - return 0; +done: + unformat_free (line_input); + + return error; } /*? @@ -912,6 +953,8 @@ set_ip_vxlan_bypass (u32 is_ip6, vnet_int_vxlan_bypass_mode (sw_if_index, is_ip6, is_enable); done: + unformat_free (line_input); + return error; } diff --git a/src/vpp/app/l2t.c b/src/vpp/app/l2t.c index 45dd2807..e1eda155 100644 --- a/src/vpp/app/l2t.c +++ b/src/vpp/app/l2t.c @@ -254,6 +254,7 @@ l2tp_session_add_command_fn (vlib_main_t * vm, u32 local_session_id = 1, remote_session_id = 1; int our_address_set = 0, client_address_set = 0; int l2_sublayer_present = 0; + clib_error_t *error = NULL; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) @@ -290,8 +291,12 @@ l2tp_session_add_command_fn (vlib_main_t * vm, else if (unformat (line_input, "l2-sublayer-present")) l2_sublayer_present = 1; else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); + { + error = clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + unformat_free (line_input); + return error; + } } unformat_free (line_input); diff --git a/src/vpp/app/vpe_cli.c b/src/vpp/app/vpe_cli.c index a26bf71f..94bdc84c 100644 --- a/src/vpp/app/vpe_cli.c +++ b/src/vpp/app/vpe_cli.c @@ -36,6 +36,7 @@ virtual_ip_cmd_fn_command_fn (vlib_main_t * vm, mac_addr_t *mac_addrs = 0; u32 sw_if_index; u32 i; + clib_error_t *error = NULL; next_hops = NULL; rpaths = NULL; @@ -49,7 +50,11 @@ virtual_ip_cmd_fn_command_fn (vlib_main_t * vm, if (!unformat (line_input, "%U %U", unformat_ip4_address, &prefix.fp_addr.ip4, unformat_vnet_sw_interface, vnm, &sw_if_index)) - goto barf; + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { @@ -67,13 +72,18 @@ virtual_ip_cmd_fn_command_fn (vlib_main_t * vm, } else { - barf: - return clib_error_return (0, "unknown input `%U'", - format_unformat_error, input); + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; } } + if (vec_len (mac_addrs) == 0 || vec_len (mac_addrs) != vec_len (next_hops)) - goto barf; + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, line_input); + goto done; + } /* Create / delete special interface route /32's */ @@ -100,10 +110,12 @@ virtual_ip_cmd_fn_command_fn (vlib_main_t * vm, &prefix, FIB_SOURCE_CLI, FIB_ENTRY_FLAG_NONE, rpaths); +done: vec_free (mac_addrs); vec_free (next_hops); + unformat_free (line_input); - return 0; + return error; } /* *INDENT-OFF* */ -- cgit 1.2.3-korg From b614d08368cc0b04e01c5222d4c11a88845394e5 Mon Sep 17 00:00:00 2001 From: Eyal Bari Date: Thu, 16 Mar 2017 10:02:57 +0200 Subject: API:replaced all REPLY_MACRO's with api_helper_macros.h Change-Id: I08ab1fd0abdd1db4aff11a38c9c0134b01368e11 Signed-off-by: Eyal Bari --- src/examples/sample-plugin/sample/sample.c | 25 +------ src/plugins/acl/acl.c | 83 ++++------------------ src/plugins/flowperpkt/flowperpkt.c | 41 +---------- .../ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.c | 27 +------ src/plugins/ioam/export/ioam_export.c | 26 +------ src/plugins/ioam/ip6/ioam_cache.c | 26 +------ src/plugins/ioam/lib-pot/pot_api.c | 41 +---------- src/plugins/ioam/udp-ping/udp_ping_api.c | 41 +---------- src/plugins/lb/api.c | 27 ++----- src/plugins/snat/snat.c | 2 +- src/vlibapi/api_helper_macros.h | 8 +-- 11 files changed, 39 insertions(+), 308 deletions(-) (limited to 'src/plugins/lb') diff --git a/src/examples/sample-plugin/sample/sample.c b/src/examples/sample-plugin/sample/sample.c index 7588dbc0..01852746 100644 --- a/src/examples/sample-plugin/sample/sample.c +++ b/src/examples/sample-plugin/sample/sample.c @@ -50,29 +50,8 @@ #include #undef vl_api_version -/* - * A handy macro to set up a message reply. - * Assumes that the following variables are available: - * mp - pointer to request message - * rmp - pointer to reply message type - * rv - return value - */ - -#define REPLY_MACRO(t) \ -do { \ - unix_shared_memory_queue_t * q = \ - vl_api_client_index_to_input_queue (mp->client_index); \ - if (!q) \ - return; \ - \ - rmp = vl_msg_api_alloc (sizeof (*rmp)); \ - rmp->_vl_msg_id = ntohs((t)+sm->msg_id_base); \ - rmp->context = mp->context; \ - rmp->retval = ntohl(rv); \ - \ - vl_msg_api_send_shmem (q, (u8 *)&rmp); \ -} while(0); - +#define REPLY_MSG_ID_BASE sm->msg_id_base +#include /* List of message types that this plugin understands */ diff --git a/src/plugins/acl/acl.c b/src/plugins/acl/acl.c index b6af7380..0d06531d 100644 --- a/src/plugins/acl/acl.c +++ b/src/plugins/acl/acl.c @@ -57,61 +57,8 @@ acl_main_t acl_main; -/* - * A handy macro to set up a message reply. - * Assumes that the following variables are available: - * mp - pointer to request message - * rmp - pointer to reply message type - * rv - return value - */ - -#define REPLY_MACRO(t) \ -do { \ - unix_shared_memory_queue_t * q = \ - vl_api_client_index_to_input_queue (mp->client_index); \ - if (!q) \ - return; \ - \ - rmp = vl_msg_api_alloc (sizeof (*rmp)); \ - rmp->_vl_msg_id = ntohs((t)+sm->msg_id_base); \ - rmp->context = mp->context; \ - rmp->retval = ntohl(rv); \ - \ - vl_msg_api_send_shmem (q, (u8 *)&rmp); \ -} while(0); - -#define REPLY_MACRO2(t, body) \ -do { \ - unix_shared_memory_queue_t * q; \ - rv = vl_msg_api_pd_handler (mp, rv); \ - q = vl_api_client_index_to_input_queue (mp->client_index); \ - if (!q) \ - return; \ - \ - rmp = vl_msg_api_alloc (sizeof (*rmp)); \ - rmp->_vl_msg_id = ntohs((t)+am->msg_id_base); \ - rmp->context = mp->context; \ - rmp->retval = ntohl(rv); \ - do {body;} while (0); \ - vl_msg_api_send_shmem (q, (u8 *)&rmp); \ -} while(0); - -#define REPLY_MACRO3(t, n, body) \ -do { \ - unix_shared_memory_queue_t * q; \ - rv = vl_msg_api_pd_handler (mp, rv); \ - q = vl_api_client_index_to_input_queue (mp->client_index); \ - if (!q) \ - return; \ - \ - rmp = vl_msg_api_alloc (sizeof (*rmp) + n); \ - rmp->_vl_msg_id = ntohs((t)+am->msg_id_base); \ - rmp->context = mp->context; \ - rmp->retval = ntohl(rv); \ - do {body;} while (0); \ - vl_msg_api_send_shmem (q, (u8 *)&rmp); \ -} while(0); - +#define REPLY_MSG_ID_BASE am->msg_id_base +#include /* List of message types that this plugin understands */ @@ -1409,7 +1356,7 @@ vl_api_acl_add_replace_t_handler (vl_api_acl_add_replace_t * mp) static void vl_api_acl_del_t_handler (vl_api_acl_del_t * mp) { - acl_main_t *sm = &acl_main; + acl_main_t *am = &acl_main; vl_api_acl_del_reply_t *rmp; int rv; @@ -1421,8 +1368,8 @@ vl_api_acl_del_t_handler (vl_api_acl_del_t * mp) static void vl_api_acl_interface_add_del_t_handler (vl_api_acl_interface_add_del_t * mp) { - acl_main_t *sm = &acl_main; - vnet_interface_main_t *im = &sm->vnet_main->interface_main; + acl_main_t *am = &acl_main; + vnet_interface_main_t *im = &am->vnet_main->interface_main; u32 sw_if_index = ntohl (mp->sw_if_index); vl_api_acl_interface_add_del_reply_t *rmp; int rv = -1; @@ -1441,11 +1388,11 @@ static void vl_api_acl_interface_set_acl_list_t_handler (vl_api_acl_interface_set_acl_list_t * mp) { - acl_main_t *sm = &acl_main; + acl_main_t *am = &acl_main; vl_api_acl_interface_set_acl_list_reply_t *rmp; int rv = 0; int i; - vnet_interface_main_t *im = &sm->vnet_main->interface_main; + vnet_interface_main_t *im = &am->vnet_main->interface_main; u32 sw_if_index = ntohl (mp->sw_if_index); if (pool_is_free_index(im->sw_interfaces, sw_if_index)) @@ -1667,7 +1614,7 @@ vl_api_macip_acl_add_t_handler (vl_api_macip_acl_add_t * mp) static void vl_api_macip_acl_del_t_handler (vl_api_macip_acl_del_t * mp) { - acl_main_t *sm = &acl_main; + acl_main_t *am = &acl_main; vl_api_macip_acl_del_reply_t *rmp; int rv; @@ -1680,10 +1627,10 @@ static void vl_api_macip_acl_interface_add_del_t_handler (vl_api_macip_acl_interface_add_del_t * mp) { - acl_main_t *sm = &acl_main; + acl_main_t *am = &acl_main; vl_api_macip_acl_interface_add_del_reply_t *rmp; int rv = -1; - vnet_interface_main_t *im = &sm->vnet_main->interface_main; + vnet_interface_main_t *im = &am->vnet_main->interface_main; u32 sw_if_index = ntohl (mp->sw_if_index); if (pool_is_free_index(im->sw_interfaces, sw_if_index)) @@ -1819,9 +1766,9 @@ vl_api_macip_acl_interface_get_t_handler (vl_api_macip_acl_interface_get_t * static clib_error_t * acl_plugin_api_hookup (vlib_main_t * vm) { - acl_main_t *sm = &acl_main; + acl_main_t *am = &acl_main; #define _(N,n) \ - vl_msg_api_set_handlers((VL_API_##N + sm->msg_id_base), \ + vl_msg_api_set_handlers((VL_API_##N + am->msg_id_base), \ #n, \ vl_api_##n##_t_handler, \ vl_noop_handler, \ @@ -1839,10 +1786,10 @@ acl_plugin_api_hookup (vlib_main_t * vm) #undef vl_msg_name_crc_list static void -setup_message_id_table (acl_main_t * sm, api_main_t * am) +setup_message_id_table (acl_main_t * am, api_main_t * apim) { #define _(id,n,crc) \ - vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + sm->msg_id_base); + vl_msg_api_add_msg_name_crc (apim, #n "_" #crc, id + am->msg_id_base); foreach_vl_msg_name_crc_acl; #undef _ } @@ -1852,11 +1799,11 @@ register_match_action_nexts (u32 next_in_ip4, u32 next_in_ip6, u32 next_out_ip4, u32 next_out_ip6) { acl_main_t *am = &acl_main; - u32 act = am->n_match_actions; if (am->n_match_actions == 255) { return ~0; } + u32 act = am->n_match_actions; am->n_match_actions++; am->acl_in_ip4_match_next[act] = next_in_ip4; am->acl_in_ip6_match_next[act] = next_in_ip6; diff --git a/src/plugins/flowperpkt/flowperpkt.c b/src/plugins/flowperpkt/flowperpkt.c index 6b292eef..587972f7 100644 --- a/src/plugins/flowperpkt/flowperpkt.c +++ b/src/plugins/flowperpkt/flowperpkt.c @@ -58,6 +58,9 @@ flowperpkt_main_t flowperpkt_main; #include #undef vl_api_version +#define REPLY_MSG_ID_BASE fm->msg_id_base +#include + /* Define the per-interface configurable features */ /* *INDENT-OFF* */ VNET_FEATURE_INIT (flow_perpacket_ipv4, static) = @@ -75,28 +78,6 @@ VNET_FEATURE_INIT (flow_perpacket_l2, static) = }; /* *INDENT-ON* */ -/* - * A handy macro to set up a message reply. - * Assumes that the following variables are available: - * mp - pointer to request message - * rmp - pointer to reply message type - * rv - return value - */ -#define REPLY_MACRO(t) \ -do { \ - unix_shared_memory_queue_t * q = \ - vl_api_client_index_to_input_queue (mp->client_index); \ - if (!q) \ - return; \ - \ - rmp = vl_msg_api_alloc (sizeof (*rmp)); \ - rmp->_vl_msg_id = ntohs((t)+fm->msg_id_base); \ - rmp->context = mp->context; \ - rmp->retval = ntohl(rv); \ - \ - vl_msg_api_send_shmem (q, (u8 *)&rmp); \ -} while(0); - /* Macro to finish up custom dump fns */ #define FINISH \ vec_add1 (s, 0); \ @@ -104,22 +85,6 @@ do { \ vec_free (s); \ return handle; -#define VALIDATE_SW_IF_INDEX(mp) \ - do { u32 __sw_if_index = ntohl(mp->sw_if_index); \ - vnet_main_t *__vnm = vnet_get_main(); \ - if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \ - __sw_if_index)) { \ - rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \ - goto bad_sw_if_index; \ - } \ -} while(0); - -#define BAD_SW_IF_INDEX_LABEL \ -do { \ -bad_sw_if_index: \ - ; \ -} while (0); - /** * @brief Create an IPFIX template packet rewrite string * @param frm flow_report_main_t * diff --git a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.c b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.c index f05b5303..b703b8d0 100644 --- a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.c +++ b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.c @@ -53,33 +53,10 @@ #include #undef vl_api_version -/* - * A handy macro to set up a message reply. - * Assumes that the following variables are available: - * mp - pointer to request message - * rmp - pointer to reply message type - * rv - return value - */ - -#define REPLY_MACRO(t) \ -do { \ - unix_shared_memory_queue_t * q = \ - vl_api_client_index_to_input_queue (mp->client_index); \ - if (!q) \ - return; \ - \ - rmp = vl_msg_api_alloc (sizeof (*rmp)); \ - rmp->_vl_msg_id = ntohs((t)+sm->msg_id_base); \ - rmp->context = mp->context; \ - rmp->retval = ntohl(rv); \ - \ - vl_msg_api_send_shmem (q, (u8 *)&rmp); \ -} while(0); - +#define REPLY_MSG_ID_BASE sm->msg_id_base +#include /* List of message types that this plugin understands */ - - #define foreach_vxlan_gpe_ioam_export_plugin_api_msg \ _(VXLAN_GPE_IOAM_EXPORT_ENABLE_DISABLE, vxlan_gpe_ioam_export_enable_disable) diff --git a/src/plugins/ioam/export/ioam_export.c b/src/plugins/ioam/export/ioam_export.c index eeeb9738..46ac3d4a 100644 --- a/src/plugins/ioam/export/ioam_export.c +++ b/src/plugins/ioam/export/ioam_export.c @@ -52,32 +52,10 @@ #include #undef vl_api_version -/* - * A handy macro to set up a message reply. - * Assumes that the following variables are available: - * mp - pointer to request message - * rmp - pointer to reply message type - * rv - return value - */ - -#define REPLY_MACRO(t) \ -do { \ - unix_shared_memory_queue_t * q = \ - vl_api_client_index_to_input_queue (mp->client_index); \ - if (!q) \ - return; \ - \ - rmp = vl_msg_api_alloc (sizeof (*rmp)); \ - rmp->_vl_msg_id = ntohs((t)+sm->msg_id_base); \ - rmp->context = mp->context; \ - rmp->retval = ntohl(rv); \ - \ - vl_msg_api_send_shmem (q, (u8 *)&rmp); \ -} while(0); - +#define REPLY_MSG_ID_BASE sm->msg_id_base +#include /* List of message types that this plugin understands */ - #define foreach_ioam_export_plugin_api_msg \ _(IOAM_EXPORT_IP6_ENABLE_DISABLE, ioam_export_ip6_enable_disable) diff --git a/src/plugins/ioam/ip6/ioam_cache.c b/src/plugins/ioam/ip6/ioam_cache.c index 9e90ff9a..a4079e84 100644 --- a/src/plugins/ioam/ip6/ioam_cache.c +++ b/src/plugins/ioam/ip6/ioam_cache.c @@ -53,32 +53,10 @@ #include #undef vl_api_version -/* - * A handy macro to set up a message reply. - * Assumes that the following variables are available: - * mp - pointer to request message - * rmp - pointer to reply message type - * rv - return value - */ - -#define REPLY_MACRO(t) \ -do { \ - unix_shared_memory_queue_t * q = \ - vl_api_client_index_to_input_queue (mp->client_index); \ - if (!q) \ - return; \ - \ - rmp = vl_msg_api_alloc (sizeof (*rmp)); \ - rmp->_vl_msg_id = ntohs((t)+cm->msg_id_base); \ - rmp->context = mp->context; \ - rmp->retval = ntohl(rv); \ - \ - vl_msg_api_send_shmem (q, (u8 *)&rmp); \ -} while(0); - +#define REPLY_MSG_ID_BASE cm->msg_id_base +#include /* List of message types that this plugin understands */ - #define foreach_ioam_cache_plugin_api_msg \ _(IOAM_CACHE_IP6_ENABLE_DISABLE, ioam_cache_ip6_enable_disable) diff --git a/src/plugins/ioam/lib-pot/pot_api.c b/src/plugins/ioam/lib-pot/pot_api.c index 04c2aaa5..cc1b7b76 100644 --- a/src/plugins/ioam/lib-pot/pot_api.c +++ b/src/plugins/ioam/lib-pot/pot_api.c @@ -51,47 +51,10 @@ #include #undef vl_api_version -/* - * A handy macro to set up a message reply. - * Assumes that the following variables are available: - * mp - pointer to request message - * rmp - pointer to reply message type - * rv - return value - */ - -#define REPLY_MACRO(t) \ -do { \ - unix_shared_memory_queue_t * q = \ - vl_api_client_index_to_input_queue (mp->client_index); \ - if (!q) \ - return; \ - \ - rmp = vl_msg_api_alloc (sizeof (*rmp)); \ - rmp->_vl_msg_id = ntohs((t)+sm->msg_id_base); \ - rmp->context = mp->context; \ - rmp->retval = ntohl(rv); \ - \ - vl_msg_api_send_shmem (q, (u8 *)&rmp); \ -} while(0); - -#define REPLY_MACRO2(t, body) \ -do { \ - unix_shared_memory_queue_t * q; \ - rv = vl_msg_api_pd_handler (mp, rv); \ - q = vl_api_client_index_to_input_queue (mp->client_index); \ - if (!q) \ - return; \ - \ - rmp = vl_msg_api_alloc (sizeof (*rmp)); \ - rmp->_vl_msg_id = ntohs((t)+sm->msg_id_base); \ - rmp->context = mp->context; \ - rmp->retval = ntohl(rv); \ - do {body;} while (0); \ - vl_msg_api_send_shmem (q, (u8 *)&rmp); \ -} while(0); +#define REPLY_MSG_ID_BASE sm->msg_id_base +#include /* List of message types that this plugin understands */ - #define foreach_pot_plugin_api_msg \ _(POT_PROFILE_ADD, pot_profile_add) \ _(POT_PROFILE_ACTIVATE, pot_profile_activate) \ diff --git a/src/plugins/ioam/udp-ping/udp_ping_api.c b/src/plugins/ioam/udp-ping/udp_ping_api.c index 8cb8cc96..6e5ef61e 100644 --- a/src/plugins/ioam/udp-ping/udp_ping_api.c +++ b/src/plugins/ioam/udp-ping/udp_ping_api.c @@ -51,47 +51,10 @@ #include #undef vl_api_version -/* - * A handy macro to set up a message reply. - * Assumes that the following variables are available: - * mp - pointer to request message - * rmp - pointer to reply message type - * rv - return value - */ - -#define REPLY_MACRO(t) \ - do { \ - unix_shared_memory_queue_t * q = \ - vl_api_client_index_to_input_queue (mp->client_index); \ - if (!q) \ - return; \ - \ - rmp = vl_msg_api_alloc (sizeof (*rmp)); \ - rmp->_vl_msg_id = ntohs((t)+sm->msg_id_base); \ - rmp->context = mp->context; \ - rmp->retval = ntohl(rv); \ - \ - vl_msg_api_send_shmem (q, (u8 *)&rmp); \ - } while(0); - -#define REPLY_MACRO2(t, body) \ - do { \ - unix_shared_memory_queue_t * q; \ - rv = vl_msg_api_pd_handler (mp, rv); \ - q = vl_api_client_index_to_input_queue (mp->client_index); \ - if (!q) \ - return; \ - \ - rmp = vl_msg_api_alloc (sizeof (*rmp)); \ - rmp->_vl_msg_id = ntohs((t)); \ - rmp->context = mp->context; \ - rmp->retval = ntohl(rv); \ - do {body;} while (0); \ - vl_msg_api_send_shmem (q, (u8 *)&rmp); \ - } while(0); +#define REPLY_MSG_ID_BASE sm->msg_id_base +#include /* List of message types that this module understands */ - #define foreach_udp_ping_api_msg \ _(UDP_PING_ADD_DEL_REQ, udp_ping_add_del_req) \ _(UDP_PING_EXPORT_REQ, udp_ping_export_req) \ diff --git a/src/plugins/lb/api.c b/src/plugins/lb/api.c index 06c53fa1..9e3bcd65 100644 --- a/src/plugins/lb/api.c +++ b/src/plugins/lb/api.c @@ -51,6 +51,10 @@ typedef enum { #include #undef vl_msg_name_crc_list + +#define REPLY_MSG_ID_BASE lbm->msg_id_base +#include + static void setup_message_id_table (lb_main_t * lbm, api_main_t * am) { @@ -67,29 +71,6 @@ setup_message_id_table (lb_main_t * lbm, api_main_t * am) vec_free (s); \ return handle; -/* - * A handy macro to set up a message reply. - * Assumes that the following variables are available: - * mp - pointer to request message - * rmp - pointer to reply message type - * rv - return value - */ - -#define REPLY_MACRO(t) \ -do { \ - unix_shared_memory_queue_t * q = \ - vl_api_client_index_to_input_queue (mp->client_index); \ - if (!q) \ - return; \ - \ - rmp = vl_msg_api_alloc (sizeof (*rmp)); \ - rmp->_vl_msg_id = ntohs((t)+lbm->msg_id_base); \ - rmp->context = mp->context; \ - rmp->retval = ntohl(rv); \ - \ - vl_msg_api_send_shmem (q, (u8 *)&rmp); \ -} while(0); - static void vl_api_lb_conf_t_handler (vl_api_lb_conf_t * mp) diff --git a/src/plugins/snat/snat.c b/src/plugins/snat/snat.c index 57274bbe..d42303f6 100644 --- a/src/plugins/snat/snat.c +++ b/src/plugins/snat/snat.c @@ -47,7 +47,7 @@ snat_main_t snat_main; #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) -#define REPLY_MSG_ID_BASE (sm->msg_id_base) +#define REPLY_MSG_ID_BASE sm->msg_id_base #include /* Get the API version number */ diff --git a/src/vlibapi/api_helper_macros.h b/src/vlibapi/api_helper_macros.h index aacea7c1..a492c3f4 100644 --- a/src/vlibapi/api_helper_macros.h +++ b/src/vlibapi/api_helper_macros.h @@ -36,7 +36,7 @@ do { \ return; \ \ rmp = vl_msg_api_alloc (sizeof (*rmp)); \ - rmp->_vl_msg_id = htons((t)+REPLY_MSG_ID_BASE); \ + rmp->_vl_msg_id = htons((t)+(REPLY_MSG_ID_BASE)); \ rmp->context = mp->context; \ rmp->retval = ntohl(rv); \ \ @@ -52,7 +52,7 @@ do { \ return; \ \ rmp = vl_msg_api_alloc (sizeof (*rmp)); \ - rmp->_vl_msg_id = htons((t)+REPLY_MSG_ID_BASE); \ + rmp->_vl_msg_id = htons((t)+(REPLY_MSG_ID_BASE)); \ rmp->context = mp->context; \ rmp->retval = ntohl(rv); \ do {body;} while (0); \ @@ -68,7 +68,7 @@ do { \ return; \ \ rmp = vl_msg_api_alloc (sizeof (*rmp) + n); \ - rmp->_vl_msg_id = htons((t)+REPLY_MSG_ID_BASE); \ + rmp->_vl_msg_id = htons((t)+(REPLY_MSG_ID_BASE)); \ rmp->context = mp->context; \ rmp->retval = ntohl(rv); \ do {body;} while (0); \ @@ -97,7 +97,7 @@ do { \ rv = VNET_API_ERROR_TABLE_TOO_BIG; \ is_error = 1; \ } \ - rmp->_vl_msg_id = htons((t)+REPLY_MSG_ID_BASE); \ + rmp->_vl_msg_id = htons((t)+(REPLY_MSG_ID_BASE)); \ rmp->context = mp->context; \ rmp->retval = ntohl(rv); \ if (!is_error) \ -- cgit 1.2.3-korg From 1bfb0ddace3ebb9010275e4bdd847c8c493ff4b3 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Wed, 22 Mar 2017 11:08:39 +0100 Subject: vlib: add description field in plugin registration Change-Id: I88b322a5d602f3d6d3310e971479180a89430e0e Signed-off-by: Damjan Marion --- src/examples/sample-plugin/sample/sample.c | 1 + src/plugins/acl/acl.c | 1 + src/plugins/dpdk/main.c | 1 + src/plugins/flowperpkt/flowperpkt.c | 1 + src/plugins/ila/ila.c | 1 + src/plugins/ioam/encap/ip6_ioam_trace.c | 1 + src/plugins/ixge/ixge.c | 1 + src/plugins/lb/lb.c | 1 + src/plugins/sixrd/sixrd.c | 3 ++- src/plugins/snat/snat.c | 1 + src/vlib/unix/plugin.c | 14 +++++++++----- src/vlib/unix/plugin.h | 1 + 12 files changed, 21 insertions(+), 6 deletions(-) (limited to 'src/plugins/lb') diff --git a/src/examples/sample-plugin/sample/sample.c b/src/examples/sample-plugin/sample/sample.c index 01852746..2f8ac4c9 100644 --- a/src/examples/sample-plugin/sample/sample.c +++ b/src/examples/sample-plugin/sample/sample.c @@ -61,6 +61,7 @@ _(SAMPLE_MACSWAP_ENABLE_DISABLE, sample_macswap_enable_disable) /* *INDENT-OFF* */ VLIB_PLUGIN_REGISTER () = { .version = SAMPLE_PLUGIN_BUILD_VER, + .description = "Sample of VPP Plugin", }; /* *INDENT-ON* */ diff --git a/src/plugins/acl/acl.c b/src/plugins/acl/acl.c index 476fbc33..4a4dd434 100644 --- a/src/plugins/acl/acl.c +++ b/src/plugins/acl/acl.c @@ -80,6 +80,7 @@ _(MACIP_ACL_INTERFACE_GET, macip_acl_interface_get) /* *INDENT-OFF* */ VLIB_PLUGIN_REGISTER () = { .version = VPP_BUILD_VER, + .description = "Access Control Lists", }; /* *INDENT-ON* */ diff --git a/src/plugins/dpdk/main.c b/src/plugins/dpdk/main.c index 8073a50a..7ee2a785 100644 --- a/src/plugins/dpdk/main.c +++ b/src/plugins/dpdk/main.c @@ -91,5 +91,6 @@ VLIB_INIT_FUNCTION (dpdk_main_init); /* *INDENT-OFF* */ VLIB_PLUGIN_REGISTER () = { .version = VPP_BUILD_VER, + .description = "Data Plane Development Kit (DPDK)", }; /* *INDENT-ON* */ diff --git a/src/plugins/flowperpkt/flowperpkt.c b/src/plugins/flowperpkt/flowperpkt.c index 587972f7..3e5fc8b0 100644 --- a/src/plugins/flowperpkt/flowperpkt.c +++ b/src/plugins/flowperpkt/flowperpkt.c @@ -448,6 +448,7 @@ _(FLOWPERPKT_TX_INTERFACE_ADD_DEL, flowperpkt_tx_interface_add_del) /* *INDENT-OFF* */ VLIB_PLUGIN_REGISTER () = { .version = VPP_BUILD_VER, + .description = "Flow per Packet", }; /* *INDENT-ON* */ diff --git a/src/plugins/ila/ila.c b/src/plugins/ila/ila.c index 52c7ea55..edbf3017 100644 --- a/src/plugins/ila/ila.c +++ b/src/plugins/ila/ila.c @@ -825,6 +825,7 @@ ila_interface (u32 sw_if_index, u8 disable) /* *INDENT-OFF* */ VLIB_PLUGIN_REGISTER () = { .version = VPP_BUILD_VER, + .description = "Identifier-locator addressing for IPv6", }; /* *INDENT-ON* */ diff --git a/src/plugins/ioam/encap/ip6_ioam_trace.c b/src/plugins/ioam/encap/ip6_ioam_trace.c index 57d3ec5d..299ee88f 100644 --- a/src/plugins/ioam/encap/ip6_ioam_trace.c +++ b/src/plugins/ioam/encap/ip6_ioam_trace.c @@ -411,6 +411,7 @@ VLIB_CLI_COMMAND (ip6_show_ioam_trace_cmd, static) = { /* *INDENT-OFF* */ VLIB_PLUGIN_REGISTER () = { .version = VPP_BUILD_VER, + .description = "Inbound OAM", }; /* *INDENT-ON* */ diff --git a/src/plugins/ixge/ixge.c b/src/plugins/ixge/ixge.c index 4eebc457..f3c5cc09 100644 --- a/src/plugins/ixge/ixge.c +++ b/src/plugins/ixge/ixge.c @@ -2935,6 +2935,7 @@ ixge_set_next_node (ixge_rx_next_t next, char *name) VLIB_PLUGIN_REGISTER () = { .version = VPP_BUILD_VER, .default_disabled = 1, + .description = "Intel 82599 Family Native Driver (experimental)", }; /* *INDENT-ON* */ diff --git a/src/plugins/lb/lb.c b/src/plugins/lb/lb.c index dc3f5be1..add81236 100644 --- a/src/plugins/lb/lb.c +++ b/src/plugins/lb/lb.c @@ -734,6 +734,7 @@ int lb_vip_del(u32 vip_index) /* *INDENT-OFF* */ VLIB_PLUGIN_REGISTER () = { .version = VPP_BUILD_VER, + .description = "Load Balancer", }; /* *INDENT-ON* */ diff --git a/src/plugins/sixrd/sixrd.c b/src/plugins/sixrd/sixrd.c index 67a9a3ad..98387525 100644 --- a/src/plugins/sixrd/sixrd.c +++ b/src/plugins/sixrd/sixrd.c @@ -356,8 +356,9 @@ VLIB_CLI_COMMAND(show_sixrd_stats_command, static) = { }; /* *INDENT-OFF* */ -VLIB_PLUGIN_REGISTER () = { +VLIB_PLUGIN_REGISTER () ={ .version = VPP_BUILD_VER, + .description = "IPv6 Rapid Deployment on IPv4 Infrastructure (RFC5969)", }; /* *INDENT-ON* */ diff --git a/src/plugins/snat/snat.c b/src/plugins/snat/snat.c index d42303f6..70b6a6e2 100644 --- a/src/plugins/snat/snat.c +++ b/src/plugins/snat/snat.c @@ -107,6 +107,7 @@ VNET_FEATURE_INIT (ip4_snat_out2in_fast, static) = { /* *INDENT-OFF* */ VLIB_PLUGIN_REGISTER () = { .version = VPP_BUILD_VER, + .description = "Network Address Translation", }; /* *INDENT-ON* */ diff --git a/src/vlib/unix/plugin.c b/src/vlib/unix/plugin.c index e9846e3b..9b341cc8 100644 --- a/src/vlib/unix/plugin.c +++ b/src/vlib/unix/plugin.c @@ -105,13 +105,13 @@ load_one_plugin (plugin_main_t * pm, plugin_info_t * pi, int from_early_init) } if (reg->default_disabled && pc->is_enabled == 0) { - clib_warning ("Plugin disabled: %s (default)", pi->name); + clib_warning ("Plugin disabled (default): %s", pi->name); goto error; } } else if (reg->default_disabled) { - clib_warning ("Plugin disabled: %s (default)", pi->name); + clib_warning ("Plugin disabled (default): %s", pi->name); goto error; } @@ -184,7 +184,10 @@ load_one_plugin (plugin_main_t * pm, plugin_info_t * pi, int from_early_init) (char *) pi->name, reg->early_init); } - clib_warning ("Loaded plugin: %s", pi->name); + if (reg->description) + clib_warning ("Loaded plugin: %s (%s)", pi->name, reg->description); + else + clib_warning ("Loaded plugin: %s", pi->name); return 0; error: @@ -374,7 +377,7 @@ vlib_plugins_show_cmd_fn (vlib_main_t * vm, plugin_info_t *pi; s = format (s, " Plugin path is: %s\n\n", pm->plugin_path); - s = format (s, " %-41s%s\n", "Plugin", "Version"); + s = format (s, " %-41s%-33s%s\n", "Plugin", "Version", "Description"); /* *INDENT-OFF* */ hash_foreach_mem (key, value, pm->plugin_by_name_hash, @@ -382,7 +385,8 @@ vlib_plugins_show_cmd_fn (vlib_main_t * vm, if (key != 0) { pi = vec_elt_at_index (pm->plugin_info, value); - s = format (s, "%3d. %-40s %s\n", index, key, pi->version); + s = format (s, "%3d. %-40s %-32s %s\n", index, key, pi->version, + pi->reg->description ? pi->reg->description : ""); index++; } }); diff --git a/src/vlib/unix/plugin.h b/src/vlib/unix/plugin.h index 01fec356..d9801ec4 100644 --- a/src/vlib/unix/plugin.h +++ b/src/vlib/unix/plugin.h @@ -62,6 +62,7 @@ typedef CLIB_PACKED(struct { const char version[32]; const char version_required[32]; const char *early_init; + const char *description; }) vlib_plugin_registration_t; /* *INDENT-ON* */ -- cgit 1.2.3-korg From 586afd762bfa149f5ca167bd5fd5a0cd59ce94fe Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Wed, 5 Apr 2017 19:18:20 +0200 Subject: Use thread local storage for thread index This patch deprecates stack-based thread identification, Also removes requirement that thread stacks are adjacent. Finally, possibly annoying for some folks, it renames all occurences of cpu_index and cpu_number with thread index. Using word "cpu" is misleading here as thread can be migrated ti different CPU, and also it is not related to linux cpu index. Change-Id: I68cdaf661e701d2336fc953dcb9978d10a70f7c1 Signed-off-by: Damjan Marion --- src/examples/srv6-sample-localsid/node.c | 4 +- src/plugins/dpdk/buffer.c | 2 +- src/plugins/dpdk/device/device.c | 8 +- src/plugins/dpdk/device/dpdk_priv.h | 8 +- src/plugins/dpdk/device/init.c | 2 +- src/plugins/dpdk/device/node.c | 32 +++--- src/plugins/dpdk/hqos/hqos.c | 16 +-- src/plugins/dpdk/ipsec/cli.c | 8 +- src/plugins/dpdk/ipsec/crypto_node.c | 4 +- src/plugins/dpdk/ipsec/esp.h | 4 +- src/plugins/dpdk/ipsec/esp_decrypt.c | 4 +- src/plugins/dpdk/ipsec/esp_encrypt.c | 5 +- src/plugins/dpdk/ipsec/ipsec.c | 2 +- src/plugins/dpdk/ipsec/ipsec.h | 4 +- src/plugins/dpdk/main.c | 2 +- src/plugins/flowperpkt/l2_node.c | 2 +- src/plugins/flowperpkt/node.c | 2 +- src/plugins/ioam/export-common/ioam_export.h | 6 +- .../ioam/ip6/ioam_cache_tunnel_select_node.c | 16 +-- src/plugins/ixge/ixge.c | 2 +- src/plugins/lb/lb.c | 8 +- src/plugins/lb/node.c | 22 ++-- src/plugins/lb/refcount.c | 8 +- src/plugins/lb/refcount.h | 4 +- src/plugins/memif/node.c | 35 +++--- src/plugins/snat/in2out.c | 110 +++++++++--------- src/plugins/snat/out2in.c | 102 ++++++++--------- src/plugins/snat/snat.h | 10 +- src/vlib/buffer.c | 6 +- src/vlib/buffer_funcs.h | 4 +- src/vlib/cli.c | 6 +- src/vlib/counter.h | 16 +-- src/vlib/error.c | 2 +- src/vlib/global_funcs.h | 2 +- src/vlib/main.c | 14 +-- src/vlib/main.h | 2 +- src/vlib/node.c | 2 +- src/vlib/node.h | 6 +- src/vlib/node_funcs.h | 8 +- src/vlib/threads.c | 69 ++++------- src/vlib/threads.h | 21 ++-- src/vlib/unix/cj.c | 7 +- src/vlib/unix/cj.h | 2 +- src/vlib/unix/main.c | 43 +++---- src/vnet/adj/adj_l2.c | 4 +- src/vnet/adj/adj_midchain.c | 8 +- src/vnet/adj/adj_nsh.c | 4 +- src/vnet/classify/vnet_classify.c | 16 +-- src/vnet/cop/ip4_whitelist.c | 8 +- src/vnet/cop/ip6_whitelist.c | 8 +- src/vnet/devices/af_packet/node.c | 20 ++-- src/vnet/devices/devices.c | 61 +++++----- src/vnet/devices/devices.h | 18 +-- src/vnet/devices/netmap/node.c | 24 ++-- src/vnet/devices/ssvm/node.c | 6 +- src/vnet/devices/virtio/vhost-user.c | 127 +++++++++++---------- src/vnet/dpo/lookup_dpo.c | 20 ++-- src/vnet/dpo/replicate_dpo.c | 12 +- src/vnet/ethernet/arp.c | 2 +- src/vnet/ethernet/interface.c | 7 +- src/vnet/ethernet/node.c | 14 +-- src/vnet/gre/node.c | 8 +- src/vnet/interface.h | 2 +- src/vnet/interface_output.c | 53 ++++----- src/vnet/ip/ip4_forward.c | 34 +++--- src/vnet/ip/ip4_input.c | 8 +- src/vnet/ip/ip6_forward.c | 24 ++-- src/vnet/ip/ip6_input.c | 8 +- src/vnet/ip/ip6_neighbor.c | 4 +- src/vnet/ipsec/esp.h | 8 +- src/vnet/ipsec/esp_decrypt.c | 13 ++- src/vnet/ipsec/esp_encrypt.c | 13 ++- src/vnet/ipsec/ikev2.c | 64 ++++++----- src/vnet/ipsec/ipsec.h | 12 +- src/vnet/ipsec/ipsec_if.c | 2 +- src/vnet/l2/l2_bvi.h | 2 +- src/vnet/l2/l2_input.c | 14 +-- src/vnet/l2/l2_output.c | 6 +- src/vnet/l2tp/decap.c | 2 +- src/vnet/l2tp/encap.c | 2 +- src/vnet/l2tp/l2tp.c | 6 +- src/vnet/lisp-gpe/decap.c | 16 +-- src/vnet/lldp/lldp_input.c | 2 +- src/vnet/map/ip4_map.c | 14 +-- src/vnet/map/ip4_map_t.c | 12 +- src/vnet/map/ip6_map.c | 19 +-- src/vnet/map/ip6_map_t.c | 12 +- src/vnet/mpls/mpls_input.c | 8 +- src/vnet/mpls/mpls_lookup.c | 20 ++-- src/vnet/mpls/mpls_output.c | 10 +- src/vnet/pg/input.c | 4 +- src/vnet/replication.c | 20 ++-- src/vnet/replication.h | 2 +- src/vnet/session/node.c | 2 +- src/vnet/sr/sr_localsid.c | 44 +++---- src/vnet/tcp/builtin_client.c | 2 +- src/vnet/tcp/tcp.c | 8 +- src/vnet/tcp/tcp_debug.h | 2 +- src/vnet/tcp/tcp_input.c | 10 +- src/vnet/tcp/tcp_output.c | 20 ++-- src/vnet/udp/udp_input.c | 2 +- src/vnet/unix/tapcli.c | 2 +- src/vnet/unix/tuntap.c | 4 +- src/vnet/vxlan-gpe/decap.c | 10 +- src/vnet/vxlan-gpe/encap.c | 12 +- src/vnet/vxlan/decap.c | 10 +- src/vnet/vxlan/encap.c | 12 +- src/vpp/stats/stats.c | 14 +-- src/vpp/stats/stats.h | 2 +- 109 files changed, 790 insertions(+), 791 deletions(-) (limited to 'src/plugins/lb') diff --git a/src/examples/srv6-sample-localsid/node.c b/src/examples/srv6-sample-localsid/node.c index 7bae9cd7..e83e2352 100644 --- a/src/examples/srv6-sample-localsid/node.c +++ b/src/examples/srv6-sample-localsid/node.c @@ -114,7 +114,7 @@ srv6_localsid_sample_fn (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_fram from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; next_index = node->cached_next_index; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); while (n_left_from > 0) { @@ -168,7 +168,7 @@ srv6_localsid_sample_fn (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_fram /* This increments the SRv6 per LocalSID counters.*/ vlib_increment_combined_counter (((next0 == SRV6_SAMPLE_LOCALSID_NEXT_ERROR) ? &(sm->sr_ls_invalid_counters) : &(sm->sr_ls_valid_counters)), - cpu_index, + thread_index, ls0 - sm->localsids, 1, vlib_buffer_length_in_chain (vm, b0)); diff --git a/src/plugins/dpdk/buffer.c b/src/plugins/dpdk/buffer.c index 2765c292..c80b3fa8 100644 --- a/src/plugins/dpdk/buffer.c +++ b/src/plugins/dpdk/buffer.c @@ -132,7 +132,7 @@ dpdk_buffer_delete_free_list (vlib_main_t * vm, u32 free_list_index) u32 merge_index; int i; - ASSERT (os_get_cpu_number () == 0); + ASSERT (vlib_get_thread_index () == 0); f = vlib_buffer_get_free_list (vm, free_list_index); diff --git a/src/plugins/dpdk/device/device.c b/src/plugins/dpdk/device/device.c index 50b26689..91661246 100644 --- a/src/plugins/dpdk/device/device.c +++ b/src/plugins/dpdk/device/device.c @@ -243,7 +243,7 @@ static_always_inline ASSERT (ring->tx_tail == 0); n_retry = 16; - queue_id = vm->cpu_index; + queue_id = vm->thread_index; do { @@ -266,7 +266,7 @@ static_always_inline { /* no wrap, transmit in one burst */ dpdk_device_hqos_per_worker_thread_t *hqos = - &xd->hqos_wt[vm->cpu_index]; + &xd->hqos_wt[vm->thread_index]; ASSERT (hqos->swq != NULL); @@ -332,7 +332,7 @@ dpdk_buffer_recycle (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_buffer_t * b, u32 bi, struct rte_mbuf **mbp) { dpdk_main_t *dm = &dpdk_main; - u32 my_cpu = vm->cpu_index; + u32 my_cpu = vm->thread_index; struct rte_mbuf *mb_new; if (PREDICT_FALSE (b->flags & VLIB_BUFFER_RECYCLE) == 0) @@ -376,7 +376,7 @@ dpdk_interface_tx (vlib_main_t * vm, tx_ring_hdr_t *ring; u32 n_on_ring; - my_cpu = vm->cpu_index; + my_cpu = vm->thread_index; queue_id = my_cpu; diff --git a/src/plugins/dpdk/device/dpdk_priv.h b/src/plugins/dpdk/device/dpdk_priv.h index dd40ff48..52b4ca4b 100644 --- a/src/plugins/dpdk/device/dpdk_priv.h +++ b/src/plugins/dpdk/device/dpdk_priv.h @@ -79,7 +79,7 @@ dpdk_update_counters (dpdk_device_t * xd, f64 now) { vlib_simple_counter_main_t *cm; vnet_main_t *vnm = vnet_get_main (); - u32 my_cpu = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); u64 rxerrors, last_rxerrors; /* only update counters for PMD interfaces */ @@ -96,7 +96,7 @@ dpdk_update_counters (dpdk_device_t * xd, f64 now) cm = vec_elt_at_index (vnm->interface_main.sw_if_counters, VNET_INTERFACE_COUNTER_RX_NO_BUF); - vlib_increment_simple_counter (cm, my_cpu, xd->vlib_sw_if_index, + vlib_increment_simple_counter (cm, thread_index, xd->vlib_sw_if_index, xd->stats.rx_nombuf - xd->last_stats.rx_nombuf); } @@ -107,7 +107,7 @@ dpdk_update_counters (dpdk_device_t * xd, f64 now) cm = vec_elt_at_index (vnm->interface_main.sw_if_counters, VNET_INTERFACE_COUNTER_RX_MISS); - vlib_increment_simple_counter (cm, my_cpu, xd->vlib_sw_if_index, + vlib_increment_simple_counter (cm, thread_index, xd->vlib_sw_if_index, xd->stats.imissed - xd->last_stats.imissed); } @@ -119,7 +119,7 @@ dpdk_update_counters (dpdk_device_t * xd, f64 now) cm = vec_elt_at_index (vnm->interface_main.sw_if_counters, VNET_INTERFACE_COUNTER_RX_ERROR); - vlib_increment_simple_counter (cm, my_cpu, xd->vlib_sw_if_index, + vlib_increment_simple_counter (cm, thread_index, xd->vlib_sw_if_index, rxerrors - last_rxerrors); } diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c index 538db6cb..7eaf8da7 100755 --- a/src/plugins/dpdk/device/init.c +++ b/src/plugins/dpdk/device/init.c @@ -324,7 +324,7 @@ dpdk_port_setup (dpdk_main_t * dm, dpdk_device_t * xd) int rv; int j; - ASSERT (os_get_cpu_number () == 0); + ASSERT (vlib_get_thread_index () == 0); if (xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP) { diff --git a/src/plugins/dpdk/device/node.c b/src/plugins/dpdk/device/node.c index e740fd18..b10e0fad 100644 --- a/src/plugins/dpdk/device/node.c +++ b/src/plugins/dpdk/device/node.c @@ -283,7 +283,7 @@ dpdk_buffer_init_from_template (void *d0, void *d1, void *d2, void *d3, */ static_always_inline u32 dpdk_device_input (dpdk_main_t * dm, dpdk_device_t * xd, - vlib_node_runtime_t * node, u32 cpu_index, u16 queue_id, + vlib_node_runtime_t * node, u32 thread_index, u16 queue_id, int maybe_multiseg) { u32 n_buffers; @@ -294,7 +294,7 @@ dpdk_device_input (dpdk_main_t * dm, dpdk_device_t * xd, uword n_rx_bytes = 0; u32 n_trace, trace_cnt __attribute__ ((unused)); vlib_buffer_free_list_t *fl; - vlib_buffer_t *bt = vec_elt_at_index (dm->buffer_templates, cpu_index); + vlib_buffer_t *bt = vec_elt_at_index (dm->buffer_templates, thread_index); if ((xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP) == 0) return 0; @@ -306,7 +306,7 @@ dpdk_device_input (dpdk_main_t * dm, dpdk_device_t * xd, return 0; } - vec_reset_length (xd->d_trace_buffers[cpu_index]); + vec_reset_length (xd->d_trace_buffers[thread_index]); trace_cnt = n_trace = vlib_get_trace_count (vm, node); if (n_trace > 0) @@ -318,7 +318,7 @@ dpdk_device_input (dpdk_main_t * dm, dpdk_device_t * xd, { struct rte_mbuf *mb = xd->rx_vectors[queue_id][mb_index++]; vlib_buffer_t *b = vlib_buffer_from_rte_mbuf (mb); - vec_add1 (xd->d_trace_buffers[cpu_index], + vec_add1 (xd->d_trace_buffers[thread_index], vlib_get_buffer_index (vm, b)); } } @@ -546,20 +546,22 @@ dpdk_device_input (dpdk_main_t * dm, dpdk_device_t * xd, vlib_put_next_frame (vm, node, next_index, n_left_to_next); } - if (PREDICT_FALSE (vec_len (xd->d_trace_buffers[cpu_index]) > 0)) + if (PREDICT_FALSE (vec_len (xd->d_trace_buffers[thread_index]) > 0)) { - dpdk_rx_trace (dm, node, xd, queue_id, xd->d_trace_buffers[cpu_index], - vec_len (xd->d_trace_buffers[cpu_index])); - vlib_set_trace_count (vm, node, n_trace - - vec_len (xd->d_trace_buffers[cpu_index])); + dpdk_rx_trace (dm, node, xd, queue_id, + xd->d_trace_buffers[thread_index], + vec_len (xd->d_trace_buffers[thread_index])); + vlib_set_trace_count (vm, node, + n_trace - + vec_len (xd->d_trace_buffers[thread_index])); } vlib_increment_combined_counter (vnet_get_main ()->interface_main.combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - cpu_index, xd->vlib_sw_if_index, mb_index, n_rx_bytes); + thread_index, xd->vlib_sw_if_index, mb_index, n_rx_bytes); - vnet_device_increment_rx_packets (cpu_index, mb_index); + vnet_device_increment_rx_packets (thread_index, mb_index); return mb_index; } @@ -630,19 +632,19 @@ dpdk_input (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * f) dpdk_device_t *xd; uword n_rx_packets = 0; dpdk_device_and_queue_t *dq; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); /* * Poll all devices on this cpu for input/interrupts. */ /* *INDENT-OFF* */ - vec_foreach (dq, dm->devices_by_cpu[cpu_index]) + vec_foreach (dq, dm->devices_by_cpu[thread_index]) { xd = vec_elt_at_index(dm->devices, dq->device); if (xd->flags & DPDK_DEVICE_FLAG_MAYBE_MULTISEG) - n_rx_packets += dpdk_device_input (dm, xd, node, cpu_index, dq->queue_id, /* maybe_multiseg */ 1); + n_rx_packets += dpdk_device_input (dm, xd, node, thread_index, dq->queue_id, /* maybe_multiseg */ 1); else - n_rx_packets += dpdk_device_input (dm, xd, node, cpu_index, dq->queue_id, /* maybe_multiseg */ 0); + n_rx_packets += dpdk_device_input (dm, xd, node, thread_index, dq->queue_id, /* maybe_multiseg */ 0); } /* *INDENT-ON* */ diff --git a/src/plugins/dpdk/hqos/hqos.c b/src/plugins/dpdk/hqos/hqos.c index a288fca7..8b251beb 100644 --- a/src/plugins/dpdk/hqos/hqos.c +++ b/src/plugins/dpdk/hqos/hqos.c @@ -397,7 +397,7 @@ static_always_inline void dpdk_hqos_thread_internal_hqos_dbg_bypass (vlib_main_t * vm) { dpdk_main_t *dm = &dpdk_main; - u32 cpu_index = vm->cpu_index; + u32 thread_index = vm->thread_index; u32 dev_pos; dev_pos = 0; @@ -405,12 +405,12 @@ dpdk_hqos_thread_internal_hqos_dbg_bypass (vlib_main_t * vm) { vlib_worker_thread_barrier_check (); - u32 n_devs = vec_len (dm->devices_by_hqos_cpu[cpu_index]); + u32 n_devs = vec_len (dm->devices_by_hqos_cpu[thread_index]); if (dev_pos >= n_devs) dev_pos = 0; dpdk_device_and_queue_t *dq = - vec_elt_at_index (dm->devices_by_hqos_cpu[cpu_index], dev_pos); + vec_elt_at_index (dm->devices_by_hqos_cpu[thread_index], dev_pos); dpdk_device_t *xd = vec_elt_at_index (dm->devices, dq->device); dpdk_device_hqos_per_hqos_thread_t *hqos = xd->hqos_ht; @@ -479,7 +479,7 @@ static_always_inline void dpdk_hqos_thread_internal (vlib_main_t * vm) { dpdk_main_t *dm = &dpdk_main; - u32 cpu_index = vm->cpu_index; + u32 thread_index = vm->thread_index; u32 dev_pos; dev_pos = 0; @@ -487,7 +487,7 @@ dpdk_hqos_thread_internal (vlib_main_t * vm) { vlib_worker_thread_barrier_check (); - u32 n_devs = vec_len (dm->devices_by_hqos_cpu[cpu_index]); + u32 n_devs = vec_len (dm->devices_by_hqos_cpu[thread_index]); if (PREDICT_FALSE (n_devs == 0)) { dev_pos = 0; @@ -497,7 +497,7 @@ dpdk_hqos_thread_internal (vlib_main_t * vm) dev_pos = 0; dpdk_device_and_queue_t *dq = - vec_elt_at_index (dm->devices_by_hqos_cpu[cpu_index], dev_pos); + vec_elt_at_index (dm->devices_by_hqos_cpu[thread_index], dev_pos); dpdk_device_t *xd = vec_elt_at_index (dm->devices, dq->device); dpdk_device_hqos_per_hqos_thread_t *hqos = xd->hqos_ht; @@ -586,7 +586,7 @@ dpdk_hqos_thread (vlib_worker_thread_t * w) vm = vlib_get_main (); - ASSERT (vm->cpu_index == os_get_cpu_number ()); + ASSERT (vm->thread_index == vlib_get_thread_index ()); clib_time_init (&vm->clib_time); clib_mem_set_heap (w->thread_mheap); @@ -595,7 +595,7 @@ dpdk_hqos_thread (vlib_worker_thread_t * w) while (tm->worker_thread_release == 0) vlib_worker_thread_barrier_check (); - if (vec_len (dm->devices_by_hqos_cpu[vm->cpu_index]) == 0) + if (vec_len (dm->devices_by_hqos_cpu[vm->thread_index]) == 0) return clib_error ("current I/O TX thread does not have any devices assigned to it"); diff --git a/src/plugins/dpdk/ipsec/cli.c b/src/plugins/dpdk/ipsec/cli.c index cd0a6037..3ae8c9b8 100644 --- a/src/plugins/dpdk/ipsec/cli.c +++ b/src/plugins/dpdk/ipsec/cli.c @@ -42,8 +42,8 @@ dpdk_ipsec_show_mapping (vlib_main_t * vm, u16 detail_display) for (i = 0; i < tm->n_vlib_mains; i++) { uword key, data; - u32 cpu_index = vlib_mains[i]->cpu_index; - crypto_worker_main_t *cwm = &dcm->workers_main[cpu_index]; + u32 thread_index = vlib_mains[i]->thread_index; + crypto_worker_main_t *cwm = &dcm->workers_main[thread_index]; u8 *s = 0; if (skip_master) @@ -57,7 +57,7 @@ dpdk_ipsec_show_mapping (vlib_main_t * vm, u16 detail_display) i32 last_cdev = -1; crypto_qp_data_t *qpd; - s = format (s, "%u\t", cpu_index); + s = format (s, "%u\t", thread_index); /* *INDENT-OFF* */ vec_foreach (qpd, cwm->qp_data) @@ -95,7 +95,7 @@ dpdk_ipsec_show_mapping (vlib_main_t * vm, u16 detail_display) cap.sym.auth.algo = p_key->auth_algo; check_algo_is_supported (&cap, auth_str); vlib_cli_output (vm, "%u\t%10s\t%15s\t%3s\t%u\t%u\n", - vlib_mains[i]->cpu_index, cipher_str, auth_str, + vlib_mains[i]->thread_index, cipher_str, auth_str, p_key->is_outbound ? "out" : "in", cwm->qp_data[data].dev_id, cwm->qp_data[data].qp_id); diff --git a/src/plugins/dpdk/ipsec/crypto_node.c b/src/plugins/dpdk/ipsec/crypto_node.c index dc3452b2..a3c45902 100644 --- a/src/plugins/dpdk/ipsec/crypto_node.c +++ b/src/plugins/dpdk/ipsec/crypto_node.c @@ -171,9 +171,9 @@ static uword dpdk_crypto_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) { - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); dpdk_crypto_main_t *dcm = &dpdk_crypto_main; - crypto_worker_main_t *cwm = &dcm->workers_main[cpu_index]; + crypto_worker_main_t *cwm = &dcm->workers_main[thread_index]; crypto_qp_data_t *qpd; u32 n_deq = 0; diff --git a/src/plugins/dpdk/ipsec/esp.h b/src/plugins/dpdk/ipsec/esp.h index 320295b1..56f0c756 100644 --- a/src/plugins/dpdk/ipsec/esp.h +++ b/src/plugins/dpdk/ipsec/esp.h @@ -170,9 +170,9 @@ static_always_inline int create_sym_sess (ipsec_sa_t * sa, crypto_sa_session_t * sa_sess, u8 is_outbound) { - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); dpdk_crypto_main_t *dcm = &dpdk_crypto_main; - crypto_worker_main_t *cwm = &dcm->workers_main[cpu_index]; + crypto_worker_main_t *cwm = &dcm->workers_main[thread_index]; struct rte_crypto_sym_xform cipher_xform = { 0 }; struct rte_crypto_sym_xform auth_xform = { 0 }; struct rte_crypto_sym_xform *xfs; diff --git a/src/plugins/dpdk/ipsec/esp_decrypt.c b/src/plugins/dpdk/ipsec/esp_decrypt.c index 286e03f8..bab76e3b 100644 --- a/src/plugins/dpdk/ipsec/esp_decrypt.c +++ b/src/plugins/dpdk/ipsec/esp_decrypt.c @@ -88,7 +88,7 @@ dpdk_esp_decrypt_node_fn (vlib_main_t * vm, { u32 n_left_from, *from, *to_next, next_index; ipsec_main_t *im = &ipsec_main; - u32 cpu_index = os_get_cpu_number(); + u32 thread_index = vlib_get_thread_index(); dpdk_crypto_main_t * dcm = &dpdk_crypto_main; dpdk_esp_main_t * em = &dpdk_esp_main; u32 i; @@ -104,7 +104,7 @@ dpdk_esp_decrypt_node_fn (vlib_main_t * vm, return n_left_from; } - crypto_worker_main_t *cwm = vec_elt_at_index(dcm->workers_main, cpu_index); + crypto_worker_main_t *cwm = vec_elt_at_index(dcm->workers_main, thread_index); u32 n_qps = vec_len(cwm->qp_data); struct rte_crypto_op ** cops_to_enq[n_qps]; u32 n_cop_qp[n_qps], * bi_to_enq[n_qps]; diff --git a/src/plugins/dpdk/ipsec/esp_encrypt.c b/src/plugins/dpdk/ipsec/esp_encrypt.c index 5b03de73..f996d7df 100644 --- a/src/plugins/dpdk/ipsec/esp_encrypt.c +++ b/src/plugins/dpdk/ipsec/esp_encrypt.c @@ -93,7 +93,7 @@ dpdk_esp_encrypt_node_fn (vlib_main_t * vm, { u32 n_left_from, *from, *to_next, next_index; ipsec_main_t *im = &ipsec_main; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); dpdk_crypto_main_t *dcm = &dpdk_crypto_main; dpdk_esp_main_t *em = &dpdk_esp_main; u32 i; @@ -111,7 +111,8 @@ dpdk_esp_encrypt_node_fn (vlib_main_t * vm, return n_left_from; } - crypto_worker_main_t *cwm = vec_elt_at_index (dcm->workers_main, cpu_index); + crypto_worker_main_t *cwm = + vec_elt_at_index (dcm->workers_main, thread_index); u32 n_qps = vec_len (cwm->qp_data); struct rte_crypto_op **cops_to_enq[n_qps]; u32 n_cop_qp[n_qps], *bi_to_enq[n_qps]; diff --git a/src/plugins/dpdk/ipsec/ipsec.c b/src/plugins/dpdk/ipsec/ipsec.c index b0aaaaec..5d8f4fba 100644 --- a/src/plugins/dpdk/ipsec/ipsec.c +++ b/src/plugins/dpdk/ipsec/ipsec.c @@ -289,7 +289,7 @@ dpdk_ipsec_process (vlib_main_t * vm, vlib_node_runtime_t * rt, if (!map) { clib_warning ("unable to create hash table for worker %u", - vlib_mains[i]->cpu_index); + vlib_mains[i]->thread_index); goto error; } cwm->algo_qp_map = map; diff --git a/src/plugins/dpdk/ipsec/ipsec.h b/src/plugins/dpdk/ipsec/ipsec.h index 28bffc80..f0f793c0 100644 --- a/src/plugins/dpdk/ipsec/ipsec.h +++ b/src/plugins/dpdk/ipsec/ipsec.h @@ -95,8 +95,8 @@ static_always_inline void crypto_alloc_cops () { dpdk_crypto_main_t *dcm = &dpdk_crypto_main; - u32 cpu_index = os_get_cpu_number (); - crypto_worker_main_t *cwm = &dcm->workers_main[cpu_index]; + u32 thread_index = vlib_get_thread_index (); + crypto_worker_main_t *cwm = &dcm->workers_main[thread_index]; unsigned socket_id = rte_socket_id (); crypto_qp_data_t *qpd; diff --git a/src/plugins/dpdk/main.c b/src/plugins/dpdk/main.c index 7ee2a785..942b8b2d 100644 --- a/src/plugins/dpdk/main.c +++ b/src/plugins/dpdk/main.c @@ -39,7 +39,7 @@ rte_delay_us_override (unsigned us) * thread then do not intercept. (Must not be called from an * independent pthread). */ - if (os_get_cpu_number () == 0) + if (vlib_get_thread_index () == 0) { /* * We're in the vlib main thread or a vlib process. Make sure diff --git a/src/plugins/flowperpkt/l2_node.c b/src/plugins/flowperpkt/l2_node.c index 1c2f681e..fdaf81d1 100644 --- a/src/plugins/flowperpkt/l2_node.c +++ b/src/plugins/flowperpkt/l2_node.c @@ -102,7 +102,7 @@ add_to_flow_record_l2 (vlib_main_t * vm, u8 * src_mac, u8 * dst_mac, u16 ethertype, u64 timestamp, u16 length, int do_flush) { - u32 my_cpu_number = vm->cpu_index; + u32 my_cpu_number = vm->thread_index; flow_report_main_t *frm = &flow_report_main; ip4_header_t *ip; udp_header_t *udp; diff --git a/src/plugins/flowperpkt/node.c b/src/plugins/flowperpkt/node.c index f77f087d..0277682d 100644 --- a/src/plugins/flowperpkt/node.c +++ b/src/plugins/flowperpkt/node.c @@ -101,7 +101,7 @@ add_to_flow_record_ipv4 (vlib_main_t * vm, u32 src_address, u32 dst_address, u8 tos, u64 timestamp, u16 length, int do_flush) { - u32 my_cpu_number = vm->cpu_index; + u32 my_cpu_number = vm->thread_index; flow_report_main_t *frm = &flow_report_main; ip4_header_t *ip; udp_header_t *udp; diff --git a/src/plugins/ioam/export-common/ioam_export.h b/src/plugins/ioam/export-common/ioam_export.h index 2bf3fd54..9de0d13b 100644 --- a/src/plugins/ioam/export-common/ioam_export.h +++ b/src/plugins/ioam/export-common/ioam_export.h @@ -477,8 +477,8 @@ do { \ from = vlib_frame_vector_args (F); \ n_left_from = (F)->n_vectors; \ next_index = (N)->cached_next_index; \ - while (__sync_lock_test_and_set ((EM)->lockp[(VM)->cpu_index], 1)); \ - my_buf = ioam_export_get_my_buffer (EM, (VM)->cpu_index); \ + while (__sync_lock_test_and_set ((EM)->lockp[(VM)->thread_index], 1)); \ + my_buf = ioam_export_get_my_buffer (EM, (VM)->thread_index); \ my_buf->touched_at = vlib_time_now (VM); \ while (n_left_from > 0) \ { \ @@ -620,7 +620,7 @@ do { \ } \ vlib_node_increment_counter (VM, export_node.index, \ EXPORT_ERROR_RECORDED, pkts_recorded); \ - *(EM)->lockp[(VM)->cpu_index] = 0; \ + *(EM)->lockp[(VM)->thread_index] = 0; \ } while(0) #endif /* __included_ioam_export_h__ */ diff --git a/src/plugins/ioam/ip6/ioam_cache_tunnel_select_node.c b/src/plugins/ioam/ip6/ioam_cache_tunnel_select_node.c index a56dc040..0cf742c9 100644 --- a/src/plugins/ioam/ip6/ioam_cache_tunnel_select_node.c +++ b/src/plugins/ioam/ip6/ioam_cache_tunnel_select_node.c @@ -396,7 +396,7 @@ ip6_reset_ts_hbh_node_fn (vlib_main_t * vm, clib_net_to_host_u32 (tcp0->seq_number) + 1, no_of_responses, now, - vm->cpu_index, &pool_index0)) + vm->thread_index, &pool_index0)) { cache_ts_added++; } @@ -419,7 +419,7 @@ ip6_reset_ts_hbh_node_fn (vlib_main_t * vm, e2e = (ioam_e2e_cache_option_t *) ((u8 *) hbh0 + cm->rewrite_pool_index_offset); - e2e->pool_id = (u8) vm->cpu_index; + e2e->pool_id = (u8) vm->thread_index; e2e->pool_index = pool_index0; ioam_e2e_id_rewrite_handler ((ioam_e2e_id_option_t *) ((u8 *) e2e + @@ -455,7 +455,7 @@ ip6_reset_ts_hbh_node_fn (vlib_main_t * vm, clib_net_to_host_u32 (tcp1->seq_number) + 1, no_of_responses, now, - vm->cpu_index, &pool_index1)) + vm->thread_index, &pool_index1)) { cache_ts_added++; } @@ -479,7 +479,7 @@ ip6_reset_ts_hbh_node_fn (vlib_main_t * vm, e2e = (ioam_e2e_cache_option_t *) ((u8 *) hbh1 + cm->rewrite_pool_index_offset); - e2e->pool_id = (u8) vm->cpu_index; + e2e->pool_id = (u8) vm->thread_index; e2e->pool_index = pool_index1; ioam_e2e_id_rewrite_handler ((ioam_e2e_id_option_t *) ((u8 *) e2e + @@ -562,7 +562,7 @@ ip6_reset_ts_hbh_node_fn (vlib_main_t * vm, clib_net_to_host_u32 (tcp0->seq_number) + 1, no_of_responses, now, - vm->cpu_index, &pool_index0)) + vm->thread_index, &pool_index0)) { cache_ts_added++; } @@ -585,7 +585,7 @@ ip6_reset_ts_hbh_node_fn (vlib_main_t * vm, e2e = (ioam_e2e_cache_option_t *) ((u8 *) hbh0 + cm->rewrite_pool_index_offset); - e2e->pool_id = (u8) vm->cpu_index; + e2e->pool_id = (u8) vm->thread_index; e2e->pool_index = pool_index0; ioam_e2e_id_rewrite_handler ((ioam_e2e_id_option_t *) ((u8 *) e2e + @@ -701,7 +701,7 @@ expired_cache_ts_timer_callback (u32 * expired_timers) ioam_cache_main_t *cm = &ioam_cache_main; int i; u32 pool_index; - u32 thread_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); u32 count = 0; for (i = 0; i < vec_len (expired_timers); i++) @@ -724,7 +724,7 @@ ioam_cache_ts_timer_tick_node_fn (vlib_main_t * vm, vlib_frame_t * f) { ioam_cache_main_t *cm = &ioam_cache_main; - u32 my_thread_index = os_get_cpu_number (); + u32 my_thread_index = vlib_get_thread_index (); struct timespec ts, tsrem; tw_timer_expire_timers_16t_2w_512sl (&cm->timer_wheels[my_thread_index], diff --git a/src/plugins/ixge/ixge.c b/src/plugins/ixge/ixge.c index f3c5cc09..08f5b692 100644 --- a/src/plugins/ixge/ixge.c +++ b/src/plugins/ixge/ixge.c @@ -1887,7 +1887,7 @@ done: vlib_increment_combined_counter (vnet_main. interface_main.combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - 0 /* cpu_index */ , + 0 /* thread_index */ , xd->vlib_sw_if_index, n_packets, dq->rx.n_bytes); diff --git a/src/plugins/lb/lb.c b/src/plugins/lb/lb.c index add81236..addc2a42 100644 --- a/src/plugins/lb/lb.c +++ b/src/plugins/lb/lb.c @@ -63,11 +63,11 @@ u8 *format_lb_main (u8 * s, va_list * args) s = format(s, " #vips: %u\n", pool_elts(lbm->vips)); s = format(s, " #ass: %u\n", pool_elts(lbm->ass) - 1); - u32 cpu_index; - for(cpu_index = 0; cpu_index < tm->n_vlib_mains; cpu_index++ ) { - lb_hash_t *h = lbm->per_cpu[cpu_index].sticky_ht; + u32 thread_index; + for(thread_index = 0; thread_index < tm->n_vlib_mains; thread_index++ ) { + lb_hash_t *h = lbm->per_cpu[thread_index].sticky_ht; if (h) { - s = format(s, "core %d\n", cpu_index); + s = format(s, "core %d\n", thread_index); s = format(s, " timeout: %ds\n", h->timeout); s = format(s, " usage: %d / %d\n", lb_hash_elts(h, lb_hash_time_now(vlib_get_main())), lb_hash_size(h)); } diff --git a/src/plugins/lb/node.c b/src/plugins/lb/node.c index 8b763c53..3171148b 100644 --- a/src/plugins/lb/node.c +++ b/src/plugins/lb/node.c @@ -60,10 +60,10 @@ format_lb_trace (u8 * s, va_list * args) return s; } -lb_hash_t *lb_get_sticky_table(u32 cpu_index) +lb_hash_t *lb_get_sticky_table(u32 thread_index) { lb_main_t *lbm = &lb_main; - lb_hash_t *sticky_ht = lbm->per_cpu[cpu_index].sticky_ht; + lb_hash_t *sticky_ht = lbm->per_cpu[thread_index].sticky_ht; //Check if size changed if (PREDICT_FALSE(sticky_ht && (lbm->per_cpu_sticky_buckets != lb_hash_nbuckets(sticky_ht)))) { @@ -71,8 +71,8 @@ lb_hash_t *lb_get_sticky_table(u32 cpu_index) lb_hash_bucket_t *b; u32 i; lb_hash_foreach_entry(sticky_ht, b, i) { - vlib_refcount_add(&lbm->as_refcount, cpu_index, b->value[i], -1); - vlib_refcount_add(&lbm->as_refcount, cpu_index, 0, 1); + vlib_refcount_add(&lbm->as_refcount, thread_index, b->value[i], -1); + vlib_refcount_add(&lbm->as_refcount, thread_index, 0, 1); } lb_hash_free(sticky_ht); @@ -81,8 +81,8 @@ lb_hash_t *lb_get_sticky_table(u32 cpu_index) //Create if necessary if (PREDICT_FALSE(sticky_ht == NULL)) { - lbm->per_cpu[cpu_index].sticky_ht = lb_hash_alloc(lbm->per_cpu_sticky_buckets, lbm->flow_timeout); - sticky_ht = lbm->per_cpu[cpu_index].sticky_ht; + lbm->per_cpu[thread_index].sticky_ht = lb_hash_alloc(lbm->per_cpu_sticky_buckets, lbm->flow_timeout); + sticky_ht = lbm->per_cpu[thread_index].sticky_ht; clib_warning("Regenerated sticky table %p", sticky_ht); } @@ -153,10 +153,10 @@ lb_node_fn (vlib_main_t * vm, { lb_main_t *lbm = &lb_main; u32 n_left_from, *from, next_index, *to_next, n_left_to_next; - u32 cpu_index = os_get_cpu_number(); + u32 thread_index = vlib_get_thread_index(); u32 lb_time = lb_hash_time_now(vm); - lb_hash_t *sticky_ht = lb_get_sticky_table(cpu_index); + lb_hash_t *sticky_ht = lb_get_sticky_table(thread_index); from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; next_index = node->cached_next_index; @@ -240,9 +240,9 @@ lb_node_fn (vlib_main_t * vm, //Configuration may be changed, vectors resized, etc... //Dereference previously used - vlib_refcount_add(&lbm->as_refcount, cpu_index, + vlib_refcount_add(&lbm->as_refcount, thread_index, lb_hash_available_value(sticky_ht, hash0, available_index0), -1); - vlib_refcount_add(&lbm->as_refcount, cpu_index, + vlib_refcount_add(&lbm->as_refcount, thread_index, asindex0, 1); //Add sticky entry @@ -260,7 +260,7 @@ lb_node_fn (vlib_main_t * vm, } vlib_increment_simple_counter(&lbm->vip_counters[counter], - cpu_index, + thread_index, vnet_buffer (p0)->ip.adj_index[VLIB_TX], 1); diff --git a/src/plugins/lb/refcount.c b/src/plugins/lb/refcount.c index 22415c88..6f01ab5a 100644 --- a/src/plugins/lb/refcount.c +++ b/src/plugins/lb/refcount.c @@ -31,10 +31,10 @@ u64 vlib_refcount_get(vlib_refcount_t *r, u32 index) { u64 count = 0; vlib_thread_main_t *tm = vlib_get_thread_main (); - u32 cpu_index; - for (cpu_index = 0; cpu_index < tm->n_vlib_mains; cpu_index++) { - if (r->per_cpu[cpu_index].length > index) - count += r->per_cpu[cpu_index].counters[index]; + u32 thread_index; + for (thread_index = 0; thread_index < tm->n_vlib_mains; thread_index++) { + if (r->per_cpu[thread_index].length > index) + count += r->per_cpu[thread_index].counters[index]; } return count; } diff --git a/src/plugins/lb/refcount.h b/src/plugins/lb/refcount.h index 8c26e7be..dcfcb3fe 100644 --- a/src/plugins/lb/refcount.h +++ b/src/plugins/lb/refcount.h @@ -45,9 +45,9 @@ typedef struct { void __vlib_refcount_resize(vlib_refcount_per_cpu_t *per_cpu, u32 size); static_always_inline -void vlib_refcount_add(vlib_refcount_t *r, u32 cpu_index, u32 counter_index, i32 v) +void vlib_refcount_add(vlib_refcount_t *r, u32 thread_index, u32 counter_index, i32 v) { - vlib_refcount_per_cpu_t *per_cpu = &r->per_cpu[cpu_index]; + vlib_refcount_per_cpu_t *per_cpu = &r->per_cpu[thread_index]; if (PREDICT_FALSE(counter_index >= per_cpu->length)) __vlib_refcount_resize(per_cpu, clib_max(counter_index + 16, per_cpu->length * 2)); diff --git a/src/plugins/memif/node.c b/src/plugins/memif/node.c index 659d5dfb..cee1f3d1 100644 --- a/src/plugins/memif/node.c +++ b/src/plugins/memif/node.c @@ -94,7 +94,7 @@ memif_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, u32 n_rx_bytes = 0; u32 *to_next = 0; u32 n_free_bufs; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); u32 bi0, bi1; vlib_buffer_t *b0, *b1; u16 ring_size = 1 << mif->log2_ring_size; @@ -105,14 +105,15 @@ memif_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, if (mif->per_interface_next_index != ~0) next_index = mif->per_interface_next_index; - n_free_bufs = vec_len (nm->rx_buffers[cpu_index]); + n_free_bufs = vec_len (nm->rx_buffers[thread_index]); if (PREDICT_FALSE (n_free_bufs < ring_size)) { - vec_validate (nm->rx_buffers[cpu_index], ring_size + n_free_bufs - 1); + vec_validate (nm->rx_buffers[thread_index], + ring_size + n_free_bufs - 1); n_free_bufs += - vlib_buffer_alloc (vm, &nm->rx_buffers[cpu_index][n_free_bufs], + vlib_buffer_alloc (vm, &nm->rx_buffers[thread_index][n_free_bufs], ring_size); - _vec_len (nm->rx_buffers[cpu_index]) = n_free_bufs; + _vec_len (nm->rx_buffers[thread_index]) = n_free_bufs; } head = ring->head; @@ -158,15 +159,15 @@ memif_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, CLIB_CACHE_LINE_BYTES, LOAD); } /* get empty buffer */ - u32 last_buf = vec_len (nm->rx_buffers[cpu_index]) - 1; - bi0 = nm->rx_buffers[cpu_index][last_buf]; - bi1 = nm->rx_buffers[cpu_index][last_buf - 1]; - _vec_len (nm->rx_buffers[cpu_index]) -= 2; + u32 last_buf = vec_len (nm->rx_buffers[thread_index]) - 1; + bi0 = nm->rx_buffers[thread_index][last_buf]; + bi1 = nm->rx_buffers[thread_index][last_buf - 1]; + _vec_len (nm->rx_buffers[thread_index]) -= 2; if (last_buf > 4) { - memif_prefetch (vm, nm->rx_buffers[cpu_index][last_buf - 2]); - memif_prefetch (vm, nm->rx_buffers[cpu_index][last_buf - 3]); + memif_prefetch (vm, nm->rx_buffers[thread_index][last_buf - 2]); + memif_prefetch (vm, nm->rx_buffers[thread_index][last_buf - 3]); } /* enqueue buffer */ @@ -256,9 +257,9 @@ memif_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, while (num_slots && n_left_to_next) { /* get empty buffer */ - u32 last_buf = vec_len (nm->rx_buffers[cpu_index]) - 1; - bi0 = nm->rx_buffers[cpu_index][last_buf]; - _vec_len (nm->rx_buffers[cpu_index]) = last_buf; + u32 last_buf = vec_len (nm->rx_buffers[thread_index]) - 1; + bi0 = nm->rx_buffers[thread_index][last_buf]; + _vec_len (nm->rx_buffers[thread_index]) = last_buf; /* enqueue buffer */ to_next[0] = bi0; @@ -315,7 +316,7 @@ memif_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, ring->tail = head; vlib_increment_combined_counter (vnm->interface_main.combined_sw_if_counters - + VNET_INTERFACE_COUNTER_RX, cpu_index, + + VNET_INTERFACE_COUNTER_RX, thread_index, mif->hw_if_index, n_rx_packets, n_rx_bytes); @@ -327,7 +328,7 @@ memif_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) { u32 n_rx_packets = 0; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); memif_main_t *nm = &memif_main; memif_if_t *mif; @@ -337,7 +338,7 @@ memif_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, if (mif->flags & MEMIF_IF_FLAG_ADMIN_UP && mif->flags & MEMIF_IF_FLAG_CONNECTED && (mif->if_index % nm->input_cpu_count) == - (cpu_index - nm->input_cpu_first_index)) + (thread_index - nm->input_cpu_first_index)) { if (mif->flags & MEMIF_IF_FLAG_IS_SLAVE) n_rx_packets += diff --git a/src/plugins/snat/in2out.c b/src/plugins/snat/in2out.c index b4961365..e5ee965f 100644 --- a/src/plugins/snat/in2out.c +++ b/src/plugins/snat/in2out.c @@ -212,7 +212,7 @@ static u32 slow_path (snat_main_t *sm, vlib_buffer_t *b0, snat_session_t ** sessionp, vlib_node_runtime_t * node, u32 next0, - u32 cpu_index) + u32 thread_index) { snat_user_t *u; snat_user_key_t user_key; @@ -246,27 +246,27 @@ static u32 slow_path (snat_main_t *sm, vlib_buffer_t *b0, if (clib_bihash_search_8_8 (&sm->user_hash, &kv0, &value0)) { /* no, make a new one */ - pool_get (sm->per_thread_data[cpu_index].users, u); + pool_get (sm->per_thread_data[thread_index].users, u); memset (u, 0, sizeof (*u)); u->addr = ip0->src_address; u->fib_index = rx_fib_index0; - pool_get (sm->per_thread_data[cpu_index].list_pool, per_user_list_head_elt); + pool_get (sm->per_thread_data[thread_index].list_pool, per_user_list_head_elt); u->sessions_per_user_list_head_index = per_user_list_head_elt - - sm->per_thread_data[cpu_index].list_pool; + sm->per_thread_data[thread_index].list_pool; - clib_dlist_init (sm->per_thread_data[cpu_index].list_pool, + clib_dlist_init (sm->per_thread_data[thread_index].list_pool, u->sessions_per_user_list_head_index); - kv0.value = u - sm->per_thread_data[cpu_index].users; + kv0.value = u - sm->per_thread_data[thread_index].users; /* add user */ clib_bihash_add_del_8_8 (&sm->user_hash, &kv0, 1 /* is_add */); } else { - u = pool_elt_at_index (sm->per_thread_data[cpu_index].users, + u = pool_elt_at_index (sm->per_thread_data[thread_index].users, value0.value); } @@ -276,25 +276,25 @@ static u32 slow_path (snat_main_t *sm, vlib_buffer_t *b0, /* Remove the oldest dynamic translation */ do { oldest_per_user_translation_list_index = - clib_dlist_remove_head (sm->per_thread_data[cpu_index].list_pool, + clib_dlist_remove_head (sm->per_thread_data[thread_index].list_pool, u->sessions_per_user_list_head_index); ASSERT (oldest_per_user_translation_list_index != ~0); /* add it back to the end of the LRU list */ - clib_dlist_addtail (sm->per_thread_data[cpu_index].list_pool, + clib_dlist_addtail (sm->per_thread_data[thread_index].list_pool, u->sessions_per_user_list_head_index, oldest_per_user_translation_list_index); /* Get the list element */ oldest_per_user_translation_list_elt = - pool_elt_at_index (sm->per_thread_data[cpu_index].list_pool, + pool_elt_at_index (sm->per_thread_data[thread_index].list_pool, oldest_per_user_translation_list_index); /* Get the session index from the list element */ session_index = oldest_per_user_translation_list_elt->value; /* Get the session */ - s = pool_elt_at_index (sm->per_thread_data[cpu_index].sessions, + s = pool_elt_at_index (sm->per_thread_data[thread_index].sessions, session_index); } while (snat_is_session_static (s)); @@ -346,7 +346,7 @@ static u32 slow_path (snat_main_t *sm, vlib_buffer_t *b0, } /* Create a new session */ - pool_get (sm->per_thread_data[cpu_index].sessions, s); + pool_get (sm->per_thread_data[thread_index].sessions, s); memset (s, 0, sizeof (*s)); s->outside_address_index = address_index; @@ -362,22 +362,22 @@ static u32 slow_path (snat_main_t *sm, vlib_buffer_t *b0, } /* Create list elts */ - pool_get (sm->per_thread_data[cpu_index].list_pool, + pool_get (sm->per_thread_data[thread_index].list_pool, per_user_translation_list_elt); - clib_dlist_init (sm->per_thread_data[cpu_index].list_pool, + clib_dlist_init (sm->per_thread_data[thread_index].list_pool, per_user_translation_list_elt - - sm->per_thread_data[cpu_index].list_pool); + sm->per_thread_data[thread_index].list_pool); per_user_translation_list_elt->value = - s - sm->per_thread_data[cpu_index].sessions; + s - sm->per_thread_data[thread_index].sessions; s->per_user_index = per_user_translation_list_elt - - sm->per_thread_data[cpu_index].list_pool; + sm->per_thread_data[thread_index].list_pool; s->per_user_list_head_index = u->sessions_per_user_list_head_index; - clib_dlist_addtail (sm->per_thread_data[cpu_index].list_pool, + clib_dlist_addtail (sm->per_thread_data[thread_index].list_pool, s->per_user_list_head_index, per_user_translation_list_elt - - sm->per_thread_data[cpu_index].list_pool); + sm->per_thread_data[thread_index].list_pool); } s->in2out = *key0; @@ -388,12 +388,12 @@ static u32 slow_path (snat_main_t *sm, vlib_buffer_t *b0, /* Add to translation hashes */ kv0.key = s->in2out.as_u64; - kv0.value = s - sm->per_thread_data[cpu_index].sessions; + kv0.value = s - sm->per_thread_data[thread_index].sessions; if (clib_bihash_add_del_8_8 (&sm->in2out, &kv0, 1 /* is_add */)) clib_warning ("in2out key add failed"); kv0.key = s->out2in.as_u64; - kv0.value = s - sm->per_thread_data[cpu_index].sessions; + kv0.value = s - sm->per_thread_data[thread_index].sessions; if (clib_bihash_add_del_8_8 (&sm->out2in, &kv0, 1 /* is_add */)) clib_warning ("out2in key add failed"); @@ -403,7 +403,7 @@ static u32 slow_path (snat_main_t *sm, vlib_buffer_t *b0, worker_by_out_key.port = s->out2in.port; worker_by_out_key.fib_index = s->out2in.fib_index; kv0.key = worker_by_out_key.as_u64; - kv0.value = cpu_index; + kv0.value = thread_index; clib_bihash_add_del_8_8 (&sm->worker_by_out, &kv0, 1); /* log NAT event */ @@ -465,7 +465,7 @@ snat_in2out_error_t icmp_get_key(icmp46_header_t *icmp0, * * @param[in,out] sm SNAT main * @param[in,out] node SNAT node runtime - * @param[in] cpu_index CPU index + * @param[in] thread_index thread index * @param[in,out] b0 buffer containing packet to be translated * @param[out] p_key address and port before NAT translation * @param[out] p_value address and port after NAT translation @@ -473,7 +473,7 @@ snat_in2out_error_t icmp_get_key(icmp46_header_t *icmp0, * @param d optional parameter */ u32 icmp_match_in2out_slow(snat_main_t *sm, vlib_node_runtime_t *node, - u32 cpu_index, vlib_buffer_t *b0, + u32 thread_index, vlib_buffer_t *b0, snat_session_key_t *p_key, snat_session_key_t *p_value, u8 *p_dont_translate, void *d) @@ -524,13 +524,13 @@ u32 icmp_match_in2out_slow(snat_main_t *sm, vlib_node_runtime_t *node, } next0 = slow_path (sm, b0, ip0, rx_fib_index0, &key0, - &s0, node, next0, cpu_index); + &s0, node, next0, thread_index); if (PREDICT_FALSE (next0 == SNAT_IN2OUT_NEXT_DROP)) goto out; } else - s0 = pool_elt_at_index (sm->per_thread_data[cpu_index].sessions, + s0 = pool_elt_at_index (sm->per_thread_data[thread_index].sessions, value0.value); out: @@ -548,7 +548,7 @@ out: * * @param[in] sm SNAT main * @param[in,out] node SNAT node runtime - * @param[in] cpu_index CPU index + * @param[in] thread_index thread index * @param[in,out] b0 buffer containing packet to be translated * @param[out] p_key address and port before NAT translation * @param[out] p_value address and port after NAT translation @@ -556,7 +556,7 @@ out: * @param d optional parameter */ u32 icmp_match_in2out_fast(snat_main_t *sm, vlib_node_runtime_t *node, - u32 cpu_index, vlib_buffer_t *b0, + u32 thread_index, vlib_buffer_t *b0, snat_session_key_t *p_key, snat_session_key_t *p_value, u8 *p_dont_translate, void *d) @@ -624,7 +624,7 @@ static inline u32 icmp_in2out (snat_main_t *sm, u32 rx_fib_index0, vlib_node_runtime_t * node, u32 next0, - u32 cpu_index, + u32 thread_index, void *d) { snat_session_key_t key0, sm0; @@ -641,7 +641,7 @@ static inline u32 icmp_in2out (snat_main_t *sm, echo0 = (icmp_echo_header_t *)(icmp0+1); - next0_tmp = sm->icmp_match_in2out_cb(sm, node, cpu_index, b0, + next0_tmp = sm->icmp_match_in2out_cb(sm, node, thread_index, b0, &key0, &sm0, &dont_translate, d); if (next0_tmp != ~0) next0 = next0_tmp; @@ -847,11 +847,11 @@ static inline u32 icmp_in2out_slow_path (snat_main_t *sm, vlib_node_runtime_t * node, u32 next0, f64 now, - u32 cpu_index, + u32 thread_index, snat_session_t ** p_s0) { next0 = icmp_in2out(sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node, - next0, cpu_index, p_s0); + next0, thread_index, p_s0); snat_session_t * s0 = *p_s0; if (PREDICT_TRUE(next0 != SNAT_IN2OUT_NEXT_DROP && s0)) { @@ -862,9 +862,9 @@ static inline u32 icmp_in2out_slow_path (snat_main_t *sm, /* Per-user LRU list maintenance for dynamic translations */ if (!snat_is_session_static (s0)) { - clib_dlist_remove (sm->per_thread_data[cpu_index].list_pool, + clib_dlist_remove (sm->per_thread_data[thread_index].list_pool, s0->per_user_index); - clib_dlist_addtail (sm->per_thread_data[cpu_index].list_pool, + clib_dlist_addtail (sm->per_thread_data[thread_index].list_pool, s0->per_user_list_head_index, s0->per_user_index); } @@ -884,7 +884,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm, snat_runtime_t * rt = (snat_runtime_t *)node->runtime_data; f64 now = vlib_time_now (vm); u32 stats_node_index; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); stats_node_index = is_slow_path ? snat_in2out_slowpath_node.index : snat_in2out_node.index; @@ -977,7 +977,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm, { next0 = icmp_in2out_slow_path (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, - node, next0, now, cpu_index, &s0); + node, next0, now, thread_index, &s0); goto trace00; } } @@ -1006,7 +1006,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm, goto trace00; next0 = slow_path (sm, b0, ip0, rx_fib_index0, &key0, - &s0, node, next0, cpu_index); + &s0, node, next0, thread_index); if (PREDICT_FALSE (next0 == SNAT_IN2OUT_NEXT_DROP)) goto trace00; } @@ -1017,7 +1017,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm, } } else - s0 = pool_elt_at_index (sm->per_thread_data[cpu_index].sessions, + s0 = pool_elt_at_index (sm->per_thread_data[thread_index].sessions, value0.value); old_addr0 = ip0->src_address.as_u32; @@ -1063,9 +1063,9 @@ snat_in2out_node_fn_inline (vlib_main_t * vm, /* Per-user LRU list maintenance for dynamic translation */ if (!snat_is_session_static (s0)) { - clib_dlist_remove (sm->per_thread_data[cpu_index].list_pool, + clib_dlist_remove (sm->per_thread_data[thread_index].list_pool, s0->per_user_index); - clib_dlist_addtail (sm->per_thread_data[cpu_index].list_pool, + clib_dlist_addtail (sm->per_thread_data[thread_index].list_pool, s0->per_user_list_head_index, s0->per_user_index); } @@ -1081,7 +1081,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm, t->next_index = next0; t->session_index = ~0; if (s0) - t->session_index = s0 - sm->per_thread_data[cpu_index].sessions; + t->session_index = s0 - sm->per_thread_data[thread_index].sessions; } pkts_processed += next0 != SNAT_IN2OUT_NEXT_DROP; @@ -1117,7 +1117,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm, { next1 = icmp_in2out_slow_path (sm, b1, ip1, icmp1, sw_if_index1, rx_fib_index1, node, - next1, now, cpu_index, &s1); + next1, now, thread_index, &s1); goto trace01; } } @@ -1146,7 +1146,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm, goto trace01; next1 = slow_path (sm, b1, ip1, rx_fib_index1, &key1, - &s1, node, next1, cpu_index); + &s1, node, next1, thread_index); if (PREDICT_FALSE (next1 == SNAT_IN2OUT_NEXT_DROP)) goto trace01; } @@ -1157,7 +1157,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm, } } else - s1 = pool_elt_at_index (sm->per_thread_data[cpu_index].sessions, + s1 = pool_elt_at_index (sm->per_thread_data[thread_index].sessions, value1.value); old_addr1 = ip1->src_address.as_u32; @@ -1203,9 +1203,9 @@ snat_in2out_node_fn_inline (vlib_main_t * vm, /* Per-user LRU list maintenance for dynamic translation */ if (!snat_is_session_static (s1)) { - clib_dlist_remove (sm->per_thread_data[cpu_index].list_pool, + clib_dlist_remove (sm->per_thread_data[thread_index].list_pool, s1->per_user_index); - clib_dlist_addtail (sm->per_thread_data[cpu_index].list_pool, + clib_dlist_addtail (sm->per_thread_data[thread_index].list_pool, s1->per_user_list_head_index, s1->per_user_index); } @@ -1220,7 +1220,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm, t->next_index = next1; t->session_index = ~0; if (s1) - t->session_index = s1 - sm->per_thread_data[cpu_index].sessions; + t->session_index = s1 - sm->per_thread_data[thread_index].sessions; } pkts_processed += next1 != SNAT_IN2OUT_NEXT_DROP; @@ -1292,7 +1292,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm, { next0 = icmp_in2out_slow_path (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node, - next0, now, cpu_index, &s0); + next0, now, thread_index, &s0); goto trace0; } } @@ -1321,7 +1321,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm, goto trace0; next0 = slow_path (sm, b0, ip0, rx_fib_index0, &key0, - &s0, node, next0, cpu_index); + &s0, node, next0, thread_index); if (PREDICT_FALSE (next0 == SNAT_IN2OUT_NEXT_DROP)) goto trace0; @@ -1333,7 +1333,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm, } } else - s0 = pool_elt_at_index (sm->per_thread_data[cpu_index].sessions, + s0 = pool_elt_at_index (sm->per_thread_data[thread_index].sessions, value0.value); old_addr0 = ip0->src_address.as_u32; @@ -1379,9 +1379,9 @@ snat_in2out_node_fn_inline (vlib_main_t * vm, /* Per-user LRU list maintenance for dynamic translation */ if (!snat_is_session_static (s0)) { - clib_dlist_remove (sm->per_thread_data[cpu_index].list_pool, + clib_dlist_remove (sm->per_thread_data[thread_index].list_pool, s0->per_user_index); - clib_dlist_addtail (sm->per_thread_data[cpu_index].list_pool, + clib_dlist_addtail (sm->per_thread_data[thread_index].list_pool, s0->per_user_list_head_index, s0->per_user_index); } @@ -1397,7 +1397,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm, t->next_index = next0; t->session_index = ~0; if (s0) - t->session_index = s0 - sm->per_thread_data[cpu_index].sessions; + t->session_index = s0 - sm->per_thread_data[thread_index].sessions; } pkts_processed += next0 != SNAT_IN2OUT_NEXT_DROP; @@ -2010,7 +2010,7 @@ snat_in2out_worker_handoff_fn (vlib_main_t * vm, u32 n_left_to_next_worker = 0, *to_next_worker = 0; u32 next_worker_index = 0; u32 current_worker_index = ~0; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); ASSERT (vec_len (sm->workers)); @@ -2048,7 +2048,7 @@ snat_in2out_worker_handoff_fn (vlib_main_t * vm, next_worker_index = sm->worker_in2out_cb(ip0, rx_fib_index0); - if (PREDICT_FALSE (next_worker_index != cpu_index)) + if (PREDICT_FALSE (next_worker_index != thread_index)) { do_handoff = 1; diff --git a/src/plugins/snat/out2in.c b/src/plugins/snat/out2in.c index 656e42db..5d308d78 100644 --- a/src/plugins/snat/out2in.c +++ b/src/plugins/snat/out2in.c @@ -129,7 +129,7 @@ create_session_for_static_mapping (snat_main_t *sm, snat_session_key_t in2out, snat_session_key_t out2in, vlib_node_runtime_t * node, - u32 cpu_index) + u32 thread_index) { snat_user_t *u; snat_user_key_t user_key; @@ -146,36 +146,36 @@ create_session_for_static_mapping (snat_main_t *sm, if (clib_bihash_search_8_8 (&sm->user_hash, &kv0, &value0)) { /* no, make a new one */ - pool_get (sm->per_thread_data[cpu_index].users, u); + pool_get (sm->per_thread_data[thread_index].users, u); memset (u, 0, sizeof (*u)); u->addr = in2out.addr; u->fib_index = in2out.fib_index; - pool_get (sm->per_thread_data[cpu_index].list_pool, + pool_get (sm->per_thread_data[thread_index].list_pool, per_user_list_head_elt); u->sessions_per_user_list_head_index = per_user_list_head_elt - - sm->per_thread_data[cpu_index].list_pool; + sm->per_thread_data[thread_index].list_pool; - clib_dlist_init (sm->per_thread_data[cpu_index].list_pool, + clib_dlist_init (sm->per_thread_data[thread_index].list_pool, u->sessions_per_user_list_head_index); - kv0.value = u - sm->per_thread_data[cpu_index].users; + kv0.value = u - sm->per_thread_data[thread_index].users; /* add user */ clib_bihash_add_del_8_8 (&sm->user_hash, &kv0, 1 /* is_add */); /* add non-traslated packets worker lookup */ - kv0.value = cpu_index; + kv0.value = thread_index; clib_bihash_add_del_8_8 (&sm->worker_by_in, &kv0, 1); } else { - u = pool_elt_at_index (sm->per_thread_data[cpu_index].users, + u = pool_elt_at_index (sm->per_thread_data[thread_index].users, value0.value); } - pool_get (sm->per_thread_data[cpu_index].sessions, s); + pool_get (sm->per_thread_data[thread_index].sessions, s); memset (s, 0, sizeof (*s)); s->outside_address_index = ~0; @@ -183,22 +183,22 @@ create_session_for_static_mapping (snat_main_t *sm, u->nstaticsessions++; /* Create list elts */ - pool_get (sm->per_thread_data[cpu_index].list_pool, + pool_get (sm->per_thread_data[thread_index].list_pool, per_user_translation_list_elt); - clib_dlist_init (sm->per_thread_data[cpu_index].list_pool, + clib_dlist_init (sm->per_thread_data[thread_index].list_pool, per_user_translation_list_elt - - sm->per_thread_data[cpu_index].list_pool); + sm->per_thread_data[thread_index].list_pool); per_user_translation_list_elt->value = - s - sm->per_thread_data[cpu_index].sessions; + s - sm->per_thread_data[thread_index].sessions; s->per_user_index = - per_user_translation_list_elt - sm->per_thread_data[cpu_index].list_pool; + per_user_translation_list_elt - sm->per_thread_data[thread_index].list_pool; s->per_user_list_head_index = u->sessions_per_user_list_head_index; - clib_dlist_addtail (sm->per_thread_data[cpu_index].list_pool, + clib_dlist_addtail (sm->per_thread_data[thread_index].list_pool, s->per_user_list_head_index, per_user_translation_list_elt - - sm->per_thread_data[cpu_index].list_pool); + sm->per_thread_data[thread_index].list_pool); s->in2out = in2out; s->out2in = out2in; @@ -206,12 +206,12 @@ create_session_for_static_mapping (snat_main_t *sm, /* Add to translation hashes */ kv0.key = s->in2out.as_u64; - kv0.value = s - sm->per_thread_data[cpu_index].sessions; + kv0.value = s - sm->per_thread_data[thread_index].sessions; if (clib_bihash_add_del_8_8 (&sm->in2out, &kv0, 1 /* is_add */)) clib_warning ("in2out key add failed"); kv0.key = s->out2in.as_u64; - kv0.value = s - sm->per_thread_data[cpu_index].sessions; + kv0.value = s - sm->per_thread_data[thread_index].sessions; if (clib_bihash_add_del_8_8 (&sm->out2in, &kv0, 1 /* is_add */)) clib_warning ("out2in key add failed"); @@ -298,7 +298,7 @@ is_interface_addr(snat_main_t *sm, vlib_node_runtime_t *node, u32 sw_if_index0, * * @param[in,out] sm SNAT main * @param[in,out] node SNAT node runtime - * @param[in] cpu_index CPU index + * @param[in] thread_index thread index * @param[in,out] b0 buffer containing packet to be translated * @param[out] p_key address and port before NAT translation * @param[out] p_value address and port after NAT translation @@ -306,7 +306,7 @@ is_interface_addr(snat_main_t *sm, vlib_node_runtime_t *node, u32 sw_if_index0, * @param d optional parameter */ u32 icmp_match_out2in_slow(snat_main_t *sm, vlib_node_runtime_t *node, - u32 cpu_index, vlib_buffer_t *b0, + u32 thread_index, vlib_buffer_t *b0, snat_session_key_t *p_key, snat_session_key_t *p_value, u8 *p_dont_translate, void *d) @@ -366,7 +366,7 @@ u32 icmp_match_out2in_slow(snat_main_t *sm, vlib_node_runtime_t *node, /* Create session initiated by host from external network */ s0 = create_session_for_static_mapping(sm, b0, sm0, key0, - node, cpu_index); + node, thread_index); if (!s0) { @@ -375,7 +375,7 @@ u32 icmp_match_out2in_slow(snat_main_t *sm, vlib_node_runtime_t *node, } } else - s0 = pool_elt_at_index (sm->per_thread_data[cpu_index].sessions, + s0 = pool_elt_at_index (sm->per_thread_data[thread_index].sessions, value0.value); out: @@ -393,7 +393,7 @@ out: * * @param[in] sm SNAT main * @param[in,out] node SNAT node runtime - * @param[in] cpu_index CPU index + * @param[in] thread_index thread index * @param[in,out] b0 buffer containing packet to be translated * @param[out] p_key address and port before NAT translation * @param[out] p_value address and port after NAT translation @@ -401,7 +401,7 @@ out: * @param d optional parameter */ u32 icmp_match_out2in_fast(snat_main_t *sm, vlib_node_runtime_t *node, - u32 cpu_index, vlib_buffer_t *b0, + u32 thread_index, vlib_buffer_t *b0, snat_session_key_t *p_key, snat_session_key_t *p_value, u8 *p_dont_translate, void *d) @@ -460,7 +460,7 @@ static inline u32 icmp_out2in (snat_main_t *sm, u32 rx_fib_index0, vlib_node_runtime_t * node, u32 next0, - u32 cpu_index, + u32 thread_index, void *d) { snat_session_key_t key0, sm0; @@ -477,7 +477,7 @@ static inline u32 icmp_out2in (snat_main_t *sm, echo0 = (icmp_echo_header_t *)(icmp0+1); - next0_tmp = sm->icmp_match_out2in_cb(sm, node, cpu_index, b0, + next0_tmp = sm->icmp_match_out2in_cb(sm, node, thread_index, b0, &key0, &sm0, &dont_translate, d); if (next0_tmp != ~0) next0 = next0_tmp; @@ -589,11 +589,11 @@ static inline u32 icmp_out2in_slow_path (snat_main_t *sm, u32 rx_fib_index0, vlib_node_runtime_t * node, u32 next0, f64 now, - u32 cpu_index, + u32 thread_index, snat_session_t ** p_s0) { next0 = icmp_out2in(sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node, - next0, cpu_index, p_s0); + next0, thread_index, p_s0); snat_session_t * s0 = *p_s0; if (PREDICT_TRUE(next0 != SNAT_OUT2IN_NEXT_DROP && s0)) { @@ -604,9 +604,9 @@ static inline u32 icmp_out2in_slow_path (snat_main_t *sm, /* Per-user LRU list maintenance for dynamic translation */ if (!snat_is_session_static (s0)) { - clib_dlist_remove (sm->per_thread_data[cpu_index].list_pool, + clib_dlist_remove (sm->per_thread_data[thread_index].list_pool, s0->per_user_index); - clib_dlist_addtail (sm->per_thread_data[cpu_index].list_pool, + clib_dlist_addtail (sm->per_thread_data[thread_index].list_pool, s0->per_user_list_head_index, s0->per_user_index); } @@ -624,7 +624,7 @@ snat_out2in_node_fn (vlib_main_t * vm, u32 pkts_processed = 0; snat_main_t * sm = &snat_main; f64 now = vlib_time_now (vm); - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -712,7 +712,7 @@ snat_out2in_node_fn (vlib_main_t * vm, { next0 = icmp_out2in_slow_path (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node, - next0, now, cpu_index, &s0); + next0, now, thread_index, &s0); goto trace0; } @@ -743,7 +743,7 @@ snat_out2in_node_fn (vlib_main_t * vm, /* Create session initiated by host from external network */ s0 = create_session_for_static_mapping(sm, b0, sm0, key0, node, - cpu_index); + thread_index); if (!s0) { b0->error = node->errors[SNAT_OUT2IN_ERROR_NO_TRANSLATION]; @@ -752,7 +752,7 @@ snat_out2in_node_fn (vlib_main_t * vm, } } else - s0 = pool_elt_at_index (sm->per_thread_data[cpu_index].sessions, + s0 = pool_elt_at_index (sm->per_thread_data[thread_index].sessions, value0.value); old_addr0 = ip0->dst_address.as_u32; @@ -796,9 +796,9 @@ snat_out2in_node_fn (vlib_main_t * vm, /* Per-user LRU list maintenance for dynamic translation */ if (!snat_is_session_static (s0)) { - clib_dlist_remove (sm->per_thread_data[cpu_index].list_pool, + clib_dlist_remove (sm->per_thread_data[thread_index].list_pool, s0->per_user_index); - clib_dlist_addtail (sm->per_thread_data[cpu_index].list_pool, + clib_dlist_addtail (sm->per_thread_data[thread_index].list_pool, s0->per_user_list_head_index, s0->per_user_index); } @@ -813,7 +813,7 @@ snat_out2in_node_fn (vlib_main_t * vm, t->next_index = next0; t->session_index = ~0; if (s0) - t->session_index = s0 - sm->per_thread_data[cpu_index].sessions; + t->session_index = s0 - sm->per_thread_data[thread_index].sessions; } pkts_processed += next0 != SNAT_OUT2IN_NEXT_DROP; @@ -847,7 +847,7 @@ snat_out2in_node_fn (vlib_main_t * vm, { next1 = icmp_out2in_slow_path (sm, b1, ip1, icmp1, sw_if_index1, rx_fib_index1, node, - next1, now, cpu_index, &s1); + next1, now, thread_index, &s1); goto trace1; } @@ -878,7 +878,7 @@ snat_out2in_node_fn (vlib_main_t * vm, /* Create session initiated by host from external network */ s1 = create_session_for_static_mapping(sm, b1, sm1, key1, node, - cpu_index); + thread_index); if (!s1) { b1->error = node->errors[SNAT_OUT2IN_ERROR_NO_TRANSLATION]; @@ -887,7 +887,7 @@ snat_out2in_node_fn (vlib_main_t * vm, } } else - s1 = pool_elt_at_index (sm->per_thread_data[cpu_index].sessions, + s1 = pool_elt_at_index (sm->per_thread_data[thread_index].sessions, value1.value); old_addr1 = ip1->dst_address.as_u32; @@ -931,9 +931,9 @@ snat_out2in_node_fn (vlib_main_t * vm, /* Per-user LRU list maintenance for dynamic translation */ if (!snat_is_session_static (s1)) { - clib_dlist_remove (sm->per_thread_data[cpu_index].list_pool, + clib_dlist_remove (sm->per_thread_data[thread_index].list_pool, s1->per_user_index); - clib_dlist_addtail (sm->per_thread_data[cpu_index].list_pool, + clib_dlist_addtail (sm->per_thread_data[thread_index].list_pool, s1->per_user_list_head_index, s1->per_user_index); } @@ -948,7 +948,7 @@ snat_out2in_node_fn (vlib_main_t * vm, t->next_index = next1; t->session_index = ~0; if (s1) - t->session_index = s1 - sm->per_thread_data[cpu_index].sessions; + t->session_index = s1 - sm->per_thread_data[thread_index].sessions; } pkts_processed += next1 != SNAT_OUT2IN_NEXT_DROP; @@ -1016,7 +1016,7 @@ snat_out2in_node_fn (vlib_main_t * vm, { next0 = icmp_out2in_slow_path (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node, - next0, now, cpu_index, &s0); + next0, now, thread_index, &s0); goto trace00; } @@ -1048,7 +1048,7 @@ snat_out2in_node_fn (vlib_main_t * vm, /* Create session initiated by host from external network */ s0 = create_session_for_static_mapping(sm, b0, sm0, key0, node, - cpu_index); + thread_index); if (!s0) { b0->error = node->errors[SNAT_OUT2IN_ERROR_NO_TRANSLATION]; @@ -1057,7 +1057,7 @@ snat_out2in_node_fn (vlib_main_t * vm, } } else - s0 = pool_elt_at_index (sm->per_thread_data[cpu_index].sessions, + s0 = pool_elt_at_index (sm->per_thread_data[thread_index].sessions, value0.value); old_addr0 = ip0->dst_address.as_u32; @@ -1101,9 +1101,9 @@ snat_out2in_node_fn (vlib_main_t * vm, /* Per-user LRU list maintenance for dynamic translation */ if (!snat_is_session_static (s0)) { - clib_dlist_remove (sm->per_thread_data[cpu_index].list_pool, + clib_dlist_remove (sm->per_thread_data[thread_index].list_pool, s0->per_user_index); - clib_dlist_addtail (sm->per_thread_data[cpu_index].list_pool, + clib_dlist_addtail (sm->per_thread_data[thread_index].list_pool, s0->per_user_list_head_index, s0->per_user_index); } @@ -1118,7 +1118,7 @@ snat_out2in_node_fn (vlib_main_t * vm, t->next_index = next0; t->session_index = ~0; if (s0) - t->session_index = s0 - sm->per_thread_data[cpu_index].sessions; + t->session_index = s0 - sm->per_thread_data[thread_index].sessions; } pkts_processed += next0 != SNAT_OUT2IN_NEXT_DROP; @@ -1599,7 +1599,7 @@ snat_out2in_worker_handoff_fn (vlib_main_t * vm, u32 n_left_to_next_worker = 0, *to_next_worker = 0; u32 next_worker_index = 0; u32 current_worker_index = ~0; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); ASSERT (vec_len (sm->workers)); @@ -1637,7 +1637,7 @@ snat_out2in_worker_handoff_fn (vlib_main_t * vm, next_worker_index = sm->worker_out2in_cb(ip0, rx_fib_index0); - if (PREDICT_FALSE (next_worker_index != cpu_index)) + if (PREDICT_FALSE (next_worker_index != thread_index)) { do_handoff = 1; diff --git a/src/plugins/snat/snat.h b/src/plugins/snat/snat.h index 017825c0..f4e1c5c0 100644 --- a/src/plugins/snat/snat.h +++ b/src/plugins/snat/snat.h @@ -221,7 +221,7 @@ struct snat_main_s; typedef u32 snat_icmp_match_function_t (struct snat_main_s *sm, vlib_node_runtime_t *node, - u32 cpu_index, + u32 thread_index, vlib_buffer_t *b0, snat_session_key_t *p_key, snat_session_key_t *p_value, @@ -402,22 +402,22 @@ typedef struct { } tcp_udp_header_t; u32 icmp_match_in2out_fast(snat_main_t *sm, vlib_node_runtime_t *node, - u32 cpu_index, vlib_buffer_t *b0, + u32 thread_index, vlib_buffer_t *b0, snat_session_key_t *p_key, snat_session_key_t *p_value, u8 *p_dont_translate, void *d); u32 icmp_match_in2out_slow(snat_main_t *sm, vlib_node_runtime_t *node, - u32 cpu_index, vlib_buffer_t *b0, + u32 thread_index, vlib_buffer_t *b0, snat_session_key_t *p_key, snat_session_key_t *p_value, u8 *p_dont_translate, void *d); u32 icmp_match_out2in_fast(snat_main_t *sm, vlib_node_runtime_t *node, - u32 cpu_index, vlib_buffer_t *b0, + u32 thread_index, vlib_buffer_t *b0, snat_session_key_t *p_key, snat_session_key_t *p_value, u8 *p_dont_translate, void *d); u32 icmp_match_out2in_slow(snat_main_t *sm, vlib_node_runtime_t *node, - u32 cpu_index, vlib_buffer_t *b0, + u32 thread_index, vlib_buffer_t *b0, snat_session_key_t *p_key, snat_session_key_t *p_value, u8 *p_dont_translate, void *d); diff --git a/src/vlib/buffer.c b/src/vlib/buffer.c index a517a597..be3b41ef 100644 --- a/src/vlib/buffer.c +++ b/src/vlib/buffer.c @@ -299,7 +299,7 @@ vlib_buffer_validate_alloc_free (vlib_main_t * vm, if (CLIB_DEBUG == 0) return; - ASSERT (os_get_cpu_number () == 0); + ASSERT (vlib_get_thread_index () == 0); /* smp disaster check */ if (vec_len (vlib_mains) > 1) @@ -355,7 +355,7 @@ vlib_buffer_create_free_list_helper (vlib_main_t * vm, vlib_buffer_free_list_t *f; int i; - ASSERT (os_get_cpu_number () == 0); + ASSERT (vlib_get_thread_index () == 0); if (!is_default && pool_elts (bm->buffer_free_list_pool) == 0) { @@ -474,7 +474,7 @@ vlib_buffer_delete_free_list_internal (vlib_main_t * vm, u32 free_list_index) u32 merge_index; int i; - ASSERT (os_get_cpu_number () == 0); + ASSERT (vlib_get_thread_index () == 0); f = vlib_buffer_get_free_list (vm, free_list_index); diff --git a/src/vlib/buffer_funcs.h b/src/vlib/buffer_funcs.h index 394c336a..328660a3 100644 --- a/src/vlib/buffer_funcs.h +++ b/src/vlib/buffer_funcs.h @@ -209,7 +209,7 @@ always_inline vlib_buffer_known_state_t vlib_buffer_is_known (vlib_main_t * vm, u32 buffer_index) { vlib_buffer_main_t *bm = vm->buffer_main; - ASSERT (os_get_cpu_number () == 0); + ASSERT (vlib_get_thread_index () == 0); uword *p = hash_get (bm->buffer_known_hash, buffer_index); return p ? p[0] : VLIB_BUFFER_UNKNOWN; @@ -221,7 +221,7 @@ vlib_buffer_set_known_state (vlib_main_t * vm, vlib_buffer_known_state_t state) { vlib_buffer_main_t *bm = vm->buffer_main; - ASSERT (os_get_cpu_number () == 0); + ASSERT (vlib_get_thread_index () == 0); hash_set (bm->buffer_known_hash, buffer_index, state); } diff --git a/src/vlib/cli.c b/src/vlib/cli.c index f853f655..3cc95076 100644 --- a/src/vlib/cli.c +++ b/src/vlib/cli.c @@ -709,7 +709,7 @@ test_heap_validate (vlib_main_t * vm, unformat_input_t * input, { /* *INDENT-OFF* */ foreach_vlib_main({ - heap = clib_per_cpu_mheaps[this_vlib_main->cpu_index]; + heap = clib_per_cpu_mheaps[this_vlib_main->thread_index]; mheap = mheap_header(heap); mheap->flags |= MHEAP_FLAG_VALIDATE; // Turn off small object cache because it delays detection of errors @@ -722,7 +722,7 @@ test_heap_validate (vlib_main_t * vm, unformat_input_t * input, { /* *INDENT-OFF* */ foreach_vlib_main({ - heap = clib_per_cpu_mheaps[this_vlib_main->cpu_index]; + heap = clib_per_cpu_mheaps[this_vlib_main->thread_index]; mheap = mheap_header(heap); mheap->flags &= ~MHEAP_FLAG_VALIDATE; mheap->flags |= MHEAP_FLAG_SMALL_OBJECT_CACHE; @@ -733,7 +733,7 @@ test_heap_validate (vlib_main_t * vm, unformat_input_t * input, { /* *INDENT-OFF* */ foreach_vlib_main({ - heap = clib_per_cpu_mheaps[this_vlib_main->cpu_index]; + heap = clib_per_cpu_mheaps[this_vlib_main->thread_index]; mheap = mheap_header(heap); mheap_validate(heap); }); diff --git a/src/vlib/counter.h b/src/vlib/counter.h index 17a85217..60e2055d 100644 --- a/src/vlib/counter.h +++ b/src/vlib/counter.h @@ -70,17 +70,17 @@ u32 vlib_simple_counter_n_counters (const vlib_simple_counter_main_t * cm); /** Increment a simple counter @param cm - (vlib_simple_counter_main_t *) simple counter main pointer - @param cpu_index - (u32) the current cpu index + @param thread_index - (u32) the current cpu index @param index - (u32) index of the counter to increment @param increment - (u64) quantitiy to add to the counter */ always_inline void vlib_increment_simple_counter (vlib_simple_counter_main_t * cm, - u32 cpu_index, u32 index, u64 increment) + u32 thread_index, u32 index, u64 increment) { counter_t *my_counters; - my_counters = cm->counters[cpu_index]; + my_counters = cm->counters[thread_index]; my_counters[index] += increment; } @@ -201,7 +201,7 @@ void vlib_clear_combined_counters (vlib_combined_counter_main_t * cm); /** Increment a combined counter @param cm - (vlib_combined_counter_main_t *) comined counter main pointer - @param cpu_index - (u32) the current cpu index + @param thread_index - (u32) the current cpu index @param index - (u32) index of the counter to increment @param packet_increment - (u64) number of packets to add to the counter @param byte_increment - (u64) number of bytes to add to the counter @@ -209,13 +209,13 @@ void vlib_clear_combined_counters (vlib_combined_counter_main_t * cm); always_inline void vlib_increment_combined_counter (vlib_combined_counter_main_t * cm, - u32 cpu_index, + u32 thread_index, u32 index, u64 n_packets, u64 n_bytes) { vlib_counter_t *my_counters; /* Use this CPU's counter array */ - my_counters = cm->counters[cpu_index]; + my_counters = cm->counters[thread_index]; my_counters[index].packets += n_packets; my_counters[index].bytes += n_bytes; @@ -224,14 +224,14 @@ vlib_increment_combined_counter (vlib_combined_counter_main_t * cm, /** Pre-fetch a per-thread combined counter for the given object index */ always_inline void vlib_prefetch_combined_counter (const vlib_combined_counter_main_t * cm, - u32 cpu_index, u32 index) + u32 thread_index, u32 index) { vlib_counter_t *cpu_counters; /* * This CPU's index is assumed to already be in cache */ - cpu_counters = cm->counters[cpu_index]; + cpu_counters = cm->counters[thread_index]; CLIB_PREFETCH (cpu_counters + index, CLIB_CACHE_LINE_BYTES, STORE); } diff --git a/src/vlib/error.c b/src/vlib/error.c index a2c23176..e4ed4ee3 100644 --- a/src/vlib/error.c +++ b/src/vlib/error.c @@ -149,7 +149,7 @@ vlib_register_errors (vlib_main_t * vm, vlib_node_t *n = vlib_get_node (vm, node_index); uword l; - ASSERT (os_get_cpu_number () == 0); + ASSERT (vlib_get_thread_index () == 0); /* Free up any previous error strings. */ if (n->n_errors > 0) diff --git a/src/vlib/global_funcs.h b/src/vlib/global_funcs.h index f51ec381..9dd01fbf 100644 --- a/src/vlib/global_funcs.h +++ b/src/vlib/global_funcs.h @@ -23,7 +23,7 @@ always_inline vlib_main_t * vlib_get_main (void) { vlib_main_t *vm; - vm = vlib_mains[os_get_cpu_number ()]; + vm = vlib_mains[vlib_get_thread_index ()]; ASSERT (vm); return vm; } diff --git a/src/vlib/main.c b/src/vlib/main.c index b22203f0..422d3e26 100644 --- a/src/vlib/main.c +++ b/src/vlib/main.c @@ -136,18 +136,18 @@ vlib_frame_alloc_to_node (vlib_main_t * vm, u32 to_node_index, else { f = clib_mem_alloc_aligned_no_fail (n, VLIB_FRAME_ALIGN); - f->cpu_index = vm->cpu_index; + f->thread_index = vm->thread_index; fi = vlib_frame_index_no_check (vm, f); } /* Poison frame when debugging. */ if (CLIB_DEBUG > 0) { - u32 save_cpu_index = f->cpu_index; + u32 save_thread_index = f->thread_index; memset (f, 0xfe, n); - f->cpu_index = save_cpu_index; + f->thread_index = save_thread_index; } /* Insert magic number. */ @@ -517,7 +517,7 @@ vlib_put_next_frame (vlib_main_t * vm, * a dangling frame reference. Each thread has its own copy of * the next_frames vector. */ - if (0 && r->cpu_index != next_runtime->cpu_index) + if (0 && r->thread_index != next_runtime->thread_index) { nf->frame_index = ~0; nf->flags &= ~(VLIB_FRAME_PENDING | VLIB_FRAME_IS_ALLOCATED); @@ -866,7 +866,7 @@ vlib_elog_main_loop_event (vlib_main_t * vm, : evm->node_call_elog_event_types, node_index), /* track */ - (vm->cpu_index ? &vlib_worker_threads[vm->cpu_index]. + (vm->thread_index ? &vlib_worker_threads[vm->thread_index]. elog_track : &em->default_track), /* data to log */ n_vectors); } @@ -963,7 +963,7 @@ dispatch_node (vlib_main_t * vm, vm->cpu_time_last_node_dispatch = last_time_stamp; - if (1 /* || vm->cpu_index == node->cpu_index */ ) + if (1 /* || vm->thread_index == node->thread_index */ ) { vlib_main_t *stat_vm; @@ -1029,7 +1029,7 @@ dispatch_node (vlib_main_t * vm, { u32 node_name, vector_length, is_polling; } *ed; - vlib_worker_thread_t *w = vlib_worker_threads + vm->cpu_index; + vlib_worker_thread_t *w = vlib_worker_threads + vm->thread_index; #endif if ((dispatch_state == VLIB_NODE_STATE_INTERRUPT diff --git a/src/vlib/main.h b/src/vlib/main.h index 0197b4f3..329bf073 100644 --- a/src/vlib/main.h +++ b/src/vlib/main.h @@ -156,7 +156,7 @@ typedef struct vlib_main_t uword *init_functions_called; /* to compare with node runtime */ - u32 cpu_index; + u32 thread_index; void **mbuf_alloc_list; diff --git a/src/vlib/node.c b/src/vlib/node.c index dc0a4de5..bbd3a42e 100644 --- a/src/vlib/node.c +++ b/src/vlib/node.c @@ -99,7 +99,7 @@ vlib_node_runtime_update (vlib_main_t * vm, u32 node_index, u32 next_index) vlib_pending_frame_t *pf; i32 i, j, n_insert; - ASSERT (os_get_cpu_number () == 0); + ASSERT (vlib_get_thread_index () == 0); vlib_worker_thread_barrier_sync (vm); diff --git a/src/vlib/node.h b/src/vlib/node.h index fc7e7da2..1e2f4c38 100644 --- a/src/vlib/node.h +++ b/src/vlib/node.h @@ -344,8 +344,8 @@ typedef struct vlib_frame_t /* Number of vector elements currently in frame. */ u16 n_vectors; - /* Owner cpuid / heap id */ - u16 cpu_index; + /* Owner thread / heap id */ + u16 thread_index; /* Scalar and vector arguments to next node. */ u8 arguments[0]; @@ -459,7 +459,7 @@ typedef struct vlib_node_runtime_t zero before first run of this node. */ - u16 cpu_index; /**< CPU this node runs on */ + u16 thread_index; /**< thread this node runs on */ u8 runtime_data[0]; /**< Function dependent node-runtime data. This data is diff --git a/src/vlib/node_funcs.h b/src/vlib/node_funcs.h index 1f7d94e1..54e36874 100644 --- a/src/vlib/node_funcs.h +++ b/src/vlib/node_funcs.h @@ -201,9 +201,9 @@ always_inline vlib_frame_t * vlib_get_frame_no_check (vlib_main_t * vm, uword frame_index) { vlib_frame_t *f; - u32 cpu_index = frame_index & VLIB_CPU_MASK; + u32 thread_index = frame_index & VLIB_CPU_MASK; u32 offset = frame_index & VLIB_OFFSET_MASK; - vm = vlib_mains[cpu_index]; + vm = vlib_mains[thread_index]; f = vm->heap_base + offset; return f; } @@ -215,10 +215,10 @@ vlib_frame_index_no_check (vlib_main_t * vm, vlib_frame_t * f) ASSERT (((uword) f & VLIB_CPU_MASK) == 0); - vm = vlib_mains[f->cpu_index]; + vm = vlib_mains[f->thread_index]; i = ((u8 *) f - (u8 *) vm->heap_base); - return i | f->cpu_index; + return i | f->thread_index; } always_inline vlib_frame_t * diff --git a/src/vlib/threads.c b/src/vlib/threads.c index ef3a24d3..4a111f8d 100644 --- a/src/vlib/threads.c +++ b/src/vlib/threads.c @@ -35,27 +35,12 @@ vl (void *p) vlib_worker_thread_t *vlib_worker_threads; vlib_thread_main_t vlib_thread_main; +__thread uword vlib_thread_index = 0; + uword os_get_cpu_number (void) { - void *sp; - uword n; - u32 len; - - len = vec_len (vlib_thread_stacks); - if (len == 0) - return 0; - - /* Get any old stack address. */ - sp = &sp; - - n = ((uword) sp - (uword) vlib_thread_stacks[0]) - >> VLIB_LOG2_THREAD_STACK_SIZE; - - /* "processes" have their own stacks, and they always run in thread 0 */ - n = n >= len ? 0 : n; - - return n; + return vlib_thread_index; } uword @@ -275,21 +260,6 @@ vlib_thread_init (vlib_main_t * vm) return 0; } -vlib_worker_thread_t * -vlib_alloc_thread (vlib_main_t * vm) -{ - vlib_worker_thread_t *w; - - if (vec_len (vlib_worker_threads) >= vec_len (vlib_thread_stacks)) - { - clib_warning ("out of worker threads... Quitting..."); - exit (1); - } - vec_add2 (vlib_worker_threads, w, 1); - w->thread_stack = vlib_thread_stacks[w - vlib_worker_threads]; - return w; -} - vlib_frame_queue_t * vlib_frame_queue_alloc (int nelts) { @@ -427,7 +397,7 @@ vlib_frame_queue_enqueue (vlib_main_t * vm, u32 node_runtime_index, f64 b4 = vlib_time_now_ticks (vm, before); vlib_worker_thread_barrier_check (vm, b4); /* Bad idea. Dequeue -> enqueue -> dequeue -> trouble */ - // vlib_frame_queue_dequeue (vm->cpu_index, vm, nm); + // vlib_frame_queue_dequeue (vm->thread_index, vm, nm); } elt = fq->elts + (new_tail & (fq->nelts - 1)); @@ -497,6 +467,8 @@ vlib_worker_thread_bootstrap_fn (void *arg) w->lwp = syscall (SYS_gettid); w->thread_id = pthread_self (); + vlib_thread_index = w - vlib_worker_threads; + rv = (void *) clib_calljmp ((uword (*)(uword)) w->thread_function, (uword) arg, w->thread_stack + VLIB_THREAD_STACK_SIZE); @@ -610,7 +582,9 @@ start_workers (vlib_main_t * vm) mheap_alloc (0 /* use VM */ , tr->mheap_size); else w->thread_mheap = main_heap; - w->thread_stack = vlib_thread_stacks[w - vlib_worker_threads]; + + w->thread_stack = + vlib_thread_stack_init (w - vlib_worker_threads); w->thread_function = tr->function; w->thread_function_arg = w; w->instance_id = k; @@ -630,7 +604,7 @@ start_workers (vlib_main_t * vm) vm_clone = clib_mem_alloc (sizeof (*vm_clone)); clib_memcpy (vm_clone, vlib_mains[0], sizeof (*vm_clone)); - vm_clone->cpu_index = worker_thread_index; + vm_clone->thread_index = worker_thread_index; vm_clone->heap_base = w->thread_mheap; vm_clone->mbuf_alloc_list = 0; vm_clone->init_functions_called = @@ -679,7 +653,7 @@ start_workers (vlib_main_t * vm) vec_foreach (rt, nm_clone->nodes_by_type[VLIB_NODE_TYPE_INPUT]) { vlib_node_t *n = vlib_get_node (vm, rt->node_index); - rt->cpu_index = vm_clone->cpu_index; + rt->thread_index = vm_clone->thread_index; /* copy initial runtime_data from node */ if (n->runtime_data && n->runtime_data_bytes > 0) clib_memcpy (rt->runtime_data, n->runtime_data, @@ -692,7 +666,7 @@ start_workers (vlib_main_t * vm) vec_foreach (rt, nm_clone->nodes_by_type[VLIB_NODE_TYPE_INPUT]) { vlib_node_t *n = vlib_get_node (vm, rt->node_index); - rt->cpu_index = vm_clone->cpu_index; + rt->thread_index = vm_clone->thread_index; /* copy initial runtime_data from node */ if (n->runtime_data && n->runtime_data_bytes > 0) clib_memcpy (rt->runtime_data, n->runtime_data, @@ -756,7 +730,8 @@ start_workers (vlib_main_t * vm) mheap_alloc (0 /* use VM */ , tr->mheap_size); else w->thread_mheap = main_heap; - w->thread_stack = vlib_thread_stacks[w - vlib_worker_threads]; + w->thread_stack = + vlib_thread_stack_init (w - vlib_worker_threads); w->thread_function = tr->function; w->thread_function_arg = w; w->instance_id = j; @@ -827,7 +802,7 @@ vlib_worker_thread_node_runtime_update (void) uword n_calls, uword n_vectors, uword n_clocks); - ASSERT (os_get_cpu_number () == 0); + ASSERT (vlib_get_thread_index () == 0); if (vec_len (vlib_mains) == 1) return; @@ -835,7 +810,7 @@ vlib_worker_thread_node_runtime_update (void) vm = vlib_mains[0]; nm = &vm->node_main; - ASSERT (os_get_cpu_number () == 0); + ASSERT (vlib_get_thread_index () == 0); ASSERT (*vlib_worker_threads->wait_at_barrier == 1); /* @@ -955,7 +930,7 @@ vlib_worker_thread_node_runtime_update (void) vec_foreach (rt, nm_clone->nodes_by_type[VLIB_NODE_TYPE_INTERNAL]) { vlib_node_t *n = vlib_get_node (vm, rt->node_index); - rt->cpu_index = vm_clone->cpu_index; + rt->thread_index = vm_clone->thread_index; /* copy runtime_data, will be overwritten later for existing rt */ if (n->runtime_data && n->runtime_data_bytes > 0) clib_memcpy (rt->runtime_data, n->runtime_data, @@ -981,7 +956,7 @@ vlib_worker_thread_node_runtime_update (void) vec_foreach (rt, nm_clone->nodes_by_type[VLIB_NODE_TYPE_INPUT]) { vlib_node_t *n = vlib_get_node (vm, rt->node_index); - rt->cpu_index = vm_clone->cpu_index; + rt->thread_index = vm_clone->thread_index; /* copy runtime_data, will be overwritten later for existing rt */ if (n->runtime_data && n->runtime_data_bytes > 0) clib_memcpy (rt->runtime_data, n->runtime_data, @@ -1180,7 +1155,7 @@ vlib_worker_thread_fork_fixup (vlib_fork_fixup_t which) if (vlib_mains == 0) return; - ASSERT (os_get_cpu_number () == 0); + ASSERT (vlib_get_thread_index () == 0); vlib_worker_thread_barrier_sync (vm); switch (which) @@ -1212,7 +1187,7 @@ vlib_worker_thread_barrier_sync (vlib_main_t * vm) vlib_worker_threads[0].barrier_sync_count++; - ASSERT (os_get_cpu_number () == 0); + ASSERT (vlib_get_thread_index () == 0); deadline = vlib_time_now (vm) + BARRIER_SYNC_TIMEOUT; @@ -1260,7 +1235,7 @@ vlib_worker_thread_barrier_release (vlib_main_t * vm) int vlib_frame_queue_dequeue (vlib_main_t * vm, vlib_frame_queue_main_t * fqm) { - u32 thread_id = vm->cpu_index; + u32 thread_id = vm->thread_index; vlib_frame_queue_t *fq = fqm->vlib_frame_queues[thread_id]; vlib_frame_queue_elt_t *elt; u32 *from, *to; @@ -1393,7 +1368,7 @@ vlib_worker_thread_fn (void *arg) vlib_main_t *vm = vlib_get_main (); clib_error_t *e; - ASSERT (vm->cpu_index == os_get_cpu_number ()); + ASSERT (vm->thread_index == vlib_get_thread_index ()); vlib_worker_thread_init (w); clib_time_init (&vm->clib_time); diff --git a/src/vlib/threads.h b/src/vlib/threads.h index eca4fc26..101d3d4a 100644 --- a/src/vlib/threads.h +++ b/src/vlib/threads.h @@ -153,8 +153,6 @@ typedef struct /* Called early, in thread 0's context */ clib_error_t *vlib_thread_init (vlib_main_t * vm); -vlib_worker_thread_t *vlib_alloc_thread (vlib_main_t * vm); - int vlib_frame_queue_enqueue (vlib_main_t * vm, u32 node_runtime_index, u32 frame_queue_index, vlib_frame_t * frame, vlib_frame_queue_msg_type_t type); @@ -183,12 +181,19 @@ u32 vlib_frame_queue_main_init (u32 node_index, u32 frame_queue_nelts); void vlib_worker_thread_barrier_sync (vlib_main_t * vm); void vlib_worker_thread_barrier_release (vlib_main_t * vm); +extern __thread uword vlib_thread_index; +static_always_inline uword +vlib_get_thread_index (void) +{ + return vlib_thread_index; +} + always_inline void vlib_smp_unsafe_warning (void) { if (CLIB_DEBUG > 0) { - if (os_get_cpu_number ()) + if (vlib_get_thread_index ()) fformat (stderr, "%s: SMP unsafe warning...\n", __FUNCTION__); } } @@ -331,21 +336,21 @@ vlib_num_workers () } always_inline u32 -vlib_get_worker_cpu_index (u32 worker_index) +vlib_get_worker_thread_index (u32 worker_index) { return worker_index + 1; } always_inline u32 -vlib_get_worker_index (u32 cpu_index) +vlib_get_worker_index (u32 thread_index) { - return cpu_index - 1; + return thread_index - 1; } always_inline u32 vlib_get_current_worker_index () { - return os_get_cpu_number () - 1; + return vlib_get_thread_index () - 1; } static inline void @@ -467,6 +472,8 @@ vlib_get_worker_handoff_queue_elt (u32 frame_queue_index, return elt; } +u8 *vlib_thread_stack_init (uword thread_index); + int vlib_thread_cb_register (struct vlib_main_t *vm, vlib_thread_callbacks_t * cb); diff --git a/src/vlib/unix/cj.c b/src/vlib/unix/cj.c index 33ba163a..7c1e9475 100644 --- a/src/vlib/unix/cj.c +++ b/src/vlib/unix/cj.c @@ -48,7 +48,7 @@ cj_log (u32 type, void *data0, void *data1) r = (cj_record_t *) & (cjm->records[new_tail & (cjm->num_records - 1)]); r->time = vlib_time_now (cjm->vlib_main); - r->cpu = os_get_cpu_number (); + r->thread_index = vlib_get_thread_index (); r->type = type; r->data[0] = pointer_to_uword (data0); r->data[1] = pointer_to_uword (data1); @@ -133,7 +133,8 @@ static inline void cj_dump_one_record (cj_record_t * r) { fprintf (stderr, "[%d]: %10.6f T%02d %llx %llx\n", - r->cpu, r->time, r->type, (long long unsigned int) r->data[0], + r->thread_index, r->time, r->type, + (long long unsigned int) r->data[0], (long long unsigned int) r->data[1]); } @@ -161,7 +162,7 @@ cj_dump_internal (u8 filter0_enable, u64 filter0, index = (cjm->tail + 1) & (cjm->num_records - 1); r = &(cjm->records[index]); - if (r->cpu != (u32) ~ 0) + if (r->thread_index != (u32) ~ 0) { /* Yes, dump from tail + 1 to the end */ for (i = index; i < cjm->num_records; i++) diff --git a/src/vlib/unix/cj.h b/src/vlib/unix/cj.h index 67626afe..d0a1d46e 100644 --- a/src/vlib/unix/cj.h +++ b/src/vlib/unix/cj.h @@ -23,7 +23,7 @@ typedef struct { f64 time; - u32 cpu; + u32 thread_index; u32 type; u64 data[2]; } cj_record_t; diff --git a/src/vlib/unix/main.c b/src/vlib/unix/main.c index 6b96cc0d..db5ddd64 100644 --- a/src/vlib/unix/main.c +++ b/src/vlib/unix/main.c @@ -510,13 +510,28 @@ thread0 (uword arg) return i; } +u8 * +vlib_thread_stack_init (uword thread_index) +{ + vec_validate (vlib_thread_stacks, thread_index); + vlib_thread_stacks[thread_index] = clib_mem_alloc_aligned + (VLIB_THREAD_STACK_SIZE, VLIB_THREAD_STACK_SIZE); + + /* + * Disallow writes to the bottom page of the stack, to + * catch stack overflows. + */ + if (mprotect (vlib_thread_stacks[thread_index], + clib_mem_get_page_size (), PROT_READ) < 0) + clib_unix_warning ("thread stack"); + return vlib_thread_stacks[thread_index]; +} + int vlib_unix_main (int argc, char *argv[]) { vlib_main_t *vm = &vlib_global_main; /* one and only time for this! */ - vlib_thread_main_t *tm = &vlib_thread_main; unformat_input_t input; - u8 *thread_stacks; clib_error_t *e; int i; @@ -548,29 +563,9 @@ vlib_unix_main (int argc, char *argv[]) } unformat_free (&input); - /* - * allocate n x VLIB_THREAD_STACK_SIZE stacks, aligned to a - * VLIB_THREAD_STACK_SIZE boundary - * See also: os_get_cpu_number() in vlib/vlib/threads.c - */ - thread_stacks = clib_mem_alloc_aligned - ((uword) tm->n_thread_stacks * VLIB_THREAD_STACK_SIZE, - VLIB_THREAD_STACK_SIZE); - - vec_validate (vlib_thread_stacks, tm->n_thread_stacks - 1); - for (i = 0; i < vec_len (vlib_thread_stacks); i++) - { - vlib_thread_stacks[i] = thread_stacks; - - /* - * Disallow writes to the bottom page of the stack, to - * catch stack overflows. - */ - if (mprotect (thread_stacks, clib_mem_get_page_size (), PROT_READ) < 0) - clib_unix_warning ("thread stack"); + vlib_thread_stack_init (0); - thread_stacks += VLIB_THREAD_STACK_SIZE; - } + vlib_thread_index = 0; i = clib_calljmp (thread0, (uword) vm, (void *) (vlib_thread_stacks[0] + diff --git a/src/vnet/adj/adj_l2.c b/src/vnet/adj/adj_l2.c index f68e54e0..20d70dd4 100644 --- a/src/vnet/adj/adj_l2.c +++ b/src/vnet/adj/adj_l2.c @@ -52,7 +52,7 @@ adj_l2_rewrite_inline (vlib_main_t * vm, { u32 * from = vlib_frame_vector_args (frame); u32 n_left_from, n_left_to_next, * to_next, next_index; - u32 cpu_index = os_get_cpu_number(); + u32 thread_index = vlib_get_thread_index(); ethernet_main_t * em = ðernet_main; n_left_from = frame->n_vectors; @@ -93,7 +93,7 @@ adj_l2_rewrite_inline (vlib_main_t * vm, vnet_buffer(p0)->sw_if_index[VLIB_TX] = adj0->rewrite_header.sw_if_index; vlib_increment_combined_counter(&adjacency_counters, - cpu_index, + thread_index, adj_index0, /* packet increment */ 0, /* byte increment */ rw_len0); diff --git a/src/vnet/adj/adj_midchain.c b/src/vnet/adj/adj_midchain.c index e8087f08..5756de43 100644 --- a/src/vnet/adj/adj_midchain.c +++ b/src/vnet/adj/adj_midchain.c @@ -49,7 +49,7 @@ adj_midchain_tx_inline (vlib_main_t * vm, u32 next_index; vnet_main_t *vnm = vnet_get_main (); vnet_interface_main_t *im = &vnm->interface_main; - u32 cpu_index = vm->cpu_index; + u32 thread_index = vm->thread_index; /* Vector of buffer / pkt indices we're supposed to process */ from = vlib_frame_vector_args (frame); @@ -124,13 +124,13 @@ adj_midchain_tx_inline (vlib_main_t * vm, { vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX, - cpu_index, + thread_index, adj0->rewrite_header.sw_if_index, 1, vlib_buffer_length_in_chain (vm, b0)); vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX, - cpu_index, + thread_index, adj1->rewrite_header.sw_if_index, 1, vlib_buffer_length_in_chain (vm, b1)); @@ -181,7 +181,7 @@ adj_midchain_tx_inline (vlib_main_t * vm, { vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX, - cpu_index, + thread_index, adj0->rewrite_header.sw_if_index, 1, vlib_buffer_length_in_chain (vm, b0)); diff --git a/src/vnet/adj/adj_nsh.c b/src/vnet/adj/adj_nsh.c index 9a0f9d8b..128570b0 100644 --- a/src/vnet/adj/adj_nsh.c +++ b/src/vnet/adj/adj_nsh.c @@ -53,7 +53,7 @@ adj_nsh_rewrite_inline (vlib_main_t * vm, { u32 * from = vlib_frame_vector_args (frame); u32 n_left_from, n_left_to_next, * to_next, next_index; - u32 cpu_index = os_get_cpu_number(); + u32 thread_index = vlib_get_thread_index(); n_left_from = frame->n_vectors; next_index = node->cached_next_index; @@ -94,7 +94,7 @@ adj_nsh_rewrite_inline (vlib_main_t * vm, vnet_buffer(p0)->ip.save_rewrite_length = rw_len0; vlib_increment_combined_counter(&adjacency_counters, - cpu_index, + thread_index, adj_index0, /* packet increment */ 0, /* byte increment */ rw_len0); diff --git a/src/vnet/classify/vnet_classify.c b/src/vnet/classify/vnet_classify.c index 98842a48..70a189b0 100644 --- a/src/vnet/classify/vnet_classify.c +++ b/src/vnet/classify/vnet_classify.c @@ -251,12 +251,12 @@ static inline void make_working_copy vnet_classify_entry_##size##_t * working_copy##size = 0; foreach_size_in_u32x4; #undef _ - u32 cpu_number = os_get_cpu_number(); + u32 thread_index = vlib_get_thread_index(); - if (cpu_number >= vec_len (t->working_copies)) + if (thread_index >= vec_len (t->working_copies)) { oldheap = clib_mem_set_heap (t->mheap); - vec_validate (t->working_copies, cpu_number); + vec_validate (t->working_copies, thread_index); clib_mem_set_heap (oldheap); } @@ -265,7 +265,7 @@ static inline void make_working_copy * updates from multiple threads will not result in sporadic, spurious * lookup failures. */ - working_copy = t->working_copies[cpu_number]; + working_copy = t->working_copies[thread_index]; t->saved_bucket.as_u64 = b->as_u64; oldheap = clib_mem_set_heap (t->mheap); @@ -290,7 +290,7 @@ static inline void make_working_copy default: abort(); } - t->working_copies[cpu_number] = working_copy; + t->working_copies[thread_index] = working_copy; } _vec_len(working_copy) = (1<log2_pages)*t->entries_per_page; @@ -318,7 +318,7 @@ static inline void make_working_copy working_bucket.offset = vnet_classify_get_offset (t, working_copy); CLIB_MEMORY_BARRIER(); b->as_u64 = working_bucket.as_u64; - t->working_copies[cpu_number] = working_copy; + t->working_copies[thread_index] = working_copy; } static vnet_classify_entry_t * @@ -387,7 +387,7 @@ int vnet_classify_add_del (vnet_classify_table_t * t, int i; u64 hash, new_hash; u32 new_log2_pages; - u32 cpu_number = os_get_cpu_number(); + u32 thread_index = vlib_get_thread_index(); u8 * key_minus_skip; ASSERT ((add_v->flags & VNET_CLASSIFY_ENTRY_FREE) == 0); @@ -498,7 +498,7 @@ int vnet_classify_add_del (vnet_classify_table_t * t, new_log2_pages = t->saved_bucket.log2_pages + 1; expand_again: - working_copy = t->working_copies[cpu_number]; + working_copy = t->working_copies[thread_index]; new_v = split_and_rehash (t, working_copy, new_log2_pages); if (new_v == 0) diff --git a/src/vnet/cop/ip4_whitelist.c b/src/vnet/cop/ip4_whitelist.c index 6ef3d7d7..1b5e336b 100644 --- a/src/vnet/cop/ip4_whitelist.c +++ b/src/vnet/cop/ip4_whitelist.c @@ -60,7 +60,7 @@ ip4_cop_whitelist_node_fn (vlib_main_t * vm, cop_feature_type_t next_index; cop_main_t *cm = &cop_main; vlib_combined_counter_main_t * vcm = &load_balance_main.lbm_via_counters; - u32 cpu_index = vm->cpu_index; + u32 thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -177,12 +177,12 @@ ip4_cop_whitelist_node_fn (vlib_main_t * vm, dpo1 = load_balance_get_bucket_i(lb1, 0); vlib_increment_combined_counter - (vcm, cpu_index, lb_index0, 1, + (vcm, thread_index, lb_index0, 1, vlib_buffer_length_in_chain (vm, b0) + sizeof(ethernet_header_t)); vlib_increment_combined_counter - (vcm, cpu_index, lb_index1, 1, + (vcm, thread_index, lb_index1, 1, vlib_buffer_length_in_chain (vm, b1) + sizeof(ethernet_header_t)); @@ -273,7 +273,7 @@ ip4_cop_whitelist_node_fn (vlib_main_t * vm, dpo0 = load_balance_get_bucket_i(lb0, 0); vlib_increment_combined_counter - (vcm, cpu_index, lb_index0, 1, + (vcm, thread_index, lb_index0, 1, vlib_buffer_length_in_chain (vm, b0) + sizeof(ethernet_header_t)); diff --git a/src/vnet/cop/ip6_whitelist.c b/src/vnet/cop/ip6_whitelist.c index c2e16ccf..f3fe62e3 100644 --- a/src/vnet/cop/ip6_whitelist.c +++ b/src/vnet/cop/ip6_whitelist.c @@ -61,7 +61,7 @@ ip6_cop_whitelist_node_fn (vlib_main_t * vm, cop_main_t *cm = &cop_main; ip6_main_t * im6 = &ip6_main; vlib_combined_counter_main_t * vcm = &load_balance_main.lbm_via_counters; - u32 cpu_index = vm->cpu_index; + u32 thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -153,12 +153,12 @@ ip6_cop_whitelist_node_fn (vlib_main_t * vm, dpo1 = load_balance_get_bucket_i(lb1, 0); vlib_increment_combined_counter - (vcm, cpu_index, lb_index0, 1, + (vcm, thread_index, lb_index0, 1, vlib_buffer_length_in_chain (vm, b0) + sizeof(ethernet_header_t)); vlib_increment_combined_counter - (vcm, cpu_index, lb_index1, 1, + (vcm, thread_index, lb_index1, 1, vlib_buffer_length_in_chain (vm, b1) + sizeof(ethernet_header_t)); @@ -233,7 +233,7 @@ ip6_cop_whitelist_node_fn (vlib_main_t * vm, dpo0 = load_balance_get_bucket_i(lb0, 0); vlib_increment_combined_counter - (vcm, cpu_index, lb_index0, 1, + (vcm, thread_index, lb_index0, 1, vlib_buffer_length_in_chain (vm, b0) + sizeof(ethernet_header_t)); diff --git a/src/vnet/devices/af_packet/node.c b/src/vnet/devices/af_packet/node.c index ba337f3f..76980102 100644 --- a/src/vnet/devices/af_packet/node.c +++ b/src/vnet/devices/af_packet/node.c @@ -124,7 +124,7 @@ af_packet_device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, u32 frame_num = apif->rx_req->tp_frame_nr; u8 *block_start = apif->rx_ring + block * block_size; uword n_trace = vlib_get_trace_count (vm, node); - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); u32 n_buffer_bytes = vlib_buffer_free_list_buffer_size (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX); u32 min_bufs = apif->rx_req->tp_frame_size / n_buffer_bytes; @@ -132,15 +132,15 @@ af_packet_device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, if (apif->per_interface_next_index != ~0) next_index = apif->per_interface_next_index; - n_free_bufs = vec_len (apm->rx_buffers[cpu_index]); + n_free_bufs = vec_len (apm->rx_buffers[thread_index]); if (PREDICT_FALSE (n_free_bufs < VLIB_FRAME_SIZE)) { - vec_validate (apm->rx_buffers[cpu_index], + vec_validate (apm->rx_buffers[thread_index], VLIB_FRAME_SIZE + n_free_bufs - 1); n_free_bufs += - vlib_buffer_alloc (vm, &apm->rx_buffers[cpu_index][n_free_bufs], + vlib_buffer_alloc (vm, &apm->rx_buffers[thread_index][n_free_bufs], VLIB_FRAME_SIZE); - _vec_len (apm->rx_buffers[cpu_index]) = n_free_bufs; + _vec_len (apm->rx_buffers[thread_index]) = n_free_bufs; } rx_frame = apif->next_rx_frame; @@ -163,11 +163,11 @@ af_packet_device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, { /* grab free buffer */ u32 last_empty_buffer = - vec_len (apm->rx_buffers[cpu_index]) - 1; + vec_len (apm->rx_buffers[thread_index]) - 1; prev_bi0 = bi0; - bi0 = apm->rx_buffers[cpu_index][last_empty_buffer]; + bi0 = apm->rx_buffers[thread_index][last_empty_buffer]; b0 = vlib_get_buffer (vm, bi0); - _vec_len (apm->rx_buffers[cpu_index]) = last_empty_buffer; + _vec_len (apm->rx_buffers[thread_index]) = last_empty_buffer; n_free_bufs--; /* copy data */ @@ -236,9 +236,9 @@ af_packet_device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_increment_combined_counter (vnet_get_main ()->interface_main.combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - os_get_cpu_number (), apif->hw_if_index, n_rx_packets, n_rx_bytes); + vlib_get_thread_index (), apif->hw_if_index, n_rx_packets, n_rx_bytes); - vnet_device_increment_rx_packets (cpu_index, n_rx_packets); + vnet_device_increment_rx_packets (thread_index, n_rx_packets); return n_rx_packets; } diff --git a/src/vnet/devices/devices.c b/src/vnet/devices/devices.c index 41645220..5e5e812c 100644 --- a/src/vnet/devices/devices.c +++ b/src/vnet/devices/devices.c @@ -104,7 +104,7 @@ vnet_device_queue_sort (void *a1, void *a2) void vnet_device_input_assign_thread (u32 hw_if_index, - u16 queue_id, uword cpu_index) + u16 queue_id, uword thread_index) { vnet_main_t *vnm = vnet_get_main (); vnet_device_main_t *vdm = &vnet_device_main; @@ -115,19 +115,19 @@ vnet_device_input_assign_thread (u32 hw_if_index, ASSERT (hw->input_node_index > 0); - if (vdm->first_worker_cpu_index == 0) - cpu_index = 0; + if (vdm->first_worker_thread_index == 0) + thread_index = 0; - if (cpu_index != 0 && - (cpu_index < vdm->first_worker_cpu_index || - cpu_index > vdm->last_worker_cpu_index)) + if (thread_index != 0 && + (thread_index < vdm->first_worker_thread_index || + thread_index > vdm->last_worker_thread_index)) { - cpu_index = vdm->next_worker_cpu_index++; - if (vdm->next_worker_cpu_index > vdm->last_worker_cpu_index) - vdm->next_worker_cpu_index = vdm->first_worker_cpu_index; + thread_index = vdm->next_worker_thread_index++; + if (vdm->next_worker_thread_index > vdm->last_worker_thread_index) + vdm->next_worker_thread_index = vdm->first_worker_thread_index; } - vm = vlib_mains[cpu_index]; + vm = vlib_mains[thread_index]; rt = vlib_node_get_runtime_data (vm, hw->input_node_index); vec_add2 (rt->devices_and_queues, dq, 1); @@ -136,33 +136,33 @@ vnet_device_input_assign_thread (u32 hw_if_index, dq->queue_id = queue_id; vec_sort_with_function (rt->devices_and_queues, vnet_device_queue_sort); - vec_validate (hw->input_node_cpu_index_by_queue, queue_id); - hw->input_node_cpu_index_by_queue[queue_id] = cpu_index; + vec_validate (hw->input_node_thread_index_by_queue, queue_id); + hw->input_node_thread_index_by_queue[queue_id] = thread_index; } static int vnet_device_input_unassign_thread (u32 hw_if_index, u16 queue_id, - uword cpu_index) + uword thread_index) { vnet_main_t *vnm = vnet_get_main (); vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index); vnet_device_input_runtime_t *rt; vnet_device_and_queue_t *dq; - uword old_cpu_index; + uword old_thread_index; - if (hw->input_node_cpu_index_by_queue == 0) + if (hw->input_node_thread_index_by_queue == 0) return VNET_API_ERROR_INVALID_INTERFACE; - if (vec_len (hw->input_node_cpu_index_by_queue) < queue_id + 1) + if (vec_len (hw->input_node_thread_index_by_queue) < queue_id + 1) return VNET_API_ERROR_INVALID_INTERFACE; - old_cpu_index = hw->input_node_cpu_index_by_queue[queue_id]; + old_thread_index = hw->input_node_thread_index_by_queue[queue_id]; - if (old_cpu_index == cpu_index) + if (old_thread_index == thread_index) return 0; rt = - vlib_node_get_runtime_data (vlib_mains[old_cpu_index], + vlib_node_get_runtime_data (vlib_mains[old_thread_index], hw->input_node_index); vec_foreach (dq, rt->devices_and_queues) @@ -240,7 +240,7 @@ set_device_placement (vlib_main_t * vm, unformat_input_t * input, vnet_device_main_t *vdm = &vnet_device_main; u32 hw_if_index = (u32) ~ 0; u32 queue_id = (u32) 0; - u32 cpu_index = (u32) ~ 0; + u32 thread_index = (u32) ~ 0; int rv; if (!unformat_user (input, unformat_line_input, line_input)) @@ -253,10 +253,10 @@ set_device_placement (vlib_main_t * vm, unformat_input_t * input, ; else if (unformat (line_input, "queue %d", &queue_id)) ; - else if (unformat (line_input, "main", &cpu_index)) - cpu_index = 0; - else if (unformat (line_input, "worker %d", &cpu_index)) - cpu_index += vdm->first_worker_cpu_index; + else if (unformat (line_input, "main", &thread_index)) + thread_index = 0; + else if (unformat (line_input, "worker %d", &thread_index)) + thread_index += vdm->first_worker_thread_index; else { error = clib_error_return (0, "parse error: '%U'", @@ -271,16 +271,17 @@ set_device_placement (vlib_main_t * vm, unformat_input_t * input, if (hw_if_index == (u32) ~ 0) return clib_error_return (0, "please specify valid interface name"); - if (cpu_index > vdm->last_worker_cpu_index) + if (thread_index > vdm->last_worker_thread_index) return clib_error_return (0, "please specify valid worker thread or main"); - rv = vnet_device_input_unassign_thread (hw_if_index, queue_id, cpu_index); + rv = + vnet_device_input_unassign_thread (hw_if_index, queue_id, thread_index); if (rv) return clib_error_return (0, "not found"); - vnet_device_input_assign_thread (hw_if_index, queue_id, cpu_index); + vnet_device_input_assign_thread (hw_if_index, queue_id, thread_index); return 0; } @@ -326,9 +327,9 @@ vnet_device_init (vlib_main_t * vm) tr = p ? (vlib_thread_registration_t *) p[0] : 0; if (tr && tr->count > 0) { - vdm->first_worker_cpu_index = tr->first_index; - vdm->next_worker_cpu_index = tr->first_index; - vdm->last_worker_cpu_index = tr->first_index + tr->count - 1; + vdm->first_worker_thread_index = tr->first_index; + vdm->next_worker_thread_index = tr->first_index; + vdm->last_worker_thread_index = tr->first_index + tr->count - 1; } return 0; } diff --git a/src/vnet/devices/devices.h b/src/vnet/devices/devices.h index bbb29fe3..966f8302 100644 --- a/src/vnet/devices/devices.h +++ b/src/vnet/devices/devices.h @@ -50,9 +50,9 @@ typedef struct typedef struct { vnet_device_per_worker_data_t *workers; - uword first_worker_cpu_index; - uword last_worker_cpu_index; - uword next_worker_cpu_index; + uword first_worker_thread_index; + uword last_worker_thread_index; + uword next_worker_thread_index; } vnet_device_main_t; typedef struct @@ -80,7 +80,7 @@ vnet_set_device_input_node (u32 hw_if_index, u32 node_index) } void vnet_device_input_assign_thread (u32 hw_if_index, u16 queue_id, - uword cpu_index); + uword thread_index); static inline u64 vnet_get_aggregate_rx_packets (void) @@ -95,12 +95,12 @@ vnet_get_aggregate_rx_packets (void) } static inline void -vnet_device_increment_rx_packets (u32 cpu_index, u64 count) +vnet_device_increment_rx_packets (u32 thread_index, u64 count) { vnet_device_main_t *vdm = &vnet_device_main; vnet_device_per_worker_data_t *pwd; - pwd = vec_elt_at_index (vdm->workers, cpu_index); + pwd = vec_elt_at_index (vdm->workers, thread_index); pwd->aggregate_rx_packets += count; } @@ -117,9 +117,9 @@ vnet_device_input_set_interrupt_pending (vnet_main_t * vnm, u32 hw_if_index, { vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index); - ASSERT (queue_id < vec_len (hw->input_node_cpu_index_by_queue)); - u32 cpu_index = hw->input_node_cpu_index_by_queue[queue_id]; - vlib_node_set_interrupt_pending (vlib_mains[cpu_index], + ASSERT (queue_id < vec_len (hw->input_node_thread_index_by_queue)); + u32 thread_index = hw->input_node_thread_index_by_queue[queue_id]; + vlib_node_set_interrupt_pending (vlib_mains[thread_index], hw->input_node_index); } diff --git a/src/vnet/devices/netmap/node.c b/src/vnet/devices/netmap/node.c index 68ea7832..e120eeae 100644 --- a/src/vnet/devices/netmap/node.c +++ b/src/vnet/devices/netmap/node.c @@ -98,22 +98,22 @@ netmap_device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, u32 n_free_bufs; struct netmap_ring *ring; int cur_ring; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); u32 n_buffer_bytes = vlib_buffer_free_list_buffer_size (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX); if (nif->per_interface_next_index != ~0) next_index = nif->per_interface_next_index; - n_free_bufs = vec_len (nm->rx_buffers[cpu_index]); + n_free_bufs = vec_len (nm->rx_buffers[thread_index]); if (PREDICT_FALSE (n_free_bufs < VLIB_FRAME_SIZE)) { - vec_validate (nm->rx_buffers[cpu_index], + vec_validate (nm->rx_buffers[thread_index], VLIB_FRAME_SIZE + n_free_bufs - 1); n_free_bufs += - vlib_buffer_alloc (vm, &nm->rx_buffers[cpu_index][n_free_bufs], + vlib_buffer_alloc (vm, &nm->rx_buffers[thread_index][n_free_bufs], VLIB_FRAME_SIZE); - _vec_len (nm->rx_buffers[cpu_index]) = n_free_bufs; + _vec_len (nm->rx_buffers[thread_index]) = n_free_bufs; } cur_ring = nif->first_rx_ring; @@ -163,11 +163,11 @@ netmap_device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_buffer_t *b0; /* grab free buffer */ u32 last_empty_buffer = - vec_len (nm->rx_buffers[cpu_index]) - 1; + vec_len (nm->rx_buffers[thread_index]) - 1; prev_bi0 = bi0; - bi0 = nm->rx_buffers[cpu_index][last_empty_buffer]; + bi0 = nm->rx_buffers[thread_index][last_empty_buffer]; b0 = vlib_get_buffer (vm, bi0); - _vec_len (nm->rx_buffers[cpu_index]) = last_empty_buffer; + _vec_len (nm->rx_buffers[thread_index]) = last_empty_buffer; n_free_bufs--; /* copy data */ @@ -247,9 +247,9 @@ netmap_device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_increment_combined_counter (vnet_get_main ()->interface_main.combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - os_get_cpu_number (), nif->hw_if_index, n_rx_packets, n_rx_bytes); + vlib_get_thread_index (), nif->hw_if_index, n_rx_packets, n_rx_bytes); - vnet_device_increment_rx_packets (cpu_index, n_rx_packets); + vnet_device_increment_rx_packets (thread_index, n_rx_packets); return n_rx_packets; } @@ -260,7 +260,7 @@ netmap_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, { int i; u32 n_rx_packets = 0; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); netmap_main_t *nm = &netmap_main; netmap_if_t *nmi; @@ -269,7 +269,7 @@ netmap_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, nmi = vec_elt_at_index (nm->interfaces, i); if (nmi->is_admin_up && (i % nm->input_cpu_count) == - (cpu_index - nm->input_cpu_first_index)) + (thread_index - nm->input_cpu_first_index)) n_rx_packets += netmap_device_input_fn (vm, node, frame, nmi); } diff --git a/src/vnet/devices/ssvm/node.c b/src/vnet/devices/ssvm/node.c index a6c9dfd7..539b4161 100644 --- a/src/vnet/devices/ssvm/node.c +++ b/src/vnet/devices/ssvm/node.c @@ -89,7 +89,7 @@ ssvm_eth_device_input (ssvm_eth_main_t * em, ethernet_header_t *eh0; u16 type0; u32 n_rx_bytes = 0, l3_offset0; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); u32 trace_cnt __attribute__ ((unused)) = vlib_get_trace_count (vm, node); volatile u32 *lock; u32 *elt_indices; @@ -284,10 +284,10 @@ out: vlib_increment_combined_counter (vnet_get_main ()->interface_main.combined_sw_if_counters - + VNET_INTERFACE_COUNTER_RX, cpu_index, + + VNET_INTERFACE_COUNTER_RX, thread_index, intfc->vlib_hw_if_index, rx_queue_index, n_rx_bytes); - vnet_device_increment_rx_packets (cpu_index, rx_queue_index); + vnet_device_increment_rx_packets (thread_index, rx_queue_index); return rx_queue_index; } diff --git a/src/vnet/devices/virtio/vhost-user.c b/src/vnet/devices/virtio/vhost-user.c index 00807dc0..5e720f65 100644 --- a/src/vnet/devices/virtio/vhost-user.c +++ b/src/vnet/devices/virtio/vhost-user.c @@ -331,7 +331,7 @@ vhost_user_tx_thread_placement (vhost_user_intf_t * vui) { //Let's try to assign one queue to each thread u32 qid = 0; - u32 cpu_index = 0; + u32 thread_index = 0; vui->use_tx_spinlock = 0; while (1) { @@ -341,20 +341,21 @@ vhost_user_tx_thread_placement (vhost_user_intf_t * vui) if (!rxvq->started || !rxvq->enabled) continue; - vui->per_cpu_tx_qid[cpu_index] = qid; - cpu_index++; - if (cpu_index == vlib_get_thread_main ()->n_vlib_mains) + vui->per_cpu_tx_qid[thread_index] = qid; + thread_index++; + if (thread_index == vlib_get_thread_main ()->n_vlib_mains) return; } //We need to loop, meaning the spinlock has to be used vui->use_tx_spinlock = 1; - if (cpu_index == 0) + if (thread_index == 0) { //Could not find a single valid one - for (cpu_index = 0; - cpu_index < vlib_get_thread_main ()->n_vlib_mains; cpu_index++) + for (thread_index = 0; + thread_index < vlib_get_thread_main ()->n_vlib_mains; + thread_index++) { - vui->per_cpu_tx_qid[cpu_index] = 0; + vui->per_cpu_tx_qid[thread_index] = 0; } return; } @@ -368,7 +369,7 @@ vhost_user_rx_thread_placement () vhost_user_intf_t *vui; vhost_cpu_t *vhc; u32 *workers = 0; - u32 cpu_index; + u32 thread_index; vlib_main_t *vm; //Let's list all workers cpu indexes @@ -400,9 +401,9 @@ vhost_user_rx_thread_placement () continue; i %= vec_len (vui_workers); - cpu_index = vui_workers[i]; + thread_index = vui_workers[i]; i++; - vhc = &vum->cpus[cpu_index]; + vhc = &vum->cpus[thread_index]; iaq.qid = qid; iaq.vhost_iface_index = vui - vum->vhost_user_interfaces; @@ -429,14 +430,14 @@ vhost_user_rx_thread_placement () vhc->operation_mode = mode; } - for (cpu_index = vum->input_cpu_first_index; - cpu_index < vum->input_cpu_first_index + vum->input_cpu_count; - cpu_index++) + for (thread_index = vum->input_cpu_first_index; + thread_index < vum->input_cpu_first_index + vum->input_cpu_count; + thread_index++) { vlib_node_state_t state = VLIB_NODE_STATE_POLLING; - vhc = &vum->cpus[cpu_index]; - vm = vlib_mains ? vlib_mains[cpu_index] : &vlib_global_main; + vhc = &vum->cpus[thread_index]; + vm = vlib_mains ? vlib_mains[thread_index] : &vlib_global_main; switch (vhc->operation_mode) { case VHOST_USER_INTERRUPT_MODE: @@ -532,7 +533,7 @@ vhost_user_set_interrupt_pending (vhost_user_intf_t * vui, u32 ifq) { vhost_user_main_t *vum = &vhost_user_main; vhost_cpu_t *vhc; - u32 cpu_index; + u32 thread_index; vhost_iface_and_queue_t *vhiq; vlib_main_t *vm; u32 ifq2; @@ -553,8 +554,8 @@ vhost_user_set_interrupt_pending (vhost_user_intf_t * vui, u32 ifq) if ((vhiq->vhost_iface_index == (ifq >> 8)) && (VHOST_VRING_IDX_TX (vhiq->qid) == (ifq & 0xff))) { - cpu_index = vhc - vum->cpus; - vm = vlib_mains ? vlib_mains[cpu_index] : &vlib_global_main; + thread_index = vhc - vum->cpus; + vm = vlib_mains ? vlib_mains[thread_index] : &vlib_global_main; /* * Convert RX virtqueue number in the lower byte to vring * queue index for the input node process. Top bytes contain @@ -1592,7 +1593,7 @@ vhost_user_if_input (vlib_main_t * vm, u32 n_trace = vlib_get_trace_count (vm, node); u16 qsz_mask; u32 map_hint = 0; - u16 cpu_index = os_get_cpu_number (); + u16 thread_index = vlib_get_thread_index (); u16 copy_len = 0; { @@ -1651,32 +1652,32 @@ vhost_user_if_input (vlib_main_t * vm, * in the loop and come back later. This is not an issue as for big packet, * processing cost really comes from the memory copy. */ - if (PREDICT_FALSE (vum->cpus[cpu_index].rx_buffers_len < n_left + 1)) + if (PREDICT_FALSE (vum->cpus[thread_index].rx_buffers_len < n_left + 1)) { - u32 curr_len = vum->cpus[cpu_index].rx_buffers_len; - vum->cpus[cpu_index].rx_buffers_len += + u32 curr_len = vum->cpus[thread_index].rx_buffers_len; + vum->cpus[thread_index].rx_buffers_len += vlib_buffer_alloc_from_free_list (vm, - vum->cpus[cpu_index].rx_buffers + + vum->cpus[thread_index].rx_buffers + curr_len, VHOST_USER_RX_BUFFERS_N - curr_len, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX); if (PREDICT_FALSE - (vum->cpus[cpu_index].rx_buffers_len < + (vum->cpus[thread_index].rx_buffers_len < VHOST_USER_RX_BUFFER_STARVATION)) { /* In case of buffer starvation, discard some packets from the queue * and log the event. * We keep doing best effort for the remaining packets. */ - u32 flush = (n_left + 1 > vum->cpus[cpu_index].rx_buffers_len) ? - n_left + 1 - vum->cpus[cpu_index].rx_buffers_len : 1; + u32 flush = (n_left + 1 > vum->cpus[thread_index].rx_buffers_len) ? + n_left + 1 - vum->cpus[thread_index].rx_buffers_len : 1; flush = vhost_user_rx_discard_packet (vm, vui, txvq, flush); n_left -= flush; vlib_increment_simple_counter (vnet_main. interface_main.sw_if_counters + VNET_INTERFACE_COUNTER_DROP, - os_get_cpu_number (), + vlib_get_thread_index (), vui->sw_if_index, flush); vlib_error_count (vm, vhost_user_input_node.index, @@ -1696,7 +1697,7 @@ vhost_user_if_input (vlib_main_t * vm, u32 desc_data_offset; vring_desc_t *desc_table = txvq->desc; - if (PREDICT_FALSE (vum->cpus[cpu_index].rx_buffers_len <= 1)) + if (PREDICT_FALSE (vum->cpus[thread_index].rx_buffers_len <= 1)) { /* Not enough rx_buffers * Note: We yeld on 1 so we don't need to do an additional @@ -1707,17 +1708,18 @@ vhost_user_if_input (vlib_main_t * vm, } desc_current = txvq->avail->ring[txvq->last_avail_idx & qsz_mask]; - vum->cpus[cpu_index].rx_buffers_len--; - bi_current = (vum->cpus[cpu_index].rx_buffers) - [vum->cpus[cpu_index].rx_buffers_len]; + vum->cpus[thread_index].rx_buffers_len--; + bi_current = (vum->cpus[thread_index].rx_buffers) + [vum->cpus[thread_index].rx_buffers_len]; b_head = b_current = vlib_get_buffer (vm, bi_current); to_next[0] = bi_current; //We do that now so we can forget about bi_current to_next++; n_left_to_next--; vlib_prefetch_buffer_with_index (vm, - (vum->cpus[cpu_index].rx_buffers) - [vum->cpus[cpu_index]. + (vum-> + cpus[thread_index].rx_buffers) + [vum->cpus[thread_index]. rx_buffers_len - 1], LOAD); /* Just preset the used descriptor id and length for later */ @@ -1791,7 +1793,7 @@ vhost_user_if_input (vlib_main_t * vm, (b_current->current_length == VLIB_BUFFER_DATA_SIZE)) { if (PREDICT_FALSE - (vum->cpus[cpu_index].rx_buffers_len == 0)) + (vum->cpus[thread_index].rx_buffers_len == 0)) { /* Cancel speculation */ to_next--; @@ -1805,17 +1807,18 @@ vhost_user_if_input (vlib_main_t * vm, * but valid. */ vhost_user_input_rewind_buffers (vm, - &vum->cpus[cpu_index], + &vum->cpus + [thread_index], b_head); n_left = 0; goto stop; } /* Get next output */ - vum->cpus[cpu_index].rx_buffers_len--; + vum->cpus[thread_index].rx_buffers_len--; u32 bi_next = - (vum->cpus[cpu_index].rx_buffers)[vum->cpus - [cpu_index].rx_buffers_len]; + (vum->cpus[thread_index].rx_buffers)[vum->cpus + [thread_index].rx_buffers_len]; b_current->next_buffer = bi_next; b_current->flags |= VLIB_BUFFER_NEXT_PRESENT; bi_current = bi_next; @@ -1823,7 +1826,7 @@ vhost_user_if_input (vlib_main_t * vm, } /* Prepare a copy order executed later for the data */ - vhost_copy_t *cpy = &vum->cpus[cpu_index].copy[copy_len]; + vhost_copy_t *cpy = &vum->cpus[thread_index].copy[copy_len]; copy_len++; u32 desc_data_l = desc_table[desc_current].len - desc_data_offset; @@ -1880,7 +1883,7 @@ vhost_user_if_input (vlib_main_t * vm, if (PREDICT_FALSE (copy_len >= VHOST_USER_RX_COPY_THRESHOLD)) { if (PREDICT_FALSE - (vhost_user_input_copy (vui, vum->cpus[cpu_index].copy, + (vhost_user_input_copy (vui, vum->cpus[thread_index].copy, copy_len, &map_hint))) { clib_warning @@ -1905,7 +1908,7 @@ vhost_user_if_input (vlib_main_t * vm, /* Do the memory copies */ if (PREDICT_FALSE - (vhost_user_input_copy (vui, vum->cpus[cpu_index].copy, + (vhost_user_input_copy (vui, vum->cpus[thread_index].copy, copy_len, &map_hint))) { clib_warning ("Memory mapping error on interface hw_if_index=%d " @@ -1933,9 +1936,9 @@ vhost_user_if_input (vlib_main_t * vm, vlib_increment_combined_counter (vnet_main.interface_main.combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - os_get_cpu_number (), vui->sw_if_index, n_rx_packets, n_rx_bytes); + vlib_get_thread_index (), vui->sw_if_index, n_rx_packets, n_rx_bytes); - vnet_device_increment_rx_packets (cpu_index, n_rx_packets); + vnet_device_increment_rx_packets (thread_index, n_rx_packets); return n_rx_packets; } @@ -1946,15 +1949,15 @@ vhost_user_input (vlib_main_t * vm, { vhost_user_main_t *vum = &vhost_user_main; uword n_rx_packets = 0; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); vhost_iface_and_queue_t *vhiq; vhost_user_intf_t *vui; vhost_cpu_t *vhc; - vhc = &vum->cpus[cpu_index]; + vhc = &vum->cpus[thread_index]; if (PREDICT_TRUE (vhc->operation_mode == VHOST_USER_POLLING_MODE)) { - vec_foreach (vhiq, vum->cpus[cpu_index].rx_queues) + vec_foreach (vhiq, vum->cpus[thread_index].rx_queues) { vui = &vum->vhost_user_interfaces[vhiq->vhost_iface_index]; n_rx_packets += vhost_user_if_input (vm, vum, vui, vhiq->qid, node); @@ -2096,7 +2099,7 @@ vhost_user_tx (vlib_main_t * vm, vhost_user_vring_t *rxvq; u16 qsz_mask; u8 error; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); u32 map_hint = 0; u8 retry = 8; u16 copy_len; @@ -2116,7 +2119,7 @@ vhost_user_tx (vlib_main_t * vm, qid = VHOST_VRING_IDX_RX (*vec_elt_at_index - (vui->per_cpu_tx_qid, os_get_cpu_number ())); + (vui->per_cpu_tx_qid, vlib_get_thread_index ())); rxvq = &vui->vrings[qid]; if (PREDICT_FALSE (vui->use_tx_spinlock)) vhost_user_vring_lock (vui, qid); @@ -2143,10 +2146,10 @@ retry: if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED)) { - vum->cpus[cpu_index].current_trace = + vum->cpus[thread_index].current_trace = vlib_add_trace (vm, node, b0, - sizeof (*vum->cpus[cpu_index].current_trace)); - vhost_user_tx_trace (vum->cpus[cpu_index].current_trace, + sizeof (*vum->cpus[thread_index].current_trace)); + vhost_user_tx_trace (vum->cpus[thread_index].current_trace, vui, qid / 2, b0, rxvq); } @@ -2188,14 +2191,14 @@ retry: { // Get a header from the header array virtio_net_hdr_mrg_rxbuf_t *hdr = - &vum->cpus[cpu_index].tx_headers[tx_headers_len]; + &vum->cpus[thread_index].tx_headers[tx_headers_len]; tx_headers_len++; hdr->hdr.flags = 0; hdr->hdr.gso_type = 0; hdr->num_buffers = 1; //This is local, no need to check // Prepare a copy order executed later for the header - vhost_copy_t *cpy = &vum->cpus[cpu_index].copy[copy_len]; + vhost_copy_t *cpy = &vum->cpus[thread_index].copy[copy_len]; copy_len++; cpy->len = vui->virtio_net_hdr_sz; cpy->dst = buffer_map_addr; @@ -2220,7 +2223,7 @@ retry: else if (vui->virtio_net_hdr_sz == 12) //MRG is available { virtio_net_hdr_mrg_rxbuf_t *hdr = - &vum->cpus[cpu_index].tx_headers[tx_headers_len - 1]; + &vum->cpus[thread_index].tx_headers[tx_headers_len - 1]; //Move from available to used buffer rxvq->used->ring[rxvq->last_used_idx & qsz_mask].id = @@ -2282,7 +2285,7 @@ retry: } { - vhost_copy_t *cpy = &vum->cpus[cpu_index].copy[copy_len]; + vhost_copy_t *cpy = &vum->cpus[thread_index].copy[copy_len]; copy_len++; cpy->len = bytes_left; cpy->len = (cpy->len > buffer_len) ? buffer_len : cpy->len; @@ -2325,8 +2328,8 @@ retry: if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED)) { - vum->cpus[cpu_index].current_trace->hdr = - vum->cpus[cpu_index].tx_headers[tx_headers_len - 1]; + vum->cpus[thread_index].current_trace->hdr = + vum->cpus[thread_index].tx_headers[tx_headers_len - 1]; } n_left--; //At the end for error counting when 'goto done' is invoked @@ -2336,7 +2339,7 @@ retry: done: //Do the memory copies if (PREDICT_FALSE - (vhost_user_tx_copy (vui, vum->cpus[cpu_index].copy, + (vhost_user_tx_copy (vui, vum->cpus[thread_index].copy, copy_len, &map_hint))) { clib_warning ("Memory mapping error on interface hw_if_index=%d " @@ -2386,7 +2389,7 @@ done3: vlib_increment_simple_counter (vnet_main.interface_main.sw_if_counters + VNET_INTERFACE_COUNTER_DROP, - os_get_cpu_number (), vui->sw_if_index, n_left); + vlib_get_thread_index (), vui->sw_if_index, n_left); } vlib_buffer_free (vm, vlib_frame_args (frame), frame->n_vectors); @@ -2773,11 +2776,11 @@ vhost_user_send_interrupt_process (vlib_main_t * vm, case ~0: vec_foreach (vhc, vum->cpus) { - u32 cpu_index = vhc - vum->cpus; + u32 thread_index = vhc - vum->cpus; f64 next_timeout; next_timeout = timeout; - vec_foreach (vhiq, vum->cpus[cpu_index].rx_queues) + vec_foreach (vhiq, vum->cpus[thread_index].rx_queues) { vui = &vum->vhost_user_interfaces[vhiq->vhost_iface_index]; vhost_user_vring_t *rxvq = diff --git a/src/vnet/dpo/lookup_dpo.c b/src/vnet/dpo/lookup_dpo.c index e94e871c..97ad0a44 100644 --- a/src/vnet/dpo/lookup_dpo.c +++ b/src/vnet/dpo/lookup_dpo.c @@ -266,7 +266,7 @@ lookup_dpo_ip4_inline (vlib_main_t * vm, int table_from_interface) { u32 n_left_from, next_index, * from, * to_next; - u32 cpu_index = os_get_cpu_number(); + u32 thread_index = vlib_get_thread_index(); vlib_combined_counter_main_t * cm = &load_balance_main.lbm_to_counters; from = vlib_frame_vector_args (from_frame); @@ -407,10 +407,10 @@ lookup_dpo_ip4_inline (vlib_main_t * vm, vnet_buffer(b1)->ip.adj_index[VLIB_TX] = dpo1->dpoi_index; vlib_increment_combined_counter - (cm, cpu_index, lbi0, 1, + (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, b0)); vlib_increment_combined_counter - (cm, cpu_index, lbi1, 1, + (cm, thread_index, lbi1, 1, vlib_buffer_length_in_chain (vm, b1)); if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED)) @@ -511,7 +511,7 @@ lookup_dpo_ip4_inline (vlib_main_t * vm, vnet_buffer(b0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index; vlib_increment_combined_counter - (cm, cpu_index, lbi0, 1, + (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, b0)); if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED)) @@ -606,7 +606,7 @@ lookup_dpo_ip6_inline (vlib_main_t * vm, { vlib_combined_counter_main_t * cm = &load_balance_main.lbm_to_counters; u32 n_left_from, next_index, * from, * to_next; - u32 cpu_index = os_get_cpu_number(); + u32 thread_index = vlib_get_thread_index(); from = vlib_frame_vector_args (from_frame); n_left_from = from_frame->n_vectors; @@ -749,10 +749,10 @@ lookup_dpo_ip6_inline (vlib_main_t * vm, vnet_buffer(b1)->ip.adj_index[VLIB_TX] = dpo1->dpoi_index; vlib_increment_combined_counter - (cm, cpu_index, lbi0, 1, + (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, b0)); vlib_increment_combined_counter - (cm, cpu_index, lbi1, 1, + (cm, thread_index, lbi1, 1, vlib_buffer_length_in_chain (vm, b1)); if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED)) @@ -853,7 +853,7 @@ lookup_dpo_ip6_inline (vlib_main_t * vm, vnet_buffer(b0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index; vlib_increment_combined_counter - (cm, cpu_index, lbi0, 1, + (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, b0)); if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED)) @@ -930,7 +930,7 @@ lookup_dpo_mpls_inline (vlib_main_t * vm, int table_from_interface) { u32 n_left_from, next_index, * from, * to_next; - u32 cpu_index = os_get_cpu_number(); + u32 thread_index = vlib_get_thread_index(); vlib_combined_counter_main_t * cm = &load_balance_main.lbm_to_counters; from = vlib_frame_vector_args (from_frame); @@ -994,7 +994,7 @@ lookup_dpo_mpls_inline (vlib_main_t * vm, vnet_buffer(b0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index; vlib_increment_combined_counter - (cm, cpu_index, lbi0, 1, + (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, b0)); if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED)) diff --git a/src/vnet/dpo/replicate_dpo.c b/src/vnet/dpo/replicate_dpo.c index a9f334be..e25ceae9 100644 --- a/src/vnet/dpo/replicate_dpo.c +++ b/src/vnet/dpo/replicate_dpo.c @@ -627,7 +627,7 @@ replicate_inline (vlib_main_t * vm, vlib_combined_counter_main_t * cm = &replicate_main.repm_counters; replicate_main_t * rm = &replicate_main; u32 n_left_from, * from, * to_next, next_index; - u32 cpu_index = os_get_cpu_number(); + u32 thread_index = vlib_get_thread_index(); from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -657,12 +657,12 @@ replicate_inline (vlib_main_t * vm, rep0 = replicate_get(repi0); vlib_increment_combined_counter( - cm, cpu_index, repi0, 1, + cm, thread_index, repi0, 1, vlib_buffer_length_in_chain(vm, b0)); - vec_validate (rm->clones[cpu_index], rep0->rep_n_buckets - 1); + vec_validate (rm->clones[thread_index], rep0->rep_n_buckets - 1); - num_cloned = vlib_buffer_clone (vm, bi0, rm->clones[cpu_index], rep0->rep_n_buckets, 128); + num_cloned = vlib_buffer_clone (vm, bi0, rm->clones[thread_index], rep0->rep_n_buckets, 128); if (num_cloned != rep0->rep_n_buckets) { @@ -673,7 +673,7 @@ replicate_inline (vlib_main_t * vm, for (bucket = 0; bucket < num_cloned; bucket++) { - ci0 = rm->clones[cpu_index][bucket]; + ci0 = rm->clones[thread_index][bucket]; c0 = vlib_get_buffer(vm, ci0); to_next[0] = ci0; @@ -700,7 +700,7 @@ replicate_inline (vlib_main_t * vm, vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); } } - vec_reset_length (rm->clones[cpu_index]); + vec_reset_length (rm->clones[thread_index]); } vlib_put_next_frame (vm, node, next_index, n_left_to_next); diff --git a/src/vnet/ethernet/arp.c b/src/vnet/ethernet/arp.c index ee757505..c74a097e 100644 --- a/src/vnet/ethernet/arp.c +++ b/src/vnet/ethernet/arp.c @@ -1771,7 +1771,7 @@ set_ip4_over_ethernet_rpc_callback (vnet_arp_set_ip4_over_ethernet_rpc_args_t * a) { vnet_main_t *vm = vnet_get_main (); - ASSERT (os_get_cpu_number () == 0); + ASSERT (vlib_get_thread_index () == 0); if (a->flags & ETHERNET_ARP_ARGS_REMOVE) vnet_arp_unset_ip4_over_ethernet_internal (vm, a); diff --git a/src/vnet/ethernet/interface.c b/src/vnet/ethernet/interface.c index 9894e3c8..335e3f9f 100644 --- a/src/vnet/ethernet/interface.c +++ b/src/vnet/ethernet/interface.c @@ -362,7 +362,7 @@ simulated_ethernet_interface_tx (vlib_main_t * vm, u32 next_index = VNET_SIMULATED_ETHERNET_TX_NEXT_ETHERNET_INPUT; u32 i, next_node_index, bvi_flag, sw_if_index; u32 n_pkts = 0, n_bytes = 0; - u32 cpu_index = vm->cpu_index; + u32 thread_index = vm->thread_index; vnet_main_t *vnm = vnet_get_main (); vnet_interface_main_t *im = &vnm->interface_main; vlib_node_main_t *nm = &vm->node_main; @@ -420,8 +420,9 @@ simulated_ethernet_interface_tx (vlib_main_t * vm, /* increment TX interface stat */ vlib_increment_combined_counter (im->combined_sw_if_counters + - VNET_INTERFACE_COUNTER_TX, cpu_index, - sw_if_index, n_pkts, n_bytes); + VNET_INTERFACE_COUNTER_TX, + thread_index, sw_if_index, n_pkts, + n_bytes); } return n_left_from; diff --git a/src/vnet/ethernet/node.c b/src/vnet/ethernet/node.c index b699e381..f7787ed2 100755 --- a/src/vnet/ethernet/node.c +++ b/src/vnet/ethernet/node.c @@ -291,7 +291,7 @@ ethernet_input_inline (vlib_main_t * vm, vlib_node_runtime_t *error_node; u32 n_left_from, next_index, *from, *to_next; u32 stats_sw_if_index, stats_n_packets, stats_n_bytes; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); u32 cached_sw_if_index = ~0; u32 cached_is_l2 = 0; /* shut up gcc */ vnet_hw_interface_t *hi = NULL; /* used for main interface only */ @@ -510,7 +510,7 @@ ethernet_input_inline (vlib_main_t * vm, interface_main.combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - cpu_index, + thread_index, new_sw_if_index0, 1, len0); if (new_sw_if_index1 != old_sw_if_index1 @@ -519,7 +519,7 @@ ethernet_input_inline (vlib_main_t * vm, interface_main.combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - cpu_index, + thread_index, new_sw_if_index1, 1, len1); @@ -530,7 +530,7 @@ ethernet_input_inline (vlib_main_t * vm, vlib_increment_combined_counter (vnm->interface_main.combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - cpu_index, + thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); stats_n_packets = stats_n_bytes = 0; @@ -696,13 +696,13 @@ ethernet_input_inline (vlib_main_t * vm, vlib_increment_combined_counter (vnm->interface_main.combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - cpu_index, new_sw_if_index0, 1, len0); + thread_index, new_sw_if_index0, 1, len0); if (stats_n_packets > 0) { vlib_increment_combined_counter (vnm->interface_main.combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - cpu_index, + thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); stats_n_packets = stats_n_bytes = 0; } @@ -734,7 +734,7 @@ ethernet_input_inline (vlib_main_t * vm, vlib_increment_combined_counter (vnm->interface_main.combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - cpu_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); + thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); node->runtime_data[0] = stats_sw_if_index; } diff --git a/src/vnet/gre/node.c b/src/vnet/gre/node.c index 2683586e..acf15f24 100644 --- a/src/vnet/gre/node.c +++ b/src/vnet/gre/node.c @@ -75,7 +75,7 @@ gre_input (vlib_main_t * vm, u64 cached_tunnel_key6[4]; u32 cached_tunnel_sw_if_index = 0, tunnel_sw_if_index = 0; - u32 cpu_index = os_get_cpu_number(); + u32 thread_index = vlib_get_thread_index(); u32 len; vnet_interface_main_t *im = &gm->vnet_main->interface_main; @@ -257,7 +257,7 @@ gre_input (vlib_main_t * vm, len = vlib_buffer_length_in_chain (vm, b0); vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - cpu_index, + thread_index, tunnel_sw_if_index, 1 /* packets */, len /* bytes */); @@ -324,7 +324,7 @@ drop0: len = vlib_buffer_length_in_chain (vm, b1); vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - cpu_index, + thread_index, tunnel_sw_if_index, 1 /* packets */, len /* bytes */); @@ -502,7 +502,7 @@ drop1: len = vlib_buffer_length_in_chain (vm, b0); vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - cpu_index, + thread_index, tunnel_sw_if_index, 1 /* packets */, len /* bytes */); diff --git a/src/vnet/interface.h b/src/vnet/interface.h index a1ea2d61..08f08b10 100644 --- a/src/vnet/interface.h +++ b/src/vnet/interface.h @@ -468,7 +468,7 @@ typedef struct vnet_hw_interface_t u32 input_node_index; /* input node cpu index by queue */ - u32 *input_node_cpu_index_by_queue; + u32 *input_node_thread_index_by_queue; } vnet_hw_interface_t; diff --git a/src/vnet/interface_output.c b/src/vnet/interface_output.c index 03f2cdca..663dc309 100644 --- a/src/vnet/interface_output.c +++ b/src/vnet/interface_output.c @@ -196,7 +196,7 @@ slow_path (vlib_main_t * vm, */ static_always_inline void incr_output_stats (vnet_main_t * vnm, - u32 cpu_index, + u32 thread_index, u32 length, u32 sw_if_index, u32 * last_sw_if_index, u32 * n_packets, u32 * n_bytes) @@ -216,7 +216,7 @@ incr_output_stats (vnet_main_t * vnm, vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX, - cpu_index, + thread_index, *last_sw_if_index, *n_packets, *n_bytes); } @@ -240,7 +240,7 @@ vnet_interface_output_node_flatten (vlib_main_t * vm, u32 n_left_to_tx, *from, *from_end, *to_tx; u32 n_bytes, n_buffers, n_packets; u32 last_sw_if_index; - u32 cpu_index = vm->cpu_index; + u32 thread_index = vm->thread_index; n_buffers = frame->n_vectors; @@ -266,7 +266,7 @@ vnet_interface_output_node_flatten (vlib_main_t * vm, cm = vec_elt_at_index (vnm->interface_main.sw_if_counters, VNET_INTERFACE_COUNTER_TX_ERROR); - vlib_increment_simple_counter (cm, cpu_index, + vlib_increment_simple_counter (cm, thread_index, rt->sw_if_index, n_buffers); return vlib_error_drop_buffers (vm, node, from, /* buffer stride */ 1, @@ -341,18 +341,18 @@ vnet_interface_output_node_flatten (vlib_main_t * vm, from += 1; to_tx += n_buffers; n_left_to_tx -= n_buffers; - incr_output_stats (vnm, cpu_index, n_slow_bytes, + incr_output_stats (vnm, thread_index, n_slow_bytes, vnet_buffer (b)->sw_if_index[VLIB_TX], &last_sw_if_index, &n_packets, &n_bytes); } } else { - incr_output_stats (vnm, cpu_index, + incr_output_stats (vnm, thread_index, vlib_buffer_length_in_chain (vm, b0), vnet_buffer (b0)->sw_if_index[VLIB_TX], &last_sw_if_index, &n_packets, &n_bytes); - incr_output_stats (vnm, cpu_index, + incr_output_stats (vnm, thread_index, vlib_buffer_length_in_chain (vm, b0), vnet_buffer (b1)->sw_if_index[VLIB_TX], &last_sw_if_index, &n_packets, &n_bytes); @@ -396,7 +396,7 @@ vnet_interface_output_node_flatten (vlib_main_t * vm, to_tx += n_buffers; n_left_to_tx -= n_buffers; } - incr_output_stats (vnm, cpu_index, + incr_output_stats (vnm, thread_index, vlib_buffer_length_in_chain (vm, b0), vnet_buffer (b0)->sw_if_index[VLIB_TX], &last_sw_if_index, &n_packets, &n_bytes); @@ -408,7 +408,7 @@ vnet_interface_output_node_flatten (vlib_main_t * vm, } /* Final update of interface stats. */ - incr_output_stats (vnm, cpu_index, 0, ~0, /* ~0 will flush stats */ + incr_output_stats (vnm, thread_index, 0, ~0, /* ~0 will flush stats */ &last_sw_if_index, &n_packets, &n_bytes); return n_buffers; @@ -428,7 +428,7 @@ vnet_interface_output_node (vlib_main_t * vm, u32 n_left_to_tx, *from, *from_end, *to_tx; u32 n_bytes, n_buffers, n_packets; u32 n_bytes_b0, n_bytes_b1, n_bytes_b2, n_bytes_b3; - u32 cpu_index = vm->cpu_index; + u32 thread_index = vm->thread_index; vnet_interface_main_t *im = &vnm->interface_main; u32 next_index = VNET_INTERFACE_OUTPUT_NEXT_TX; u32 current_config_index = ~0; @@ -458,7 +458,7 @@ vnet_interface_output_node (vlib_main_t * vm, cm = vec_elt_at_index (vnm->interface_main.sw_if_counters, VNET_INTERFACE_COUNTER_TX_ERROR); - vlib_increment_simple_counter (cm, cpu_index, + vlib_increment_simple_counter (cm, thread_index, rt->sw_if_index, n_buffers); return vlib_error_drop_buffers (vm, node, from, @@ -558,7 +558,7 @@ vnet_interface_output_node (vlib_main_t * vm, { vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX, - cpu_index, tx_swif0, 1, + thread_index, tx_swif0, 1, n_bytes_b0); } @@ -567,7 +567,7 @@ vnet_interface_output_node (vlib_main_t * vm, vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX, - cpu_index, tx_swif1, 1, + thread_index, tx_swif1, 1, n_bytes_b1); } @@ -576,7 +576,7 @@ vnet_interface_output_node (vlib_main_t * vm, vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX, - cpu_index, tx_swif2, 1, + thread_index, tx_swif2, 1, n_bytes_b2); } if (PREDICT_FALSE (tx_swif3 != rt->sw_if_index)) @@ -584,7 +584,7 @@ vnet_interface_output_node (vlib_main_t * vm, vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX, - cpu_index, tx_swif3, 1, + thread_index, tx_swif3, 1, n_bytes_b3); } } @@ -623,7 +623,7 @@ vnet_interface_output_node (vlib_main_t * vm, vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX, - cpu_index, tx_swif0, 1, + thread_index, tx_swif0, 1, n_bytes_b0); } } @@ -634,7 +634,7 @@ vnet_interface_output_node (vlib_main_t * vm, /* Update main interface stats. */ vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX, - cpu_index, + thread_index, rt->sw_if_index, n_packets, n_bytes); return n_buffers; } @@ -893,7 +893,7 @@ process_drop_punt (vlib_main_t * vm, u32 current_sw_if_index, n_errors_current_sw_if_index; u64 current_counter; vlib_simple_counter_main_t *cm; - u32 cpu_index = vm->cpu_index; + u32 thread_index = vm->thread_index; static vlib_error_t memory[VNET_ERROR_N_DISPOSITION]; static char memory_init[VNET_ERROR_N_DISPOSITION]; @@ -965,19 +965,19 @@ process_drop_punt (vlib_main_t * vm, current_counter -= 2; n_errors_current_sw_if_index -= 2; - vlib_increment_simple_counter (cm, cpu_index, sw_if_index0, 1); - vlib_increment_simple_counter (cm, cpu_index, sw_if_index1, 1); + vlib_increment_simple_counter (cm, thread_index, sw_if_index0, 1); + vlib_increment_simple_counter (cm, thread_index, sw_if_index1, 1); /* Increment super-interface drop/punt counters for sub-interfaces. */ sw_if0 = vnet_get_sw_interface (vnm, sw_if_index0); vlib_increment_simple_counter - (cm, cpu_index, sw_if0->sup_sw_if_index, + (cm, thread_index, sw_if0->sup_sw_if_index, sw_if0->sup_sw_if_index != sw_if_index0); sw_if1 = vnet_get_sw_interface (vnm, sw_if_index1); vlib_increment_simple_counter - (cm, cpu_index, sw_if1->sup_sw_if_index, + (cm, thread_index, sw_if1->sup_sw_if_index, sw_if1->sup_sw_if_index != sw_if_index1); em->counters[current_counter_index] = current_counter; @@ -1013,11 +1013,12 @@ process_drop_punt (vlib_main_t * vm, sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX]; /* Increment drop/punt counters. */ - vlib_increment_simple_counter (cm, cpu_index, sw_if_index0, 1); + vlib_increment_simple_counter (cm, thread_index, sw_if_index0, 1); /* Increment super-interface drop/punt counters for sub-interfaces. */ sw_if0 = vnet_get_sw_interface (vnm, sw_if_index0); - vlib_increment_simple_counter (cm, cpu_index, sw_if0->sup_sw_if_index, + vlib_increment_simple_counter (cm, thread_index, + sw_if0->sup_sw_if_index, sw_if0->sup_sw_if_index != sw_if_index0); if (PREDICT_FALSE (e0 != current_error)) @@ -1041,12 +1042,12 @@ process_drop_punt (vlib_main_t * vm, { vnet_sw_interface_t *si; - vlib_increment_simple_counter (cm, cpu_index, current_sw_if_index, + vlib_increment_simple_counter (cm, thread_index, current_sw_if_index, n_errors_current_sw_if_index); si = vnet_get_sw_interface (vnm, current_sw_if_index); if (si->sup_sw_if_index != current_sw_if_index) - vlib_increment_simple_counter (cm, cpu_index, si->sup_sw_if_index, + vlib_increment_simple_counter (cm, thread_index, si->sup_sw_if_index, n_errors_current_sw_if_index); } diff --git a/src/vnet/ip/ip4_forward.c b/src/vnet/ip/ip4_forward.c index ee1703e7..fdfe7f63 100644 --- a/src/vnet/ip/ip4_forward.c +++ b/src/vnet/ip/ip4_forward.c @@ -75,7 +75,7 @@ ip4_lookup_inline (vlib_main_t * vm, vlib_combined_counter_main_t *cm = &load_balance_main.lbm_to_counters; u32 n_left_from, n_left_to_next, *from, *to_next; ip_lookup_next_t next; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -292,19 +292,19 @@ ip4_lookup_inline (vlib_main_t * vm, vnet_buffer (p3)->ip.adj_index[VLIB_TX] = dpo3->dpoi_index; vlib_increment_combined_counter - (cm, cpu_index, lb_index0, 1, + (cm, thread_index, lb_index0, 1, vlib_buffer_length_in_chain (vm, p0) + sizeof (ethernet_header_t)); vlib_increment_combined_counter - (cm, cpu_index, lb_index1, 1, + (cm, thread_index, lb_index1, 1, vlib_buffer_length_in_chain (vm, p1) + sizeof (ethernet_header_t)); vlib_increment_combined_counter - (cm, cpu_index, lb_index2, 1, + (cm, thread_index, lb_index2, 1, vlib_buffer_length_in_chain (vm, p2) + sizeof (ethernet_header_t)); vlib_increment_combined_counter - (cm, cpu_index, lb_index3, 1, + (cm, thread_index, lb_index3, 1, vlib_buffer_length_in_chain (vm, p3) + sizeof (ethernet_header_t)); @@ -392,7 +392,7 @@ ip4_lookup_inline (vlib_main_t * vm, vnet_buffer (p0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index; vlib_increment_combined_counter - (cm, cpu_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0)); + (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0)); from += 1; to_next += 1; @@ -479,7 +479,7 @@ ip4_load_balance (vlib_main_t * vm, vlib_combined_counter_main_t *cm = &load_balance_main.lbm_via_counters; u32 n_left_from, n_left_to_next, *from, *to_next; ip_lookup_next_t next; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -584,9 +584,9 @@ ip4_load_balance (vlib_main_t * vm, vnet_buffer (p1)->ip.adj_index[VLIB_TX] = dpo1->dpoi_index; vlib_increment_combined_counter - (cm, cpu_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0)); + (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0)); vlib_increment_combined_counter - (cm, cpu_index, lbi1, 1, vlib_buffer_length_in_chain (vm, p1)); + (cm, thread_index, lbi1, 1, vlib_buffer_length_in_chain (vm, p1)); vlib_validate_buffer_enqueue_x2 (vm, node, next, to_next, n_left_to_next, @@ -639,7 +639,7 @@ ip4_load_balance (vlib_main_t * vm, vnet_buffer (p0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index; vlib_increment_combined_counter - (cm, cpu_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0)); + (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0)); vlib_validate_buffer_enqueue_x1 (vm, node, next, to_next, n_left_to_next, @@ -2330,7 +2330,7 @@ ip4_rewrite_inline (vlib_main_t * vm, n_left_from = frame->n_vectors; next_index = node->cached_next_index; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); while (n_left_from > 0) { @@ -2379,9 +2379,9 @@ ip4_rewrite_inline (vlib_main_t * vm, if (do_counters) { vlib_prefetch_combined_counter (&adjacency_counters, - cpu_index, adj_index0); + thread_index, adj_index0); vlib_prefetch_combined_counter (&adjacency_counters, - cpu_index, adj_index1); + thread_index, adj_index1); } ip0 = vlib_buffer_get_current (p0); @@ -2527,13 +2527,13 @@ ip4_rewrite_inline (vlib_main_t * vm, { vlib_increment_combined_counter (&adjacency_counters, - cpu_index, + thread_index, adj_index0, 1, vlib_buffer_length_in_chain (vm, p0) + rw_len0); vlib_increment_combined_counter (&adjacency_counters, - cpu_index, + thread_index, adj_index1, 1, vlib_buffer_length_in_chain (vm, p1) + rw_len1); } @@ -2618,7 +2618,7 @@ ip4_rewrite_inline (vlib_main_t * vm, if (do_counters) vlib_prefetch_combined_counter (&adjacency_counters, - cpu_index, adj_index0); + thread_index, adj_index0); /* Guess we are only writing on simple Ethernet header. */ vnet_rewrite_one_header (adj0[0], ip0, sizeof (ethernet_header_t)); @@ -2637,7 +2637,7 @@ ip4_rewrite_inline (vlib_main_t * vm, if (do_counters) vlib_increment_combined_counter (&adjacency_counters, - cpu_index, adj_index0, 1, + thread_index, adj_index0, 1, vlib_buffer_length_in_chain (vm, p0) + rw_len0); /* Check MTU of outgoing interface. */ diff --git a/src/vnet/ip/ip4_input.c b/src/vnet/ip/ip4_input.c index ba200a9f..3b08f4b0 100644 --- a/src/vnet/ip/ip4_input.c +++ b/src/vnet/ip/ip4_input.c @@ -85,7 +85,7 @@ ip4_input_inline (vlib_main_t * vm, vlib_node_runtime_t *error_node = vlib_node_get_runtime (vm, ip4_input_node.index); vlib_simple_counter_main_t *cm; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -178,8 +178,8 @@ ip4_input_inline (vlib_main_t * vm, vnet_feature_arc_start (arc0, sw_if_index0, &next0, p0); vnet_feature_arc_start (arc1, sw_if_index1, &next1, p1); - vlib_increment_simple_counter (cm, cpu_index, sw_if_index0, 1); - vlib_increment_simple_counter (cm, cpu_index, sw_if_index1, 1); + vlib_increment_simple_counter (cm, thread_index, sw_if_index0, 1); + vlib_increment_simple_counter (cm, thread_index, sw_if_index1, 1); /* Punt packets with options or wrong version. */ if (PREDICT_FALSE (ip0->ip_version_and_header_length != 0x45)) @@ -299,7 +299,7 @@ ip4_input_inline (vlib_main_t * vm, vnet_buffer (p0)->ip.adj_index[VLIB_RX] = ~0; vnet_feature_arc_start (arc0, sw_if_index0, &next0, p0); - vlib_increment_simple_counter (cm, cpu_index, sw_if_index0, 1); + vlib_increment_simple_counter (cm, thread_index, sw_if_index0, 1); /* Punt packets with options or wrong version. */ if (PREDICT_FALSE (ip0->ip_version_and_header_length != 0x45)) diff --git a/src/vnet/ip/ip6_forward.c b/src/vnet/ip/ip6_forward.c index c120f12c..c2fc4f87 100644 --- a/src/vnet/ip/ip6_forward.c +++ b/src/vnet/ip/ip6_forward.c @@ -74,7 +74,7 @@ ip6_lookup_inline (vlib_main_t * vm, vlib_combined_counter_main_t *cm = &load_balance_main.lbm_to_counters; u32 n_left_from, n_left_to_next, *from, *to_next; ip_lookup_next_t next; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -185,9 +185,9 @@ ip6_lookup_inline (vlib_main_t * vm, vnet_buffer (p1)->ip.adj_index[VLIB_TX] = dpo1->dpoi_index; vlib_increment_combined_counter - (cm, cpu_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0)); + (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0)); vlib_increment_combined_counter - (cm, cpu_index, lbi1, 1, vlib_buffer_length_in_chain (vm, p1)); + (cm, thread_index, lbi1, 1, vlib_buffer_length_in_chain (vm, p1)); from += 2; to_next += 2; @@ -291,7 +291,7 @@ ip6_lookup_inline (vlib_main_t * vm, vnet_buffer (p0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index; vlib_increment_combined_counter - (cm, cpu_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0)); + (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0)); from += 1; to_next += 1; @@ -703,7 +703,7 @@ ip6_load_balance (vlib_main_t * vm, vlib_combined_counter_main_t *cm = &load_balance_main.lbm_via_counters; u32 n_left_from, n_left_to_next, *from, *to_next; ip_lookup_next_t next; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); ip6_main_t *im = &ip6_main; from = vlib_frame_vector_args (frame); @@ -824,9 +824,9 @@ ip6_load_balance (vlib_main_t * vm, vnet_buffer (p1)->ip.adj_index[VLIB_TX] = dpo1->dpoi_index; vlib_increment_combined_counter - (cm, cpu_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0)); + (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0)); vlib_increment_combined_counter - (cm, cpu_index, lbi1, 1, vlib_buffer_length_in_chain (vm, p1)); + (cm, thread_index, lbi1, 1, vlib_buffer_length_in_chain (vm, p1)); vlib_validate_buffer_enqueue_x2 (vm, node, next, to_next, n_left_to_next, @@ -886,7 +886,7 @@ ip6_load_balance (vlib_main_t * vm, } vlib_increment_combined_counter - (cm, cpu_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0)); + (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0)); vlib_validate_buffer_enqueue_x1 (vm, node, next, to_next, n_left_to_next, @@ -1897,7 +1897,7 @@ ip6_rewrite_inline (vlib_main_t * vm, n_left_from = frame->n_vectors; next_index = node->cached_next_index; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); while (n_left_from > 0) { @@ -2019,11 +2019,11 @@ ip6_rewrite_inline (vlib_main_t * vm, { vlib_increment_combined_counter (&adjacency_counters, - cpu_index, adj_index0, 1, + thread_index, adj_index0, 1, vlib_buffer_length_in_chain (vm, p0) + rw_len0); vlib_increment_combined_counter (&adjacency_counters, - cpu_index, adj_index1, 1, + thread_index, adj_index1, 1, vlib_buffer_length_in_chain (vm, p1) + rw_len1); } @@ -2156,7 +2156,7 @@ ip6_rewrite_inline (vlib_main_t * vm, { vlib_increment_combined_counter (&adjacency_counters, - cpu_index, adj_index0, 1, + thread_index, adj_index0, 1, vlib_buffer_length_in_chain (vm, p0) + rw_len0); } diff --git a/src/vnet/ip/ip6_input.c b/src/vnet/ip/ip6_input.c index 20306088..ffdc4727 100644 --- a/src/vnet/ip/ip6_input.c +++ b/src/vnet/ip/ip6_input.c @@ -82,7 +82,7 @@ ip6_input (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) vlib_node_runtime_t *error_node = vlib_node_get_runtime (vm, ip6_input_node.index); vlib_simple_counter_main_t *cm; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -171,8 +171,8 @@ ip6_input (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) vnet_feature_arc_start (arc0, sw_if_index0, &next0, p0); vnet_feature_arc_start (arc1, sw_if_index1, &next1, p1); - vlib_increment_simple_counter (cm, cpu_index, sw_if_index0, 1); - vlib_increment_simple_counter (cm, cpu_index, sw_if_index1, 1); + vlib_increment_simple_counter (cm, thread_index, sw_if_index0, 1); + vlib_increment_simple_counter (cm, thread_index, sw_if_index1, 1); error0 = error1 = IP6_ERROR_NONE; @@ -270,7 +270,7 @@ ip6_input (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) vnet_buffer (p0)->ip.adj_index[VLIB_RX] = ~0; vnet_feature_arc_start (arc0, sw_if_index0, &next0, p0); - vlib_increment_simple_counter (cm, cpu_index, sw_if_index0, 1); + vlib_increment_simple_counter (cm, thread_index, sw_if_index0, 1); error0 = IP6_ERROR_NONE; /* Version != 6? Drop it. */ diff --git a/src/vnet/ip/ip6_neighbor.c b/src/vnet/ip/ip6_neighbor.c index 5d1fb6f8..2af546df 100644 --- a/src/vnet/ip/ip6_neighbor.c +++ b/src/vnet/ip/ip6_neighbor.c @@ -581,7 +581,7 @@ vnet_set_ip6_ethernet_neighbor (vlib_main_t * vm, u32 next_index; pending_resolution_t *pr, *mc; - if (os_get_cpu_number ()) + if (vlib_get_thread_index ()) { set_unset_ip6_neighbor_rpc (vm, sw_if_index, a, link_layer_address, 1 /* set new neighbor */ , is_static, @@ -722,7 +722,7 @@ vnet_unset_ip6_ethernet_neighbor (vlib_main_t * vm, uword *p; int rv = 0; - if (os_get_cpu_number ()) + if (vlib_get_thread_index ()) { set_unset_ip6_neighbor_rpc (vm, sw_if_index, a, link_layer_address, 0 /* unset */ , 0, 0); diff --git a/src/vnet/ipsec/esp.h b/src/vnet/ipsec/esp.h index 50cac806..799003b9 100644 --- a/src/vnet/ipsec/esp.h +++ b/src/vnet/ipsec/esp.h @@ -282,8 +282,8 @@ hmac_calc (ipsec_integ_alg_t alg, u8 * data, int data_len, u8 * signature, u8 use_esn, u32 seq_hi) { esp_main_t *em = &esp_main; - u32 cpu_index = os_get_cpu_number (); - HMAC_CTX *ctx = &(em->per_thread_data[cpu_index].hmac_ctx); + u32 thread_index = vlib_get_thread_index (); + HMAC_CTX *ctx = &(em->per_thread_data[thread_index].hmac_ctx); const EVP_MD *md = NULL; unsigned int len; @@ -292,10 +292,10 @@ hmac_calc (ipsec_integ_alg_t alg, if (PREDICT_FALSE (em->esp_integ_algs[alg].md == 0)) return 0; - if (PREDICT_FALSE (alg != em->per_thread_data[cpu_index].last_integ_alg)) + if (PREDICT_FALSE (alg != em->per_thread_data[thread_index].last_integ_alg)) { md = em->esp_integ_algs[alg].md; - em->per_thread_data[cpu_index].last_integ_alg = alg; + em->per_thread_data[thread_index].last_integ_alg = alg; } HMAC_Init (ctx, key, key_len, md); diff --git a/src/vnet/ipsec/esp_decrypt.c b/src/vnet/ipsec/esp_decrypt.c index 7289b260..925d2b45 100644 --- a/src/vnet/ipsec/esp_decrypt.c +++ b/src/vnet/ipsec/esp_decrypt.c @@ -85,8 +85,8 @@ esp_decrypt_aes_cbc (ipsec_crypto_alg_t alg, u8 * in, u8 * out, size_t in_len, u8 * key, u8 * iv) { esp_main_t *em = &esp_main; - u32 cpu_index = os_get_cpu_number (); - EVP_CIPHER_CTX *ctx = &(em->per_thread_data[cpu_index].decrypt_ctx); + u32 thread_index = vlib_get_thread_index (); + EVP_CIPHER_CTX *ctx = &(em->per_thread_data[thread_index].decrypt_ctx); const EVP_CIPHER *cipher = NULL; int out_len; @@ -95,10 +95,11 @@ esp_decrypt_aes_cbc (ipsec_crypto_alg_t alg, if (PREDICT_FALSE (em->esp_crypto_algs[alg].type == 0)) return; - if (PREDICT_FALSE (alg != em->per_thread_data[cpu_index].last_decrypt_alg)) + if (PREDICT_FALSE + (alg != em->per_thread_data[thread_index].last_decrypt_alg)) { cipher = em->esp_crypto_algs[alg].type; - em->per_thread_data[cpu_index].last_decrypt_alg = alg; + em->per_thread_data[thread_index].last_decrypt_alg = alg; } EVP_DecryptInit_ex (ctx, cipher, NULL, key, iv); @@ -117,11 +118,11 @@ esp_decrypt_node_fn (vlib_main_t * vm, u32 *recycle = 0; from = vlib_frame_vector_args (from_frame); n_left_from = from_frame->n_vectors; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); ipsec_alloc_empty_buffers (vm, im); - u32 *empty_buffers = im->empty_buffers[cpu_index]; + u32 *empty_buffers = im->empty_buffers[thread_index]; if (PREDICT_FALSE (vec_len (empty_buffers) < n_left_from)) { diff --git a/src/vnet/ipsec/esp_encrypt.c b/src/vnet/ipsec/esp_encrypt.c index 44ae2297..b2bc4e0b 100644 --- a/src/vnet/ipsec/esp_encrypt.c +++ b/src/vnet/ipsec/esp_encrypt.c @@ -88,8 +88,8 @@ esp_encrypt_aes_cbc (ipsec_crypto_alg_t alg, u8 * in, u8 * out, size_t in_len, u8 * key, u8 * iv) { esp_main_t *em = &esp_main; - u32 cpu_index = os_get_cpu_number (); - EVP_CIPHER_CTX *ctx = &(em->per_thread_data[cpu_index].encrypt_ctx); + u32 thread_index = vlib_get_thread_index (); + EVP_CIPHER_CTX *ctx = &(em->per_thread_data[thread_index].encrypt_ctx); const EVP_CIPHER *cipher = NULL; int out_len; @@ -98,10 +98,11 @@ esp_encrypt_aes_cbc (ipsec_crypto_alg_t alg, if (PREDICT_FALSE (em->esp_crypto_algs[alg].type == IPSEC_CRYPTO_ALG_NONE)) return; - if (PREDICT_FALSE (alg != em->per_thread_data[cpu_index].last_encrypt_alg)) + if (PREDICT_FALSE + (alg != em->per_thread_data[thread_index].last_encrypt_alg)) { cipher = em->esp_crypto_algs[alg].type; - em->per_thread_data[cpu_index].last_encrypt_alg = alg; + em->per_thread_data[thread_index].last_encrypt_alg = alg; } EVP_EncryptInit_ex (ctx, cipher, NULL, key, iv); @@ -119,11 +120,11 @@ esp_encrypt_node_fn (vlib_main_t * vm, n_left_from = from_frame->n_vectors; ipsec_main_t *im = &ipsec_main; u32 *recycle = 0; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); ipsec_alloc_empty_buffers (vm, im); - u32 *empty_buffers = im->empty_buffers[cpu_index]; + u32 *empty_buffers = im->empty_buffers[thread_index]; if (PREDICT_FALSE (vec_len (empty_buffers) < n_left_from)) { diff --git a/src/vnet/ipsec/ikev2.c b/src/vnet/ipsec/ikev2.c index 2c1074d8..3f9978a7 100644 --- a/src/vnet/ipsec/ikev2.c +++ b/src/vnet/ipsec/ikev2.c @@ -303,16 +303,16 @@ static void ikev2_delete_sa (ikev2_sa_t * sa) { ikev2_main_t *km = &ikev2_main; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); uword *p; ikev2_sa_free_all_vec (sa); - p = hash_get (km->per_thread_data[cpu_index].sa_by_rspi, sa->rspi); + p = hash_get (km->per_thread_data[thread_index].sa_by_rspi, sa->rspi); if (p) { - hash_unset (km->per_thread_data[cpu_index].sa_by_rspi, sa->rspi); - pool_put (km->per_thread_data[cpu_index].sas, sa); + hash_unset (km->per_thread_data[thread_index].sa_by_rspi, sa->rspi); + pool_put (km->per_thread_data[thread_index].sas, sa); } } @@ -776,29 +776,31 @@ ikev2_initial_contact_cleanup (ikev2_sa_t * sa) ikev2_sa_t *tmp; u32 i, *delete = 0; ikev2_child_sa_t *c; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); if (!sa->initial_contact) return; /* find old IKE SAs with the same authenticated identity */ /* *INDENT-OFF* */ - pool_foreach (tmp, km->per_thread_data[cpu_index].sas, ({ + pool_foreach (tmp, km->per_thread_data[thread_index].sas, ({ if (tmp->i_id.type != sa->i_id.type || vec_len(tmp->i_id.data) != vec_len(sa->i_id.data) || memcmp(sa->i_id.data, tmp->i_id.data, vec_len(sa->i_id.data))) continue; if (sa->rspi != tmp->rspi) - vec_add1(delete, tmp - km->per_thread_data[cpu_index].sas); + vec_add1(delete, tmp - km->per_thread_data[thread_index].sas); })); /* *INDENT-ON* */ for (i = 0; i < vec_len (delete); i++) { - tmp = pool_elt_at_index (km->per_thread_data[cpu_index].sas, delete[i]); - vec_foreach (c, tmp->childs) - ikev2_delete_tunnel_interface (km->vnet_main, tmp, c); + tmp = + pool_elt_at_index (km->per_thread_data[thread_index].sas, delete[i]); + vec_foreach (c, + tmp->childs) ikev2_delete_tunnel_interface (km->vnet_main, + tmp, c); ikev2_delete_sa (tmp); } @@ -1922,10 +1924,10 @@ ikev2_retransmit_sa_init (ike_header_t * ike, { ikev2_main_t *km = &ikev2_main; ikev2_sa_t *sa; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); /* *INDENT-OFF* */ - pool_foreach (sa, km->per_thread_data[cpu_index].sas, ({ + pool_foreach (sa, km->per_thread_data[thread_index].sas, ({ if (sa->ispi == clib_net_to_host_u64(ike->ispi) && sa->iaddr.as_u32 == iaddr.as_u32 && sa->raddr.as_u32 == raddr.as_u32) @@ -2036,7 +2038,7 @@ ikev2_node_fn (vlib_main_t * vm, u32 n_left_from, *from, *to_next; ikev2_next_t next_index; ikev2_main_t *km = &ikev2_main; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -2134,11 +2136,14 @@ ikev2_node_fn (vlib_main_t * vm, if (sa0->state == IKEV2_STATE_SA_INIT) { /* add SA to the pool */ - pool_get (km->per_thread_data[cpu_index].sas, sa0); + pool_get (km->per_thread_data[thread_index].sas, + sa0); clib_memcpy (sa0, &sa, sizeof (*sa0)); - hash_set (km->per_thread_data[cpu_index].sa_by_rspi, + hash_set (km-> + per_thread_data[thread_index].sa_by_rspi, sa0->rspi, - sa0 - km->per_thread_data[cpu_index].sas); + sa0 - + km->per_thread_data[thread_index].sas); } else { @@ -2169,11 +2174,11 @@ ikev2_node_fn (vlib_main_t * vm, if (sa0->state == IKEV2_STATE_SA_INIT) { /* add SA to the pool */ - pool_get (km->per_thread_data[cpu_index].sas, sa0); + pool_get (km->per_thread_data[thread_index].sas, sa0); clib_memcpy (sa0, &sa, sizeof (*sa0)); - hash_set (km->per_thread_data[cpu_index].sa_by_rspi, + hash_set (km->per_thread_data[thread_index].sa_by_rspi, sa0->rspi, - sa0 - km->per_thread_data[cpu_index].sas); + sa0 - km->per_thread_data[thread_index].sas); } else { @@ -2184,12 +2189,13 @@ ikev2_node_fn (vlib_main_t * vm, else if (ike0->exchange == IKEV2_EXCHANGE_IKE_AUTH) { uword *p; - p = hash_get (km->per_thread_data[cpu_index].sa_by_rspi, + p = hash_get (km->per_thread_data[thread_index].sa_by_rspi, clib_net_to_host_u64 (ike0->rspi)); if (p) { - sa0 = pool_elt_at_index (km->per_thread_data[cpu_index].sas, - p[0]); + sa0 = + pool_elt_at_index (km->per_thread_data[thread_index].sas, + p[0]); r = ikev2_retransmit_resp (sa0, ike0); if (r == 1) @@ -2240,12 +2246,13 @@ ikev2_node_fn (vlib_main_t * vm, else if (ike0->exchange == IKEV2_EXCHANGE_INFORMATIONAL) { uword *p; - p = hash_get (km->per_thread_data[cpu_index].sa_by_rspi, + p = hash_get (km->per_thread_data[thread_index].sa_by_rspi, clib_net_to_host_u64 (ike0->rspi)); if (p) { - sa0 = pool_elt_at_index (km->per_thread_data[cpu_index].sas, - p[0]); + sa0 = + pool_elt_at_index (km->per_thread_data[thread_index].sas, + p[0]); r = ikev2_retransmit_resp (sa0, ike0); if (r == 1) @@ -2305,12 +2312,13 @@ ikev2_node_fn (vlib_main_t * vm, else if (ike0->exchange == IKEV2_EXCHANGE_CREATE_CHILD_SA) { uword *p; - p = hash_get (km->per_thread_data[cpu_index].sa_by_rspi, + p = hash_get (km->per_thread_data[thread_index].sa_by_rspi, clib_net_to_host_u64 (ike0->rspi)); if (p) { - sa0 = pool_elt_at_index (km->per_thread_data[cpu_index].sas, - p[0]); + sa0 = + pool_elt_at_index (km->per_thread_data[thread_index].sas, + p[0]); r = ikev2_retransmit_resp (sa0, ike0); if (r == 1) diff --git a/src/vnet/ipsec/ipsec.h b/src/vnet/ipsec/ipsec.h index 58f0f145..c884e360 100644 --- a/src/vnet/ipsec/ipsec.h +++ b/src/vnet/ipsec/ipsec.h @@ -324,21 +324,21 @@ int ipsec_set_interface_key (vnet_main_t * vnm, u32 hw_if_index, always_inline void ipsec_alloc_empty_buffers (vlib_main_t * vm, ipsec_main_t * im) { - u32 cpu_index = os_get_cpu_number (); - uword l = vec_len (im->empty_buffers[cpu_index]); + u32 thread_index = vlib_get_thread_index (); + uword l = vec_len (im->empty_buffers[thread_index]); uword n_alloc = 0; if (PREDICT_FALSE (l < VLIB_FRAME_SIZE)) { - if (!im->empty_buffers[cpu_index]) + if (!im->empty_buffers[thread_index]) { - vec_alloc (im->empty_buffers[cpu_index], 2 * VLIB_FRAME_SIZE); + vec_alloc (im->empty_buffers[thread_index], 2 * VLIB_FRAME_SIZE); } - n_alloc = vlib_buffer_alloc (vm, im->empty_buffers[cpu_index] + l, + n_alloc = vlib_buffer_alloc (vm, im->empty_buffers[thread_index] + l, 2 * VLIB_FRAME_SIZE - l); - _vec_len (im->empty_buffers[cpu_index]) = l + n_alloc; + _vec_len (im->empty_buffers[thread_index]) = l + n_alloc; } } diff --git a/src/vnet/ipsec/ipsec_if.c b/src/vnet/ipsec/ipsec_if.c index dc882004..ed124894 100644 --- a/src/vnet/ipsec/ipsec_if.c +++ b/src/vnet/ipsec/ipsec_if.c @@ -99,7 +99,7 @@ static int ipsec_add_del_tunnel_if_rpc_callback (ipsec_add_del_tunnel_args_t * a) { vnet_main_t *vnm = vnet_get_main (); - ASSERT (os_get_cpu_number () == 0); + ASSERT (vlib_get_thread_index () == 0); return ipsec_add_del_tunnel_if_internal (vnm, a); } diff --git a/src/vnet/l2/l2_bvi.h b/src/vnet/l2/l2_bvi.h index dd1130a6..e21a1616 100644 --- a/src/vnet/l2/l2_bvi.h +++ b/src/vnet/l2/l2_bvi.h @@ -97,7 +97,7 @@ l2_to_bvi (vlib_main_t * vlib_main, vlib_increment_combined_counter (vnet_main->interface_main.combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - vlib_main->cpu_index, + vlib_main->thread_index, vnet_buffer (b0)->sw_if_index[VLIB_RX], 1, vlib_buffer_length_in_chain (vlib_main, b0)); return TO_BVI_ERR_OK; diff --git a/src/vnet/l2/l2_input.c b/src/vnet/l2/l2_input.c index 041ff38d..e5d6878a 100644 --- a/src/vnet/l2/l2_input.c +++ b/src/vnet/l2/l2_input.c @@ -117,7 +117,7 @@ typedef enum static_always_inline void classify_and_dispatch (vlib_main_t * vm, vlib_node_runtime_t * node, - u32 cpu_index, + u32 thread_index, l2input_main_t * msm, vlib_buffer_t * b0, u32 * next0) { /* @@ -237,7 +237,7 @@ l2input_node_inline (vlib_main_t * vm, u32 n_left_from, *from, *to_next; l2input_next_t next_index; l2input_main_t *msm = &l2input_main; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; /* number of packets to process */ @@ -350,10 +350,10 @@ l2input_node_inline (vlib_main_t * vm, vlib_node_increment_counter (vm, l2input_node.index, L2INPUT_ERROR_L2INPUT, 4); - classify_and_dispatch (vm, node, cpu_index, msm, b0, &next0); - classify_and_dispatch (vm, node, cpu_index, msm, b1, &next1); - classify_and_dispatch (vm, node, cpu_index, msm, b2, &next2); - classify_and_dispatch (vm, node, cpu_index, msm, b3, &next3); + classify_and_dispatch (vm, node, thread_index, msm, b0, &next0); + classify_and_dispatch (vm, node, thread_index, msm, b1, &next1); + classify_and_dispatch (vm, node, thread_index, msm, b2, &next2); + classify_and_dispatch (vm, node, thread_index, msm, b3, &next3); /* verify speculative enqueues, maybe switch current next frame */ /* if next0==next1==next_index then nothing special needs to be done */ @@ -393,7 +393,7 @@ l2input_node_inline (vlib_main_t * vm, vlib_node_increment_counter (vm, l2input_node.index, L2INPUT_ERROR_L2INPUT, 1); - classify_and_dispatch (vm, node, cpu_index, msm, b0, &next0); + classify_and_dispatch (vm, node, thread_index, msm, b0, &next0); /* verify speculative enqueue, maybe switch current next frame */ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, diff --git a/src/vnet/l2/l2_output.c b/src/vnet/l2/l2_output.c index 00f22571..e17b2a16 100644 --- a/src/vnet/l2/l2_output.c +++ b/src/vnet/l2/l2_output.c @@ -643,11 +643,11 @@ l2output_create_output_node_mapping (vlib_main_t * vlib_main, vnet_main_t * vnet hw0 = vnet_get_sup_hw_interface (vnet_main, sw_if_index); - uword cpu_number; + uword thread_index; - cpu_number = os_get_cpu_number (); + thread_index = vlib_get_thread_index (); - if (cpu_number) + if (thread_index) { u32 oldflags; diff --git a/src/vnet/l2tp/decap.c b/src/vnet/l2tp/decap.c index e8986935..46104129 100644 --- a/src/vnet/l2tp/decap.c +++ b/src/vnet/l2tp/decap.c @@ -149,7 +149,7 @@ last_stage (vlib_main_t * vm, vlib_node_runtime_t * node, u32 bi) /* per-mapping byte stats include the ethernet header */ vlib_increment_combined_counter (&lm->counter_main, - os_get_cpu_number (), + vlib_get_thread_index (), counter_index, 1 /* packet_increment */ , vlib_buffer_length_in_chain (vm, b) + sizeof (ethernet_header_t)); diff --git a/src/vnet/l2tp/encap.c b/src/vnet/l2tp/encap.c index ed7a9580..dcdfde4b 100644 --- a/src/vnet/l2tp/encap.c +++ b/src/vnet/l2tp/encap.c @@ -124,7 +124,7 @@ last_stage (vlib_main_t * vm, vlib_node_runtime_t * node, u32 bi) /* per-mapping byte stats include the ethernet header */ vlib_increment_combined_counter (&lm->counter_main, - os_get_cpu_number (), + vlib_get_thread_index (), counter_index, 1 /* packet_increment */ , vlib_buffer_length_in_chain (vm, b)); diff --git a/src/vnet/l2tp/l2tp.c b/src/vnet/l2tp/l2tp.c index cb94d7e7..3dedc447 100644 --- a/src/vnet/l2tp/l2tp.c +++ b/src/vnet/l2tp/l2tp.c @@ -157,7 +157,7 @@ test_counters_command_fn (vlib_main_t * vm, u32 session_index; u32 counter_index; u32 nincr = 0; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); /* *INDENT-OFF* */ pool_foreach (session, lm->sessions, @@ -167,11 +167,11 @@ test_counters_command_fn (vlib_main_t * vm, session_index_to_counter_index (session_index, SESSION_COUNTER_USER_TO_NETWORK); vlib_increment_combined_counter (&lm->counter_main, - cpu_index, + thread_index, counter_index, 1/*pkt*/, 1111 /*bytes*/); vlib_increment_combined_counter (&lm->counter_main, - cpu_index, + thread_index, counter_index+1, 1/*pkt*/, 2222 /*bytes*/); nincr++; diff --git a/src/vnet/lisp-gpe/decap.c b/src/vnet/lisp-gpe/decap.c index d887a95f..68769710 100644 --- a/src/vnet/lisp-gpe/decap.c +++ b/src/vnet/lisp-gpe/decap.c @@ -103,7 +103,7 @@ next_index_to_iface (lisp_gpe_main_t * lgm, u32 next_index) } static_always_inline void -incr_decap_stats (vnet_main_t * vnm, u32 cpu_index, u32 length, +incr_decap_stats (vnet_main_t * vnm, u32 thread_index, u32 length, u32 sw_if_index, u32 * last_sw_if_index, u32 * n_packets, u32 * n_bytes) { @@ -122,7 +122,7 @@ incr_decap_stats (vnet_main_t * vnm, u32 cpu_index, u32 length, vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - cpu_index, *last_sw_if_index, + thread_index, *last_sw_if_index, *n_packets, *n_bytes); } *last_sw_if_index = sw_if_index; @@ -150,11 +150,11 @@ static uword lisp_gpe_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * from_frame, u8 is_v4) { - u32 n_left_from, next_index, *from, *to_next, cpu_index; + u32 n_left_from, next_index, *from, *to_next, thread_index; u32 n_bytes = 0, n_packets = 0, last_sw_if_index = ~0, drops = 0; lisp_gpe_main_t *lgm = vnet_lisp_gpe_get_main (); - cpu_index = os_get_cpu_number (); + thread_index = vlib_get_thread_index (); from = vlib_frame_vector_args (from_frame); n_left_from = from_frame->n_vectors; @@ -267,7 +267,7 @@ lisp_gpe_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, if (si0) { - incr_decap_stats (lgm->vnet_main, cpu_index, + incr_decap_stats (lgm->vnet_main, thread_index, vlib_buffer_length_in_chain (vm, b0), si0[0], &last_sw_if_index, &n_packets, &n_bytes); vnet_buffer (b0)->sw_if_index[VLIB_RX] = si0[0]; @@ -282,7 +282,7 @@ lisp_gpe_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, if (si1) { - incr_decap_stats (lgm->vnet_main, cpu_index, + incr_decap_stats (lgm->vnet_main, thread_index, vlib_buffer_length_in_chain (vm, b1), si1[0], &last_sw_if_index, &n_packets, &n_bytes); vnet_buffer (b1)->sw_if_index[VLIB_RX] = si1[0]; @@ -397,7 +397,7 @@ lisp_gpe_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, if (si0) { - incr_decap_stats (lgm->vnet_main, cpu_index, + incr_decap_stats (lgm->vnet_main, thread_index, vlib_buffer_length_in_chain (vm, b0), si0[0], &last_sw_if_index, &n_packets, &n_bytes); vnet_buffer (b0)->sw_if_index[VLIB_RX] = si0[0]; @@ -430,7 +430,7 @@ lisp_gpe_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, } /* flush iface stats */ - incr_decap_stats (lgm->vnet_main, cpu_index, 0, ~0, &last_sw_if_index, + incr_decap_stats (lgm->vnet_main, thread_index, 0, ~0, &last_sw_if_index, &n_packets, &n_bytes); vlib_node_increment_counter (vm, lisp_gpe_ip4_input_node.index, LISP_GPE_ERROR_NO_TUNNEL, drops); diff --git a/src/vnet/lldp/lldp_input.c b/src/vnet/lldp/lldp_input.c index 762743d0..e88f6fdb 100644 --- a/src/vnet/lldp/lldp_input.c +++ b/src/vnet/lldp/lldp_input.c @@ -35,7 +35,7 @@ typedef struct static void lldp_rpc_update_peer_cb (const lldp_intf_update_t * a) { - ASSERT (os_get_cpu_number () == 0); + ASSERT (vlib_get_thread_index () == 0); lldp_intf_t *n = lldp_get_intf (&lldp_main, a->hw_if_index); if (!n) diff --git a/src/vnet/map/ip4_map.c b/src/vnet/map/ip4_map.c index 1a20d704..e39b6f14 100644 --- a/src/vnet/map/ip4_map.c +++ b/src/vnet/map/ip4_map.c @@ -248,7 +248,7 @@ ip4_map (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) next_index = node->cached_next_index; map_main_t *mm = &map_main; vlib_combined_counter_main_t *cm = mm->domain_counters; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); while (n_left_from > 0) { @@ -377,7 +377,7 @@ ip4_map (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) ip40) ? IP4_MAP_NEXT_IP6_REWRITE : next0; vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_TX, - cpu_index, + thread_index, map_domain_index0, 1, clib_net_to_host_u16 (ip6h0->payload_length) + @@ -409,7 +409,7 @@ ip4_map (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) ip41) ? IP4_MAP_NEXT_IP6_REWRITE : next1; vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_TX, - cpu_index, + thread_index, map_domain_index1, 1, clib_net_to_host_u16 (ip6h1->payload_length) + @@ -520,7 +520,7 @@ ip4_map (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) ip40) ? IP4_MAP_NEXT_IP6_REWRITE : next0; vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_TX, - cpu_index, + thread_index, map_domain_index0, 1, clib_net_to_host_u16 (ip6h0->payload_length) + @@ -564,7 +564,7 @@ ip4_map_reass (vlib_main_t * vm, next_index = node->cached_next_index; map_main_t *mm = &map_main; vlib_combined_counter_main_t *cm = mm->domain_counters; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); u32 *fragments_to_drop = NULL; u32 *fragments_to_loopback = NULL; @@ -694,8 +694,8 @@ ip4_map_reass (vlib_main_t * vm, { if (error0 == MAP_ERROR_NONE) vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_TX, - cpu_index, map_domain_index0, - 1, + thread_index, + map_domain_index0, 1, clib_net_to_host_u16 (ip60->payload_length) + 40); next0 = diff --git a/src/vnet/map/ip4_map_t.c b/src/vnet/map/ip4_map_t.c index b63d76bf..5f2bcbf9 100644 --- a/src/vnet/map/ip4_map_t.c +++ b/src/vnet/map/ip4_map_t.c @@ -477,7 +477,7 @@ ip4_map_t_icmp (vlib_main_t * vm, n_left_from = frame->n_vectors; next_index = node->cached_next_index; vlib_combined_counter_main_t *cm = map_main.domain_counters; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); while (n_left_from > 0) { @@ -520,7 +520,7 @@ ip4_map_t_icmp (vlib_main_t * vm, if (PREDICT_TRUE (error0 == MAP_ERROR_NONE)) { vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_TX, - cpu_index, + thread_index, vnet_buffer (p0)->map_t. map_domain_index, 1, len0); } @@ -1051,7 +1051,7 @@ ip4_map_t (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) n_left_from = frame->n_vectors; next_index = node->cached_next_index; vlib_combined_counter_main_t *cm = map_main.domain_counters; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); while (n_left_from > 0) { @@ -1158,7 +1158,7 @@ ip4_map_t (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) (error0 == MAP_ERROR_NONE && next0 != IP4_MAPT_NEXT_MAPT_ICMP)) { vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_TX, - cpu_index, + thread_index, vnet_buffer (p0)->map_t. map_domain_index, 1, clib_net_to_host_u16 (ip40-> @@ -1169,7 +1169,7 @@ ip4_map_t (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) (error1 == MAP_ERROR_NONE && next1 != IP4_MAPT_NEXT_MAPT_ICMP)) { vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_TX, - cpu_index, + thread_index, vnet_buffer (p1)->map_t. map_domain_index, 1, clib_net_to_host_u16 (ip41-> @@ -1252,7 +1252,7 @@ ip4_map_t (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) (error0 == MAP_ERROR_NONE && next0 != IP4_MAPT_NEXT_MAPT_ICMP)) { vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_TX, - cpu_index, + thread_index, vnet_buffer (p0)->map_t. map_domain_index, 1, clib_net_to_host_u16 (ip40-> diff --git a/src/vnet/map/ip6_map.c b/src/vnet/map/ip6_map.c index f7eb768f..63ada962 100644 --- a/src/vnet/map/ip6_map.c +++ b/src/vnet/map/ip6_map.c @@ -172,7 +172,7 @@ ip6_map (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) vlib_node_get_runtime (vm, ip6_map_node.index); map_main_t *mm = &map_main; vlib_combined_counter_main_t *cm = mm->domain_counters; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -319,7 +319,7 @@ ip6_map (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) IP6_MAP_NEXT_IP4_REWRITE : next0; } vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_RX, - cpu_index, + thread_index, map_domain_index0, 1, clib_net_to_host_u16 (ip40->length)); @@ -352,7 +352,7 @@ ip6_map (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) IP6_MAP_NEXT_IP4_REWRITE : next1; } vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_RX, - cpu_index, + thread_index, map_domain_index1, 1, clib_net_to_host_u16 (ip41->length)); @@ -505,7 +505,7 @@ ip6_map (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) IP6_MAP_NEXT_IP4_REWRITE : next0; } vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_RX, - cpu_index, + thread_index, map_domain_index0, 1, clib_net_to_host_u16 (ip40->length)); @@ -820,7 +820,7 @@ ip6_map_ip4_reass (vlib_main_t * vm, vlib_node_get_runtime (vm, ip6_map_ip4_reass_node.index); map_main_t *mm = &map_main; vlib_combined_counter_main_t *cm = mm->domain_counters; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); u32 *fragments_to_drop = NULL; u32 *fragments_to_loopback = NULL; @@ -958,8 +958,8 @@ ip6_map_ip4_reass (vlib_main_t * vm, { if (error0 == MAP_ERROR_NONE) vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_RX, - cpu_index, map_domain_index0, - 1, + thread_index, + map_domain_index0, 1, clib_net_to_host_u16 (ip40->length)); next0 = @@ -1015,7 +1015,7 @@ ip6_map_icmp_relay (vlib_main_t * vm, vlib_node_runtime_t *error_node = vlib_node_get_runtime (vm, ip6_map_icmp_relay_node.index); map_main_t *mm = &map_main; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); u16 *fragment_ids, *fid; from = vlib_frame_vector_args (frame); @@ -1143,7 +1143,8 @@ ip6_map_icmp_relay (vlib_main_t * vm, ip_csum_t sum = ip_incremental_checksum (0, new_icmp40, nlen - 20); new_icmp40->checksum = ~ip_csum_fold (sum); - vlib_increment_simple_counter (&mm->icmp_relayed, cpu_index, 0, 1); + vlib_increment_simple_counter (&mm->icmp_relayed, thread_index, 0, + 1); error: if (PREDICT_FALSE (p0->flags & VLIB_BUFFER_IS_TRACED)) diff --git a/src/vnet/map/ip6_map_t.c b/src/vnet/map/ip6_map_t.c index eb3996c2..99151678 100644 --- a/src/vnet/map/ip6_map_t.c +++ b/src/vnet/map/ip6_map_t.c @@ -448,7 +448,7 @@ ip6_map_t_icmp (vlib_main_t * vm, n_left_from = frame->n_vectors; next_index = node->cached_next_index; vlib_combined_counter_main_t *cm = map_main.domain_counters; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); while (n_left_from > 0) { @@ -493,7 +493,7 @@ ip6_map_t_icmp (vlib_main_t * vm, if (PREDICT_TRUE (error0 == MAP_ERROR_NONE)) { vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_RX, - cpu_index, + thread_index, vnet_buffer (p0)-> map_t.map_domain_index, 1, len0); @@ -1051,7 +1051,7 @@ ip6_map_t (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) vlib_node_runtime_t *error_node = vlib_node_get_runtime (vm, ip6_map_t_node.index); vlib_combined_counter_main_t *cm = map_main.domain_counters; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -1218,7 +1218,7 @@ ip6_map_t (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) (error0 == MAP_ERROR_NONE && next0 != IP6_MAPT_NEXT_MAPT_ICMP)) { vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_RX, - cpu_index, + thread_index, vnet_buffer (p0)-> map_t.map_domain_index, 1, clib_net_to_host_u16 @@ -1229,7 +1229,7 @@ ip6_map_t (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) (error1 == MAP_ERROR_NONE && next1 != IP6_MAPT_NEXT_MAPT_ICMP)) { vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_RX, - cpu_index, + thread_index, vnet_buffer (p1)-> map_t.map_domain_index, 1, clib_net_to_host_u16 @@ -1403,7 +1403,7 @@ ip6_map_t (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) (error0 == MAP_ERROR_NONE && next0 != IP6_MAPT_NEXT_MAPT_ICMP)) { vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_RX, - cpu_index, + thread_index, vnet_buffer (p0)-> map_t.map_domain_index, 1, clib_net_to_host_u16 diff --git a/src/vnet/mpls/mpls_input.c b/src/vnet/mpls/mpls_input.c index 893c4511..1b9bdd05 100644 --- a/src/vnet/mpls/mpls_input.c +++ b/src/vnet/mpls/mpls_input.c @@ -76,7 +76,7 @@ mpls_input_inline (vlib_main_t * vm, u32 n_left_from, next_index, * from, * to_next; mpls_input_runtime_t * rt; mpls_main_t * mm; - u32 cpu_index = os_get_cpu_number(); + u32 thread_index = vlib_get_thread_index(); vlib_simple_counter_main_t * cm; vnet_main_t * vnm = vnet_get_main(); @@ -151,7 +151,7 @@ mpls_input_inline (vlib_main_t * vm, next0 = MPLS_INPUT_NEXT_LOOKUP; vnet_feature_arc_start(mm->input_feature_arc_index, sw_if_index0, &next0, b0); - vlib_increment_simple_counter (cm, cpu_index, sw_if_index0, 1); + vlib_increment_simple_counter (cm, thread_index, sw_if_index0, 1); } if (PREDICT_FALSE(h1[3] == 0)) @@ -164,7 +164,7 @@ mpls_input_inline (vlib_main_t * vm, next1 = MPLS_INPUT_NEXT_LOOKUP; vnet_feature_arc_start(mm->input_feature_arc_index, sw_if_index1, &next1, b1); - vlib_increment_simple_counter (cm, cpu_index, sw_if_index1, 1); + vlib_increment_simple_counter (cm, thread_index, sw_if_index1, 1); } if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED)) @@ -215,7 +215,7 @@ mpls_input_inline (vlib_main_t * vm, { next0 = MPLS_INPUT_NEXT_LOOKUP; vnet_feature_arc_start(mm->input_feature_arc_index, sw_if_index0, &next0, b0); - vlib_increment_simple_counter (cm, cpu_index, sw_if_index0, 1); + vlib_increment_simple_counter (cm, thread_index, sw_if_index0, 1); } if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED)) diff --git a/src/vnet/mpls/mpls_lookup.c b/src/vnet/mpls/mpls_lookup.c index 475bb204..ace6a70f 100644 --- a/src/vnet/mpls/mpls_lookup.c +++ b/src/vnet/mpls/mpls_lookup.c @@ -67,7 +67,7 @@ mpls_lookup (vlib_main_t * vm, vlib_combined_counter_main_t * cm = &load_balance_main.lbm_to_counters; u32 n_left_from, next_index, * from, * to_next; mpls_main_t * mm = &mpls_main; - u32 cpu_index = os_get_cpu_number(); + u32 thread_index = vlib_get_thread_index(); from = vlib_frame_vector_args (from_frame); n_left_from = from_frame->n_vectors; @@ -220,16 +220,16 @@ mpls_lookup (vlib_main_t * vm, vnet_buffer (b3)->ip.adj_index[VLIB_TX] = dpo3->dpoi_index; vlib_increment_combined_counter - (cm, cpu_index, lbi0, 1, + (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, b0)); vlib_increment_combined_counter - (cm, cpu_index, lbi1, 1, + (cm, thread_index, lbi1, 1, vlib_buffer_length_in_chain (vm, b1)); vlib_increment_combined_counter - (cm, cpu_index, lbi2, 1, + (cm, thread_index, lbi2, 1, vlib_buffer_length_in_chain (vm, b2)); vlib_increment_combined_counter - (cm, cpu_index, lbi3, 1, + (cm, thread_index, lbi3, 1, vlib_buffer_length_in_chain (vm, b3)); /* @@ -351,7 +351,7 @@ mpls_lookup (vlib_main_t * vm, vnet_buffer (b0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index; vlib_increment_combined_counter - (cm, cpu_index, lbi0, 1, + (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, b0)); /* @@ -440,7 +440,7 @@ mpls_load_balance (vlib_main_t * vm, { vlib_combined_counter_main_t * cm = &load_balance_main.lbm_via_counters; u32 n_left_from, n_left_to_next, * from, * to_next; - u32 cpu_index = os_get_cpu_number(); + u32 thread_index = vlib_get_thread_index(); u32 next; from = vlib_frame_vector_args (frame); @@ -536,10 +536,10 @@ mpls_load_balance (vlib_main_t * vm, vnet_buffer (p1)->ip.adj_index[VLIB_TX] = dpo1->dpoi_index; vlib_increment_combined_counter - (cm, cpu_index, lbi0, 1, + (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0)); vlib_increment_combined_counter - (cm, cpu_index, lbi1, 1, + (cm, thread_index, lbi1, 1, vlib_buffer_length_in_chain (vm, p1)); if (PREDICT_FALSE(p0->flags & VLIB_BUFFER_IS_TRACED)) @@ -597,7 +597,7 @@ mpls_load_balance (vlib_main_t * vm, vnet_buffer (p0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index; vlib_increment_combined_counter - (cm, cpu_index, lbi0, 1, + (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0)); vlib_validate_buffer_enqueue_x1 (vm, node, next, diff --git a/src/vnet/mpls/mpls_output.c b/src/vnet/mpls/mpls_output.c index 08018fd1..d90dec21 100644 --- a/src/vnet/mpls/mpls_output.c +++ b/src/vnet/mpls/mpls_output.c @@ -64,12 +64,12 @@ mpls_output_inline (vlib_main_t * vm, vlib_frame_t * from_frame, int is_midchain) { - u32 n_left_from, next_index, * from, * to_next, cpu_index; + u32 n_left_from, next_index, * from, * to_next, thread_index; vlib_node_runtime_t * error_node; u32 n_left_to_next; mpls_main_t *mm; - cpu_index = os_get_cpu_number(); + thread_index = vlib_get_thread_index(); error_node = vlib_node_get_runtime (vm, mpls_output_node.index); from = vlib_frame_vector_args (from_frame); n_left_from = from_frame->n_vectors; @@ -137,13 +137,13 @@ mpls_output_inline (vlib_main_t * vm, /* Bump the adj counters for packet and bytes */ vlib_increment_combined_counter (&adjacency_counters, - cpu_index, + thread_index, adj_index0, 1, vlib_buffer_length_in_chain (vm, p0) + rw_len0); vlib_increment_combined_counter (&adjacency_counters, - cpu_index, + thread_index, adj_index1, 1, vlib_buffer_length_in_chain (vm, p1) + rw_len1); @@ -245,7 +245,7 @@ mpls_output_inline (vlib_main_t * vm, vlib_increment_combined_counter (&adjacency_counters, - cpu_index, + thread_index, adj_index0, 1, vlib_buffer_length_in_chain (vm, p0) + rw_len0); diff --git a/src/vnet/pg/input.c b/src/vnet/pg/input.c index 2649798b..597ae060 100644 --- a/src/vnet/pg/input.c +++ b/src/vnet/pg/input.c @@ -893,7 +893,7 @@ pg_generate_set_lengths (pg_main_t * pg, vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - os_get_cpu_number (), + vlib_get_thread_index (), si->sw_if_index, n_buffers, length_sum); } @@ -1266,7 +1266,7 @@ pg_stream_fill_helper (pg_main_t * pg, l += vlib_buffer_index_length_in_chain (vm, buffers[i]); vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - os_get_cpu_number (), + vlib_get_thread_index (), si->sw_if_index, n_alloc, l); s->current_replay_packet_index += n_alloc; s->current_replay_packet_index %= diff --git a/src/vnet/replication.c b/src/vnet/replication.c index 86d922b5..233a8c2f 100644 --- a/src/vnet/replication.c +++ b/src/vnet/replication.c @@ -31,16 +31,16 @@ replication_prep (vlib_main_t * vm, { replication_main_t *rm = &replication_main; replication_context_t *ctx; - uword cpu_number = vm->cpu_index; + uword thread_index = vm->thread_index; ip4_header_t *ip; u32 ctx_id; /* Allocate a context, reserve context 0 */ - if (PREDICT_FALSE (rm->contexts[cpu_number] == 0)) - pool_get_aligned (rm->contexts[cpu_number], ctx, CLIB_CACHE_LINE_BYTES); + if (PREDICT_FALSE (rm->contexts[thread_index] == 0)) + pool_get_aligned (rm->contexts[thread_index], ctx, CLIB_CACHE_LINE_BYTES); - pool_get_aligned (rm->contexts[cpu_number], ctx, CLIB_CACHE_LINE_BYTES); - ctx_id = ctx - rm->contexts[cpu_number]; + pool_get_aligned (rm->contexts[thread_index], ctx, CLIB_CACHE_LINE_BYTES); + ctx_id = ctx - rm->contexts[thread_index]; /* Save state from vlib buffer */ ctx->saved_free_list_index = b0->free_list_index; @@ -94,11 +94,11 @@ replication_recycle (vlib_main_t * vm, vlib_buffer_t * b0, u32 is_last) { replication_main_t *rm = &replication_main; replication_context_t *ctx; - uword cpu_number = vm->cpu_index; + uword thread_index = vm->thread_index; ip4_header_t *ip; /* Get access to the replication context */ - ctx = pool_elt_at_index (rm->contexts[cpu_number], b0->recycle_count); + ctx = pool_elt_at_index (rm->contexts[thread_index], b0->recycle_count); /* Restore vnet buffer state */ clib_memcpy (vnet_buffer (b0), ctx->vnet_buffer, @@ -133,7 +133,7 @@ replication_recycle (vlib_main_t * vm, vlib_buffer_t * b0, u32 is_last) b0->flags &= ~VLIB_BUFFER_RECYCLE; /* Free context back to its pool */ - pool_put (rm->contexts[cpu_number], ctx); + pool_put (rm->contexts[thread_index], ctx); } return ctx; @@ -160,7 +160,7 @@ replication_recycle_callback (vlib_main_t * vm, vlib_buffer_free_list_t * fl) replication_main_t *rm = &replication_main; replication_context_t *ctx; u32 feature_node_index = 0; - uword cpu_number = vm->cpu_index; + uword thread_index = vm->thread_index; /* * All buffers in the list are destined to the same recycle node. @@ -172,7 +172,7 @@ replication_recycle_callback (vlib_main_t * vm, vlib_buffer_free_list_t * fl) { bi0 = fl->buffers[0]; b0 = vlib_get_buffer (vm, bi0); - ctx = pool_elt_at_index (rm->contexts[cpu_number], b0->recycle_count); + ctx = pool_elt_at_index (rm->contexts[thread_index], b0->recycle_count); feature_node_index = ctx->recycle_node_index; } diff --git a/src/vnet/replication.h b/src/vnet/replication.h index 5dc554c9..ce4b3ff1 100644 --- a/src/vnet/replication.h +++ b/src/vnet/replication.h @@ -100,7 +100,7 @@ replication_get_ctx (vlib_buffer_t * b0) replication_main_t *rm = &replication_main; return replication_is_recycled (b0) ? - pool_elt_at_index (rm->contexts[os_get_cpu_number ()], + pool_elt_at_index (rm->contexts[vlib_get_thread_index ()], b0->recycle_count) : 0; } diff --git a/src/vnet/session/node.c b/src/vnet/session/node.c index b86e87d9..dd211c51 100644 --- a/src/vnet/session/node.c +++ b/src/vnet/session/node.c @@ -311,7 +311,7 @@ session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, unix_shared_memory_queue_t *q; application_t *app; int n_tx_packets = 0; - u32 my_thread_index = vm->cpu_index; + u32 my_thread_index = vm->thread_index; int i, rv; f64 now = vlib_time_now (vm); diff --git a/src/vnet/sr/sr_localsid.c b/src/vnet/sr/sr_localsid.c index 2e3d56de..6d72a506 100755 --- a/src/vnet/sr/sr_localsid.c +++ b/src/vnet/sr/sr_localsid.c @@ -887,7 +887,7 @@ sr_localsid_d_fn (vlib_main_t * vm, vlib_node_runtime_t * node, from = vlib_frame_vector_args (from_frame); n_left_from = from_frame->n_vectors; next_index = node->cached_next_index; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); while (n_left_from > 0) { @@ -974,26 +974,26 @@ sr_localsid_d_fn (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_increment_combined_counter (((next0 == SR_LOCALSID_NEXT_ERROR) ? &(sm->sr_ls_invalid_counters) : - &(sm->sr_ls_valid_counters)), cpu_index, ls0 - sm->localsids, 1, - vlib_buffer_length_in_chain (vm, b0)); + &(sm->sr_ls_valid_counters)), thread_index, ls0 - sm->localsids, + 1, vlib_buffer_length_in_chain (vm, b0)); vlib_increment_combined_counter (((next1 == SR_LOCALSID_NEXT_ERROR) ? &(sm->sr_ls_invalid_counters) : - &(sm->sr_ls_valid_counters)), cpu_index, ls1 - sm->localsids, 1, - vlib_buffer_length_in_chain (vm, b1)); + &(sm->sr_ls_valid_counters)), thread_index, ls1 - sm->localsids, + 1, vlib_buffer_length_in_chain (vm, b1)); vlib_increment_combined_counter (((next2 == SR_LOCALSID_NEXT_ERROR) ? &(sm->sr_ls_invalid_counters) : - &(sm->sr_ls_valid_counters)), cpu_index, ls2 - sm->localsids, 1, - vlib_buffer_length_in_chain (vm, b2)); + &(sm->sr_ls_valid_counters)), thread_index, ls2 - sm->localsids, + 1, vlib_buffer_length_in_chain (vm, b2)); vlib_increment_combined_counter (((next3 == SR_LOCALSID_NEXT_ERROR) ? &(sm->sr_ls_invalid_counters) : - &(sm->sr_ls_valid_counters)), cpu_index, ls3 - sm->localsids, 1, - vlib_buffer_length_in_chain (vm, b3)); + &(sm->sr_ls_valid_counters)), thread_index, ls3 - sm->localsids, + 1, vlib_buffer_length_in_chain (vm, b3)); vlib_validate_buffer_enqueue_x4 (vm, node, next_index, to_next, n_left_to_next, bi0, bi1, bi2, bi3, @@ -1062,8 +1062,8 @@ sr_localsid_d_fn (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_increment_combined_counter (((next0 == SR_LOCALSID_NEXT_ERROR) ? &(sm->sr_ls_invalid_counters) : - &(sm->sr_ls_valid_counters)), cpu_index, ls0 - sm->localsids, 1, - vlib_buffer_length_in_chain (vm, b0)); + &(sm->sr_ls_valid_counters)), thread_index, ls0 - sm->localsids, + 1, vlib_buffer_length_in_chain (vm, b0)); vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, n_left_to_next, bi0, next0); @@ -1103,7 +1103,7 @@ sr_localsid_fn (vlib_main_t * vm, vlib_node_runtime_t * node, from = vlib_frame_vector_args (from_frame); n_left_from = from_frame->n_vectors; next_index = node->cached_next_index; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); while (n_left_from > 0) { @@ -1205,26 +1205,26 @@ sr_localsid_fn (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_increment_combined_counter (((next0 == SR_LOCALSID_NEXT_ERROR) ? &(sm->sr_ls_invalid_counters) : - &(sm->sr_ls_valid_counters)), cpu_index, ls0 - sm->localsids, 1, - vlib_buffer_length_in_chain (vm, b0)); + &(sm->sr_ls_valid_counters)), thread_index, ls0 - sm->localsids, + 1, vlib_buffer_length_in_chain (vm, b0)); vlib_increment_combined_counter (((next1 == SR_LOCALSID_NEXT_ERROR) ? &(sm->sr_ls_invalid_counters) : - &(sm->sr_ls_valid_counters)), cpu_index, ls1 - sm->localsids, 1, - vlib_buffer_length_in_chain (vm, b1)); + &(sm->sr_ls_valid_counters)), thread_index, ls1 - sm->localsids, + 1, vlib_buffer_length_in_chain (vm, b1)); vlib_increment_combined_counter (((next2 == SR_LOCALSID_NEXT_ERROR) ? &(sm->sr_ls_invalid_counters) : - &(sm->sr_ls_valid_counters)), cpu_index, ls2 - sm->localsids, 1, - vlib_buffer_length_in_chain (vm, b2)); + &(sm->sr_ls_valid_counters)), thread_index, ls2 - sm->localsids, + 1, vlib_buffer_length_in_chain (vm, b2)); vlib_increment_combined_counter (((next3 == SR_LOCALSID_NEXT_ERROR) ? &(sm->sr_ls_invalid_counters) : - &(sm->sr_ls_valid_counters)), cpu_index, ls3 - sm->localsids, 1, - vlib_buffer_length_in_chain (vm, b3)); + &(sm->sr_ls_valid_counters)), thread_index, ls3 - sm->localsids, + 1, vlib_buffer_length_in_chain (vm, b3)); vlib_validate_buffer_enqueue_x4 (vm, node, next_index, to_next, n_left_to_next, bi0, bi1, bi2, bi3, @@ -1295,8 +1295,8 @@ sr_localsid_fn (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_increment_combined_counter (((next0 == SR_LOCALSID_NEXT_ERROR) ? &(sm->sr_ls_invalid_counters) : - &(sm->sr_ls_valid_counters)), cpu_index, ls0 - sm->localsids, 1, - vlib_buffer_length_in_chain (vm, b0)); + &(sm->sr_ls_valid_counters)), thread_index, ls0 - sm->localsids, + 1, vlib_buffer_length_in_chain (vm, b0)); vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, n_left_to_next, bi0, next0); diff --git a/src/vnet/tcp/builtin_client.c b/src/vnet/tcp/builtin_client.c index e3705060..c1567aa0 100644 --- a/src/vnet/tcp/builtin_client.c +++ b/src/vnet/tcp/builtin_client.c @@ -174,7 +174,7 @@ tclient_thread_fn (void *arg) pthread_sigmask (SIG_SETMASK, &s, 0); } - clib_per_cpu_mheaps[os_get_cpu_number ()] = clib_per_cpu_mheaps[0]; + clib_per_cpu_mheaps[vlib_get_thread_index ()] = clib_per_cpu_mheaps[0]; while (1) { diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c index b2a371e2..b6c34828 100644 --- a/src/vnet/tcp/tcp.c +++ b/src/vnet/tcp/tcp.c @@ -646,10 +646,10 @@ const static transport_proto_vft_t tcp6_proto = { void tcp_timer_keep_handler (u32 conn_index) { - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); tcp_connection_t *tc; - tc = tcp_connection_get (conn_index, cpu_index); + tc = tcp_connection_get (conn_index, thread_index); tc->timers[TCP_TIMER_KEEP] = TCP_TIMER_HANDLE_INVALID; tcp_connection_close (tc); @@ -675,10 +675,10 @@ tcp_timer_establish_handler (u32 conn_index) void tcp_timer_waitclose_handler (u32 conn_index) { - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); tcp_connection_t *tc; - tc = tcp_connection_get (conn_index, cpu_index); + tc = tcp_connection_get (conn_index, thread_index); tc->timers[TCP_TIMER_WAITCLOSE] = TCP_TIMER_HANDLE_INVALID; /* Session didn't come back with a close(). Send FIN either way diff --git a/src/vnet/tcp/tcp_debug.h b/src/vnet/tcp/tcp_debug.h index 0090e15e..eaca672c 100644 --- a/src/vnet/tcp/tcp_debug.h +++ b/src/vnet/tcp/tcp_debug.h @@ -343,7 +343,7 @@ typedef enum _tcp_dbg_evt } \ else \ { \ - u32 _thread_index = os_get_cpu_number (); \ + u32 _thread_index = vlib_get_thread_index (); \ _tc = tcp_connection_get (_tc_index, _thread_index); \ } \ ELOG_TYPE_DECLARE (_e) = \ diff --git a/src/vnet/tcp/tcp_input.c b/src/vnet/tcp/tcp_input.c index a8224dc2..7e9fa47b 100644 --- a/src/vnet/tcp/tcp_input.c +++ b/src/vnet/tcp/tcp_input.c @@ -1142,7 +1142,7 @@ tcp46_established_inline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * from_frame, int is_ip4) { u32 n_left_from, next_index, *from, *to_next; - u32 my_thread_index = vm->cpu_index, errors = 0; + u32 my_thread_index = vm->thread_index, errors = 0; tcp_main_t *tm = vnet_get_tcp_main (); from = vlib_frame_vector_args (from_frame); @@ -1332,7 +1332,7 @@ tcp46_syn_sent_inline (vlib_main_t * vm, vlib_node_runtime_t * node, { tcp_main_t *tm = vnet_get_tcp_main (); u32 n_left_from, next_index, *from, *to_next; - u32 my_thread_index = vm->cpu_index, errors = 0; + u32 my_thread_index = vm->thread_index, errors = 0; u8 sst = is_ip4 ? SESSION_TYPE_IP4_TCP : SESSION_TYPE_IP6_TCP; from = vlib_frame_vector_args (from_frame); @@ -1634,7 +1634,7 @@ tcp46_rcv_process_inline (vlib_main_t * vm, vlib_node_runtime_t * node, { tcp_main_t *tm = vnet_get_tcp_main (); u32 n_left_from, next_index, *from, *to_next; - u32 my_thread_index = vm->cpu_index, errors = 0; + u32 my_thread_index = vm->thread_index, errors = 0; from = vlib_frame_vector_args (from_frame); n_left_from = from_frame->n_vectors; @@ -1989,7 +1989,7 @@ tcp46_listen_inline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * from_frame, int is_ip4) { u32 n_left_from, next_index, *from, *to_next; - u32 my_thread_index = vm->cpu_index; + u32 my_thread_index = vm->thread_index; tcp_main_t *tm = vnet_get_tcp_main (); u8 sst = is_ip4 ? SESSION_TYPE_IP4_TCP : SESSION_TYPE_IP6_TCP; @@ -2243,7 +2243,7 @@ tcp46_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * from_frame, int is_ip4) { u32 n_left_from, next_index, *from, *to_next; - u32 my_thread_index = vm->cpu_index; + u32 my_thread_index = vm->thread_index; tcp_main_t *tm = vnet_get_tcp_main (); from = vlib_frame_vector_args (from_frame); diff --git a/src/vnet/tcp/tcp_output.c b/src/vnet/tcp/tcp_output.c index ea157bd7..e18bfad7 100644 --- a/src/vnet/tcp/tcp_output.c +++ b/src/vnet/tcp/tcp_output.c @@ -387,8 +387,8 @@ tcp_make_options (tcp_connection_t * tc, tcp_options_t * opts, #define tcp_get_free_buffer_index(tm, bidx) \ do { \ u32 *my_tx_buffers, n_free_buffers; \ - u32 cpu_index = os_get_cpu_number(); \ - my_tx_buffers = tm->tx_buffers[cpu_index]; \ + u32 thread_index = vlib_get_thread_index(); \ + my_tx_buffers = tm->tx_buffers[thread_index]; \ if (PREDICT_FALSE(vec_len (my_tx_buffers) == 0)) \ { \ n_free_buffers = 32; /* TODO config or macro */ \ @@ -396,7 +396,7 @@ do { \ _vec_len(my_tx_buffers) = vlib_buffer_alloc_from_free_list ( \ tm->vlib_main, my_tx_buffers, n_free_buffers, \ VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX); \ - tm->tx_buffers[cpu_index] = my_tx_buffers; \ + tm->tx_buffers[thread_index] = my_tx_buffers; \ } \ /* buffer shortage */ \ if (PREDICT_FALSE (vec_len (my_tx_buffers) == 0)) \ @@ -408,8 +408,8 @@ do { \ #define tcp_return_buffer(tm) \ do { \ u32 *my_tx_buffers; \ - u32 cpu_index = os_get_cpu_number(); \ - my_tx_buffers = tm->tx_buffers[cpu_index]; \ + u32 thread_index = vlib_get_thread_index(); \ + my_tx_buffers = tm->tx_buffers[thread_index]; \ _vec_len (my_tx_buffers) +=1; \ } while (0) @@ -942,7 +942,7 @@ tcp_send_ack (tcp_connection_t * tc) void tcp_timer_delack_handler (u32 index) { - u32 thread_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); tcp_connection_t *tc; tc = tcp_connection_get (index, thread_index); @@ -1022,7 +1022,7 @@ tcp_timer_retransmit_handler_i (u32 index, u8 is_syn) { tcp_main_t *tm = vnet_get_tcp_main (); vlib_main_t *vm = vlib_get_main (); - u32 thread_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); tcp_connection_t *tc; vlib_buffer_t *b; u32 bi, snd_space, n_bytes; @@ -1152,7 +1152,7 @@ tcp_timer_persist_handler (u32 index) { tcp_main_t *tm = vnet_get_tcp_main (); vlib_main_t *vm = vlib_get_main (); - u32 thread_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); tcp_connection_t *tc; vlib_buffer_t *b; u32 bi, n_bytes; @@ -1313,7 +1313,7 @@ tcp46_output_inline (vlib_main_t * vm, vlib_frame_t * from_frame, int is_ip4) { u32 n_left_from, next_index, *from, *to_next; - u32 my_thread_index = vm->cpu_index; + u32 my_thread_index = vm->thread_index; from = vlib_frame_vector_args (from_frame); n_left_from = from_frame->n_vectors; @@ -1524,7 +1524,7 @@ tcp46_send_reset_inline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * from_frame, u8 is_ip4) { u32 n_left_from, next_index, *from, *to_next; - u32 my_thread_index = vm->cpu_index; + u32 my_thread_index = vm->thread_index; from = vlib_frame_vector_args (from_frame); n_left_from = from_frame->n_vectors; diff --git a/src/vnet/udp/udp_input.c b/src/vnet/udp/udp_input.c index 4b22109b..810278e6 100644 --- a/src/vnet/udp/udp_input.c +++ b/src/vnet/udp/udp_input.c @@ -70,7 +70,7 @@ udp4_uri_input_node_fn (vlib_main_t * vm, udp4_uri_input_next_t next_index; udp_uri_main_t *um = vnet_get_udp_main (); session_manager_main_t *smm = vnet_get_session_manager_main (); - u32 my_thread_index = vm->cpu_index; + u32 my_thread_index = vm->thread_index; u8 my_enqueue_epoch; u32 *session_indices_to_enqueue; static u32 serial_number; diff --git a/src/vnet/unix/tapcli.c b/src/vnet/unix/tapcli.c index fb1a8bac..0fc62f6c 100644 --- a/src/vnet/unix/tapcli.c +++ b/src/vnet/unix/tapcli.c @@ -366,7 +366,7 @@ static uword tapcli_rx_iface(vlib_main_t * vm, vlib_increment_combined_counter ( vnet_main.interface_main.combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - os_get_cpu_number(), ti->sw_if_index, + vlib_get_thread_index(), ti->sw_if_index, 1, n_bytes_in_packet); if (PREDICT_FALSE(n_trace > 0)) { diff --git a/src/vnet/unix/tuntap.c b/src/vnet/unix/tuntap.c index 2cfcc92f..ac674653 100644 --- a/src/vnet/unix/tuntap.c +++ b/src/vnet/unix/tuntap.c @@ -189,7 +189,7 @@ tuntap_tx (vlib_main_t * vm, /* Update tuntap interface output stats. */ vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX, - vm->cpu_index, + vm->thread_index, tm->sw_if_index, n_packets, n_bytes); @@ -297,7 +297,7 @@ tuntap_rx (vlib_main_t * vm, vlib_increment_combined_counter (vnet_main.interface_main.combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - os_get_cpu_number(), + vlib_get_thread_index(), tm->sw_if_index, 1, n_bytes_in_packet); diff --git a/src/vnet/vxlan-gpe/decap.c b/src/vnet/vxlan-gpe/decap.c index 22ab4b62..d4fe4231 100644 --- a/src/vnet/vxlan-gpe/decap.c +++ b/src/vnet/vxlan-gpe/decap.c @@ -115,7 +115,7 @@ vxlan_gpe_input (vlib_main_t * vm, vxlan4_gpe_tunnel_key_t last_key4; vxlan6_gpe_tunnel_key_t last_key6; u32 pkts_decapsulated = 0; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); u32 stats_sw_if_index, stats_n_packets, stats_n_bytes; if (is_ip4) @@ -342,7 +342,7 @@ vxlan_gpe_input (vlib_main_t * vm, if (stats_n_packets) vlib_increment_combined_counter ( im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - cpu_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); + thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); stats_n_packets = 1; stats_n_bytes = len0; stats_sw_if_index = sw_if_index0; @@ -427,7 +427,7 @@ vxlan_gpe_input (vlib_main_t * vm, if (stats_n_packets) vlib_increment_combined_counter ( im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - cpu_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); + thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); stats_n_packets = 1; stats_n_bytes = len1; stats_sw_if_index = sw_if_index1; @@ -588,7 +588,7 @@ vxlan_gpe_input (vlib_main_t * vm, if (stats_n_packets) vlib_increment_combined_counter ( im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - cpu_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); + thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); stats_n_packets = 1; stats_n_bytes = len0; stats_sw_if_index = sw_if_index0; @@ -615,7 +615,7 @@ vxlan_gpe_input (vlib_main_t * vm, if (stats_n_packets) { vlib_increment_combined_counter ( - im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, cpu_index, + im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); node->runtime_data[0] = stats_sw_if_index; } diff --git a/src/vnet/vxlan-gpe/encap.c b/src/vnet/vxlan-gpe/encap.c index 3a486e56..67ed94b4 100644 --- a/src/vnet/vxlan-gpe/encap.c +++ b/src/vnet/vxlan-gpe/encap.c @@ -151,7 +151,7 @@ vxlan_gpe_encap (vlib_main_t * vm, vnet_main_t * vnm = ngm->vnet_main; vnet_interface_main_t * im = &vnm->interface_main; u32 pkts_encapsulated = 0; - u32 cpu_index = os_get_cpu_number (); + u32 thread_index = vlib_get_thread_index (); u32 stats_sw_if_index, stats_n_packets, stats_n_bytes; from = vlib_frame_vector_args (from_frame); @@ -253,7 +253,7 @@ vxlan_gpe_encap (vlib_main_t * vm, if (stats_n_packets) vlib_increment_combined_counter ( im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX, - cpu_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); + thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); stats_sw_if_index = sw_if_index0; stats_n_packets = 2; stats_n_bytes = len0 + len1; @@ -262,10 +262,10 @@ vxlan_gpe_encap (vlib_main_t * vm, { vlib_increment_combined_counter ( im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX, - cpu_index, sw_if_index0, 1, len0); + thread_index, sw_if_index0, 1, len0); vlib_increment_combined_counter ( im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX, - cpu_index, sw_if_index1, 1, len1); + thread_index, sw_if_index1, 1, len1); } } @@ -335,7 +335,7 @@ vxlan_gpe_encap (vlib_main_t * vm, if (stats_n_packets) vlib_increment_combined_counter ( im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX, - cpu_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); + thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); stats_n_packets = 1; stats_n_bytes = len0; stats_sw_if_index = sw_if_index0; @@ -359,7 +359,7 @@ vxlan_gpe_encap (vlib_main_t * vm, if (stats_n_packets) { vlib_increment_combined_counter ( - im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX, cpu_index, + im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX, thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); node->runtime_data[0] = stats_sw_if_index; } diff --git a/src/vnet/vxlan/decap.c b/src/vnet/vxlan/decap.c index 514b2c99..2acb1f6f 100644 --- a/src/vnet/vxlan/decap.c +++ b/src/vnet/vxlan/decap.c @@ -81,7 +81,7 @@ vxlan_input (vlib_main_t * vm, vxlan4_tunnel_key_t last_key4; vxlan6_tunnel_key_t last_key6; u32 pkts_decapsulated = 0; - u32 cpu_index = os_get_cpu_number(); + u32 thread_index = vlib_get_thread_index(); u32 stats_sw_if_index, stats_n_packets, stats_n_bytes; if (is_ip4) @@ -314,7 +314,7 @@ vxlan_input (vlib_main_t * vm, if (stats_n_packets) vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - cpu_index, stats_sw_if_index, + thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); stats_n_packets = 1; stats_n_bytes = len0; @@ -468,7 +468,7 @@ vxlan_input (vlib_main_t * vm, if (stats_n_packets) vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - cpu_index, stats_sw_if_index, + thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); stats_n_packets = 1; stats_n_bytes = len1; @@ -674,7 +674,7 @@ vxlan_input (vlib_main_t * vm, if (stats_n_packets) vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - cpu_index, stats_sw_if_index, + thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); stats_n_packets = 1; stats_n_bytes = len0; @@ -711,7 +711,7 @@ vxlan_input (vlib_main_t * vm, { vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, - cpu_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); + thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); node->runtime_data[0] = stats_sw_if_index; } diff --git a/src/vnet/vxlan/encap.c b/src/vnet/vxlan/encap.c index 5b63064a..4cfbbc23 100644 --- a/src/vnet/vxlan/encap.c +++ b/src/vnet/vxlan/encap.c @@ -77,7 +77,7 @@ vxlan_encap_inline (vlib_main_t * vm, vnet_interface_main_t * im = &vnm->interface_main; u32 pkts_encapsulated = 0; u16 old_l0 = 0, old_l1 = 0; - u32 cpu_index = os_get_cpu_number(); + u32 thread_index = vlib_get_thread_index(); u32 stats_sw_if_index, stats_n_packets, stats_n_bytes; u32 sw_if_index0 = 0, sw_if_index1 = 0; u32 next0 = 0, next1 = 0; @@ -301,7 +301,7 @@ vxlan_encap_inline (vlib_main_t * vm, if (stats_n_packets) vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX, - cpu_index, stats_sw_if_index, + thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); stats_sw_if_index = sw_if_index0; stats_n_packets = 2; @@ -311,10 +311,10 @@ vxlan_encap_inline (vlib_main_t * vm, { vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX, - cpu_index, sw_if_index0, 1, len0); + thread_index, sw_if_index0, 1, len0); vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX, - cpu_index, sw_if_index1, 1, len1); + thread_index, sw_if_index1, 1, len1); } } @@ -464,7 +464,7 @@ vxlan_encap_inline (vlib_main_t * vm, if (stats_n_packets) vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX, - cpu_index, stats_sw_if_index, + thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); stats_n_packets = 1; stats_n_bytes = len0; @@ -496,7 +496,7 @@ vxlan_encap_inline (vlib_main_t * vm, { vlib_increment_combined_counter (im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX, - cpu_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); + thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes); node->runtime_data[0] = stats_sw_if_index; } diff --git a/src/vpp/stats/stats.c b/src/vpp/stats/stats.c index 042d02e2..4309cd51 100644 --- a/src/vpp/stats/stats.c +++ b/src/vpp/stats/stats.c @@ -66,14 +66,14 @@ _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) void dslock (stats_main_t * sm, int release_hint, int tag) { - u32 thread_id; + u32 thread_index; data_structure_lock_t *l = sm->data_structure_lock; if (PREDICT_FALSE (l == 0)) return; - thread_id = os_get_cpu_number (); - if (l->lock && l->thread_id == thread_id) + thread_index = vlib_get_thread_index (); + if (l->lock && l->thread_index == thread_index) { l->count++; return; @@ -85,7 +85,7 @@ dslock (stats_main_t * sm, int release_hint, int tag) while (__sync_lock_test_and_set (&l->lock, 1)) /* zzzz */ ; l->tag = tag; - l->thread_id = thread_id; + l->thread_index = thread_index; l->count = 1; } @@ -99,14 +99,14 @@ stats_dslock_with_hint (int hint, int tag) void dsunlock (stats_main_t * sm) { - u32 thread_id; + u32 thread_index; data_structure_lock_t *l = sm->data_structure_lock; if (PREDICT_FALSE (l == 0)) return; - thread_id = os_get_cpu_number (); - ASSERT (l->lock && l->thread_id == thread_id); + thread_index = vlib_get_thread_index (); + ASSERT (l->lock && l->thread_index == thread_index); l->count--; if (l->count == 0) { diff --git a/src/vpp/stats/stats.h b/src/vpp/stats/stats.h index 118115be..024dc78e 100644 --- a/src/vpp/stats/stats.h +++ b/src/vpp/stats/stats.h @@ -30,7 +30,7 @@ typedef struct { volatile u32 lock; volatile u32 release_hint; - u32 thread_id; + u32 thread_index; u32 count; int tag; } data_structure_lock_t; -- cgit 1.2.3-korg From a0558307187ef2317f31e3e876a1a5e1faa2541c Mon Sep 17 00:00:00 2001 From: Neale Ranns Date: Thu, 13 Apr 2017 00:44:52 -0700 Subject: Remove unsed parameter from fib_table_entry_special_add() (only used in FIB tests). The DPO was incorrectly initialised with FIB_PROTO_MAX Change-Id: I962df9e162e4dfb6837a5ce79ea795d5ff2d7315 Signed-off-by: Neale Ranns --- src/plugins/ila/ila.c | 3 +-- src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_ioam.c | 4 +--- src/plugins/lb/lb.c | 3 +-- src/vnet/dhcp/client.c | 3 +-- src/vnet/dhcp/dhcp4_proxy_node.c | 3 +-- src/vnet/fib/fib_bfd.c | 3 +-- src/vnet/fib/fib_path.c | 3 +-- src/vnet/fib/fib_table.c | 15 ++------------- src/vnet/fib/fib_table.h | 14 ++++++-------- src/vnet/fib/fib_test.c | 16 ++++++++-------- src/vnet/fib/ip4_fib.c | 3 +-- src/vnet/fib/ip6_fib.c | 6 ++---- src/vnet/gre/interface.c | 3 +-- src/vnet/ip/ip4_forward.c | 6 ++---- src/vnet/ip/ip4_source_check.c | 2 +- src/vnet/lisp-gpe/lisp_gpe_tunnel.c | 3 +-- src/vnet/map/map.c | 4 +--- src/vnet/vxlan/vxlan.c | 2 +- 18 files changed, 33 insertions(+), 63 deletions(-) (limited to 'src/plugins/lb') diff --git a/src/plugins/ila/ila.c b/src/plugins/ila/ila.c index edbf3017..fd56043e 100644 --- a/src/plugins/ila/ila.c +++ b/src/plugins/ila/ila.c @@ -736,8 +736,7 @@ ila_add_del_entry (ila_add_del_entry_args_t * args) fib_table_entry_special_add(0, &next_hop, FIB_SOURCE_RR, - FIB_ENTRY_FLAG_NONE, - ADJ_INDEX_INVALID); + FIB_ENTRY_FLAG_NONE); e->next_hop_child_index = fib_entry_child_add(e->next_hop_fib_entry_index, ila_fib_node_type, diff --git a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_ioam.c b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_ioam.c index 88d7d205..cfc550cd 100644 --- a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_ioam.c +++ b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_ioam.c @@ -336,9 +336,7 @@ vxlan_gpe_enable_disable_ioam_for_dest (vlib_main_t * vm, t1->fib_entry_index = fib_table_entry_special_add (outer_fib_index, &tun_dst_pfx, - FIB_SOURCE_RR, - FIB_ENTRY_FLAG_NONE, - ADJ_INDEX_INVALID); + FIB_SOURCE_RR, FIB_ENTRY_FLAG_NONE); t1->sibling_index = fib_entry_child_add (t1->fib_entry_index, hm->fib_entry_type, t1 - hm->dst_tunnels); diff --git a/src/plugins/lb/lb.c b/src/plugins/lb/lb.c index addc2a42..cc3f8532 100644 --- a/src/plugins/lb/lb.c +++ b/src/plugins/lb/lb.c @@ -510,8 +510,7 @@ next: fib_table_entry_special_add(0, &nh, FIB_SOURCE_RR, - FIB_ENTRY_FLAG_NONE, - ADJ_INDEX_INVALID); + FIB_ENTRY_FLAG_NONE); as->next_hop_child_index = fib_entry_child_add(as->next_hop_fib_entry_index, lbm->fib_node_type, diff --git a/src/vnet/dhcp/client.c b/src/vnet/dhcp/client.c index 29749a33..7c3f7f6a 100644 --- a/src/vnet/dhcp/client.c +++ b/src/vnet/dhcp/client.c @@ -781,8 +781,7 @@ int dhcp_client_add_del (dhcp_client_add_del_args_t * a) c->sw_if_index), &all_1s, FIB_SOURCE_DHCP, - FIB_ENTRY_FLAG_LOCAL, - ADJ_INDEX_INVALID); + FIB_ENTRY_FLAG_LOCAL); /* * enable the interface to RX IPv4 packets diff --git a/src/vnet/dhcp/dhcp4_proxy_node.c b/src/vnet/dhcp/dhcp4_proxy_node.c index 1c84881a..26e1e65c 100644 --- a/src/vnet/dhcp/dhcp4_proxy_node.c +++ b/src/vnet/dhcp/dhcp4_proxy_node.c @@ -807,8 +807,7 @@ dhcp4_proxy_set_server (ip46_address_t *addr, fib_table_entry_special_add(rx_fib_index, &all_1s, FIB_SOURCE_DHCP, - FIB_ENTRY_FLAG_LOCAL, - ADJ_INDEX_INVALID); + FIB_ENTRY_FLAG_LOCAL); fib_table_lock (rx_fib_index, FIB_PROTOCOL_IP4); } } diff --git a/src/vnet/fib/fib_bfd.c b/src/vnet/fib/fib_bfd.c index e5affb8d..734ee8cc 100644 --- a/src/vnet/fib/fib_bfd.c +++ b/src/vnet/fib/fib_bfd.c @@ -109,8 +109,7 @@ fib_bfd_notify (bfd_listen_event_e event, fei = fib_table_entry_special_add(key->fib_index, &pfx, FIB_SOURCE_RR, - FIB_ENTRY_FLAG_NONE, - ADJ_INDEX_INVALID); + FIB_ENTRY_FLAG_NONE); fib_entry_lock(fei); fed = fib_entry_delegate_find_or_add(fib_entry_get(fei), diff --git a/src/vnet/fib/fib_path.c b/src/vnet/fib/fib_path.c index cd7d9278..70c87905 100644 --- a/src/vnet/fib/fib_path.c +++ b/src/vnet/fib/fib_path.c @@ -1621,8 +1621,7 @@ fib_path_resolve (fib_node_index_t path_index) fei = fib_table_entry_special_add(path->recursive.fp_tbl_id, &pfx, FIB_SOURCE_RR, - FIB_ENTRY_FLAG_NONE, - ADJ_INDEX_INVALID); + FIB_ENTRY_FLAG_NONE); path = fib_path_get(path_index); path->fp_via_fib = fei; diff --git a/src/vnet/fib/fib_table.c b/src/vnet/fib/fib_table.c index b31f35e3..0938ce9b 100644 --- a/src/vnet/fib/fib_table.c +++ b/src/vnet/fib/fib_table.c @@ -371,23 +371,12 @@ fib_node_index_t fib_table_entry_special_add (u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, - fib_entry_flag_t flags, - adj_index_t adj_index) + fib_entry_flag_t flags) { fib_node_index_t fib_entry_index; dpo_id_t tmp_dpo = DPO_INVALID; - if (ADJ_INDEX_INVALID != adj_index) - { - dpo_set(&tmp_dpo, - DPO_ADJACENCY, - FIB_PROTOCOL_MAX, - adj_index); - } - else - { - dpo_copy(&tmp_dpo, drop_dpo_get(fib_proto_to_dpo(prefix->fp_proto))); - } + dpo_copy(&tmp_dpo, drop_dpo_get(fib_proto_to_dpo(prefix->fp_proto))); fib_entry_index = fib_table_entry_special_dpo_add(fib_index, prefix, source, flags, &tmp_dpo); diff --git a/src/vnet/fib/fib_table.h b/src/vnet/fib/fib_table.h index b310aea6..f24d28b7 100644 --- a/src/vnet/fib/fib_table.h +++ b/src/vnet/fib/fib_table.h @@ -126,14 +126,16 @@ extern fib_node_index_t fib_table_get_less_specific(u32 fib_index, /** * @brief - * Add a 'special' entry to the FIB that links to the adj passed + * Add a 'special' entry to the FIB. * A special entry is an entry that the FIB is not expect to resolve * via the usual mechanisms (i.e. recurisve or neighbour adj DB lookup). - * Instead the client/source provides the adj to link to. + * Instead the will link to a DPO valid for the source and/or the flags. * This add is reference counting per-source. So n 'removes' are required * for n 'adds', if the entry is no longer required. + * If the source needs to provide non-default forwarding use: + * fib_table_entry_special_dpo_add() * - * @param fib_index + * @param fib_index * The index of the FIB * * @param prefix @@ -145,17 +147,13 @@ extern fib_node_index_t fib_table_get_less_specific(u32 fib_index, * @param flags * Flags for the entry. * - * @param adj_index - * The adjacency to link to. - * * @return * the index of the fib_entry_t that is created (or exists already). */ extern fib_node_index_t fib_table_entry_special_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, - fib_entry_flag_t flags, - adj_index_t adj_index); + fib_entry_flag_t flags); /** * @brief diff --git a/src/vnet/fib/fib_test.c b/src/vnet/fib/fib_test.c index e4a8a70e..c58dc5a1 100644 --- a/src/vnet/fib/fib_test.c +++ b/src/vnet/fib/fib_test.c @@ -1378,8 +1378,8 @@ fib_test_v4 (void) fib_entry_pool_size()); /* - * An EXCLUSIVE route; one where the user (me) provides the exclusive - * adjacency through which the route will resovle + * An special route; one where the user (me) provides the + * adjacency through which the route will resovle by setting the flags */ fib_prefix_t ex_pfx = { .fp_len = 32, @@ -1393,11 +1393,12 @@ fib_test_v4 (void) fib_table_entry_special_add(fib_index, &ex_pfx, FIB_SOURCE_SPECIAL, - FIB_ENTRY_FLAG_EXCLUSIVE, - locked_ai); + FIB_ENTRY_FLAG_LOCAL); fei = fib_table_lookup_exact_match(fib_index, &ex_pfx); - FIB_TEST((ai == fib_entry_get_adj(fei)), - "Exclusive route links to user adj"); + dpo = fib_entry_contribute_ip_forwarding(fei); + dpo = load_balance_get_bucket(dpo->dpoi_index, 0); + FIB_TEST((DPO_RECEIVE == dpo->dpoi_type), + "local interface adj is local"); fib_table_entry_special_remove(fib_index, &ex_pfx, @@ -3675,8 +3676,7 @@ fib_test_v4 (void) fei = fib_table_entry_special_add(fib_index, &pfx_4_1_1_1_s_32, FIB_SOURCE_URPF_EXEMPT, - FIB_ENTRY_FLAG_DROP, - ADJ_INDEX_INVALID); + FIB_ENTRY_FLAG_DROP); dpo = fib_entry_contribute_ip_forwarding(fei); FIB_TEST(load_balance_is_drop(dpo), "uRPF exempt 4.1.1.1/32 DROP"); diff --git a/src/vnet/fib/ip4_fib.c b/src/vnet/fib/ip4_fib.c index b03186e8..8e92d851 100644 --- a/src/vnet/fib/ip4_fib.c +++ b/src/vnet/fib/ip4_fib.c @@ -149,8 +149,7 @@ ip4_create_fib_with_table_id (u32 table_id) fib_table_entry_special_add(fib_table->ft_index, &prefix, ip4_specials[ii].ift_source, - ip4_specials[ii].ift_flag, - ADJ_INDEX_INVALID); + ip4_specials[ii].ift_flag); } return (fib_table->ft_index); diff --git a/src/vnet/fib/ip6_fib.c b/src/vnet/fib/ip6_fib.c index 00297140..d00f4c55 100644 --- a/src/vnet/fib/ip6_fib.c +++ b/src/vnet/fib/ip6_fib.c @@ -35,8 +35,7 @@ vnet_ip6_fib_init (u32 fib_index) fib_table_entry_special_add(fib_index, &pfx, FIB_SOURCE_DEFAULT_ROUTE, - FIB_ENTRY_FLAG_DROP, - ADJ_INDEX_INVALID); + FIB_ENTRY_FLAG_DROP); /* * all link local for us @@ -47,8 +46,7 @@ vnet_ip6_fib_init (u32 fib_index) fib_table_entry_special_add(fib_index, &pfx, FIB_SOURCE_SPECIAL, - FIB_ENTRY_FLAG_LOCAL, - ADJ_INDEX_INVALID); + FIB_ENTRY_FLAG_LOCAL); } static u32 diff --git a/src/vnet/gre/interface.c b/src/vnet/gre/interface.c index 91a3899f..d574e596 100644 --- a/src/vnet/gre/interface.c +++ b/src/vnet/gre/interface.c @@ -427,8 +427,7 @@ vnet_gre_tunnel_add (vnet_gre_add_del_tunnel_args_t *a, fib_table_entry_special_add(outer_fib_index, &t->tunnel_dst, FIB_SOURCE_RR, - FIB_ENTRY_FLAG_NONE, - ADJ_INDEX_INVALID); + FIB_ENTRY_FLAG_NONE); t->sibling_index = fib_entry_child_add(t->fib_entry_index, FIB_NODE_TYPE_GRE_TUNNEL, diff --git a/src/vnet/ip/ip4_forward.c b/src/vnet/ip/ip4_forward.c index e42b3637..0f562037 100644 --- a/src/vnet/ip/ip4_forward.c +++ b/src/vnet/ip/ip4_forward.c @@ -732,16 +732,14 @@ ip4_add_interface_routes (u32 sw_if_index, &net_pfx, FIB_SOURCE_INTERFACE, (FIB_ENTRY_FLAG_DROP | - FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT), - ADJ_INDEX_INVALID); + FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT)); net_pfx.fp_addr.ip4.as_u32 |= ~im->fib_masks[pfx.fp_len]; if (net_pfx.fp_addr.ip4.as_u32 != pfx.fp_addr.ip4.as_u32) fib_table_entry_special_add(fib_index, &net_pfx, FIB_SOURCE_INTERFACE, (FIB_ENTRY_FLAG_DROP | - FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT), - ADJ_INDEX_INVALID); + FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT)); } else if (pfx.fp_len == 31) { diff --git a/src/vnet/ip/ip4_source_check.c b/src/vnet/ip/ip4_source_check.c index 63b7594d..17a1cb1b 100644 --- a/src/vnet/ip/ip4_source_check.c +++ b/src/vnet/ip/ip4_source_check.c @@ -509,7 +509,7 @@ ip_source_check_accept (vlib_main_t * vm, fib_table_entry_special_add (fib_index, &pfx, FIB_SOURCE_URPF_EXEMPT, - FIB_ENTRY_FLAG_DROP, ADJ_INDEX_INVALID); + FIB_ENTRY_FLAG_DROP); } else { diff --git a/src/vnet/lisp-gpe/lisp_gpe_tunnel.c b/src/vnet/lisp-gpe/lisp_gpe_tunnel.c index 444bfe14..dd6c6fdd 100644 --- a/src/vnet/lisp-gpe/lisp_gpe_tunnel.c +++ b/src/vnet/lisp-gpe/lisp_gpe_tunnel.c @@ -179,8 +179,7 @@ lisp_gpe_tunnel_find_or_create_and_lock (const locator_pair_t * pair, lgt->fib_entry_index = fib_table_entry_special_add (rloc_fib_index, &pfx, FIB_SOURCE_RR, - FIB_ENTRY_FLAG_NONE, - ADJ_INDEX_INVALID); + FIB_ENTRY_FLAG_NONE); hash_set_mem (lisp_gpe_tunnel_db, &lgt->key, (lgt - lisp_gpe_tunnel_pool)); diff --git a/src/vnet/map/map.c b/src/vnet/map/map.c index 811a0abc..6a707df1 100644 --- a/src/vnet/map/map.c +++ b/src/vnet/map/map.c @@ -518,9 +518,7 @@ map_fib_resolve (map_main_pre_resolved_t * pr, pr->fei = fib_table_entry_special_add (0, // default fib &pfx, - FIB_SOURCE_RR, - FIB_ENTRY_FLAG_NONE, - ADJ_INDEX_INVALID); + FIB_SOURCE_RR, FIB_ENTRY_FLAG_NONE); pr->sibling = fib_entry_child_add (pr->fei, FIB_NODE_TYPE_MAP_E, proto); map_stack (pr); } diff --git a/src/vnet/vxlan/vxlan.c b/src/vnet/vxlan/vxlan.c index 61cb13c9..1b3df2a8 100644 --- a/src/vnet/vxlan/vxlan.c +++ b/src/vnet/vxlan/vxlan.c @@ -486,7 +486,7 @@ int vnet_vxlan_add_del_tunnel vtep_addr_ref(&t->src); t->fib_entry_index = fib_table_entry_special_add (t->encap_fib_index, &tun_dst_pfx, FIB_SOURCE_RR, - FIB_ENTRY_FLAG_NONE, ADJ_INDEX_INVALID); + FIB_ENTRY_FLAG_NONE); t->sibling_index = fib_entry_child_add (t->fib_entry_index, FIB_NODE_TYPE_VXLAN_TUNNEL, t - vxm->tunnels); vxlan_tunnel_restack_dpo(t); -- cgit 1.2.3-korg From 11b8dbf78af49d270a0e72abe7dea73eec30d85f Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Mon, 24 Apr 2017 10:46:54 -0400 Subject: "autoreply" flag: autogenerate standard xxx_reply_t messages Change-Id: I72298aaae7d172082ece3a8edea4217c11b28d79 Signed-off-by: Dave Barach --- src/examples/sample-plugin/sample/sample.api | 10 +- src/plugins/acl/acl.api | 60 +--- src/plugins/dpdk/api/dpdk.api | 35 +- src/plugins/flowperpkt/flowperpkt.api | 23 +- .../export-vxlan-gpe/vxlan_gpe_ioam_export.api | 10 +- src/plugins/ioam/export/ioam_export.api | 10 +- src/plugins/ioam/ip6/ioam_cache.api | 10 +- src/plugins/ioam/lib-pot/pot.api | 34 +- src/plugins/ioam/lib-trace/trace.api | 26 +- src/plugins/ioam/lib-vxlan-gpe/ioam_vxlan_gpe.api | 82 +---- src/plugins/lb/lb.api | 21 +- src/plugins/memif/memif.api | 12 +- src/plugins/snat/snat.api | 88 +---- src/tools/vppapigen/gram.y | 3 +- src/tools/vppapigen/lex.c | 57 +++- src/tools/vppapigen/lex.h | 1 + src/tools/vppapigen/node.c | 5 + src/tools/vppapigen/node.h | 2 + src/vlibmemory/memclnt.api | 7 +- src/vlibmemory/memory_vlib.c | 8 +- src/vnet/bfd/bfd.api | 132 +------- src/vnet/classify/classify.api | 37 +-- src/vnet/cop/cop.api | 28 +- src/vnet/devices/af_packet/af_packet.api | 12 +- src/vnet/devices/netmap/netmap.api | 24 +- src/vnet/devices/virtio/vhost_user.api | 24 +- src/vnet/dhcp/dhcp.api | 38 +-- src/vnet/flow/flow.api | 32 +- src/vnet/interface.api | 108 +----- src/vnet/ip/ip.api | 108 +----- src/vnet/ipsec/ipsec.api | 224 ++----------- src/vnet/l2/l2.api | 96 +----- src/vnet/l2tp/l2tp.api | 28 +- src/vnet/lisp-cp/lisp.api | 164 +-------- src/vnet/lisp-cp/one.api | 185 +---------- src/vnet/lisp-gpe/lisp_gpe.api | 48 +-- src/vnet/map/map.api | 22 +- src/vnet/mpls/mpls.api | 26 +- src/vnet/session/session.api | 68 +--- src/vnet/span/span.api | 10 +- src/vnet/sr/sr.api | 60 +--- src/vnet/unix/tap.api | 12 +- src/vnet/vxlan/vxlan.api | 12 +- src/vpp/api/vpe.api | 367 ++------------------- 44 files changed, 271 insertions(+), 2098 deletions(-) (limited to 'src/plugins/lb') diff --git a/src/examples/sample-plugin/sample/sample.api b/src/examples/sample-plugin/sample/sample.api index f99cdb38..d565c0b1 100644 --- a/src/examples/sample-plugin/sample/sample.api +++ b/src/examples/sample-plugin/sample/sample.api @@ -16,7 +16,7 @@ /* Define a simple binary API to control the feature */ -define sample_macswap_enable_disable { +autoreply define sample_macswap_enable_disable { /* Client identifier, set from api_main.my_client_index */ u32 client_index; @@ -29,11 +29,3 @@ define sample_macswap_enable_disable { /* Interface handle */ u32 sw_if_index; }; - -define sample_macswap_enable_disable_reply { - /* From the request */ - u32 context; - - /* Return value, zero means all OK */ - i32 retval; -}; diff --git a/src/plugins/acl/acl.api b/src/plugins/acl/acl.api index d981338d..3b334113 100644 --- a/src/plugins/acl/acl.api +++ b/src/plugins/acl/acl.api @@ -161,24 +161,13 @@ define acl_add_replace_reply @param acl_index - ACL index to delete */ -manual_print define acl_del +autoreply manual_print define acl_del { u32 client_index; u32 context; u32 acl_index; }; -/** \brief Reply to delete the ACL - @param context - returned sender context, to match reply w/ request - @param retval 0 - no error -*/ - -define acl_del_reply -{ - u32 context; - i32 retval; -}; - /* acl_interface_add_del(_reply) to be deprecated in lieu of acl_interface_set_acl_list */ /** \brief Use acl_interface_set_acl_list instead Append/remove an ACL index to/from the list of ACLs checked for an interface @@ -190,7 +179,7 @@ define acl_del_reply @param acl_index - index of ACL for the operation */ -manual_print define acl_interface_add_del +autoreply manual_print define acl_interface_add_del { u32 client_index; u32 context; @@ -204,17 +193,6 @@ manual_print define acl_interface_add_del u32 acl_index; }; -/** \brief Reply to alter the ACL list - @param context - returned sender context, to match reply w/ request - @param retval 0 - no error -*/ - -define acl_interface_add_del_reply -{ - u32 context; - i32 retval; -}; - /** \brief Set the vector of input/output ACLs checked for an interface @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -224,7 +202,7 @@ define acl_interface_add_del_reply @param acls - vector of ACL indices */ -manual_print define acl_interface_set_acl_list +autoreply manual_print define acl_interface_set_acl_list { u32 client_index; u32 context; @@ -239,12 +217,6 @@ manual_print define acl_interface_set_acl_list @param retval 0 - no error */ -define acl_interface_set_acl_list_reply -{ - u32 context; - i32 retval; -}; - /** \brief Dump the specific ACL contents or all of the ACLs' contents @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -341,24 +313,13 @@ define macip_acl_add_reply @param acl_index - MACIP ACL index to delete */ -manual_print define macip_acl_del +autoreply manual_print define macip_acl_del { u32 client_index; u32 context; u32 acl_index; }; -/** \brief Reply to delete the MACIP ACL - @param context - returned sender context, to match reply w/ request - @param retval 0 - no error -*/ - -define macip_acl_del_reply -{ - u32 context; - i32 retval; -}; - /** \brief Add or delete a MACIP ACL to/from interface @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -367,7 +328,7 @@ define macip_acl_del_reply @param acl_index - MACIP ACL index */ -manual_print define macip_acl_interface_add_del +autoreply manual_print define macip_acl_interface_add_del { u32 client_index; u32 context; @@ -377,17 +338,6 @@ manual_print define macip_acl_interface_add_del u32 acl_index; }; -/** \brief Reply to apply/unapply the MACIP ACL - @param context - returned sender context, to match reply w/ request - @param retval 0 - no error -*/ - -define macip_acl_interface_add_del_reply -{ - u32 context; - i32 retval; -}; - /** \brief Dump one or all defined MACIP ACLs @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/plugins/dpdk/api/dpdk.api b/src/plugins/dpdk/api/dpdk.api index 21215d45..d43f8a36 100644 --- a/src/plugins/dpdk/api/dpdk.api +++ b/src/plugins/dpdk/api/dpdk.api @@ -21,7 +21,7 @@ @param pipe - pipe ID within its subport @param profile - pipe profile ID */ -define sw_interface_set_dpdk_hqos_pipe { +autoreply define sw_interface_set_dpdk_hqos_pipe { u32 client_index; u32 context; u32 sw_if_index; @@ -30,15 +30,6 @@ define sw_interface_set_dpdk_hqos_pipe { u32 profile; }; -/** \brief DPDK interface HQoS pipe profile set reply - @param context - sender context, to match reply w/ request - @param retval - request return code -*/ -define sw_interface_set_dpdk_hqos_pipe_reply { - u32 context; - i32 retval; -}; - /** \brief DPDK interface HQoS subport parameters set request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -49,7 +40,7 @@ define sw_interface_set_dpdk_hqos_pipe_reply { @param tc_rate - subport traffic class 0 .. 3 rates (measured in bytes/second) @param tc_period - enforcement period for rates (measured in milliseconds) */ -define sw_interface_set_dpdk_hqos_subport { +autoreply define sw_interface_set_dpdk_hqos_subport { u32 client_index; u32 context; u32 sw_if_index; @@ -60,15 +51,6 @@ define sw_interface_set_dpdk_hqos_subport { u32 tc_period; }; -/** \brief DPDK interface HQoS subport parameters set reply - @param context - sender context, to match reply w/ request - @param retval - request return code -*/ -define sw_interface_set_dpdk_hqos_subport_reply { - u32 context; - i32 retval; -}; - /** \brief DPDK interface HQoS tctbl entry set request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -77,7 +59,7 @@ define sw_interface_set_dpdk_hqos_subport_reply { @param tc - traffic class (0 .. 3) @param queue - traffic class queue (0 .. 3) */ -define sw_interface_set_dpdk_hqos_tctbl { +autoreply define sw_interface_set_dpdk_hqos_tctbl { u32 client_index; u32 context; u32 sw_if_index; @@ -86,18 +68,9 @@ define sw_interface_set_dpdk_hqos_tctbl { u32 queue; }; -/** \brief DPDK interface HQoS tctbl entry set reply - @param context - sender context, to match reply w/ request - @param retval - request return code -*/ -define sw_interface_set_dpdk_hqos_tctbl_reply { - u32 context; - i32 retval; -}; - /* * Local Variables: * eval: (c-set-style "gnu") * End: */ - \ No newline at end of file + diff --git a/src/plugins/flowperpkt/flowperpkt.api b/src/plugins/flowperpkt/flowperpkt.api index 1cf62c54..3ff92dca 100644 --- a/src/plugins/flowperpkt/flowperpkt.api +++ b/src/plugins/flowperpkt/flowperpkt.api @@ -12,7 +12,7 @@ @param is_ipv6 - if non-zero the address is ipv6, else ipv4 @param sw_if_index - index of the interface */ -manual_print define flowperpkt_tx_interface_add_del +autoreply manual_print define flowperpkt_tx_interface_add_del { /* Client identifier, set from api_main.my_client_index */ u32 client_index; @@ -28,20 +28,7 @@ manual_print define flowperpkt_tx_interface_add_del u32 sw_if_index; }; -/** \brief Reply to enable/disable per-packet IPFIX recording messages - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define flowperpkt_tx_interface_add_del_reply -{ - /* From the request */ - u32 context; - - /* Return value, zero means all OK */ - i32 retval; -}; - -define flowperpkt_params +autoreply define flowperpkt_params { u32 client_index; u32 context; @@ -51,9 +38,3 @@ define flowperpkt_params u32 active_timer; /* ~0 is off, 0 is default */ u32 passive_timer; /* ~0 is off, 0 is default */ }; - -define flowperpkt_params_reply -{ - u32 context; - i32 retval; -}; diff --git a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.api b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.api index 7b17c3f7..caa97e6e 100644 --- a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.api +++ b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.api @@ -16,7 +16,7 @@ /* Define a simple binary API to control the feature */ -define vxlan_gpe_ioam_export_enable_disable { +autoreply define vxlan_gpe_ioam_export_enable_disable { /* Client identifier, set from api_main.my_client_index */ u32 client_index; @@ -32,11 +32,3 @@ define vxlan_gpe_ioam_export_enable_disable { /* Src ip address */ }; - -define vxlan_gpe_ioam_export_enable_disable_reply { - /* From the request */ - u32 context; - - /* Return value, zero means all OK */ - i32 retval; -}; \ No newline at end of file diff --git a/src/plugins/ioam/export/ioam_export.api b/src/plugins/ioam/export/ioam_export.api index f22d9fc8..bb830561 100644 --- a/src/plugins/ioam/export/ioam_export.api +++ b/src/plugins/ioam/export/ioam_export.api @@ -16,7 +16,7 @@ /* Define a simple binary API to control the feature */ -define ioam_export_ip6_enable_disable { +autoreply define ioam_export_ip6_enable_disable { /* Client identifier, set from api_main.my_client_index */ u32 client_index; @@ -32,11 +32,3 @@ define ioam_export_ip6_enable_disable { /* Src ip address */ }; - -define ioam_export_ip6_enable_disable_reply { - /* From the request */ - u32 context; - - /* Return value, zero means all OK */ - i32 retval; -}; diff --git a/src/plugins/ioam/ip6/ioam_cache.api b/src/plugins/ioam/ip6/ioam_cache.api index de50d57d..dd9c0186 100644 --- a/src/plugins/ioam/ip6/ioam_cache.api +++ b/src/plugins/ioam/ip6/ioam_cache.api @@ -16,7 +16,7 @@ /* API to control ioam caching */ -define ioam_cache_ip6_enable_disable { +autoreply define ioam_cache_ip6_enable_disable { /* Client identifier, set from api_main.my_client_index */ u32 client_index; @@ -27,11 +27,3 @@ define ioam_cache_ip6_enable_disable { u8 is_disable; }; - -define ioam_cache_ip6_enable_disable_reply { - /* From the request */ - u32 context; - - /* Return value, zero means all OK */ - i32 retval; -}; diff --git a/src/plugins/ioam/lib-pot/pot.api b/src/plugins/ioam/lib-pot/pot.api index fa2fc126..c377cde0 100644 --- a/src/plugins/ioam/lib-pot/pot.api +++ b/src/plugins/ioam/lib-pot/pot.api @@ -27,7 +27,7 @@ @param list_name_len - length of the name of this profile list @param list_name - name of this profile list */ -define pot_profile_add { +autoreply define pot_profile_add { u32 client_index; u32 context; u8 id; @@ -42,22 +42,12 @@ define pot_profile_add { u8 list_name[0]; }; -/** \brief Proof of Transit profile add / del response - @param context - sender context, to match reply w/ request - @param retval - return value for request -*/ -define pot_profile_add_reply { - u32 context; - i32 retval; -}; - - /** \brief Proof of Transit(POT): Activate POT profile in the list @param id - id of the profile @param list_name_len - length of the name of this profile list @param list_name - name of this profile list */ -define pot_profile_activate { +autoreply define pot_profile_activate { u32 client_index; u32 context; u8 id; @@ -65,37 +55,19 @@ define pot_profile_activate { u8 list_name[0]; }; -/** \brief Proof of Transit profile activate response - @param context - sender context, to match reply w/ request - @param retval - return value for request -*/ -define pot_profile_activate_reply { - u32 context; - i32 retval; -}; - /** \brief Delete POT Profile @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param list_name_len - length of the name of the profile list @param list_name - name of profile list to delete */ -define pot_profile_del { +autoreply define pot_profile_del { u32 client_index; u32 context; u8 list_name_len; u8 list_name[0]; }; -/** \brief Proof of Transit profile add / del response - @param context - sender context, to match reply w/ request - @param retval - return value for request -*/ -define pot_profile_del_reply { - u32 context; - i32 retval; -}; - /** \brief Show POT Profiles @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/plugins/ioam/lib-trace/trace.api b/src/plugins/ioam/lib-trace/trace.api index cb958325..2f45c6e2 100644 --- a/src/plugins/ioam/lib-trace/trace.api +++ b/src/plugins/ioam/lib-trace/trace.api @@ -22,7 +22,7 @@ @param trace_tsp- Timestamp resolution @param app_data - Application specific opaque */ -define trace_profile_add { +autoreply define trace_profile_add { u32 client_index; u32 context; u8 trace_type; @@ -32,37 +32,15 @@ define trace_profile_add { u32 app_data; }; -/** \brief Trace profile add / del response - @param context - sender context, to match reply w/ request - @param retval - return value for request -*/ -define trace_profile_add_reply { - u32 context; - i32 retval; -}; - - - /** \brief Delete trace Profile @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request */ -define trace_profile_del { +autoreply define trace_profile_del { u32 client_index; u32 context; }; -/** \brief Trace profile add / del response - @param context - sender context, to match reply w/ request - @param retval - return value for request -*/ -define trace_profile_del_reply { - u32 context; - i32 retval; -}; - - - /** \brief Show trace Profile @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/plugins/ioam/lib-vxlan-gpe/ioam_vxlan_gpe.api b/src/plugins/ioam/lib-vxlan-gpe/ioam_vxlan_gpe.api index 056529a4..a6761f07 100644 --- a/src/plugins/ioam/lib-vxlan-gpe/ioam_vxlan_gpe.api +++ b/src/plugins/ioam/lib-vxlan-gpe/ioam_vxlan_gpe.api @@ -24,7 +24,7 @@ @param trace_enable - iOAM Trace enabled or not flag */ -define vxlan_gpe_ioam_enable { +autoreply define vxlan_gpe_ioam_enable { u32 client_index; u32 context; u16 id; @@ -33,38 +33,18 @@ define vxlan_gpe_ioam_enable { u8 trace_enable; }; -/** \brief iOAM Over VxLAN-GPE - Set iOAM transport for VXLAN-GPE reply - @param context - sender context, to match reply w/ request - @param retval - return value for request -*/ -define vxlan_gpe_ioam_enable_reply { - u32 context; - i32 retval; -}; - - /** \brief iOAM for VxLAN-GPE disable @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param id - profile id */ -define vxlan_gpe_ioam_disable +autoreply define vxlan_gpe_ioam_disable { u32 client_index; u32 context; u16 id; }; -/** \brief vxlan_gpe_ioam disable response - @param context - sender context, to match reply w/ request - @param retval - return value for request -*/ -define vxlan_gpe_ioam_disable_reply -{ - u32 context; - i32 retval; -}; - /** \brief Enable iOAM for a VNI (VXLAN-GPE) @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -73,7 +53,7 @@ define vxlan_gpe_ioam_disable_reply @param remote - IPv4/6 Address of the remote VTEP */ -define vxlan_gpe_ioam_vni_enable { +autoreply define vxlan_gpe_ioam_vni_enable { u32 client_index; u32 context; u32 vni; @@ -82,18 +62,6 @@ define vxlan_gpe_ioam_vni_enable { u8 is_ipv6; }; -/** \brief Reply to enable iOAM for a VNI (VXLAN-GPE) - @param client_index - opaque cookie to identify the sender - @param context - sender context, to match reply w/ request - @param retval - return value for request - -*/ -define vxlan_gpe_ioam_vni_enable_reply { - u32 client_index; - u32 context; - i32 retval; -}; - /** \brief Disable iOAM for a VNI (VXLAN-GPE) @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -102,7 +70,7 @@ define vxlan_gpe_ioam_vni_enable_reply { @param remote - IPv4/6 Address of the remote VTEP */ -define vxlan_gpe_ioam_vni_disable { +autoreply define vxlan_gpe_ioam_vni_disable { u32 client_index; u32 context; u32 vni; @@ -111,19 +79,6 @@ define vxlan_gpe_ioam_vni_disable { u8 is_ipv6; }; -/** \brief Reply to disable iOAM for a VNI (VXLAN-GPE) - @param client_index - opaque cookie to identify the sender - @param context - sender context, to match reply w/ request - @param retval - return value for request - -*/ -define vxlan_gpe_ioam_vni_disable_reply { - u32 client_index; - u32 context; - i32 retval; -}; - - /** \brief Enable iOAM for a VXLAN-GPE transit @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -131,7 +86,7 @@ define vxlan_gpe_ioam_vni_disable_reply { @param outer_fib_index- FIB index */ -define vxlan_gpe_ioam_transit_enable { +autoreply define vxlan_gpe_ioam_transit_enable { u32 client_index; u32 context; u32 outer_fib_index; @@ -139,18 +94,6 @@ define vxlan_gpe_ioam_transit_enable { u8 is_ipv6; }; -/** \brief Reply to enable iOAM for VXLAN-GPE transit - @param client_index - opaque cookie to identify the sender - @param context - sender context, to match reply w/ request - @param retval - return value for request - -*/ -define vxlan_gpe_ioam_transit_enable_reply { - u32 client_index; - u32 context; - i32 retval; -}; - /** \brief Disable iOAM for VXLAN-GPE transit @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -158,7 +101,7 @@ define vxlan_gpe_ioam_transit_enable_reply { @param outer_fib_index- FIB index */ -define vxlan_gpe_ioam_transit_disable { +autoreply define vxlan_gpe_ioam_transit_disable { u32 client_index; u32 context; u32 outer_fib_index; @@ -166,16 +109,3 @@ define vxlan_gpe_ioam_transit_disable { u8 is_ipv6; }; -/** \brief Reply to disable iOAM for VXLAN-GPE transit - @param client_index - opaque cookie to identify the sender - @param context - sender context, to match reply w/ request - @param retval - return value for request - -*/ -define vxlan_gpe_ioam_transit_disable_reply { - u32 client_index; - u32 context; - i32 retval; -}; - - diff --git a/src/plugins/lb/lb.api b/src/plugins/lb/lb.api index 39ee3c8f..32cc669b 100644 --- a/src/plugins/lb/lb.api +++ b/src/plugins/lb/lb.api @@ -8,7 +8,7 @@ @param flow_timeout - Time in seconds after which, if no packet is received for a given flow, the flow is removed from the established flow table. */ -define lb_conf +autoreply define lb_conf { u32 client_index; u32 context; @@ -18,11 +18,6 @@ define lb_conf u32 flow_timeout; }; -define lb_conf_reply { - u32 context; - i32 retval; -}; - /** \brief Add a virtual address (or prefix) @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -33,7 +28,7 @@ define lb_conf_reply { for this VIP (must be power of 2). @param is_del - The VIP should be removed. */ -define lb_add_del_vip { +autoreply define lb_add_del_vip { u32 client_index; u32 context; u8 ip_prefix[16]; @@ -43,11 +38,6 @@ define lb_add_del_vip { u8 is_del; }; -define lb_add_del_vip_reply { - u32 context; - i32 retval; -}; - /** \brief Add an application server for a given VIP @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -56,7 +46,7 @@ define lb_add_del_vip_reply { @param as_address - The application server address (IPv4 in lower order 32 bits). @param is_del - The AS should be removed. */ -define lb_add_del_as { +autoreply define lb_add_del_as { u32 client_index; u32 context; u8 vip_ip_prefix[16]; @@ -64,8 +54,3 @@ define lb_add_del_as { u8 as_address[16]; u8 is_del; }; - -define lb_add_del_as_reply { - u32 context; - i32 retval; -}; diff --git a/src/plugins/memif/memif.api b/src/plugins/memif/memif.api index 6f946421..95e016c3 100644 --- a/src/plugins/memif/memif.api +++ b/src/plugins/memif/memif.api @@ -57,7 +57,7 @@ define memif_create_reply @param context - sender context, to match reply w/ request @param sw_if_index - software index of the interface to delete */ -define memif_delete +autoreply define memif_delete { u32 client_index; u32 context; @@ -65,16 +65,6 @@ define memif_delete u32 sw_if_index; }; -/** \brief Delete host-interface response - @param context - sender context, to match reply w/ request - @param retval - return value for request -*/ -define memif_delete_reply -{ - u32 context; - i32 retval; -}; - /** \brief Memory interface details structure @param context - sender context, to match reply w/ request (memif_dump) @param sw_if_index - index of the interface diff --git a/src/plugins/snat/snat.api b/src/plugins/snat/snat.api index 9689f5f9..573b6753 100644 --- a/src/plugins/snat/snat.api +++ b/src/plugins/snat/snat.api @@ -29,7 +29,7 @@ @param vrf_id - VRF id of tenant, ~0 means independent of VRF @param is_add - 1 if add, 0 if delete */ -define snat_add_address_range { +autoreply define snat_add_address_range { u32 client_index; u32 context; u8 is_ip4; @@ -39,15 +39,6 @@ define snat_add_address_range { u8 is_add; }; -/** \brief Add S-NAT address range reply - @param context - sender context, to match reply w/ request - @param retval - return code -*/ -define snat_add_address_range_reply { - u32 context; - i32 retval; -}; - /** \brief Dump S-NAT addresses @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -77,7 +68,7 @@ define snat_address_details { @param is_inside - 1 if inside, 0 if outside @param sw_if_index - software index of the interface */ -define snat_interface_add_del_feature { +autoreply define snat_interface_add_del_feature { u32 client_index; u32 context; u8 is_add; @@ -85,15 +76,6 @@ define snat_interface_add_del_feature { u32 sw_if_index; }; -/** \brief Enable/disable S-NAT feature on the interface reply - @param context - sender context, to match reply w/ request - @param retval - return code -*/ -define snat_interface_add_del_feature_reply { - u32 context; - i32 retval; -}; - /** \brief Dump interfaces with S-NAT feature @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -130,7 +112,7 @@ define snat_interface_details { used) @param vfr_id - VRF ID */ -define snat_add_static_mapping { +autoreply define snat_add_static_mapping { u32 client_index; u32 context; u8 is_add; @@ -145,15 +127,6 @@ define snat_add_static_mapping { u32 vrf_id; }; -/** \brief Add/delete S-NAT static mapping reply - @param context - sender context, to match reply w/ request - @param retval - return code -*/ -define snat_add_static_mapping_reply { - u32 context; - i32 retval; -}; - /** \brief Dump S-NAT static mappings @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -257,21 +230,12 @@ define snat_show_config_reply @param context - sender context, to match reply w/ request @param worker_mask - S-NAT workers mask */ -define snat_set_workers { +autoreply define snat_set_workers { u32 client_index; u32 context; u64 worker_mask; }; -/** \brief Set S-NAT workers reply - @param context - sender context, to match reply w/ request - @param retval - return code -*/ -define snat_set_workers_reply { - u32 context; - i32 retval; -}; - /** \brief Dump S-NAT workers @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -300,7 +264,7 @@ define snat_worker_details { @param is_add - 1 if add, 0 if delete @param sw_if_index - software index of the interface */ -define snat_add_del_interface_addr { +autoreply define snat_add_del_interface_addr { u32 client_index; u32 context; u8 is_add; @@ -308,15 +272,6 @@ define snat_add_del_interface_addr { u32 sw_if_index; }; -/** \brief Add/delete S-NAT pool address from specific interfce reply - @param context - sender context, to match reply w/ request - @param retval - return code -*/ -define snat_add_del_interface_addr_reply { - u32 context; - i32 retval; -}; - /** \brief Dump S-NAT pool addresses interfaces @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -342,7 +297,7 @@ define snat_interface_addr_details { @param src_port - source port number @param enable - 1 if enable, 0 if disable */ -define snat_ipfix_enable_disable { +autoreply define snat_ipfix_enable_disable { u32 client_index; u32 context; u32 domain_id; @@ -350,15 +305,6 @@ define snat_ipfix_enable_disable { u8 enable; }; -/** \brief Enable/disable S-NAT IPFIX logging reply - @param context - sender context, to match reply w/ request - @param retval - return code -*/ -define snat_ipfix_enable_disable_reply { - u32 context; - i32 retval; -}; - /** \brief Dump S-NAT users @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -437,7 +383,7 @@ define snat_user_session_details { @param out_addr - outside IP address @param out_addr - outside IP address prefix length */ -define snat_add_det_map { +autoreply define snat_add_det_map { u32 client_index; u32 context; u8 is_add; @@ -449,15 +395,6 @@ define snat_add_det_map { u8 out_plen; }; -/** \brief Add/delete S-NAT deterministic mapping reply - @param context - sender context, to match reply w/ request - @param retval - return code -*/ -define snat_add_det_map_reply { - u32 context; - i32 retval; -}; - /** \brief Get outside address and port range from inside address @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -556,7 +493,7 @@ define snat_det_map_details { @param tcp_transitory - TCP transitory timeout (default 240sec) @param icmp - ICMP timeout (default 60sec) */ -define snat_det_set_timeouts { +autoreply define snat_det_set_timeouts { u32 client_index; u32 context; u32 udp; @@ -565,15 +502,6 @@ define snat_det_set_timeouts { u32 icmp; }; -/** \brief Set values of timeouts for deterministic NAT reply - @param context - sender context, to match reply w/ request - @param retval - return code -*/ -define snat_det_set_timeouts_reply { - u32 context; - i32 retval; -}; - /** \brief Get values of timeouts for deterministic NAT (seconds) @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/tools/vppapigen/gram.y b/src/tools/vppapigen/gram.y index de26af8d..9cea6023 100644 --- a/src/tools/vppapigen/gram.y +++ b/src/tools/vppapigen/gram.y @@ -38,7 +38,7 @@ void generate (YYSTYPE); %token NAME RPAR LPAR SEMI LBRACK RBRACK NUMBER PRIMTYPE BARF %token TPACKED DEFINE LCURLY RCURLY STRING UNION %token HELPER_STRING COMMA -%token NOVERSION MANUAL_PRINT MANUAL_ENDIAN TYPEONLY DONT_TRACE +%token NOVERSION MANUAL_PRINT MANUAL_ENDIAN TYPEONLY DONT_TRACE AUTOREPLY %% @@ -64,6 +64,7 @@ flag: | MANUAL_ENDIAN {$$ = $1;} | DONT_TRACE {$$ = $1;} | TYPEONLY {$$ = $1;} + | AUTOREPLY {$$ = $1;} ; defn: DEFINE NAME LCURLY defbody RCURLY SEMI diff --git a/src/tools/vppapigen/lex.c b/src/tools/vppapigen/lex.c index 733942ad..e6358143 100644 --- a/src/tools/vppapigen/lex.c +++ b/src/tools/vppapigen/lex.c @@ -27,6 +27,9 @@ #include "lex.h" #include "node.h" #include "tools/vppapigen/gram.h" +#include +#include +#include FILE *ifp, *ofp, *pythonfp, *jsonfp; char *vlib_app_name = "vpp"; @@ -38,6 +41,9 @@ int current_filename_allocated; unsigned long input_crc; unsigned long message_crc; int yydebug; +char *push_input_fifo; +char saved_ungetc_char; +char have_ungetc_char; /* * lexer variable definitions @@ -469,9 +475,50 @@ static char namebuf [MAXNAME]; static inline char getc_char (FILE *ifp) { + char rv; + + if (have_ungetc_char) { + have_ungetc_char = 0; + return saved_ungetc_char; + } + + if (clib_fifo_elts (push_input_fifo)) { + clib_fifo_sub1(push_input_fifo, rv); + return (rv & 0x7f); + } return ((char)(getc(ifp) & 0x7f)); } +u32 fe (char *fifo) +{ + return clib_fifo_elts (fifo); +} + +static inline void +ungetc_char (char c, FILE *ifp) +{ + saved_ungetc_char = c; + have_ungetc_char = 1; +} + +void autoreply (void *np_arg) +{ + static u8 *s; + node_t *np = (node_t *)np_arg; + int i; + + vec_reset_length (s); + + s = format (0, " define %s_reply\n", (char *)(np->data[0])); + s = format (s, "{\n"); + s = format (s, " u32 context;\n"); + s = format (s, " i32 retval;\n"); + s = format (s, "};\n"); + + for (i = 0; i < vec_len (s); i++) + clib_fifo_add1 (push_input_fifo, s[i]); +} + /* * yylex (well, yylex_1: The real yylex below does crc-hackery) */ @@ -595,7 +642,7 @@ static int yylex_1 (void) return (EOF); if (!isalnum (c) && c != '_') { - ungetc (c, ifp); + ungetc_char (c, ifp); namebuf [nameidx] = 0; the_lexer_state = START_STATE; return (name_check (namebuf, &yylval)); @@ -616,7 +663,7 @@ static int yylex_1 (void) return (EOF); if (!isdigit (c)) { - ungetc (c, ifp); + ungetc_char (c, ifp); namebuf [nameidx] = 0; the_lexer_state = START_STATE; yylval = (void *) atol(namebuf); @@ -889,6 +936,7 @@ int yylex (void) case MANUAL_ENDIAN: code = 276; break; case TYPEONLY: code = 278; break; case DONT_TRACE: code = 279; break; + case AUTOREPLY: code = 280; break; case EOF: code = ~0; break; /* hysterical compatibility */ @@ -929,6 +977,7 @@ static struct keytab { } keytab [] = /* Keep the table sorted, binary search used below! */ { + {"autoreply", NODE_AUTOREPLY}, {"define", NODE_DEFINE}, {"dont_trace", NODE_DONT_TRACE}, {"f64", NODE_F64}, @@ -1005,6 +1054,10 @@ static int name_check (const char *s, YYSTYPE *token_value) *token_value = (YYSTYPE) NODE_FLAG_DONT_TRACE; return(DONT_TRACE); + case NODE_AUTOREPLY: + *token_value = (YYSTYPE) NODE_FLAG_AUTOREPLY; + return(AUTOREPLY); + case NODE_NOVERSION: return(NOVERSION); diff --git a/src/tools/vppapigen/lex.h b/src/tools/vppapigen/lex.h index a0fdc735..275cf685 100644 --- a/src/tools/vppapigen/lex.h +++ b/src/tools/vppapigen/lex.h @@ -24,6 +24,7 @@ extern int yylex (void); extern void yyerror (char *); extern int yyparse (void); +extern void autoreply (void *); #ifndef YYSTYPE #define YYSTYPE void * diff --git a/src/tools/vppapigen/node.c b/src/tools/vppapigen/node.c index 359ac9c9..9f234037 100644 --- a/src/tools/vppapigen/node.c +++ b/src/tools/vppapigen/node.c @@ -1050,6 +1050,11 @@ YYSTYPE set_flags(YYSTYPE a1, YYSTYPE a2) flags = (int)(uword) a1; np->flags |= flags; + + /* Generate a foo_reply_t right here */ + if (flags & NODE_FLAG_AUTOREPLY) + autoreply(np); + return (a2); } /* diff --git a/src/tools/vppapigen/node.h b/src/tools/vppapigen/node.h index 297d6036..65bd5d10 100644 --- a/src/tools/vppapigen/node.h +++ b/src/tools/vppapigen/node.h @@ -53,6 +53,7 @@ enum node_subclass { /* WARNING: indices must match the vft... */ NODE_MANUAL_PRINT, NODE_MANUAL_ENDIAN, NODE_DONT_TRACE, + NODE_AUTOREPLY, }; enum passid { @@ -84,6 +85,7 @@ typedef struct node_ { #define NODE_FLAG_MANUAL_ENDIAN (1<<1) #define NODE_FLAG_TYPEONLY (1<<3) #define NODE_FLAG_DONT_TRACE (1<<4) +#define NODE_FLAG_AUTOREPLY (1<<5) typedef struct node_vft_ { void (*print)(struct node_ *); diff --git a/src/vlibmemory/memclnt.api b/src/vlibmemory/memclnt.api index c38b483c..32e51407 100644 --- a/src/vlibmemory/memclnt.api +++ b/src/vlibmemory/memclnt.api @@ -72,7 +72,7 @@ define memclnt_read_timeout { /* * RPC */ -define rpc_call { +autoreply define rpc_call { u32 client_index; u32 context; u64 function; @@ -82,11 +82,6 @@ define rpc_call { u8 data[0]; }; -define rpc_reply { - i32 retval; - u32 context; -}; - /* * Lookup message-ID base by name */ diff --git a/src/vlibmemory/memory_vlib.c b/src/vlibmemory/memory_vlib.c index 7a536ee8..43574dea 100644 --- a/src/vlibmemory/memory_vlib.c +++ b/src/vlibmemory/memory_vlib.c @@ -1275,7 +1275,7 @@ VLIB_CLI_COMMAND (cli_show_api_plugin_command, static) = { static void vl_api_rpc_call_t_handler (vl_api_rpc_call_t * mp) { - vl_api_rpc_reply_t *rmp; + vl_api_rpc_call_reply_t *rmp; int (*fp) (void *); i32 rv = 0; vlib_main_t *vm = vlib_get_main (); @@ -1305,7 +1305,7 @@ vl_api_rpc_call_t_handler (vl_api_rpc_call_t * mp) if (q) { rmp = vl_msg_api_alloc_as_if_client (sizeof (*rmp)); - rmp->_vl_msg_id = ntohs (VL_API_RPC_REPLY); + rmp->_vl_msg_id = ntohs (VL_API_RPC_CALL_REPLY); rmp->context = mp->context; rmp->retval = rv; vl_msg_api_send_shmem (q, (u8 *) & rmp); @@ -1318,7 +1318,7 @@ vl_api_rpc_call_t_handler (vl_api_rpc_call_t * mp) } static void -vl_api_rpc_reply_t_handler (vl_api_rpc_reply_t * mp) +vl_api_rpc_call_reply_t_handler (vl_api_rpc_call_reply_t * mp) { clib_warning ("unimplemented"); } @@ -1415,7 +1415,7 @@ vl_api_trace_plugin_msg_ids_t_handler (vl_api_trace_plugin_msg_ids_t * mp) #define foreach_rpc_api_msg \ _(RPC_CALL,rpc_call) \ -_(RPC_REPLY,rpc_reply) +_(RPC_CALL_REPLY,rpc_call_reply) #define foreach_plugin_trace_msg \ _(TRACE_PLUGIN_MSG_IDS,trace_plugin_msg_ids) diff --git a/src/vnet/bfd/bfd.api b/src/vnet/bfd/bfd.api index 2cdcfad3..7bcaa4c3 100644 --- a/src/vnet/bfd/bfd.api +++ b/src/vnet/bfd/bfd.api @@ -18,43 +18,23 @@ @param context - sender context, to match reply w/ request @param sw_if_index - interface to use as echo source */ -define bfd_udp_set_echo_source +autoreply define bfd_udp_set_echo_source { u32 client_index; u32 context; u32 sw_if_index; }; -/** \brief Set BFD feature response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define bfd_udp_set_echo_source_reply -{ - u32 context; - i32 retval; -}; - /** \brief Delete BFD echo source @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request */ -define bfd_udp_del_echo_source +autoreply define bfd_udp_del_echo_source { u32 client_index; u32 context; }; -/** \brief Delete BFD echo source response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define bfd_udp_del_echo_source_reply -{ - u32 context; - i32 retval; -}; - /** \brief Add UDP BFD session on interface @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -69,7 +49,7 @@ define bfd_udp_del_echo_source_reply @param bfd_key_id - key id sent out in BFD packets (if is_authenticated) @param conf_key_id - id of already configured key (if is_authenticated) */ -define bfd_udp_add +autoreply define bfd_udp_add { u32 client_index; u32 context; @@ -85,16 +65,6 @@ define bfd_udp_add u32 conf_key_id; }; -/** \brief Add UDP BFD session response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define bfd_udp_add_reply -{ - u32 context; - i32 retval; -}; - /** \brief Modify UDP BFD session on interface @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -106,7 +76,7 @@ define bfd_udp_add_reply @param is_ipv6 - local_addr, peer_addr are IPv6 if non-zero, otherwise IPv4 @param detect_mult - detect multiplier (# of packets missed before connection goes down) */ -define bfd_udp_mod +autoreply define bfd_udp_mod { u32 client_index; u32 context; @@ -119,16 +89,6 @@ define bfd_udp_mod u8 detect_mult; }; -/** \brief Modify UDP BFD session response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define bfd_udp_mod_reply -{ - u32 context; - i32 retval; -}; - /** \brief Delete UDP BFD session on interface @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -137,7 +97,7 @@ define bfd_udp_mod_reply @param peer_addr - peer address @param is_ipv6 - local_addr, peer_addr are IPv6 if non-zero, otherwise IPv4 */ -define bfd_udp_del +autoreply define bfd_udp_del { u32 client_index; u32 context; @@ -147,16 +107,6 @@ define bfd_udp_del u8 is_ipv6; }; -/** \brief Delete UDP BFD session response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define bfd_udp_del_reply -{ - u32 context; - i32 retval; -}; - /** \brief Get all BFD sessions @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -206,7 +156,7 @@ define bfd_udp_session_details @param is_ipv6 - local_addr, peer_addr are IPv6 if non-zero, otherwise IPv4 @param admin_up_down - set the admin state, 1 = up, 0 = down */ -define bfd_udp_session_set_flags +autoreply define bfd_udp_session_set_flags { u32 client_index; u32 context; @@ -217,23 +167,13 @@ define bfd_udp_session_set_flags u8 admin_up_down; }; -/** \brief Reply to bfd_udp_session_set_flags - @param context - sender context which was passed in the request - @param retval - return code of the set flags request -*/ -define bfd_udp_session_set_flags_reply -{ - u32 context; - i32 retval; -}; - /** \brief Register for BFD events @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param enable_disable - 1 => register for events, 0 => cancel registration @param pid - sender's pid */ -define want_bfd_events +autoreply define want_bfd_events { u32 client_index; u32 context; @@ -241,16 +181,6 @@ define want_bfd_events u32 pid; }; -/** \brief Reply for BFD events registration - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define want_bfd_events_reply -{ - u32 context; - i32 retval; -}; - /** \brief BFD UDP - add/replace key to configuration @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -259,7 +189,7 @@ define want_bfd_events_reply @param auth_type - authentication type (RFC 5880/4.1/Auth Type) @param key - key data */ -define bfd_auth_set_key +autoreply define bfd_auth_set_key { u32 client_index; u32 context; @@ -269,16 +199,6 @@ define bfd_auth_set_key u8 key[20]; }; -/** \brief BFD UDP - add/replace key reply - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define bfd_auth_set_key_reply -{ - u32 context; - i32 retval; -}; - /** \brief BFD UDP - delete key from configuration @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -286,23 +206,13 @@ define bfd_auth_set_key_reply @param key_len - length of key (must be non-zero) @param key - key data */ -define bfd_auth_del_key +autoreply define bfd_auth_del_key { u32 client_index; u32 context; u32 conf_key_id; }; -/** \brief BFD UDP - delete key reply - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define bfd_auth_del_key_reply -{ - u32 context; - i32 retval; -}; - /** \brief Get a list of configured authentication keys @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -338,7 +248,7 @@ define bfd_auth_keys_details @param bfd_key_id - key id sent out in BFD packets @param conf_key_id - id of already configured key */ -define bfd_udp_auth_activate +autoreply define bfd_udp_auth_activate { u32 client_index; u32 context; @@ -351,16 +261,6 @@ define bfd_udp_auth_activate u32 conf_key_id; }; -/** \brief BFD UDP - activate/change authentication reply - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define bfd_udp_auth_activate_reply -{ - u32 context; - i32 retval; -}; - /** \brief BFD UDP - deactivate authentication @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -370,7 +270,7 @@ define bfd_udp_auth_activate_reply @param is_ipv6 - local_addr, peer_addr are IPv6 if non-zero, otherwise IPv4 @param is_delayed - change is applied once peer applies the change (on first received non-authenticated packet) */ -define bfd_udp_auth_deactivate +autoreply define bfd_udp_auth_deactivate { u32 client_index; u32 context; @@ -381,16 +281,6 @@ define bfd_udp_auth_deactivate u8 is_delayed; }; -/** \brief BFD UDP - deactivate authentication reply - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define bfd_udp_auth_deactivate_reply -{ - u32 context; - i32 retval; -}; - /* * Local Variables: * eval: (c-set-style "gnu") diff --git a/src/vnet/classify/classify.api b/src/vnet/classify/classify.api index 51ebd6c8..cacb9bed 100644 --- a/src/vnet/classify/classify.api +++ b/src/vnet/classify/classify.api @@ -92,7 +92,7 @@ define classify_add_del_table_reply VRF id if action is 1 or 2. @param match[] - for add, match value for session, required */ -define classify_add_del_session +autoreply define classify_add_del_session { u32 client_index; u32 context; @@ -106,16 +106,6 @@ define classify_add_del_session u8 match[0]; }; -/** \brief Classify add / del session response - @param context - sender context, to match reply w/ request - @param retval - return code for the add/del session request -*/ -define classify_add_del_session_reply -{ - u32 context; - i32 retval; -}; - /** \brief Set/unset policer classify interface @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -127,7 +117,7 @@ define classify_add_del_session_reply Note: User is recommeneded to use just one valid table_index per call. (ip4_table_index, ip6_table_index, or l2_table_index) */ -define policer_classify_set_interface +autoreply define policer_classify_set_interface { u32 client_index; u32 context; @@ -138,16 +128,6 @@ define policer_classify_set_interface u8 is_add; }; -/** \brief Set/unset policer classify interface response - @param context - sender context, to match reply w/ request - @param retval - return value for request -*/ -define policer_classify_set_interface_reply -{ - u32 context; - i32 retval; -}; - /** \brief Get list of policer classify interfaces and tables @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -308,7 +288,7 @@ define classify_session_details Note: User is recommeneded to use just one valid table_index per call. (ip4_table_index, ip6_table_index, or l2_table_index) */ -define flow_classify_set_interface { +autoreply define flow_classify_set_interface { u32 client_index; u32 context; u32 sw_if_index; @@ -317,15 +297,6 @@ define flow_classify_set_interface { u8 is_add; }; -/** \brief Set/unset flow classify interface response - @param context - sender context, to match reply w/ request - @param retval - return value for request -*/ -define flow_classify_set_interface_reply { - u32 context; - i32 retval; -}; - /** \brief Get list of flow classify interfaces and tables @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -353,4 +324,4 @@ define flow_classify_details { * eval: (c-set-style "gnu") * End: */ - \ No newline at end of file + diff --git a/src/vnet/cop/cop.api b/src/vnet/cop/cop.api index b34dae80..69316001 100644 --- a/src/vnet/cop/cop.api +++ b/src/vnet/cop/cop.api @@ -20,7 +20,7 @@ @param enable_disable - 1 => enable, 0 => disable */ -define cop_interface_enable_disable +autoreply define cop_interface_enable_disable { u32 client_index; u32 context; @@ -28,17 +28,6 @@ define cop_interface_enable_disable u8 enable_disable; }; -/** \brief cop: interface enable/disable junk filtration reply - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ - -define cop_interface_enable_disable_reply -{ - u32 context; - i32 retval; -}; - /** \brief cop: enable/disable whitelist filtration features on an interface Note: the supplied fib_id must match in order to remove the feature! @@ -51,7 +40,7 @@ define cop_interface_enable_disable_reply @param default_cop - 1 => enable non-ip4, non-ip6 filtration 0=> disable it */ -define cop_whitelist_enable_disable +autoreply define cop_whitelist_enable_disable { u32 client_index; u32 context; @@ -62,17 +51,6 @@ define cop_whitelist_enable_disable u8 default_cop; }; -/** \brief cop: interface enable/disable junk filtration reply - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ - -define cop_whitelist_enable_disable_reply -{ - u32 context; - i32 retval; -}; - /** \brief get_node_graph - get a copy of the vpp node graph including the current set of graph arcs. @@ -85,4 +63,4 @@ define cop_whitelist_enable_disable_reply * eval: (c-set-style "gnu") * End: */ - \ No newline at end of file + diff --git a/src/vnet/devices/af_packet/af_packet.api b/src/vnet/devices/af_packet/af_packet.api index 9fb2a207..8d40ad60 100644 --- a/src/vnet/devices/af_packet/af_packet.api +++ b/src/vnet/devices/af_packet/af_packet.api @@ -46,7 +46,7 @@ define af_packet_create_reply @param context - sender context, to match reply w/ request @param host_if_name - interface name */ -define af_packet_delete +autoreply define af_packet_delete { u32 client_index; u32 context; @@ -54,16 +54,6 @@ define af_packet_delete u8 host_if_name[64]; }; -/** \brief Delete host-interface response - @param context - sender context, to match reply w/ request - @param retval - return value for request -*/ -define af_packet_delete_reply -{ - u32 context; - i32 retval; -}; - /* * Local Variables: * eval: (c-set-style "gnu") diff --git a/src/vnet/devices/netmap/netmap.api b/src/vnet/devices/netmap/netmap.api index 377ccffd..8dc698b9 100644 --- a/src/vnet/devices/netmap/netmap.api +++ b/src/vnet/devices/netmap/netmap.api @@ -22,7 +22,7 @@ @param is_pipe - is pipe @param is_master - 0=slave, 1=master */ -define netmap_create +autoreply define netmap_create { u32 client_index; u32 context; @@ -34,22 +34,12 @@ define netmap_create u8 is_master; }; -/** \brief Create netmap response - @param context - sender context, to match reply w/ request - @param retval - return value for request -*/ -define netmap_create_reply -{ - u32 context; - i32 retval; -}; - /** \brief Delete netmap @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param netmap_if_name - interface name */ -define netmap_delete +autoreply define netmap_delete { u32 client_index; u32 context; @@ -57,16 +47,6 @@ define netmap_delete u8 netmap_if_name[64]; }; -/** \brief Delete netmap response - @param context - sender context, to match reply w/ request - @param retval - return value for request -*/ -define netmap_delete_reply -{ - u32 context; - i32 retval; -}; - /* * Local Variables: * eval: (c-set-style "gnu") diff --git a/src/vnet/devices/virtio/vhost_user.api b/src/vnet/devices/virtio/vhost_user.api index 4f604e45..df7ce7ab 100644 --- a/src/vnet/devices/virtio/vhost_user.api +++ b/src/vnet/devices/virtio/vhost_user.api @@ -53,7 +53,7 @@ define create_vhost_user_if_reply @param sock_filename - unix socket filename, used to speak with frontend @param operation_mode - polling=0, interrupt=1, or adaptive=2 */ -define modify_vhost_user_if +autoreply define modify_vhost_user_if { u32 client_index; u32 context; @@ -65,36 +65,16 @@ define modify_vhost_user_if u8 operation_mode; }; -/** \brief vhost-user interface modify response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define modify_vhost_user_if_reply -{ - u32 context; - i32 retval; -}; - /** \brief vhost-user interface delete request @param client_index - opaque cookie to identify the sender */ -define delete_vhost_user_if +autoreply define delete_vhost_user_if { u32 client_index; u32 context; u32 sw_if_index; }; -/** \brief vhost-user interface delete response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define delete_vhost_user_if_reply -{ - u32 context; - i32 retval; -}; - /** \brief Vhost-user interface details structure (fix this) @param sw_if_index - index of the interface @param interface_name - name of interface diff --git a/src/vnet/dhcp/dhcp.api b/src/vnet/dhcp/dhcp.api index 2db85a79..eb0b070d 100644 --- a/src/vnet/dhcp/dhcp.api +++ b/src/vnet/dhcp/dhcp.api @@ -24,7 +24,7 @@ @param dhcp_server[] - server address @param dhcp_src_address[] - */ -define dhcp_proxy_config +autoreply define dhcp_proxy_config { u32 client_index; u32 context; @@ -36,16 +36,6 @@ define dhcp_proxy_config u8 dhcp_src_address[16]; }; -/** \brief DHCP Proxy config response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define dhcp_proxy_config_reply -{ - u32 context; - i32 retval; -}; - /** \brief DHCP Proxy set / unset vss request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -55,7 +45,7 @@ define dhcp_proxy_config_reply @param is_ipv6 - ip6 if non-zero, else ip4 @param is_add - set vss if non-zero, else delete */ -define dhcp_proxy_set_vss +autoreply define dhcp_proxy_set_vss { u32 client_index; u32 context; @@ -66,16 +56,6 @@ define dhcp_proxy_set_vss u8 is_add; }; -/** \brief DHCP proxy set / unset vss response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define dhcp_proxy_set_vss_reply -{ - u32 context; - i32 retval; -}; - /** \brief DHCP Client config add / del request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -86,7 +66,7 @@ define dhcp_proxy_set_vss_reply via dhcp_compl_event API message if non-zero @param pid - sender's pid */ -define dhcp_client_config +autoreply define dhcp_client_config { u32 client_index; u32 context; @@ -97,16 +77,6 @@ define dhcp_client_config u32 pid; }; -/** \brief DHCP Client config response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define dhcp_client_config_reply -{ - u32 context; - i32 retval; -}; - /** \brief Tell client about a DHCP completion event @param client_index - opaque cookie to identify the sender @param pid - client pid registered to receive notification @@ -162,4 +132,4 @@ manual_endian manual_print define dhcp_proxy_details * Local Variables: * eval: (c-set-style "gnu") * End: - */ \ No newline at end of file + */ diff --git a/src/vnet/flow/flow.api b/src/vnet/flow/flow.api index 0e0f99bf..1c5e8c5c 100644 --- a/src/vnet/flow/flow.api +++ b/src/vnet/flow/flow.api @@ -24,7 +24,7 @@ @param template_interval - number of seconds after which to resend template @param udp_checksum - UDP checksum calculation enable flag */ -define set_ipfix_exporter +autoreply define set_ipfix_exporter { u32 client_index; u32 context; @@ -37,15 +37,6 @@ define set_ipfix_exporter u8 udp_checksum; }; -/** \brief Reply to IPFIX exporter configure request - @param context - sender context which was passed in the request -*/ -define set_ipfix_exporter_reply -{ - u32 context; - i32 retval; -}; - /** \brief IPFIX exporter dump request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -84,22 +75,13 @@ define ipfix_exporter_details @param domain_id - domain ID reported in IPFIX messages for classify stream @param src_port - source port of UDP session for classify stream */ -define set_ipfix_classify_stream { +autoreply define set_ipfix_classify_stream { u32 client_index; u32 context; u32 domain_id; u16 src_port; }; -/** \brief IPFIX classify stream configure response - @param context - sender context, to match reply w/ request - @param retval - return value for request -*/ -define set_ipfix_classify_stream_reply { - u32 context; - i32 retval; -}; - /** \brief IPFIX classify stream dump request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -127,7 +109,7 @@ define ipfix_classify_stream_details { @param ip_version - version of IP used in the classifier table @param transport_protocol - transport protocol used in the classifier table or 255 for unspecified */ -define ipfix_classify_table_add_del { +autoreply define ipfix_classify_table_add_del { u32 client_index; u32 context; u32 table_id; @@ -136,14 +118,6 @@ define ipfix_classify_table_add_del { u8 is_add; }; -/** \brief IPFIX add classifier table response - @param context - sender context which was passed in the request -*/ -define ipfix_classify_table_add_del_reply { - u32 context; - i32 retval; -}; - /** \brief IPFIX classify tables dump request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/vnet/interface.api b/src/vnet/interface.api index 85fd73fb..9df63f18 100644 --- a/src/vnet/interface.api +++ b/src/vnet/interface.api @@ -6,7 +6,7 @@ @param link_up_down - Oper state sent on change event, not used in config. @param deleted - interface was deleted */ -define sw_interface_set_flags +autoreply define sw_interface_set_flags { u32 client_index; u32 context; @@ -17,23 +17,13 @@ define sw_interface_set_flags u8 deleted; }; -/** \brief Reply to sw_interface_set_flags - @param context - sender context which was passed in the request - @param retval - return code of the set flags request -*/ -define sw_interface_set_flags_reply -{ - u32 context; - i32 retval; -}; - /** \brief Set interface MTU @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 to set MTU on @param mtu - MTU */ -define sw_interface_set_mtu +autoreply define sw_interface_set_mtu { u32 client_index; u32 context; @@ -41,23 +31,13 @@ define sw_interface_set_mtu u16 mtu; }; -/** \brief Reply to sw_interface_set_mtu - @param context - sender context which was passed in the request - @param retval - return code of the set flags request -*/ -define sw_interface_set_mtu_reply -{ - u32 context; - i32 retval; -}; - /** \brief Register for interface events @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param enable_disable - 1 => register for events, 0 => cancel registration @param pid - sender's pid */ -define want_interface_events +autoreply define want_interface_events { u32 client_index; u32 context; @@ -65,16 +45,6 @@ define want_interface_events u32 pid; }; -/** \brief Reply for interface events registration - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define want_interface_events_reply -{ - u32 context; - i32 retval; -}; - /** \brief Interface details structure (fix this) @param sw_if_index - index of the interface @param sup_sw_if_index - index of parent interface if any, else same as sw_if_index @@ -184,7 +154,7 @@ define sw_interface_dump @param address_length - address length in bytes, 4 for ip4, 16 for ip6 @param address - array of address bytes */ -define sw_interface_add_del_address +autoreply define sw_interface_add_del_address { u32 client_index; u32 context; @@ -196,16 +166,6 @@ define sw_interface_add_del_address u8 address[16]; }; -/** \brief Reply to sw_interface_add_del_address - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define sw_interface_add_del_address_reply -{ - u32 context; - i32 retval; -}; - /** \brief Associate the specified interface with a fib table @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -213,7 +173,7 @@ define sw_interface_add_del_address_reply @param is_ipv6 - if non-zero ipv6, else ipv4 @param vrf_id - fib table/vrd id to associate the interface with */ -define sw_interface_set_table +autoreply define sw_interface_set_table { u32 client_index; u32 context; @@ -222,16 +182,6 @@ define sw_interface_set_table u32 vrf_id; }; -/** \brief Reply to sw_interface_set_table - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define sw_interface_set_table_reply -{ - u32 context; - 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 @@ -280,7 +230,7 @@ define vnet_interface_counters @param unnumbered_sw_if_index - interface which will use the address @param is_add - if non-zero set the association, else unset it */ -define sw_interface_set_unnumbered +autoreply define sw_interface_set_unnumbered { u32 client_index; u32 context; @@ -289,38 +239,18 @@ define sw_interface_set_unnumbered u8 is_add; }; -/** \brief Set unnumbered interface add / del response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define sw_interface_set_unnumbered_reply -{ - u32 context; - i32 retval; -}; - /** \brief Clear interface statistics @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 to clear statistics */ -define sw_interface_clear_stats +autoreply define sw_interface_clear_stats { u32 client_index; u32 context; u32 sw_if_index; }; -/** \brief Reply to sw_interface_clear_stats - @param context - sender context which was passed in the request - @param retval - return code of the set flags request -*/ -define sw_interface_clear_stats_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 @@ -328,7 +258,7 @@ define sw_interface_clear_stats_reply @param add_del - 1 = add, 0 = delete @param tag - an ascii tag */ -define sw_interface_tag_add_del +autoreply define sw_interface_tag_add_del { u32 client_index; u32 context; @@ -337,23 +267,13 @@ define sw_interface_tag_add_del 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; -}; - /** \brief Set an interface's MAC address @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param sw_if_index - the interface whose MAC will be set @param mac_addr - the new MAC address */ -define sw_interface_set_mac_address +autoreply define sw_interface_set_mac_address { u32 client_index; u32 context; @@ -361,16 +281,6 @@ define sw_interface_set_mac_address u8 mac_address[6]; }; -/** \brief Reply to setting an interface MAC address request - @param context - sender context which was passed in the request - @param retval - return code for the request -*/ -define sw_interface_set_mac_address_reply -{ - u32 context; - i32 retval; -}; - /* * Local Variables: * eval: (c-set-style "gnu") diff --git a/src/vnet/ip/ip.api b/src/vnet/ip/ip.api index 6af1714f..7097a130 100644 --- a/src/vnet/ip/ip.api +++ b/src/vnet/ip/ip.api @@ -136,7 +136,7 @@ define ip_neighbor_details { @param mac_address - l2 address of the neighbor @param dst_address - ip4 or ip6 address of the neighbor */ -define ip_neighbor_add_del +autoreply define ip_neighbor_add_del { u32 client_index; u32 context; @@ -150,16 +150,6 @@ define ip_neighbor_add_del u8 dst_address[16]; }; -/** \brief Reply for IP Neighbor add / delete request - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define ip_neighbor_add_del_reply -{ - u32 context; - i32 retval; -}; - /** \brief Set the ip flow hash config for a fib request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -172,7 +162,7 @@ define ip_neighbor_add_del_reply @param proto -if non-zero include proto in flow hash @param reverse - if non-zero include reverse in flow hash */ -define set_ip_flow_hash +autoreply define set_ip_flow_hash { u32 client_index; u32 context; @@ -186,16 +176,6 @@ define set_ip_flow_hash u8 reverse; }; -/** \brief Set the ip flow hash config for a fib response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define set_ip_flow_hash_reply -{ - u32 context; - i32 retval; -}; - /** \brief IPv6 router advertisement config request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -213,7 +193,7 @@ define set_ip_flow_hash_reply @param initial_count - @param initial_interval - */ -define sw_interface_ip6nd_ra_config +autoreply define sw_interface_ip6nd_ra_config { u32 client_index; u32 context; @@ -233,16 +213,6 @@ define sw_interface_ip6nd_ra_config u32 initial_interval; }; -/** \brief IPv6 router advertisement config response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define sw_interface_ip6nd_ra_config_reply -{ - u32 context; - i32 retval; -}; - /** \brief IPv6 router advertisement prefix config request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -272,7 +242,7 @@ define sw_interface_ip6nd_ra_config_reply preferred [ADDRCONF]. A value of all one bits (0xffffffff) represents infinity. */ -define sw_interface_ip6nd_ra_prefix +autoreply define sw_interface_ip6nd_ra_prefix { u32 client_index; u32 context; @@ -289,16 +259,6 @@ define sw_interface_ip6nd_ra_prefix u32 pref_lifetime; }; -/** \brief IPv6 router advertisement prefix config response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define sw_interface_ip6nd_ra_prefix_reply -{ - u32 context; - i32 retval; -}; - /** \brief IPv6 ND proxy config @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -306,7 +266,7 @@ define sw_interface_ip6nd_ra_prefix_reply @param address - The address of the host for which to proxy for @param is_add - Adding or deleting */ -define ip6nd_proxy_add_del +autoreply define ip6nd_proxy_add_del { u32 client_index; u32 context; @@ -315,16 +275,6 @@ define ip6nd_proxy_add_del u8 address[16]; }; -/** \brief IPv6 ND proxy response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define ip6nd_proxy_add_del_reply -{ - u32 context; - i32 retval; -}; - /** \brief IPv6 ND proxy details returned after request @param context - sender context, to match reply w/ request @param retval - return code for the request @@ -355,7 +305,7 @@ define ip6nd_proxy_dump @param sw_if_index - interface used to reach neighbor @param enable - if non-zero enable ip6 on interface, else disable */ -define sw_interface_ip6_enable_disable +autoreply define sw_interface_ip6_enable_disable { u32 client_index; u32 context; @@ -363,23 +313,13 @@ define sw_interface_ip6_enable_disable u8 enable; /* set to true if enable */ }; -/** \brief IPv6 interface enable / disable response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define sw_interface_ip6_enable_disable_reply -{ - u32 context; - i32 retval; -}; - /** \brief IPv6 set link local address on interface request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param sw_if_index - interface to set link local on @param address[] - the new link local address */ -define sw_interface_ip6_set_link_local_address +autoreply define sw_interface_ip6_set_link_local_address { u32 client_index; u32 context; @@ -387,16 +327,6 @@ define sw_interface_ip6_set_link_local_address u8 address[16]; }; -/** \brief IPv6 set link local address on interface response - @param context - sender context, to match reply w/ request - @param retval - error code for the request -*/ -define sw_interface_ip6_set_link_local_address_reply -{ - u32 context; - i32 retval; -}; - /** \brief Add / del route request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -422,7 +352,7 @@ define sw_interface_ip6_set_link_local_address_reply @param next_hop_out_label_stack - the next-hop output label stack, outer most first @param next_hop_via_label - The next-hop is a resolved via a local label */ -define ip_add_del_route +autoreply define ip_add_del_route { u32 client_index; u32 context; @@ -452,16 +382,6 @@ define ip_add_del_route u32 next_hop_out_label_stack[next_hop_n_out_labels]; }; -/** \brief Reply for add / del route request - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define ip_add_del_route_reply -{ - u32 context; - i32 retval; -}; - /** \brief Add / del route request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -470,7 +390,7 @@ define ip_add_del_route_reply FIXME */ -define ip_mroute_add_del +autoreply define ip_mroute_add_del { u32 client_index; u32 context; @@ -488,16 +408,6 @@ define ip_mroute_add_del u8 src_address[16]; }; -/** \brief Reply for add / del mroute request - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define ip_mroute_add_del_reply -{ - u32 context; - i32 retval; -}; - /** \brief Dump IP multicast fib table @param client_index - opaque cookie to identify the sender */ diff --git a/src/vnet/ipsec/ipsec.api b/src/vnet/ipsec/ipsec.api index ef090f84..203c5272 100644 --- a/src/vnet/ipsec/ipsec.api +++ b/src/vnet/ipsec/ipsec.api @@ -20,7 +20,7 @@ @param spd_id - SPD instance id (control plane allocated) */ -define ipsec_spd_add_del +autoreply define ipsec_spd_add_del { u32 client_index; u32 context; @@ -28,17 +28,6 @@ define ipsec_spd_add_del u32 spd_id; }; -/** \brief Reply for IPsec: Add/delete Security Policy Database entry - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ - -define ipsec_spd_add_del_reply -{ - u32 context; - i32 retval; -}; - /** \brief IPsec: Add/delete SPD from interface @param client_index - opaque cookie to identify the sender @@ -49,7 +38,7 @@ define ipsec_spd_add_del_reply */ -define ipsec_interface_add_del_spd +autoreply define ipsec_interface_add_del_spd { u32 client_index; u32 context; @@ -59,17 +48,6 @@ define ipsec_interface_add_del_spd u32 spd_id; }; -/** \brief Reply for IPsec: Add/delete SPD from interface - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ - -define ipsec_interface_add_del_spd_reply -{ - u32 context; - i32 retval; -}; - /** \brief IPsec: Add/delete Security Policy Database entry See RFC 4301, 4.4.1.1 on how to match packet to selectors @@ -95,7 +73,7 @@ define ipsec_interface_add_del_spd_reply */ -define ipsec_spd_add_del_entry +autoreply define ipsec_spd_add_del_entry { u32 client_index; u32 context; @@ -125,17 +103,6 @@ define ipsec_spd_add_del_entry u32 sa_id; }; -/** \brief Reply for IPsec: Add/delete Security Policy Database entry - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ - -define ipsec_spd_add_del_entry_reply -{ - u32 context; - i32 retval; -}; - /** \brief IPsec: Add/delete Security Association Database entry @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -167,7 +134,7 @@ define ipsec_spd_add_del_entry_reply IPsec tunnel address copy mode (to support GDOI) */ -define ipsec_sad_add_del_entry +autoreply define ipsec_sad_add_del_entry { u32 client_index; u32 context; @@ -195,17 +162,6 @@ define ipsec_sad_add_del_entry u8 tunnel_dst_address[16]; }; -/** \brief Reply for IPsec: Add/delete Security Association Database entry - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ - -define ipsec_sad_add_del_entry_reply -{ - u32 context; - i32 retval; -}; - /** \brief IPsec: Update Security Association keys @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -219,7 +175,7 @@ define ipsec_sad_add_del_entry_reply @param integrity_key - integrity keying material */ -define ipsec_sa_set_key +autoreply define ipsec_sa_set_key { u32 client_index; u32 context; @@ -233,17 +189,6 @@ define ipsec_sa_set_key u8 integrity_key[128]; }; -/** \brief Reply for IPsec: Update Security Association keys - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ - -define ipsec_sa_set_key_reply -{ - u32 context; - i32 retval; -}; - /** \brief IKEv2: Add/delete profile @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -251,7 +196,7 @@ define ipsec_sa_set_key_reply @param name - IKEv2 profile name @param is_add - Add IKEv2 profile if non-zero, else delete */ -define ikev2_profile_add_del +autoreply define ikev2_profile_add_del { u32 client_index; u32 context; @@ -260,16 +205,6 @@ define ikev2_profile_add_del u8 is_add; }; -/** \brief Reply for IKEv2: Add/delete profile - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define ikev2_profile_add_del_reply -{ - u32 context; - i32 retval; -}; - /** \brief IKEv2: Set IKEv2 profile authentication method @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -280,7 +215,7 @@ define ikev2_profile_add_del_reply @param data_len - Authentication data length @param data - Authentication data (for rsa-sig cert file path) */ -define ikev2_profile_set_auth +autoreply define ikev2_profile_set_auth { u32 client_index; u32 context; @@ -292,16 +227,6 @@ define ikev2_profile_set_auth u8 data[0]; }; -/** \brief Reply for IKEv2: Set IKEv2 profile authentication method - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define ikev2_profile_set_auth_reply -{ - u32 context; - i32 retval; -}; - /** \brief IKEv2: Set IKEv2 profile local/remote identification @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -312,7 +237,7 @@ define ikev2_profile_set_auth_reply @param data_len - Identification data length @param data - Identification data */ -define ikev2_profile_set_id +autoreply define ikev2_profile_set_id { u32 client_index; u32 context; @@ -324,16 +249,6 @@ define ikev2_profile_set_id u8 data[0]; }; -/** \brief Reply for IKEv2: - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define ikev2_profile_set_id_reply -{ - u32 context; - i32 retval; -}; - /** \brief IKEv2: Set IKEv2 profile traffic selector parameters @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -346,7 +261,7 @@ define ikev2_profile_set_id_reply @param start_addr - The smallest address included in traffic selector @param end_addr - The largest address included in traffic selector */ -define ikev2_profile_set_ts +autoreply define ikev2_profile_set_ts { u32 client_index; u32 context; @@ -360,23 +275,13 @@ define ikev2_profile_set_ts u32 end_addr; }; -/** \brief Reply for IKEv2: Set IKEv2 profile traffic selector parameters - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define ikev2_profile_set_ts_reply -{ - u32 context; - i32 retval; -}; - /** \brief IKEv2: Set IKEv2 local RSA private key @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param key_file - Key file absolute path */ -define ikev2_set_local_key +autoreply define ikev2_set_local_key { u32 client_index; u32 context; @@ -384,16 +289,6 @@ define ikev2_set_local_key u8 key_file[256]; }; -/** \brief Reply for IKEv2: Set IKEv2 local key - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define ikev2_set_local_key_reply -{ - u32 context; - i32 retval; -}; - /** \brief IKEv2: Set IKEv2 responder interface and IP address @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -402,7 +297,7 @@ define ikev2_set_local_key_reply @param sw_if_index - interface index @param address - interface address */ -define ikev2_set_responder +autoreply define ikev2_set_responder { u32 client_index; u32 context; @@ -412,17 +307,6 @@ define ikev2_set_responder u8 address[4]; }; -/** \brief Reply for IKEv2: Set IKEv2 responder interface and IP address - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define ikev2_set_responder_reply -{ - u32 context; - i32 retval; -}; - - /** \brief IKEv2: Set IKEv2 IKE transforms in SA_INIT proposal (RFC 7296) @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -434,7 +318,7 @@ define ikev2_set_responder_reply @param dh_group - Diffie-Hellman group */ -define ikev2_set_ike_transforms +autoreply define ikev2_set_ike_transforms { u32 client_index; u32 context; @@ -446,16 +330,6 @@ define ikev2_set_ike_transforms u32 dh_group; }; -/** \brief Reply for IKEv2: Set IKEv2 IKE transforms - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define ikev2_set_ike_transforms_reply -{ - u32 context; - i32 retval; -}; - /** \brief IKEv2: Set IKEv2 ESP transforms in SA_INIT proposal (RFC 7296) @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -467,7 +341,7 @@ define ikev2_set_ike_transforms_reply @param dh_group - Diffie-Hellman group */ -define ikev2_set_esp_transforms +autoreply define ikev2_set_esp_transforms { u32 client_index; u32 context; @@ -479,16 +353,6 @@ define ikev2_set_esp_transforms u32 dh_group; }; -/** \brief Reply for IKEv2: Set IKEv2 ESP transforms - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define ikev2_set_esp_transforms_reply -{ - u32 context; - i32 retval; -}; - /** \brief IKEv2: Set Child SA lifetime, limited by time and/or data @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -500,7 +364,7 @@ define ikev2_set_esp_transforms_reply @param lifetime_maxdata - SA maximum life time in bytes (0 to disable) */ -define ikev2_set_sa_lifetime +autoreply define ikev2_set_sa_lifetime { u32 client_index; u32 context; @@ -512,16 +376,6 @@ define ikev2_set_sa_lifetime u64 lifetime_maxdata; }; -/** \brief Reply for IKEv2: Set Child SA lifetime - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define ikev2_set_sa_lifetime_reply -{ - u32 context; - i32 retval; -}; - /** \brief IKEv2: Initiate the SA_INIT exchange @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -529,7 +383,7 @@ define ikev2_set_sa_lifetime_reply @param name - IKEv2 profile name */ -define ikev2_initiate_sa_init +autoreply define ikev2_initiate_sa_init { u32 client_index; u32 context; @@ -537,16 +391,6 @@ define ikev2_initiate_sa_init u8 name[64]; }; -/** \brief Reply for IKEv2: Initiate the SA_INIT exchange - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define ikev2_initiate_sa_init_reply -{ - u32 context; - i32 retval; -}; - /** \brief IKEv2: Initiate the delete IKE SA exchange @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -554,7 +398,7 @@ define ikev2_initiate_sa_init_reply @param ispi - IKE SA initiator SPI */ -define ikev2_initiate_del_ike_sa +autoreply define ikev2_initiate_del_ike_sa { u32 client_index; u32 context; @@ -562,16 +406,6 @@ define ikev2_initiate_del_ike_sa u64 ispi; }; -/** \brief Reply for IKEv2: Initiate the delete IKE SA exchange - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define ikev2_initiate_del_ike_sa_reply -{ - u32 context; - i32 retval; -}; - /** \brief IKEv2: Initiate the delete Child SA exchange @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -579,7 +413,7 @@ define ikev2_initiate_del_ike_sa_reply @param ispi - Child SA initiator SPI */ -define ikev2_initiate_del_child_sa +autoreply define ikev2_initiate_del_child_sa { u32 client_index; u32 context; @@ -587,16 +421,6 @@ define ikev2_initiate_del_child_sa u32 ispi; }; -/** \brief Reply for IKEv2: Initiate the delete Child SA exchange - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define ikev2_initiate_del_child_sa_reply -{ - u32 context; - i32 retval; -}; - /** \brief IKEv2: Initiate the rekey Child SA exchange @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -604,7 +428,7 @@ define ikev2_initiate_del_child_sa_reply @param ispi - Child SA initiator SPI */ -define ikev2_initiate_rekey_child_sa +autoreply define ikev2_initiate_rekey_child_sa { u32 client_index; u32 context; @@ -612,16 +436,6 @@ define ikev2_initiate_rekey_child_sa u32 ispi; }; -/** \brief Reply for IKEv2: Initiate the rekey Child SA exchange - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define ikev2_initiate_rekey_child_sa_reply -{ - u32 context; - i32 retval; -}; - /** \brief Dump ipsec policy database data @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -682,4 +496,4 @@ define ipsec_spd_details { * eval: (c-set-style "gnu") * End: */ - \ No newline at end of file + diff --git a/src/vnet/l2/l2.api b/src/vnet/l2/l2.api index c23eebec..db42d635 100644 --- a/src/vnet/l2/l2.api +++ b/src/vnet/l2/l2.api @@ -70,66 +70,36 @@ define l2_fib_table_dump @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request */ -define l2_fib_clear_table +autoreply define l2_fib_clear_table { u32 client_index; u32 context; }; -/** \brief L2 fib clear table response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define l2_fib_clear_table_reply -{ - u32 context; - i32 retval; -}; - /** \brief L2 FIB flush bridge domain entries @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param bd_id - the entry's bridge domain id */ -define l2fib_flush_bd +autoreply define l2fib_flush_bd { u32 client_index; u32 context; u32 bd_id; }; -/** \brief L2 FIB flush bridge domain entries response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define l2fib_flush_bd_reply -{ - u32 context; - i32 retval; -}; - /** \brief L2 FIB flush interface entries @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param bd_id - the entry's bridge domain id */ -define l2fib_flush_int +autoreply define l2fib_flush_int { u32 client_index; u32 context; u32 sw_if_index; }; -/** \brief L2 FIB flush interface entries response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define l2fib_flush_int_reply -{ - u32 context; - i32 retval; -}; - /** \brief L2 FIB add entry request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -140,7 +110,7 @@ define l2fib_flush_int_reply @param static_mac - @param filter_mac - */ -define l2fib_add_del +autoreply define l2fib_add_del { u32 client_index; u32 context; @@ -153,16 +123,6 @@ define l2fib_add_del u8 bvi_mac; }; -/** \brief L2 FIB add entry response - @param context - sender context, to match reply w/ request - @param retval - return code for the add l2fib entry request -*/ -define l2fib_add_del_reply -{ - u32 context; - i32 retval; -}; - /** \brief Set L2 flags request !!! TODO - need more info, feature bits in l2_input.h @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -196,7 +156,7 @@ define l2_flags_reply @param bd_id - the bridge domain to create @param mac_age - mac aging time in min, 0 for disabled */ -define bridge_domain_set_mac_age +autoreply define bridge_domain_set_mac_age { u32 client_index; u32 context; @@ -204,16 +164,6 @@ define bridge_domain_set_mac_age u8 mac_age; }; -/** \brief Set bridge domain response - @param context - sender context, to match reply w/ request - @param retval - return code for the set l2 bits request -*/ -define bridge_domain_set_mac_age_reply -{ - u32 context; - i32 retval; -}; - /** \brief L2 bridge domain add or delete request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -226,7 +176,7 @@ define bridge_domain_set_mac_age_reply @param mac_age - mac aging time in min, 0 for disabled @param is_add - add or delete flag */ -define bridge_domain_add_del +autoreply define bridge_domain_add_del { u32 client_index; u32 context; @@ -240,16 +190,6 @@ define bridge_domain_add_del u8 is_add; }; -/** \brief L2 bridge domain add or delete response - @param context - sender context, to match reply w/ request - @param retval - return code for the set bridge flags request -*/ -define bridge_domain_add_del_reply -{ - u32 context; - i32 retval; -}; - /** \brief L2 bridge domain request operational state details @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -337,7 +277,7 @@ define bridge_flags_reply @param tag1 - Needed for any push or translate vtr op @param tag2 - Needed for any push 2 or translate x-2 vtr ops */ -define l2_interface_vlan_tag_rewrite +autoreply define l2_interface_vlan_tag_rewrite { u32 client_index; u32 context; @@ -348,16 +288,6 @@ define l2_interface_vlan_tag_rewrite u32 tag2; // second pushed tag }; -/** \brief L2 interface vlan tag rewrite response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define l2_interface_vlan_tag_rewrite_reply -{ - u32 context; - i32 retval; -}; - /** \brief L2 interface pbb tag rewrite configure request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -370,7 +300,7 @@ define l2_interface_vlan_tag_rewrite_reply @param b_vlanid - B-tag vlanid, needed for any push or translate qinq vtr op @param i_sid - I-tag service id, needed for any push or translate qinq vtr op */ -define l2_interface_pbb_tag_rewrite +autoreply define l2_interface_pbb_tag_rewrite { u32 client_index; u32 context; @@ -383,16 +313,6 @@ define l2_interface_pbb_tag_rewrite u32 i_sid; }; -/** \brief L2 interface pbb tag rewrite response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define l2_interface_pbb_tag_rewrite_reply -{ - u32 context; - i32 retval; -}; - /* * Local Variables: * eval: (c-set-style "gnu") diff --git a/src/vnet/l2tp/l2tp.api b/src/vnet/l2tp/l2tp.api index 5a5a5a48..4587a807 100644 --- a/src/vnet/l2tp/l2tp.api +++ b/src/vnet/l2tp/l2tp.api @@ -52,7 +52,7 @@ define l2tpv3_create_tunnel_reply u32 sw_if_index; }; -define l2tpv3_set_tunnel_cookies +autoreply define l2tpv3_set_tunnel_cookies { u32 client_index; u32 context; @@ -61,16 +61,6 @@ define l2tpv3_set_tunnel_cookies u64 new_remote_cookie; }; -/** \brief L2TP tunnel set cookies response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define l2tpv3_set_tunnel_cookies_reply -{ - u32 context; - i32 retval; -}; - define sw_if_l2tpv3_tunnel_details { u32 context; @@ -91,7 +81,7 @@ define sw_if_l2tpv3_tunnel_dump u32 context; }; -define l2tpv3_interface_enable_disable +autoreply define l2tpv3_interface_enable_disable { u32 client_index; u32 context; @@ -99,13 +89,7 @@ define l2tpv3_interface_enable_disable u32 sw_if_index; }; -define l2tpv3_interface_enable_disable_reply -{ - u32 context; - i32 retval; -}; - -define l2tpv3_set_lookup_key +autoreply define l2tpv3_set_lookup_key { u32 client_index; u32 context; @@ -113,12 +97,6 @@ define l2tpv3_set_lookup_key u8 key; }; -define l2tpv3_set_lookup_key_reply -{ - u32 context; - i32 retval; -}; - /* * Local Variables: * eval: (c-set-style "gnu") diff --git a/src/vnet/lisp-cp/lisp.api b/src/vnet/lisp-cp/lisp.api index a50a5ccb..8bed71b3 100644 --- a/src/vnet/lisp-cp/lisp.api +++ b/src/vnet/lisp-cp/lisp.api @@ -59,7 +59,7 @@ define lisp_add_del_locator_set_reply @param priority - priority of the lisp locator @param weight - weight of the lisp locator */ -define lisp_add_del_locator +autoreply define lisp_add_del_locator { u32 client_index; u32 context; @@ -70,16 +70,6 @@ define lisp_add_del_locator u8 weight; }; -/** \brief Reply for locator add/del - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define lisp_add_del_locator_reply -{ - u32 context; - i32 retval; -}; - /** \brief add or delete lisp eid-table @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -98,7 +88,7 @@ define lisp_add_del_locator_reply HMAC_SHA_256_128 2 @param key - secret key */ -define lisp_add_del_local_eid +autoreply define lisp_add_del_local_eid { u32 client_index; u32 context; @@ -112,16 +102,6 @@ define lisp_add_del_local_eid u8 key[64]; }; -/** \brief Reply for local_eid add/del - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define lisp_add_del_local_eid_reply -{ - u32 context; - i32 retval; -}; - /** \brief Add/delete map server @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -129,7 +109,7 @@ define lisp_add_del_local_eid_reply @param is_ipv6 - if non-zero the address is ipv6, else ipv4 @param ip_address - map server IP address */ -define lisp_add_del_map_server +autoreply define lisp_add_del_map_server { u32 client_index; u32 context; @@ -138,16 +118,6 @@ define lisp_add_del_map_server u8 ip_address[16]; }; -/** \brief Reply for lisp_add_del_map_server - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define lisp_add_del_map_server_reply -{ - u32 context; - i32 retval; -}; - /** \brief add or delete map-resolver @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -155,7 +125,7 @@ define lisp_add_del_map_server_reply @param is_ipv6 - if non-zero the address is ipv6, else ipv4 @param ip_address - array of address bytes */ -define lisp_add_del_map_resolver +autoreply define lisp_add_del_map_resolver { u32 client_index; u32 context; @@ -164,45 +134,25 @@ define lisp_add_del_map_resolver u8 ip_address[16]; }; -/** \brief Reply for map_resolver add/del - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define lisp_add_del_map_resolver_reply -{ - u32 context; - i32 retval; -}; - /** \brief enable or disable LISP feature @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param is_en - enable protocol if non-zero, else disable */ -define lisp_enable_disable +autoreply define lisp_enable_disable { u32 client_index; u32 context; u8 is_en; }; -/** \brief Reply for gpe enable/disable - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define lisp_enable_disable_reply -{ - u32 context; - i32 retval; -}; - /** \brief configure or disable LISP PITR node @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param ls_name - locator set name @param is_add - add locator set if non-zero, else disable pitr */ -define lisp_pitr_set_locator_set +autoreply define lisp_pitr_set_locator_set { u32 client_index; u32 context; @@ -210,16 +160,6 @@ define lisp_pitr_set_locator_set u8 ls_name[64]; }; -/** \brief Reply for lisp_pitr_set_locator_set - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define lisp_pitr_set_locator_set_reply -{ - u32 context; - i32 retval; -}; - /** \brief configure or disable use of PETR @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -227,7 +167,7 @@ define lisp_pitr_set_locator_set_reply @param address - PETR IP address @param is_add - add locator set if non-zero, else disable pitr */ -define lisp_use_petr +autoreply define lisp_use_petr { u32 client_index; u32 context; @@ -236,16 +176,6 @@ define lisp_use_petr u8 is_add; }; -/** \brief Reply for lisp_pitr_set_locator_set - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define lisp_use_petr_reply -{ - u32 context; - i32 retval; -}; - /** \brief Request for LISP PETR status @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -298,45 +228,25 @@ define show_lisp_rloc_probe_state_reply @param context - sender context, to match reply w/ request @param is_enable - enable if non-zero; disable otherwise */ -define lisp_rloc_probe_enable_disable +autoreply define lisp_rloc_probe_enable_disable { u32 client_index; u32 context; u8 is_enabled; }; -/** \brief Reply for lisp_rloc_probe_enable_disable - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define lisp_rloc_probe_enable_disable_reply -{ - u32 context; - i32 retval; -}; - /** \brief enable/disable LISP map-register @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param is_enable - enable if non-zero; disable otherwise */ -define lisp_map_register_enable_disable +autoreply define lisp_map_register_enable_disable { u32 client_index; u32 context; u8 is_enabled; }; -/** \brief Reply for lisp_map_register_enable_disable - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define lisp_map_register_enable_disable_reply -{ - u32 context; - i32 retval; -}; - /** \brief Get state of LISP map-register @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -366,23 +276,13 @@ define show_lisp_map_register_state_reply 0 - destination only 1 - source/destaination */ -define lisp_map_request_mode +autoreply define lisp_map_request_mode { u32 client_index; u32 context; u8 mode; }; -/** \brief Reply for lisp_map_request_mode - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define lisp_map_request_mode_reply -{ - u32 context; - i32 retval; -}; - /** \brief Request for LISP map-request mode @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -430,7 +330,7 @@ typeonly manual_endian manual_print define remote_locator @param rloc_num - number of remote locators @param rlocs - remote locator records */ -manual_print manual_endian define lisp_add_del_remote_mapping +autoreply manual_print manual_endian define lisp_add_del_remote_mapping { u32 client_index; u32 context; @@ -448,16 +348,6 @@ manual_print manual_endian define lisp_add_del_remote_mapping vl_api_remote_locator_t rlocs[rloc_num]; }; -/** \brief Reply for lisp_add_del_remote_mapping - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define lisp_add_del_remote_mapping_reply -{ - u32 context; - i32 retval; -}; - /** \brief add or delete LISP adjacency adjacency @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -470,7 +360,7 @@ define lisp_add_del_remote_mapping_reply @param reid - remote EID @param leid - local EID */ -define lisp_add_del_adjacency +autoreply define lisp_add_del_adjacency { u32 client_index; u32 context; @@ -483,23 +373,13 @@ define lisp_add_del_adjacency u8 leid_len; }; -/** \brief Reply for lisp_add_del_adjacency - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define lisp_add_del_adjacency_reply -{ - u32 context; - i32 retval; -}; - /** \brief add or delete map request itr rlocs @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param is_add - add address if non-zero, else delete @param locator_set_name - locator set name */ -define lisp_add_del_map_request_itr_rlocs +autoreply define lisp_add_del_map_request_itr_rlocs { u32 client_index; u32 context; @@ -512,12 +392,6 @@ define lisp_add_del_map_request_itr_rlocs @param retval - return code */ -define lisp_add_del_map_request_itr_rlocs_reply -{ - u32 context; - i32 retval; -}; - /** \brief map/unmap vni/bd_index to vrf @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -525,7 +399,7 @@ define lisp_add_del_map_request_itr_rlocs_reply @param dp_table - virtual network id/bridge domain index @param vrf - vrf */ -define lisp_eid_table_add_del_map +autoreply define lisp_eid_table_add_del_map { u32 client_index; u32 context; @@ -535,16 +409,6 @@ define lisp_eid_table_add_del_map u8 is_l2; }; -/** \brief Reply for lisp_eid_table_add_del_map - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define lisp_eid_table_add_del_map_reply -{ - u32 context; - i32 retval; -}; - /** \brief Request for map lisp locator status @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/vnet/lisp-cp/one.api b/src/vnet/lisp-cp/one.api index ca82f694..2fa1edf6 100644 --- a/src/vnet/lisp-cp/one.api +++ b/src/vnet/lisp-cp/one.api @@ -59,7 +59,7 @@ define one_add_del_locator_set_reply @param priority - priority of the locator @param weight - weight of the locator */ -define one_add_del_locator +autoreply define one_add_del_locator { u32 client_index; u32 context; @@ -70,16 +70,6 @@ define one_add_del_locator u8 weight; }; -/** \brief Reply for locator add/del - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define one_add_del_locator_reply -{ - u32 context; - i32 retval; -}; - /** \brief add or delete ONE eid-table @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -98,7 +88,7 @@ define one_add_del_locator_reply HMAC_SHA_256_128 2 @param key - secret key */ -define one_add_del_local_eid +autoreply define one_add_del_local_eid { u32 client_index; u32 context; @@ -112,16 +102,6 @@ define one_add_del_local_eid u8 key[64]; }; -/** \brief Reply for local_eid add/del - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define one_add_del_local_eid_reply -{ - u32 context; - i32 retval; -}; - /** \brief Add/delete map server @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -129,7 +109,7 @@ define one_add_del_local_eid_reply @param is_ipv6 - if non-zero the address is ipv6, else ipv4 @param ip_address - map server IP address */ -define one_add_del_map_server +autoreply define one_add_del_map_server { u32 client_index; u32 context; @@ -138,16 +118,6 @@ define one_add_del_map_server u8 ip_address[16]; }; -/** \brief Reply for one_add_del_map_server - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define one_add_del_map_server_reply -{ - u32 context; - i32 retval; -}; - /** \brief add or delete map-resolver @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -155,7 +125,7 @@ define one_add_del_map_server_reply @param is_ipv6 - if non-zero the address is ipv6, else ipv4 @param ip_address - array of address bytes */ -define one_add_del_map_resolver +autoreply define one_add_del_map_resolver { u32 client_index; u32 context; @@ -164,45 +134,25 @@ define one_add_del_map_resolver u8 ip_address[16]; }; -/** \brief Reply for map_resolver add/del - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define one_add_del_map_resolver_reply -{ - u32 context; - i32 retval; -}; - /** \brief enable or disable ONE feature @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param is_en - enable protocol if non-zero, else disable */ -define one_enable_disable +autoreply define one_enable_disable { u32 client_index; u32 context; u8 is_en; }; -/** \brief Reply for gpe enable/disable - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define one_enable_disable_reply -{ - u32 context; - i32 retval; -}; - /** \brief configure or disable ONE PITR node @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param ls_name - locator set name @param is_add - add locator set if non-zero, else disable pitr */ -define one_pitr_set_locator_set +autoreply define one_pitr_set_locator_set { u32 client_index; u32 context; @@ -210,16 +160,6 @@ define one_pitr_set_locator_set u8 ls_name[64]; }; -/** \brief Reply for one_pitr_set_locator_set - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define one_pitr_set_locator_set_reply -{ - u32 context; - i32 retval; -}; - /** \brief configure or disable use of PETR @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -227,7 +167,7 @@ define one_pitr_set_locator_set_reply @param address - PETR IP address @param is_add - add locator set if non-zero, else disable PETR */ -define one_use_petr +autoreply define one_use_petr { u32 client_index; u32 context; @@ -236,16 +176,6 @@ define one_use_petr u8 is_add; }; -/** \brief Reply for one_use_petr - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define one_use_petr_reply -{ - u32 context; - i32 retval; -}; - /** \brief Request for ONE PETR status @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -298,45 +228,25 @@ define show_one_rloc_probe_state_reply @param context - sender context, to match reply w/ request @param is_enable - enable if non-zero; disable otherwise */ -define one_rloc_probe_enable_disable +autoreply define one_rloc_probe_enable_disable { u32 client_index; u32 context; u8 is_enabled; }; -/** \brief Reply for one_rloc_probe_enable_disable - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define one_rloc_probe_enable_disable_reply -{ - u32 context; - i32 retval; -}; - /** \brief enable/disable ONE map-register @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param is_enable - enable if non-zero; disable otherwise */ -define one_map_register_enable_disable +autoreply define one_map_register_enable_disable { u32 client_index; u32 context; u8 is_enabled; }; -/** \brief Reply for one_map_register_enable_disable - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define one_map_register_enable_disable_reply -{ - u32 context; - i32 retval; -}; - /** \brief Get state of ONE map-register @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -366,23 +276,13 @@ define show_one_map_register_state_reply 0 - destination only 1 - source/destaination */ -define one_map_request_mode +autoreply define one_map_request_mode { u32 client_index; u32 context; u8 mode; }; -/** \brief Reply for one_map_request_mode - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define one_map_request_mode_reply -{ - u32 context; - i32 retval; -}; - /** \brief Request for ONE map-request mode @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -430,7 +330,7 @@ typeonly manual_endian manual_print define one_remote_locator @param rloc_num - number of remote locators @param rlocs - remote locator records */ -manual_print manual_endian define one_add_del_remote_mapping +autoreply manual_print manual_endian define one_add_del_remote_mapping { u32 client_index; u32 context; @@ -448,16 +348,6 @@ manual_print manual_endian define one_add_del_remote_mapping vl_api_one_remote_locator_t rlocs[rloc_num]; }; -/** \brief Reply for one_add_del_remote_mapping - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define one_add_del_remote_mapping_reply -{ - u32 context; - i32 retval; -}; - /** \brief add or delete ONE adjacency adjacency @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -470,7 +360,7 @@ define one_add_del_remote_mapping_reply @param reid - remote EID @param leid - local EID */ -define one_add_del_adjacency +autoreply define one_add_del_adjacency { u32 client_index; u32 context; @@ -483,23 +373,13 @@ define one_add_del_adjacency u8 leid_len; }; -/** \brief Reply for one_add_del_adjacency - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define one_add_del_adjacency_reply -{ - u32 context; - i32 retval; -}; - /** \brief add or delete map request itr rlocs @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param is_add - add address if non-zero, else delete @param locator_set_name - locator set name */ -define one_add_del_map_request_itr_rlocs +autoreply define one_add_del_map_request_itr_rlocs { u32 client_index; u32 context; @@ -507,17 +387,6 @@ define one_add_del_map_request_itr_rlocs u8 locator_set_name[64]; }; -/** \brief Reply for one_add_del_map_request_itr_rlocs - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ - -define one_add_del_map_request_itr_rlocs_reply -{ - u32 context; - i32 retval; -}; - /** \brief map/unmap vni/bd_index to vrf @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -525,7 +394,7 @@ define one_add_del_map_request_itr_rlocs_reply @param dp_table - virtual network id/bridge domain index @param vrf - vrf */ -define one_eid_table_add_del_map +autoreply define one_eid_table_add_del_map { u32 client_index; u32 context; @@ -535,16 +404,6 @@ define one_eid_table_add_del_map u8 is_l2; }; -/** \brief Reply for one_eid_table_add_del_map - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define one_eid_table_add_del_map_reply -{ - u32 context; - i32 retval; -}; - /** \brief Request for map one locator status @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -901,31 +760,19 @@ define one_stats_details u32 bytes; }; -define one_stats_flush +autoreply define one_stats_flush { u32 client_index; u32 context; }; -define one_stats_flush_reply -{ - u32 context; - i32 retval; -}; - -define one_stats_enable_disable +autoreply define one_stats_enable_disable { u32 client_index; u32 context; u8 is_en; }; -define one_stats_enable_disable_reply -{ - u32 context; - i32 retval; -}; - define show_one_stats_enable_disable { u32 client_index; diff --git a/src/vnet/lisp-gpe/lisp_gpe.api b/src/vnet/lisp-gpe/lisp_gpe.api index 43a6a6cd..f79d18c1 100644 --- a/src/vnet/lisp-gpe/lisp_gpe.api +++ b/src/vnet/lisp-gpe/lisp_gpe.api @@ -43,7 +43,7 @@ typeonly manual_print manual_endian define gpe_locator @param loc_num - number of locators @param locs - array of remote locators */ -manual_print manual_endian define gpe_add_del_fwd_entry +autoreply manual_print manual_endian define gpe_add_del_fwd_entry { u32 client_index; u32 context; @@ -60,44 +60,24 @@ manual_print manual_endian define gpe_add_del_fwd_entry vl_api_gpe_locator_t locs[loc_num]; }; -/** \brief Reply for gpe_fwd_entry add/del - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define gpe_add_del_fwd_entry_reply -{ - u32 context; - i32 retval; -}; - /** \brief enable or disable gpe protocol @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param is_en - enable protocol if non-zero, else disable */ -define gpe_enable_disable +autoreply define gpe_enable_disable { u32 client_index; u32 context; u8 is_en; }; -/** \brief Reply for gpe enable/disable - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define gpe_enable_disable_reply -{ - u32 context; - i32 retval; -}; - /** \brief add or delete gpe_iface @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param is_add - add address if non-zero, else delete */ -define gpe_add_del_iface +autoreply define gpe_add_del_iface { u32 client_index; u32 context; @@ -107,16 +87,6 @@ define gpe_add_del_iface u32 vni; }; -/** \brief Reply for gpe_iface add/del - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define gpe_add_del_iface_reply -{ - u32 context; - i32 retval; -}; - define gpe_fwd_entries_get { u32 client_index; @@ -163,23 +133,13 @@ manual_endian manual_print define gpe_fwd_entry_path_details @param context - sender context, to match reply w/ request @param mode - LISP (value 0) or VXLAN (value 1) */ -define gpe_set_encap_mode +autoreply define gpe_set_encap_mode { u32 client_index; u32 context; u8 mode; }; -/** \brief Reply for set_encap_mode - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define gpe_set_encap_mode_reply -{ - u32 context; - i32 retval; -}; - /** \brief get GPE encapsulation mode @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/vnet/map/map.api b/src/vnet/map/map.api index 4e4be85e..d68f13f0 100644 --- a/src/vnet/map/map.api +++ b/src/vnet/map/map.api @@ -62,22 +62,13 @@ define map_add_domain_reply @param context - sender context, to match reply w/ request @param index - MAP Domain index */ -define map_del_domain +autoreply define map_del_domain { u32 client_index; u32 context; u32 index; }; -/** \brief Reply for MAP domain del - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define map_del_domain_reply -{ - u32 context; - i32 retval; -}; /** \brief Add or Delete MAP rule from a domain (Only used for shared IPv4 per subscriber) @param client_index - opaque cookie to identify the sender @@ -87,7 +78,7 @@ define map_del_domain_reply @param ip6_dst - MAP CE IPv6 address @param psid - Rule PSID */ -define map_add_del_rule +autoreply define map_add_del_rule { u32 client_index; u32 context; @@ -97,15 +88,6 @@ define map_add_del_rule u16 psid; }; -/** \brief Reply for MAP rule add/del - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define map_add_del_rule_reply -{ - u32 context; - i32 retval; -}; /** \brief Get list of map domains @param client_index - opaque cookie to identify the sender diff --git a/src/vnet/mpls/mpls.api b/src/vnet/mpls/mpls.api index a1e1270a..c8a3ffb7 100644 --- a/src/vnet/mpls/mpls.api +++ b/src/vnet/mpls/mpls.api @@ -26,7 +26,7 @@ @param mb_address_length - Length of IP prefix @param mb_address[16] - IP prefix/ */ -define mpls_ip_bind_unbind +autoreply define mpls_ip_bind_unbind { u32 client_index; u32 context; @@ -40,16 +40,6 @@ define mpls_ip_bind_unbind u8 mb_address[16]; }; -/** \brief Reply for MPLS IP bind/unbind request - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define mpls_ip_bind_unbind_reply -{ - u32 context; - i32 retval; -}; - /** \brief MPLS tunnel Add / del route @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -172,7 +162,7 @@ manual_endian manual_print define mpls_tunnel_details @param mr_next_hop_out_label_stack - the next-hop output label stack, outer most first @param next_hop_via_label - The next-hop is a resolved via a local label */ -define mpls_route_add_del +autoreply define mpls_route_add_del { u32 client_index; u32 context; @@ -199,16 +189,6 @@ define mpls_route_add_del u32 mr_next_hop_out_label_stack[mr_next_hop_n_out_labels]; }; -/** \brief Reply for MPLS route add / del request - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define mpls_route_add_del_reply -{ - u32 context; - i32 retval; -}; - /** \brief Dump MPLS fib table @param client_index - opaque cookie to identify the sender */ @@ -240,4 +220,4 @@ manual_endian manual_print define mpls_fib_details * eval: (c-set-style "gnu") * End: */ - \ No newline at end of file + diff --git a/src/vnet/session/session.api b/src/vnet/session/session.api index e207e46f..4aef09da 100644 --- a/src/vnet/session/session.api +++ b/src/vnet/session/session.api @@ -49,26 +49,17 @@ define application_attach_reply { @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request */ - define application_detach { +autoreply define application_detach { u32 client_index; u32 context; }; - /** \brief detach reply - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define application_detach_reply { - u32 context; - i32 retval; -}; - /** \brief vpp->client, please map an additional shared memory segment @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param segment_name - */ -define map_another_segment { +autoreply define map_another_segment { u32 client_index; u32 context; u32 segment_size; @@ -83,7 +74,7 @@ define map_another_segment { "tcp://::/0/80" [ipv6] etc. @param options - socket options, fifo sizes, etc. */ -define bind_uri { +autoreply define bind_uri { u32 client_index; u32 context; u32 accept_cookie; @@ -97,7 +88,7 @@ define bind_uri { "tcp://::/0/80" [ipv6], etc. @param options - socket options, fifo sizes, etc. */ -define unbind_uri { +autoreply define unbind_uri { u32 client_index; u32 context; u8 uri[128]; @@ -122,24 +113,6 @@ define connect_uri { u64 options[16]; }; -/** \brief Bind reply - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define bind_uri_reply { - u32 context; - i32 retval; -}; - -/** \brief unbind reply - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define unbind_uri_reply { - u32 context; - i32 retval; -}; - /** \brief vpp->client, connect reply @param context - sender context, to match reply w/ request @param retval - return code for the request @@ -165,15 +138,6 @@ define connect_uri_reply { u8 segment_name[128]; }; -/** \brief client->vpp - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define map_another_segment_reply { - u32 context; - i32 retval; -}; - /** \brief vpp->client, accept this session @param context - sender context, to match reply w/ request @param listener_handle - tells client which listener this pertains to @@ -290,7 +254,7 @@ define bind_sock { @param context - sender context, to match reply w/ request @param handle - bind handle obtained from bind reply */ -define unbind_sock { +autoreply define unbind_sock { u32 client_index; u32 context; u64 handle; @@ -339,15 +303,6 @@ define bind_sock_reply { u8 segment_name[128]; }; -/** \brief unbind reply - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define unbind_sock_reply { - u32 context; - i32 retval; -}; - /** \brief vpp/server->client, connect reply @param context - sender context, to match reply w/ request @param retval - return code for the request @@ -378,23 +333,14 @@ define connect_sock_reply { @param context - sender context, to match reply w/ request @param is_enable - disable session layer if 0, enable otherwise */ -define session_enable_disable { +autoreply define session_enable_disable { u32 client_index; u32 context; u8 is_enable; }; -/** \brief Reply for session enable/disable - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define session_enable_disable_reply { - u32 context; - i32 retval; -}; - /* * Local Variables: * eval: (c-set-style "gnu") * End: - */ \ No newline at end of file + */ diff --git a/src/vnet/span/span.api b/src/vnet/span/span.api index 4babdd83..914fd8d0 100644 --- a/src/vnet/span/span.api +++ b/src/vnet/span/span.api @@ -21,7 +21,7 @@ @param sw_if_index_to - interface where the traffic is mirrored @param state - 0 = disabled, 1 = rx enabled, 2 = tx enabled, 3 tx & rx enabled */ -define sw_interface_span_enable_disable { +autoreply define sw_interface_span_enable_disable { u32 client_index; u32 context; u32 sw_if_index_from; @@ -29,14 +29,6 @@ define sw_interface_span_enable_disable { u8 state; }; -/** \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 diff --git a/src/vnet/sr/sr.api b/src/vnet/sr/sr.api index 5feadcb0..9e900741 100644 --- a/src/vnet/sr/sr.api +++ b/src/vnet/sr/sr.api @@ -25,7 +25,7 @@ @param fib_table FIB table in which we should install the localsid entry @param nh_addr Next Hop IPv4/IPv6 address. Only for L2/L3 xconnect. */ -define sr_localsid_add_del +autoreply define sr_localsid_add_del { u32 client_index; u32 context; @@ -39,16 +39,6 @@ define sr_localsid_add_del u8 nh_addr[16]; }; -/** \brief IPv6 SR LocalSID add/del request response - @param context - sender context, to match reply w/ request - @param retval - return value for request -*/ -define sr_localsid_add_del_reply -{ - u32 context; - i32 retval; -}; - /** \brief IPv6 SR policy add @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -59,7 +49,7 @@ define sr_localsid_add_del_reply @param fib_table is the VRF where to install the FIB entry for the BSID @param segments is a vector of IPv6 address composing the segment list */ -define sr_policy_add +autoreply define sr_policy_add { u32 client_index; u32 context; @@ -72,16 +62,6 @@ define sr_policy_add u8 segments[0]; }; -/** \brief IPv6 SR Policy add request response - @param context - sender context, to match reply w/ request - @param retval - return value for request -*/ -define sr_policy_add_reply -{ - u32 context; - i32 retval; -}; - /** \brief IPv6 SR policy modification @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -94,7 +74,7 @@ define sr_policy_add_reply @param weight is the weight of the sid list. optional. @param is_encap Mode. Encapsulation or SRH insertion. */ -define sr_policy_mod +autoreply define sr_policy_mod { u32 client_index; u32 context; @@ -108,23 +88,13 @@ define sr_policy_mod u8 segments[0]; }; -/** \brief IPv6 SR Policy modification request response - @param context - sender context, to match reply w/ request - @param retval - return value for request -*/ -define sr_policy_mod_reply -{ - u32 context; - i32 retval; -}; - /** \brief IPv6 SR policy deletion @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param bsid is the bindingSID of the SR Policy @param index is the index of the SR policy */ -define sr_policy_del +autoreply define sr_policy_del { u32 client_index; u32 context; @@ -132,16 +102,6 @@ define sr_policy_del u32 sr_policy_index; }; -/** \brief IPv6 SR Policy deletion request response - @param context - sender context, to match reply w/ request - @param retval - return value for request -*/ -define sr_policy_del_reply -{ - u32 context; - i32 retval; -}; - /** \brief IPv6 SR steering add/del @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -154,7 +114,7 @@ define sr_policy_del_reply @param sw_if_index is the incoming interface for L2 traffic @param traffic_type describes the type of traffic */ -define sr_steering_add_del +autoreply define sr_steering_add_del { u32 client_index; u32 context; @@ -168,16 +128,6 @@ define sr_steering_add_del u8 traffic_type; }; -/** \brief IPv6 SR steering add/del request response - @param context - sender context, to match reply w/ request - @param retval - return value for request -*/ -define sr_steering_add_del_reply -{ - u32 context; - i32 retval; -}; - /** \brief Dump the list of SR LocalSIDs @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/vnet/unix/tap.api b/src/vnet/unix/tap.api index 1fd0bb09..d9fba371 100644 --- a/src/vnet/unix/tap.api +++ b/src/vnet/unix/tap.api @@ -93,23 +93,13 @@ define tap_modify_reply @param context - sender context, to match reply w/ request @param sw_if_index - interface index of existing tap interface */ -define tap_delete +autoreply define tap_delete { u32 client_index; u32 context; u32 sw_if_index; }; -/** \brief Reply for tap delete request - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define tap_delete_reply -{ - u32 context; - i32 retval; -}; - /** \brief Dump tap interfaces request */ define sw_interface_tap_dump { diff --git a/src/vnet/vxlan/vxlan.api b/src/vnet/vxlan/vxlan.api index 048220fb..6c331a58 100644 --- a/src/vnet/vxlan/vxlan.api +++ b/src/vnet/vxlan/vxlan.api @@ -61,7 +61,7 @@ define vxlan_tunnel_details @param is_ipv6 - if non-zero, enable ipv6-vxlan-bypass, else ipv4-vxlan-bypass @param enable - if non-zero enable, else disable */ -define sw_interface_set_vxlan_bypass +autoreply define sw_interface_set_vxlan_bypass { u32 client_index; u32 context; @@ -69,13 +69,3 @@ define sw_interface_set_vxlan_bypass u8 is_ipv6; u8 enable; }; - -/** \brief Interface set vxlan-bypass response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define sw_interface_set_vxlan_bypass_reply -{ - u32 context; - i32 retval; -}; \ No newline at end of file diff --git a/src/vpp/api/vpe.api b/src/vpp/api/vpe.api index a4ba180d..7c07c822 100644 --- a/src/vpp/api/vpe.api +++ b/src/vpp/api/vpe.api @@ -80,7 +80,7 @@ define create_vlan_subif_reply @param sw_if_index - index of the interface @param enable - if non-zero enable, else disable */ -define sw_interface_set_mpls_enable +autoreply define sw_interface_set_mpls_enable { u32 client_index; u32 context; @@ -88,16 +88,6 @@ define sw_interface_set_mpls_enable u8 enable; }; -/** \brief Reply for MPLS state on an interface - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define sw_interface_set_mpls_enable_reply -{ - u32 context; - i32 retval; -}; - /** \brief Proxy ARP add / del request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -106,7 +96,7 @@ define sw_interface_set_mpls_enable_reply @param low_address[4] - Low address of the Proxy ARP range @param hi_address[4] - High address of the Proxy ARP range */ -define proxy_arp_add_del +autoreply define proxy_arp_add_del { u32 client_index; u32 context; @@ -116,23 +106,13 @@ define proxy_arp_add_del u8 hi_address[4]; }; -/** \brief Reply for proxy arp add / del request - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define proxy_arp_add_del_reply -{ - u32 context; - i32 retval; -}; - /** \brief Proxy ARP add / del request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param sw_if_index - Which interface to enable / disable Proxy Arp on @param enable_disable - 1 to enable Proxy ARP on interface, 0 to disable */ -define proxy_arp_intfc_enable_disable +autoreply define proxy_arp_intfc_enable_disable { u32 client_index; u32 context; @@ -141,23 +121,13 @@ define proxy_arp_intfc_enable_disable u8 enable_disable; }; -/** \brief Reply for Proxy ARP interface enable / disable request - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define proxy_arp_intfc_enable_disable_reply -{ - u32 context; - i32 retval; -}; - /** \brief Reset VRF (remove all routes etc) request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param is_ipv6 - 1 for IPv6 neighbor, 0 for IPv4 @param vrf_id - ID of th FIB table / VRF to reset */ -define reset_vrf +autoreply define reset_vrf { u32 client_index; u32 context; @@ -165,16 +135,6 @@ define reset_vrf u32 vrf_id; }; -/** \brief Reply for Reset VRF request - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define reset_vrf_reply -{ - u32 context; - i32 retval; -}; - /** \brief Is Address Reachable request - DISABLED @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -200,7 +160,7 @@ define is_address_reachable @param enable_disable - 1 = enable stats, 0 = disable @param pid - pid of process requesting stats updates */ -define want_stats +autoreply define want_stats { u32 client_index; u32 context; @@ -208,16 +168,6 @@ define want_stats u32 pid; }; -/** \brief Reply for Want Stats request - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define want_stats_reply -{ - u32 context; - i32 retval; -}; - typeonly manual_print manual_endian define ip4_fib_counter { u32 address; @@ -331,7 +281,7 @@ define oam_event @param enable_disable- enable if non-zero, else disable @param pid - pid of the requesting process */ -define want_oam_events +autoreply define want_oam_events { u32 client_index; u32 context; @@ -339,16 +289,6 @@ define want_oam_events u32 pid; }; -/** \brief Want OAM events response - @param context - sender context, to match reply w/ request - @param retval - return code for the want oam stats request -*/ -define want_oam_events_reply -{ - u32 context; - i32 retval; -}; - /** \brief OAM add / del target request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -357,7 +297,7 @@ define want_oam_events_reply @param dst_address[] - destination address of the target @param is_add - add target if non-zero, else delete */ -define oam_add_del +autoreply define oam_add_del { u32 client_index; u32 context; @@ -367,23 +307,13 @@ define oam_add_del u8 is_add; }; -/** \brief OAM add / del target response - @param context - sender context, to match reply w/ request - @param retval - return code of the request -*/ -define oam_add_del_reply -{ - u32 context; - i32 retval; -}; - /** \brief Reset fib table request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param vrf_id - vrf/table id of the fib table to reset @param is_ipv6 - an ipv6 fib to reset if non-zero, else ipv4 */ -define reset_fib +autoreply define reset_fib { u32 client_index; u32 context; @@ -391,16 +321,6 @@ define reset_fib u8 is_ipv6; }; -/** \brief Reset fib response - @param context - sender context, to match reply w/ request - @param retval - return code for the reset bfib request -*/ -define reset_fib_reply -{ - u32 context; - i32 retval; -}; - /** \brief Create loopback interface request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -458,23 +378,13 @@ define create_loopback_instance_reply @param context - sender context, to match reply w/ request @param sw_if_index - sw index of the interface that was created */ -define delete_loopback +autoreply define delete_loopback { u32 client_index; u32 context; u32 sw_if_index; }; -/** \brief Delete loopback interface response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define delete_loopback_reply -{ - u32 context; - i32 retval; -}; - /** \brief Control ping from client to api server request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -543,7 +453,7 @@ define cli_inband_reply @param is_ipv6 - neighbor limit if non-zero, else ARP limit @param arp_neighbor_limit - the new limit, defaults are ~ 50k */ -define set_arp_neighbor_limit +autoreply define set_arp_neighbor_limit { u32 client_index; u32 context; @@ -551,16 +461,6 @@ define set_arp_neighbor_limit u32 arp_neighbor_limit; }; -/** \brief Set max allowed ARP or ip6 neighbor entries response - @param context - sender context, to match reply w/ request - @param retval - return code for request -*/ -define set_arp_neighbor_limit_reply -{ - u32 context; - i32 retval; -}; - /** \brief L2 interface patch add / del request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -568,7 +468,7 @@ define set_arp_neighbor_limit_reply @param tx_sw_if_index - transmit side interface @param is_add - if non-zero set up the interface patch, else remove it */ -define l2_patch_add_del +autoreply define l2_patch_add_del { u32 client_index; u32 context; @@ -577,23 +477,13 @@ define l2_patch_add_del u8 is_add; }; -/** \brief L2 interface patch add / del response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define l2_patch_add_del_reply -{ - u32 context; - i32 retval; -}; - /** \brief Interface set vpath request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param sw_if_index - interface used to reach neighbor @param enable - if non-zero enable, else disable */ -define sw_interface_set_vpath +autoreply define sw_interface_set_vpath { u32 client_index; u32 context; @@ -601,16 +491,6 @@ define sw_interface_set_vpath u8 enable; }; -/** \brief Interface set vpath response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define sw_interface_set_vpath_reply -{ - u32 context; - i32 retval; -}; - /** \brief Set L2 XConnect between two interfaces request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -618,7 +498,7 @@ define sw_interface_set_vpath_reply @param tx_sw_if_index - Transmit interface index @param enable - enable xconnect if not 0, else set to L3 mode */ -define sw_interface_set_l2_xconnect +autoreply define sw_interface_set_l2_xconnect { u32 client_index; u32 context; @@ -627,16 +507,6 @@ define sw_interface_set_l2_xconnect u8 enable; }; -/** \brief Set L2 XConnect response - @param context - sender context, to match reply w/ request - @param retval - L2 XConnect request return code -*/ -define sw_interface_set_l2_xconnect_reply -{ - u32 context; - i32 retval; -}; - /** \brief Interface bridge mode request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -646,7 +516,7 @@ define sw_interface_set_l2_xconnect_reply @param shg - Shared horizon group, for bridge mode only @param enable - Enable beige mode if not 0, else set to L3 mode */ -define sw_interface_set_l2_bridge +autoreply define sw_interface_set_l2_bridge { u32 client_index; u32 context; @@ -657,16 +527,6 @@ define sw_interface_set_l2_bridge u8 enable; }; -/** \brief Interface bridge mode response - @param context - sender context, to match reply w/ request - @param retval - Bridge mode request return code -*/ -define sw_interface_set_l2_bridge_reply -{ - u32 context; - i32 retval; -}; - /** \brief Set bridge domain ip to mac entry request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -676,7 +536,7 @@ define sw_interface_set_l2_bridge_reply @param mac_address - MAC address @param */ -define bd_ip_mac_add_del +autoreply define bd_ip_mac_add_del { u32 client_index; u32 context; @@ -687,16 +547,6 @@ define bd_ip_mac_add_del u8 mac_address[6]; }; -/** \brief Set bridge domain ip to mac entry response - @param context - sender context, to match reply w/ request - @param retval - return code for the set bridge flags request -*/ -define bd_ip_mac_add_del_reply -{ - u32 context; - i32 retval; -}; - /** \brief Set/unset the classification table for an interface request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -704,7 +554,7 @@ define bd_ip_mac_add_del_reply @param sw_if_index - interface to associate with the table @param table_index - index of the table, if ~0 unset the table */ -define classify_set_interface_ip_table +autoreply define classify_set_interface_ip_table { u32 client_index; u32 context; @@ -713,16 +563,6 @@ define classify_set_interface_ip_table u32 table_index; /* ~0 => off */ }; -/** \brief Set/unset interface classification table response - @param context - sender context, to match reply w/ request - @param retval - return code -*/ -define classify_set_interface_ip_table_reply -{ - u32 context; - i32 retval; -}; - /** \brief Set/unset l2 classification tables for an interface request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -731,7 +571,7 @@ define classify_set_interface_ip_table_reply @param ip6_table_index - ip6 index @param other_table_index - other index */ -define classify_set_interface_l2_tables +autoreply define classify_set_interface_l2_tables { u32 client_index; u32 context; @@ -743,16 +583,6 @@ define classify_set_interface_l2_tables u8 is_input; }; -/** \brief Set/unset l2 classification tables for an interface response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define classify_set_interface_l2_tables_reply -{ - u32 context; - i32 retval; -}; - /** \brief Get node index using name request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -809,7 +639,7 @@ define add_node_next_reply @param sw_if_index - interface to enable/disable filtering on @param enable_disable - if non-zero enable filtering, else disable */ -define l2_interface_efp_filter +autoreply define l2_interface_efp_filter { u32 client_index; u32 context; @@ -817,16 +647,6 @@ define l2_interface_efp_filter u32 enable_disable; }; -/** \brief L2 interface ethernet flow point filtering response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define l2_interface_efp_filter_reply -{ - u32 context; - i32 retval; -}; - define create_subif { u32 client_index; @@ -882,7 +702,7 @@ define show_version_reply }; /* Gross kludge, DGMS */ -define interface_name_renumber +autoreply define interface_name_renumber { u32 client_index; u32 context; @@ -890,12 +710,6 @@ define interface_name_renumber u32 new_show_dev_instance; }; -define interface_name_renumber_reply -{ - u32 context; - i32 retval; -}; - /** \brief Register for ip4 arp resolution events @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -903,7 +717,7 @@ define interface_name_renumber_reply @param pid - sender's pid @param address - the exact ip4 address of interest */ -define want_ip4_arp_events +autoreply define want_ip4_arp_events { u32 client_index; u32 context; @@ -912,16 +726,6 @@ define want_ip4_arp_events u32 address; }; -/** \brief Reply for interface events registration - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define want_ip4_arp_events_reply -{ - u32 context; - i32 retval; -}; - /** \brief Tell client about an ip4 arp resolution event @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -949,7 +753,7 @@ define ip4_arp_event @param pid - sender's pid @param address - the exact ip6 address of interest */ -define want_ip6_nd_events +autoreply define want_ip6_nd_events { u32 client_index; u32 context; @@ -958,16 +762,6 @@ define want_ip6_nd_events u8 address[16]; }; -/** \brief Reply for ip6 nd resolution events registration - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define want_ip6_nd_events_reply -{ - u32 context; - i32 retval; -}; - /** \brief Tell client about an ip6 nd resolution or mac/ip event @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -999,7 +793,7 @@ define ip6_nd_event Note: User is recommeneded to use just one valid table_index per call. (ip4_table_index, ip6_table_index, or l2_table_index) */ -define input_acl_set_interface +autoreply define input_acl_set_interface { u32 client_index; u32 context; @@ -1010,16 +804,6 @@ define input_acl_set_interface u8 is_add; }; -/** \brief Set/unset input ACL interface response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define input_acl_set_interface_reply -{ - u32 context; - i32 retval; -}; - define get_node_graph { u32 client_index; @@ -1048,7 +832,7 @@ define get_node_graph_reply @param pow_enable - Proof of Work enabled or not flag @param trace_enable - iOAM Trace enabled or not flag */ -define ioam_enable +autoreply define ioam_enable { u32 client_index; u32 context; @@ -1060,38 +844,18 @@ define ioam_enable u32 node_id; }; -/** \brief iOAM Trace profile add / del response - @param context - sender context, to match reply w/ request - @param retval - return value for request -*/ -define ioam_enable_reply -{ - u32 context; - i32 retval; -}; - /** \brief iOAM disable @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param index - MAP Domain index */ -define ioam_disable +autoreply define ioam_disable { u32 client_index; u32 context; u16 id; }; -/** \brief iOAM disable response - @param context - sender context, to match reply w/ request - @param retval - return value for request -*/ -define ioam_disable_reply -{ - u32 context; - i32 retval; -}; - /** \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 @@ -1149,7 +913,7 @@ define pg_create_interface_reply @param count - number of packets to be captured @param pcap_file - pacp file name to store captured packets */ -define pg_capture +autoreply define pg_capture { u32 client_index; u32 context; @@ -1160,23 +924,13 @@ define pg_capture u8 pcap_file_name[pcap_name_length]; }; -/** \brief PacketGenerator capture packets response - @param context - sender context, to match reply w/ request - @param retval - return value for request -*/ -define pg_capture_reply -{ - u32 context; - i32 retval; -}; - /** \brief Enable / disable packet generator request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param is_enabled - 1 if enabling streams, 0 if disabling @param stream - stream name to be enable/disabled, if not specified handle all streams */ -define pg_enable_disable +autoreply define pg_enable_disable { u32 client_index; u32 context; @@ -1185,16 +939,6 @@ define pg_enable_disable u8 stream_name[stream_name_length]; }; -/** \brief Reply for enable / disable packet generator - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define pg_enable_disable_reply -{ - u32 context; - i32 retval; -}; - /** \brief Configure IP source and L4 port-range check @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -1208,7 +952,7 @@ define pg_enable_disable_reply @param vrf_id - fib table/vrf id to associate the source and port-range check with @note To specify a single port set low_port and high_port entry the same */ -define ip_source_and_port_range_check_add_del +autoreply define ip_source_and_port_range_check_add_del { u32 client_index; u32 context; @@ -1222,16 +966,6 @@ define ip_source_and_port_range_check_add_del u32 vrf_id; }; -/** \brief Configure IP source and L4 port-range check reply - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define ip_source_and_port_range_check_add_del_reply -{ - u32 context; - i32 retval; -}; - /** \brief Set interface source and L4 port-range request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -1239,7 +973,7 @@ define ip_source_and_port_range_check_add_del_reply @param tcp_vrf_id - VRF associated with source and TCP port-range check @param udp_vrf_id - VRF associated with source and TCP port-range check */ -define ip_source_and_port_range_check_interface_add_del +autoreply define ip_source_and_port_range_check_interface_add_del { u32 client_index; u32 context; @@ -1251,36 +985,17 @@ define ip_source_and_port_range_check_interface_add_del u32 udp_out_vrf_id; }; -/** \brief Set interface source and L4 port-range response - @param context - sender context, to match reply w/ request - @param retval - return value for request -*/ -define ip_source_and_port_range_check_interface_add_del_reply -{ - u32 context; - i32 retval; -}; - /** \brief Delete sub interface request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param sw_if_index - sw index of the interface that was created by create_subif */ -define delete_subif { +autoreply define delete_subif { u32 client_index; u32 context; u32 sw_if_index; }; -/** \brief Delete sub interface response - @param context - sender context, to match reply w/ request - @param retval - return code for the request -*/ -define delete_subif_reply { - u32 context; - i32 retval; -}; - /** \brief Punt traffic to the host @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -1289,7 +1004,7 @@ define delete_subif_reply { @param l4_protocol - L4 protocol to be punted, only UDP (0x11) is supported @param l4_port - TCP/UDP port to be punted */ -define punt { +autoreply define punt { u32 client_index; u32 context; u8 is_add; @@ -1298,23 +1013,13 @@ define punt { u16 l4_port; }; -/** \brief Reply to the punt request - @param context - sender context which was passed in the request - @param retval - return code of punt request -*/ -define punt_reply -{ - u32 context; - i32 retval; -}; - /** \brief Feature path enable/disable request @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 enable - 1 = on, 0 = off */ -define feature_enable_disable { +autoreply define feature_enable_disable { u32 client_index; u32 context; u32 sw_if_index; @@ -1323,16 +1028,6 @@ define feature_enable_disable { u8 feature_name[64]; }; -/** \brief Reply to the eature path enable/disable request - @param context - sender context which was passed in the request - @param retval - return code for the request -*/ -define feature_enable_disable_reply -{ - u32 context; - i32 retval; -}; - /* * Local Variables: * eval: (c-set-style "gnu") -- cgit 1.2.3-korg From 0f68c79a9d8533d492c8221f924b14cf4e222136 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Wed, 26 Apr 2017 13:05:05 +0200 Subject: Add crc32c inline function, allows compilation on 32-bit systems 32-bit code still can use crc32c instructions, but it operates on 32 registers Change-Id: I9bb6b0b59635d6ea6a753584676ebcf59c8f6584 Signed-off-by: Damjan Marion --- src/plugins/acl/bihash_40_8.h | 9 ++----- src/plugins/lb/lbhash.h | 2 +- src/vnet/bfd/bfd_main.c | 2 +- src/vppinfra.am | 1 + src/vppinfra/bihash_24_8.h | 7 ++---- src/vppinfra/bihash_8_8.h | 7 ++---- src/vppinfra/crc32.h | 58 +++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 67 insertions(+), 19 deletions(-) create mode 100644 src/vppinfra/crc32.h (limited to 'src/plugins/lb') diff --git a/src/plugins/acl/bihash_40_8.h b/src/plugins/acl/bihash_40_8.h index ba3dfbea..1dfb6a1e 100644 --- a/src/plugins/acl/bihash_40_8.h +++ b/src/plugins/acl/bihash_40_8.h @@ -24,6 +24,7 @@ #include #include #include +#include typedef struct { @@ -44,13 +45,7 @@ static inline u64 clib_bihash_hash_40_8 (const clib_bihash_kv_40_8_t * v) { #if __SSE4_2__ - u32 value = 0; - value = _mm_crc32_u64 (value, v->key[0]); - value = _mm_crc32_u64 (value, v->key[1]); - value = _mm_crc32_u64 (value, v->key[2]); - value = _mm_crc32_u64 (value, v->key[3]); - value = _mm_crc32_u64 (value, v->key[4]); - return value; + return clib_crc32c ((u8 *) v->key, 40); #else u64 tmp = v->key[0] ^ v->key[1] ^ v->key[2] ^ v->key[3] ^ v->key[4]; return clib_xxhash (tmp); diff --git a/src/plugins/lb/lbhash.h b/src/plugins/lb/lbhash.h index ca3cc143..c514fb57 100644 --- a/src/plugins/lb/lbhash.h +++ b/src/plugins/lb/lbhash.h @@ -101,7 +101,7 @@ void lb_hash_free(lb_hash_t *h) vec_free(mem); } -#if __SSE4_2__ +#if __SSE4_2__ && !defined (__i386__) static_always_inline u32 lb_hash_hash(u64 k0, u64 k1, u64 k2, u64 k3, u64 k4) { diff --git a/src/vnet/bfd/bfd_main.c b/src/vnet/bfd/bfd_main.c index 66b31ce5..b58a5132 100644 --- a/src/vnet/bfd/bfd_main.c +++ b/src/vnet/bfd/bfd_main.c @@ -39,7 +39,7 @@ static u64 bfd_calc_echo_checksum (u32 discriminator, u64 expire_time, u32 secret) { u64 checksum = 0; -#if __SSE4_2__ +#if __SSE4_2__ && !defined (__i386__) checksum = _mm_crc32_u64 (0, discriminator); checksum = _mm_crc32_u64 (checksum, expire_time); checksum = _mm_crc32_u64 (checksum, secret); diff --git a/src/vppinfra.am b/src/vppinfra.am index fed1981e..3939d3ce 100644 --- a/src/vppinfra.am +++ b/src/vppinfra.am @@ -168,6 +168,7 @@ nobase_include_HEADERS = \ vppinfra/cache.h \ vppinfra/clib.h \ vppinfra/cpu.h \ + vppinfra/crc32.h \ vppinfra/dlist.h \ vppinfra/elf.h \ vppinfra/elf_clib.h \ diff --git a/src/vppinfra/bihash_24_8.h b/src/vppinfra/bihash_24_8.h index 353f06bf..655dab80 100644 --- a/src/vppinfra/bihash_24_8.h +++ b/src/vppinfra/bihash_24_8.h @@ -24,6 +24,7 @@ #include #include #include +#include typedef struct { @@ -44,11 +45,7 @@ static inline u64 clib_bihash_hash_24_8 (const clib_bihash_kv_24_8_t * v) { #if __SSE4_2__ - u32 value = 0; - value = _mm_crc32_u64 (value, v->key[0]); - value = _mm_crc32_u64 (value, v->key[1]); - value = _mm_crc32_u64 (value, v->key[2]); - return value; + return clib_crc32c ((u8 *) v->key, 24); #else u64 tmp = v->key[0] ^ v->key[1] ^ v->key[2]; return clib_xxhash (tmp); diff --git a/src/vppinfra/bihash_8_8.h b/src/vppinfra/bihash_8_8.h index d70da596..b5c17461 100644 --- a/src/vppinfra/bihash_8_8.h +++ b/src/vppinfra/bihash_8_8.h @@ -24,10 +24,7 @@ #include #include #include - -#if __SSE4_2__ -#include -#endif +#include /** 8 octet key, 8 octet key value pair */ typedef struct @@ -55,7 +52,7 @@ clib_bihash_hash_8_8 (clib_bihash_kv_8_8_t * v) { /* Note: to torture-test linear scan, make this fn return a constant */ #if __SSE4_2__ - return _mm_crc32_u64 (0, v->key); + return clib_crc32c ((u8 *) & v->key, 8); #else return clib_xxhash (v->key); #endif diff --git a/src/vppinfra/crc32.h b/src/vppinfra/crc32.h new file mode 100644 index 00000000..abb2953f --- /dev/null +++ b/src/vppinfra/crc32.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __included_crc32_h__ +#define __included_crc32_h__ + +#if __SSE4_2__ +#include + +static_always_inline u32 +clib_crc32c (u8 * s, int len) +{ + u32 v = 0; + +#if __x86_64__ + for (; len >= 8; len -= 8, s += 8) + v = _mm_crc32_u64 (v, *((u64 *) s)); +#else + /* workaround weird GCC bug when using _mm_crc32_u32 + which happens with -O2 optimization */ + volatile ("":::"memory"); +#endif + + for (; len >= 4; len -= 4, s += 4) + v = _mm_crc32_u32 (v, *((u32 *) s)); + + for (; len >= 2; len -= 2, s += 2) + v = _mm_crc32_u16 (v, *((u16 *) s)); + + for (; len >= 1; len -= 1, s += 1) + v = _mm_crc32_u8 (v, *((u16 *) s)); + + return v; +} + +#endif + +#endif /* __included_crc32_h__ */ + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ -- cgit 1.2.3-korg From 755e41e4574103f5435ca45384c236bf11d8e28f Mon Sep 17 00:00:00 2001 From: Hongjun Ni Date: Tue, 25 Jul 2017 22:03:08 +0800 Subject: Fix IP fragment-id and offset issue in LB-GRE4 Change-Id: Ic1c440b2594c3ec4cdc75730069f16432cdb9587 Signed-off-by: Hongjun Ni --- src/plugins/lb/node.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/plugins/lb') diff --git a/src/plugins/lb/node.c b/src/plugins/lb/node.c index 3171148b..4a7485eb 100644 --- a/src/plugins/lb/node.c +++ b/src/plugins/lb/node.c @@ -277,6 +277,8 @@ lb_node_fn (vlib_main_t * vm, ip40->dst_address = lbm->ass[asindex0].address.ip4; ip40->ip_version_and_header_length = 0x45; ip40->ttl = 128; + ip40->fragment_id = 0; + ip40->flags_and_fragment_offset = 0; ip40->length = clib_host_to_net_u16(len0 + sizeof(gre_header_t) + sizeof(ip4_header_t)); ip40->protocol = IP_PROTOCOL_GRE; ip40->checksum = ip4_header_checksum (ip40); -- cgit 1.2.3-korg From c4a51546deebba1933a42a139f66b3d94436145f Mon Sep 17 00:00:00 2001 From: flyingeagle23 Date: Fri, 8 Sep 2017 15:32:59 +0800 Subject: lb_vip_command_fn param redundancy when unformat ip address(VPP-977) Change-Id: I92de5b9ed42cda6c0438b8dc71892d322b642a70 Signed-off-by: flyingeagle23 --- src/plugins/lb/cli.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/lb') diff --git a/src/plugins/lb/cli.c b/src/plugins/lb/cli.c index 6452a875..f6d65201 100644 --- a/src/plugins/lb/cli.c +++ b/src/plugins/lb/cli.c @@ -33,7 +33,7 @@ lb_vip_command_fn (vlib_main_t * vm, if (!unformat_user (input, unformat_line_input, line_input)) return 0; - if (!unformat(line_input, "%U", unformat_ip46_prefix, &prefix, &plen, IP46_TYPE_ANY, &plen)) { + if (!unformat(line_input, "%U", unformat_ip46_prefix, &prefix, &plen, IP46_TYPE_ANY)) { error = clib_error_return (0, "invalid vip prefix: '%U'", format_unformat_error, line_input); goto done; -- cgit 1.2.3-korg