From 0d056e5ede136cd0111dc3f9f41ef7b36a938027 Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Thu, 28 Sep 2017 15:11:16 -0400 Subject: [PATCH] vppapigen: support per-file (major,minor,patch) version stamps Add one of these statements to foo.api: vl_api_version 1.2.3 to generate a version tuple stanza in foo.api.h: /****** Version tuple *****/ vl_api_version_tuple(foo, 1, 2, 3) Change-Id: Ic514439e4677999daa8463a94f948f76b132ff15 Signed-off-by: Dave Barach Signed-off-by: Ole Troan --- src/examples/sample-plugin/sample/sample.api | 2 + src/plugins/acl/acl.api | 1 + src/plugins/dpdk/api/dpdk.api | 2 + src/plugins/flowprobe/flowprobe.api | 2 + src/plugins/gtpu/gtpu.api | 2 + .../export-vxlan-gpe/vxlan_gpe_ioam_export.api | 2 + src/plugins/ioam/export/ioam_export.api | 2 + src/plugins/ioam/ip6/ioam_cache.api | 2 + src/plugins/ioam/lib-pot/pot.api | 1 + src/plugins/ioam/lib-trace/trace.api | 1 + src/plugins/ioam/lib-vxlan-gpe/ioam_vxlan_gpe.api | 1 + src/plugins/ioam/udp-ping/udp_ping.api | 1 + src/plugins/lb/lb.api | 2 + src/plugins/memif/memif.api | 2 + src/plugins/nat/nat.api | 3 ++ src/plugins/pppoe/pppoe.api | 2 + src/tools/vppapigen/gram.y | 7 ++- src/tools/vppapigen/lex.c | 9 ++++ src/tools/vppapigen/node.c | 59 +++++++++++++++++++++- src/tools/vppapigen/node.h | 8 ++- src/vlibapi/api.h | 2 + src/vlibapi/api_common.h | 11 ++++ src/vlibapi/api_shared.c | 9 ++++ src/vlibmemory/memclnt.api | 23 +++++++++ src/vlibmemory/memory_vlib.c | 38 +++++++++++++- src/vnet/bfd/bfd.api | 2 + src/vnet/classify/classify.api | 2 + src/vnet/cop/cop.api | 2 + src/vnet/devices/af_packet/af_packet.api | 2 + src/vnet/devices/netmap/netmap.api | 2 + src/vnet/devices/virtio/vhost_user.api | 2 + src/vnet/dhcp/dhcp.api | 2 + src/vnet/ethernet/p2p_ethernet.api | 2 + src/vnet/flow/flow.api | 2 + src/vnet/gre/gre.api | 2 + src/vnet/interface.api | 2 + src/vnet/ip/ip.api | 2 + src/vnet/ipsec-gre/ipsec_gre.api | 2 + src/vnet/ipsec/ipsec.api | 2 + src/vnet/l2/l2.api | 2 + src/vnet/l2tp/l2tp.api | 2 + src/vnet/lisp-cp/lisp.api | 2 + src/vnet/lisp-cp/one.api | 2 + src/vnet/lisp-gpe/lisp_gpe.api | 2 + src/vnet/lldp/lldp.api | 2 + src/vnet/map/map.api | 1 + src/vnet/mpls/mpls.api | 2 + src/vnet/policer/policer.api | 2 + src/vnet/session/session.api | 4 +- src/vnet/span/span.api | 2 + src/vnet/srv6/sr.api | 8 ++- src/vnet/unix/tap.api | 2 + src/vnet/vxlan-gpe/vxlan_gpe.api | 2 + src/vnet/vxlan/vxlan.api | 4 +- src/vpp/api/api.c | 5 ++ src/vpp/api/vpe.api | 2 + src/vpp/stats/stats.api | 1 + 57 files changed, 260 insertions(+), 9 deletions(-) diff --git a/src/examples/sample-plugin/sample/sample.api b/src/examples/sample-plugin/sample/sample.api index d565c0b178b..f3604b6d127 100644 --- a/src/examples/sample-plugin/sample/sample.api +++ b/src/examples/sample-plugin/sample/sample.api @@ -16,6 +16,8 @@ /* Define a simple binary API to control the feature */ +vl_api_version 0.1.0 + autoreply define sample_macswap_enable_disable { /* Client identifier, set from api_main.my_client_index */ u32 client_index; diff --git a/src/plugins/acl/acl.api b/src/plugins/acl/acl.api index a0de24a2340..19f007aeea7 100644 --- a/src/plugins/acl/acl.api +++ b/src/plugins/acl/acl.api @@ -19,6 +19,7 @@ used to control the ACL plugin */ +vl_api_version 1.0.0 /** \brief Get the plugin version @param client_index - opaque cookie to identify the sender diff --git a/src/plugins/dpdk/api/dpdk.api b/src/plugins/dpdk/api/dpdk.api index d43f8a36c4a..5ded450136a 100644 --- a/src/plugins/dpdk/api/dpdk.api +++ b/src/plugins/dpdk/api/dpdk.api @@ -13,6 +13,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /** \brief DPDK interface HQoS pipe profile set request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/plugins/flowprobe/flowprobe.api b/src/plugins/flowprobe/flowprobe.api index 3f8c583bcf2..5bfe4510178 100644 --- a/src/plugins/flowprobe/flowprobe.api +++ b/src/plugins/flowprobe/flowprobe.api @@ -5,6 +5,8 @@ used to control the flowprobe plugin */ +vl_api_version 1.0.0 + /** \brief Enable / disable per-packet IPFIX recording on an interface @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/plugins/gtpu/gtpu.api b/src/plugins/gtpu/gtpu.api index 55ba03904d4..fea47916b8c 100644 --- a/src/plugins/gtpu/gtpu.api +++ b/src/plugins/gtpu/gtpu.api @@ -13,6 +13,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /** \brief Set or delete an GTPU tunnel @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request 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 caa97e6ec7d..3637ae8e4b2 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 @@ -14,6 +14,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /* Define a simple binary API to control the feature */ autoreply define vxlan_gpe_ioam_export_enable_disable { diff --git a/src/plugins/ioam/export/ioam_export.api b/src/plugins/ioam/export/ioam_export.api index bb830561309..47a8cc057c4 100644 --- a/src/plugins/ioam/export/ioam_export.api +++ b/src/plugins/ioam/export/ioam_export.api @@ -14,6 +14,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /* Define a simple binary API to control the feature */ autoreply define ioam_export_ip6_enable_disable { diff --git a/src/plugins/ioam/ip6/ioam_cache.api b/src/plugins/ioam/ip6/ioam_cache.api index dd9c0186556..c953b674fe6 100644 --- a/src/plugins/ioam/ip6/ioam_cache.api +++ b/src/plugins/ioam/ip6/ioam_cache.api @@ -14,6 +14,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /* API to control ioam caching */ autoreply define ioam_cache_ip6_enable_disable { diff --git a/src/plugins/ioam/lib-pot/pot.api b/src/plugins/ioam/lib-pot/pot.api index c377cde0dfe..d1bfe447e34 100644 --- a/src/plugins/ioam/lib-pot/pot.api +++ b/src/plugins/ioam/lib-pot/pot.api @@ -14,6 +14,7 @@ * limitations under the License. */ +vl_api_version 1.0.0 /** \brief Proof of Transit(POT): Set POT profile @param id - id of the profile diff --git a/src/plugins/ioam/lib-trace/trace.api b/src/plugins/ioam/lib-trace/trace.api index 2f45c6e28fd..59d664adbd7 100644 --- a/src/plugins/ioam/lib-trace/trace.api +++ b/src/plugins/ioam/lib-trace/trace.api @@ -14,6 +14,7 @@ * limitations under the License. */ +vl_api_version 1.0.0 /** \brief iOAM6 Trace - Set the iOAM6 trace profile @param trace_type - Type of trace requested 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 a6761f07e40..dfaecff60c9 100644 --- a/src/plugins/ioam/lib-vxlan-gpe/ioam_vxlan_gpe.api +++ b/src/plugins/ioam/lib-vxlan-gpe/ioam_vxlan_gpe.api @@ -14,6 +14,7 @@ * limitations under the License. */ +vl_api_version 1.0.0 /** \brief iOAM Over VxLAN-GPE - Set iOAM transport for VxLAN-GPE @param client_index - opaque cookie to identify the sender diff --git a/src/plugins/ioam/udp-ping/udp_ping.api b/src/plugins/ioam/udp-ping/udp_ping.api index 87945816044..6a5a6e68a03 100644 --- a/src/plugins/ioam/udp-ping/udp_ping.api +++ b/src/plugins/ioam/udp-ping/udp_ping.api @@ -14,6 +14,7 @@ * limitations under the License. */ +vl_api_version 1.0.0 /** \brief UDP-Probe Add/Delete request @param src_ip_address - Source ipv4/v6 address for the udp-ping flow diff --git a/src/plugins/lb/lb.api b/src/plugins/lb/lb.api index 32cc669b518..7f48666a4b1 100644 --- a/src/plugins/lb/lb.api +++ b/src/plugins/lb/lb.api @@ -1,3 +1,5 @@ +vl_api_version 1.0.0 + /** \brief Configure Load-Balancer global parameters @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/plugins/memif/memif.api b/src/plugins/memif/memif.api index c9632d10357..08d056f04dd 100644 --- a/src/plugins/memif/memif.api +++ b/src/plugins/memif/memif.api @@ -13,6 +13,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /** \brief Create memory interface @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/plugins/nat/nat.api b/src/plugins/nat/nat.api index d7a4a9efe22..84187578c9d 100644 --- a/src/plugins/nat/nat.api +++ b/src/plugins/nat/nat.api @@ -12,6 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +vl_api_version 1.0.0 + /** * @file nat.api * @brief VPP control-plane API messages. diff --git a/src/plugins/pppoe/pppoe.api b/src/plugins/pppoe/pppoe.api index e8cd989f41b..78982f3e2e4 100644 --- a/src/plugins/pppoe/pppoe.api +++ b/src/plugins/pppoe/pppoe.api @@ -13,6 +13,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /** \brief Set or delete an PPPOE session @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 52bb65c524a..5c5d46ff4e0 100644 --- a/src/tools/vppapigen/gram.y +++ b/src/tools/vppapigen/gram.y @@ -33,11 +33,12 @@ void generate (YYSTYPE); YYSTYPE add_vector_vbl(YYSTYPE, YYSTYPE); YYSTYPE add_variable_length_vector_vbl(YYSTYPE, YYSTYPE); YYSTYPE set_flags(YYSTYPE, YYSTYPE); + YYSTYPE add_version(YYSTYPE, YYSTYPE, YYSTYPE); %} %token NAME RPAR LPAR SEMI LBRACK RBRACK NUMBER PRIMTYPE BARF %token TPACKED DEFINE LCURLY RCURLY STRING UNION -%token HELPER_STRING COMMA +%token HELPER_STRING COMMA DOT VL_API_VERSION %token NOVERSION MANUAL_PRINT MANUAL_ENDIAN TYPEONLY DONT_TRACE AUTOREPLY %% @@ -51,6 +52,7 @@ slist: slist stmt {$$ = add_slist ($1, $2);} stmt: flist defn {$$ = set_flags($1, $2);} | defn {$$ = $1;} + | api_version {$$ = $1;} ; flist: flist flag {$$ = (YYSTYPE)(unsigned long) @@ -89,3 +91,6 @@ vbl: NAME {$$ = add_scalar_vbl($1);} | NAME LBRACK NUMBER RBRACK {$$ = add_vector_vbl($1, $3);} | NAME LBRACK NAME RBRACK {$$ = add_variable_length_vector_vbl($1, $3);} ; + +api_version: VL_API_VERSION NUMBER DOT NUMBER DOT NUMBER + {$$ = add_version ($2, $4, $6);} diff --git a/src/tools/vppapigen/lex.c b/src/tools/vppapigen/lex.c index e63581433b7..d9f82c2b9f1 100644 --- a/src/tools/vppapigen/lex.c +++ b/src/tools/vppapigen/lex.c @@ -581,6 +581,9 @@ static int yylex_1 (void) case ',': return (COMMA); + case '.': + return (DOT); + case '"': nameidx = 0; the_lexer_state = STRING_STATE; @@ -937,6 +940,8 @@ int yylex (void) case TYPEONLY: code = 278; break; case DONT_TRACE: code = 279; break; case AUTOREPLY: code = 280; break; + case DOT: code = 281; break; + case VL_API_VERSION: code = 282; break; case EOF: code = ~0; break; /* hysterical compatibility */ @@ -996,6 +1001,7 @@ static struct keytab { {"u8", NODE_U8}, {"union", NODE_UNION}, {"uword", NODE_UWORD}, + {"vl_api_version", NODE_VERSION}, }; static int name_check (const char *s, YYSTYPE *token_value) @@ -1061,6 +1067,9 @@ static int name_check (const char *s, YYSTYPE *token_value) case NODE_NOVERSION: return(NOVERSION); + case NODE_VERSION: + return(VL_API_VERSION); + case NODE_UNION: return(UNION); diff --git a/src/tools/vppapigen/node.c b/src/tools/vppapigen/node.c index 4c85a11305f..37ba4931a1f 100644 --- a/src/tools/vppapigen/node.c +++ b/src/tools/vppapigen/node.c @@ -832,6 +832,22 @@ node_vft_t node_noversion_vft = { 0, }; +void node_version_print (node_t *this) +{ + primtype_recursive_print (this, "version "); +} + +void node_version_generate (node_t *this, enum passid which, FILE *ofp) +{ + fprintf(stderr, "node_version_generate called...\n"); +} + +node_vft_t node_version_vft = { + node_version_print, + node_version_generate, + 0, +}; + void node_uword_print (node_t *this) { primtype_recursive_print(this, "uword "); @@ -866,6 +882,7 @@ node_vft_t *the_vft[NODE_N_TYPES] = { &node_vector_vft, &node_complex_vft, &node_noversion_vft, + &node_version_vft, &node_uword_vft, }; @@ -1133,7 +1150,8 @@ void generate_top_boilerplate(FILE *fp) fprintf (fp, "#if defined(vl_msg_id)||defined(vl_union_id)||"); fprintf (fp, "defined(vl_printfun) \\\n ||defined(vl_endianfun)||"); fprintf (fp, " defined(vl_api_version)||defined(vl_typedefs) \\\n"); - fprintf (fp, " ||defined(vl_msg_name)||defined(vl_msg_name_crc_list)\n"); + fprintf (fp, " ||defined(vl_msg_name)||defined(vl_msg_name_crc_list) \\\n"); + fprintf (fp, " ||defined(vl_api_version_tuple)\n"); fprintf (fp, "/* ok, something was selected */\n"); fprintf (fp, "#else\n"); fprintf (fp, "#warning no content included from %s\n", input_filename); @@ -1144,7 +1162,8 @@ void generate_top_boilerplate(FILE *fp) void generate_bottom_boilerplate(FILE *fp) { - fprintf (fp, "\n#ifdef vl_api_version\n"); + fprintf(fp, "/****** API CRC (whole file) *****/\n\n"); + fprintf (fp, "#ifdef vl_api_version\n"); if (dont_output_version) { fprintf (fp, "/* WARNING: API FILE VERSION CHECK DISABLED */\n"); @@ -1153,6 +1172,7 @@ void generate_bottom_boilerplate(FILE *fp) fprintf (fp, "vl_api_version(%s, 0x%08x)\n\n", fixed_name, (unsigned int)input_crc); + fprintf (fp, "#endif\n\n"); } @@ -1416,6 +1436,20 @@ void add_msg_ids(YYSTYPE a1) } } +/* + * add_scalar_vbl (char *name) + */ +YYSTYPE add_version (YYSTYPE a1, YYSTYPE a2, YYSTYPE a3) +{ + node_t *np; + + np = make_node(NODE_VERSION); + np->data[0] = (void *) a1; + np->data[1] = (void *) a2; + np->data[2] = (void *) a3; + return ((YYSTYPE) np); +} + void generate_python_msg_definitions(YYSTYPE a1, FILE *fp) { node_t *np = (node_t *)a1; @@ -1517,6 +1551,26 @@ void generate_json(YYSTYPE a1, FILE *fp) fprintf (fp, "}\n"); } +void generate_version_tuple(YYSTYPE a1, FILE *fp) +{ + node_t *this = (node_t *)a1; + + fprintf(fp, "/****** Version tuple *****/\n\n"); + + fprintf(fp, "#ifdef vl_api_version_tuple\n\n"); + + /* Walk the top-level node-list */ + while (this) { + if (this->type == NODE_VERSION) { + fprintf (fp, "vl_api_version_tuple(%s, %d, %d, %d)\n", + fixed_name, IDATA0, IDATA1, IDATA2); + } + this = this->peer; + } + + fprintf(fp, "\n#endif /* vl_api_version_tuple */\n\n"); +} + void generate(YYSTYPE a1) { if (dump_tree) { @@ -1535,6 +1589,7 @@ void generate(YYSTYPE a1) generate_uniondefs(a1, ofp); generate_printfun(a1, ofp); generate_endianfun(a1, ofp); + generate_version_tuple(a1, ofp); generate_bottom_boilerplate(ofp); } diff --git a/src/tools/vppapigen/node.h b/src/tools/vppapigen/node.h index 65bd5d10060..58570d8d096 100644 --- a/src/tools/vppapigen/node.h +++ b/src/tools/vppapigen/node.h @@ -44,6 +44,7 @@ enum node_subclass { /* WARNING: indices must match the vft... */ NODE_VECTOR, NODE_COMPLEX, NODE_NOVERSION, + NODE_VERSION, NODE_UWORD, NODE_N_TYPES, /* number of node types with VFT's */ @@ -77,10 +78,15 @@ typedef struct node_ { /* To shut up gcc-4.2.x warnings */ #define CDATA0 ((char *)(this->data[0])) -#define IDATA1 ((int)(uword)(this->data[1])) +#define CDATA1 ((char *)(this->data[0])) #define CDATA2 ((char *)(this->data[2])) #define CDATA3 ((char *)(this->data[3])) +#define IDATA0 ((int)(uword)(this->data[0])) +#define IDATA1 ((int)(uword)(this->data[1])) +#define IDATA2 ((int)(uword)(this->data[2])) +#define IDATA3 ((int)(uword)(this->data[3])) + #define NODE_FLAG_MANUAL_PRINT (1<<0) #define NODE_FLAG_MANUAL_ENDIAN (1<<1) #define NODE_FLAG_TYPEONLY (1<<3) diff --git a/src/vlibapi/api.h b/src/vlibapi/api.h index 49f5d5fb085..6820a541cba 100644 --- a/src/vlibapi/api.h +++ b/src/vlibapi/api.h @@ -114,6 +114,8 @@ vl_api_trace_t *vl_msg_api_trace_get (api_main_t * am, vl_api_trace_which_t which); void vl_msg_api_add_msg_name_crc (api_main_t * am, const char *string, u32 id); +void vl_msg_api_add_version (api_main_t * am, const char *string, + u32 major, u32 minor, u32 patch); /* node_serialize.c prototypes */ u8 *vlib_node_serialize (vlib_node_main_t * nm, u8 * vector, u32 max_threads, int include_nexts, diff --git a/src/vlibapi/api_common.h b/src/vlibapi/api_common.h index 845199efcd0..56b036d7f07 100644 --- a/src/vlibapi/api_common.h +++ b/src/vlibapi/api_common.h @@ -186,6 +186,14 @@ typedef struct _vl_msg_api_init_function_list_elt vl_msg_api_init_function_t *f; } _vl_msg_api_function_list_elt_t; +typedef struct +{ + u32 major; + u32 minor; + u32 patch; + char name[64]; +} api_version_t; + /** API main structure, used by both vpp and binary API clients */ typedef struct { @@ -312,6 +320,9 @@ typedef struct /** client message index hash table */ uword *msg_index_by_name_and_crc; + /** api version list */ + api_version_t *api_version_list; + /** Shared VM binary API region name */ const char *region_name; diff --git a/src/vlibapi/api_shared.c b/src/vlibapi/api_shared.c index 27898c3b952..831e863393b 100644 --- a/src/vlibapi/api_shared.c +++ b/src/vlibapi/api_shared.c @@ -915,6 +915,15 @@ vl_msg_api_add_msg_name_crc (api_main_t * am, const char *string, u32 id) hash_set_mem (am->msg_index_by_name_and_crc, string, id); } +void +vl_msg_api_add_version (api_main_t * am, const char *string, + u32 major, u32 minor, u32 patch) +{ + api_version_t version = {.major = major,.minor = minor,.patch = patch }; + ASSERT (strlen (string) < 64); + strncpy (version.name, string, 64); + vec_add1 (am->api_version_list, version); +} /* * fd.io coding-style-patch-verification: ON diff --git a/src/vlibmemory/memclnt.api b/src/vlibmemory/memclnt.api index 94c99ad5d45..6d6a1fe06dc 100644 --- a/src/vlibmemory/memclnt.api +++ b/src/vlibmemory/memclnt.api @@ -14,6 +14,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /* * Create a client registration */ @@ -98,6 +100,27 @@ define get_first_msg_id_reply { u16 first_msg_id; }; +/* + * Get API version table (includes built-in and plugins) + */ +typeonly define module_version { + u32 major; + u32 minor; + u32 patch; + u8 name[64]; +}; +define api_versions { + u32 client_index; + u32 context; +}; +define api_versions_reply { + u32 client_index; + u32 context; + i32 retval; + u32 count; + vl_api_module_version_t api_versions[count]; +}; + /* * Trace the plugin message-id allocator * so we stand a chance of dealing with different sets of plugins diff --git a/src/vlibmemory/memory_vlib.c b/src/vlibmemory/memory_vlib.c index 2242abcfedf..c3aef65e854 100644 --- a/src/vlibmemory/memory_vlib.c +++ b/src/vlibmemory/memory_vlib.c @@ -470,12 +470,48 @@ vl_api_memclnt_keepalive_t_handler (vl_api_memclnt_keepalive_t * mp) vl_msg_api_send_shmem (shmem_hdr->vl_input_queue, (u8 *) & rmp); } +void +vl_api_api_versions_t_handler (vl_api_api_versions_t * mp) +{ + api_main_t *am = &api_main; + vl_api_api_versions_reply_t *rmp; + unix_shared_memory_queue_t *q; + u32 nmsg = vec_len (am->api_version_list); + int msg_size = sizeof (*rmp) + sizeof (rmp->api_versions[0]) * nmsg; + int i; + + q = vl_api_client_index_to_input_queue (mp->client_index); + if (q == 0) + return; + + rmp = vl_msg_api_alloc (msg_size); + memset (rmp, 0, msg_size); + rmp->_vl_msg_id = ntohs (VL_API_API_VERSIONS_REPLY); + + /* fill in the message */ + rmp->context = mp->context; + rmp->count = htonl (nmsg); + + for (i = 0; i < nmsg; ++i) + { + api_version_t *vl = &am->api_version_list[i]; + rmp->api_versions[i].major = htonl (vl->major); + rmp->api_versions[i].minor = htonl (vl->minor); + rmp->api_versions[i].patch = htonl (vl->patch); + strncpy ((char *) rmp->api_versions[i].name, vl->name, 64); + } + + vl_msg_api_send_shmem (q, (u8 *) & rmp); + +} + #define foreach_vlib_api_msg \ _(MEMCLNT_CREATE, memclnt_create) \ _(MEMCLNT_DELETE, memclnt_delete) \ _(GET_FIRST_MSG_ID, get_first_msg_id) \ _(MEMCLNT_KEEPALIVE, memclnt_keepalive) \ -_(MEMCLNT_KEEPALIVE_REPLY, memclnt_keepalive_reply) +_(MEMCLNT_KEEPALIVE_REPLY, memclnt_keepalive_reply) \ +_(API_VERSIONS, api_versions) /* * vl_api_init diff --git a/src/vnet/bfd/bfd.api b/src/vnet/bfd/bfd.api index 7bcaa4c322f..1c5c578619e 100644 --- a/src/vnet/bfd/bfd.api +++ b/src/vnet/bfd/bfd.api @@ -13,6 +13,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /** \brief Set BFD echo source @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/vnet/classify/classify.api b/src/vnet/classify/classify.api index cacb9bed7d4..de9de773858 100644 --- a/src/vnet/classify/classify.api +++ b/src/vnet/classify/classify.api @@ -13,6 +13,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /** \brief Add/Delete classification table request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/vnet/cop/cop.api b/src/vnet/cop/cop.api index 693160018a4..a11b45170a4 100644 --- a/src/vnet/cop/cop.api +++ b/src/vnet/cop/cop.api @@ -13,6 +13,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /** \brief cop: enable/disable junk filtration features on an interface @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/vnet/devices/af_packet/af_packet.api b/src/vnet/devices/af_packet/af_packet.api index 8d40ad60c02..f815042ad55 100644 --- a/src/vnet/devices/af_packet/af_packet.api +++ b/src/vnet/devices/af_packet/af_packet.api @@ -13,6 +13,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /** \brief Create host-interface @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/vnet/devices/netmap/netmap.api b/src/vnet/devices/netmap/netmap.api index 8dc698b999b..d2de03388ea 100644 --- a/src/vnet/devices/netmap/netmap.api +++ b/src/vnet/devices/netmap/netmap.api @@ -13,6 +13,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /** \brief Create netmap @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/vnet/devices/virtio/vhost_user.api b/src/vnet/devices/virtio/vhost_user.api index 28d5e8916b6..6f21cb6c3ab 100644 --- a/src/vnet/devices/virtio/vhost_user.api +++ b/src/vnet/devices/virtio/vhost_user.api @@ -13,6 +13,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /** \brief vhost-user interface create request @param client_index - opaque cookie to identify the sender @param is_server - our side is socket server diff --git a/src/vnet/dhcp/dhcp.api b/src/vnet/dhcp/dhcp.api index c632c0877ae..628b674e1c6 100644 --- a/src/vnet/dhcp/dhcp.api +++ b/src/vnet/dhcp/dhcp.api @@ -13,6 +13,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /** \brief DHCP Proxy config add / del request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/vnet/ethernet/p2p_ethernet.api b/src/vnet/ethernet/p2p_ethernet.api index 8fb66376522..ead7cab9f80 100644 --- a/src/vnet/ethernet/p2p_ethernet.api +++ b/src/vnet/ethernet/p2p_ethernet.api @@ -13,6 +13,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + define p2p_ethernet_add { u32 client_index; diff --git a/src/vnet/flow/flow.api b/src/vnet/flow/flow.api index 1c5e8c5c1fe..6c49428f152 100644 --- a/src/vnet/flow/flow.api +++ b/src/vnet/flow/flow.api @@ -13,6 +13,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /** \brief Configure IPFIX exporter process request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/vnet/gre/gre.api b/src/vnet/gre/gre.api index 28f6dbc94fa..1091835617c 100644 --- a/src/vnet/gre/gre.api +++ b/src/vnet/gre/gre.api @@ -13,6 +13,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + define gre_add_del_tunnel { u32 client_index; diff --git a/src/vnet/interface.api b/src/vnet/interface.api index 94ecdd9f9ff..2f2e8373357 100644 --- a/src/vnet/interface.api +++ b/src/vnet/interface.api @@ -1,3 +1,5 @@ +vl_api_version 1.0.0 + /** \brief Set flags on the interface @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/vnet/ip/ip.api b/src/vnet/ip/ip.api index 4b7019f087e..69ab7011943 100644 --- a/src/vnet/ip/ip.api +++ b/src/vnet/ip/ip.api @@ -19,6 +19,8 @@ called through a shared memory interface. */ +vl_api_version 1.0.0 + /** \brief Add / del table request A table can be added multiple times, but need be deleted only once. @param client_index - opaque cookie to identify the sender diff --git a/src/vnet/ipsec-gre/ipsec_gre.api b/src/vnet/ipsec-gre/ipsec_gre.api index 793bca0afcd..ad6ec4e84e0 100644 --- a/src/vnet/ipsec-gre/ipsec_gre.api +++ b/src/vnet/ipsec-gre/ipsec_gre.api @@ -13,6 +13,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /** \brief Add / del ipsec gre tunnel request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/vnet/ipsec/ipsec.api b/src/vnet/ipsec/ipsec.api index 4e283b6069e..14d6c187503 100644 --- a/src/vnet/ipsec/ipsec.api +++ b/src/vnet/ipsec/ipsec.api @@ -13,6 +13,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /** \brief IPsec: Add/delete Security Policy Database @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/vnet/l2/l2.api b/src/vnet/l2/l2.api index ac923de4032..18383652827 100644 --- a/src/vnet/l2/l2.api +++ b/src/vnet/l2/l2.api @@ -14,6 +14,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /** \brief Reply to l2_xconnect_dump @param context - sender context which was passed in the request @param rx_sw_if_index - Receive interface index diff --git a/src/vnet/l2tp/l2tp.api b/src/vnet/l2tp/l2tp.api index 4587a8076ec..1ccf71b89a7 100644 --- a/src/vnet/l2tp/l2tp.api +++ b/src/vnet/l2tp/l2tp.api @@ -13,6 +13,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /** \brief l2tpv3 tunnel interface create request @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/lisp.api b/src/vnet/lisp-cp/lisp.api index 8bed71b3bf7..7ec17d99799 100644 --- a/src/vnet/lisp-cp/lisp.api +++ b/src/vnet/lisp-cp/lisp.api @@ -13,6 +13,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + typeonly manual_print manual_endian define local_locator { u32 sw_if_index; diff --git a/src/vnet/lisp-cp/one.api b/src/vnet/lisp-cp/one.api index 39f2802da29..6cb2ef3a620 100644 --- a/src/vnet/lisp-cp/one.api +++ b/src/vnet/lisp-cp/one.api @@ -13,6 +13,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + typeonly manual_print manual_endian define one_local_locator { u32 sw_if_index; diff --git a/src/vnet/lisp-gpe/lisp_gpe.api b/src/vnet/lisp-gpe/lisp_gpe.api index 07ee3d7bf77..626038fc234 100644 --- a/src/vnet/lisp-gpe/lisp_gpe.api +++ b/src/vnet/lisp-gpe/lisp_gpe.api @@ -13,6 +13,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /** \brief GPE locator structure @param is_ip4 - whether addr is IPv4 or v6 @param weight - locator weight diff --git a/src/vnet/lldp/lldp.api b/src/vnet/lldp/lldp.api index 02fe32ca742..8117ed41b9c 100644 --- a/src/vnet/lldp/lldp.api +++ b/src/vnet/lldp/lldp.api @@ -13,6 +13,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /** \brief configure global parameter for LLDP @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 4b142c8fb4a..14f10e73342 100644 --- a/src/vnet/map/map.api +++ b/src/vnet/map/map.api @@ -13,6 +13,7 @@ * limitations under the License. */ +vl_api_version 1.0.0 /** \brief Add 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 36488d0c7b9..3c817db1306 100644 --- a/src/vnet/mpls/mpls.api +++ b/src/vnet/mpls/mpls.api @@ -13,6 +13,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /** \brief Bind/Unbind an MPLS local label to an IP prefix. i.e. create a per-prefix label entry. @param client_index - opaque cookie to identify the sender diff --git a/src/vnet/policer/policer.api b/src/vnet/policer/policer.api index 26c69032907..13024ddee15 100644 --- a/src/vnet/policer/policer.api +++ b/src/vnet/policer/policer.api @@ -13,6 +13,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /** \brief Add/del policer @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/vnet/session/session.api b/src/vnet/session/session.api index 30d2ae96bff..992a0638698 100644 --- a/src/vnet/session/session.api +++ b/src/vnet/session/session.api @@ -12,7 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + +vl_api_version 1.0.0 + /** \brief client->vpp, attach application to session layer @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/vnet/span/span.api b/src/vnet/span/span.api index 03cd60ecf24..a0f29153d27 100644 --- a/src/vnet/span/span.api +++ b/src/vnet/span/span.api @@ -14,6 +14,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /** \brief Enable/Disable span to mirror traffic from one interface to another @param client_index - opaque cookie to identify the sender @param context - sender context which was passed in the request diff --git a/src/vnet/srv6/sr.api b/src/vnet/srv6/sr.api index 9e9007418b5..2c72cc55ed2 100644 --- a/src/vnet/srv6/sr.api +++ b/src/vnet/srv6/sr.api @@ -1,3 +1,4 @@ +/* Hey Emacs use -*- mode: C -*- */ /* * Copyright (c) 2015-2016 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,6 +14,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /** \brief IPv6 SR LocalSID add/del request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @@ -20,7 +23,8 @@ @param localsid_addr IPv6 address of the localsid @param end_psp Boolean of whether decapsulation is allowed in this function @param behavior Type of behavior (function) for this localsid - @param sw_if_index Only for L2/L3 xconnect. OIF. In VRF variant the fib_table. + @param sw_if_index Only for L2/L3 xconnect. OIF. In VRF variant the + fib_table. @param vlan_index Only for L2 xconnect. Outgoing VLAN tag. @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. @@ -161,7 +165,7 @@ autoreply define sr_steering_add_del };*/ /* - * fd.io coding-style-patch-verification: ON + * fd.io coding-style-patch-verification: OFF * Local Variables: * eval: (c-set-style "gnu") * End: diff --git a/src/vnet/unix/tap.api b/src/vnet/unix/tap.api index d9fba37134e..6b1b2b4f0fc 100644 --- a/src/vnet/unix/tap.api +++ b/src/vnet/unix/tap.api @@ -19,6 +19,8 @@ the Linux kernel TAP device driver */ +vl_api_version 1.0.0 + /** \brief Initialize a new tap interface with the given paramters @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/vnet/vxlan-gpe/vxlan_gpe.api b/src/vnet/vxlan-gpe/vxlan_gpe.api index 04082d69c65..6391148f687 100644 --- a/src/vnet/vxlan-gpe/vxlan_gpe.api +++ b/src/vnet/vxlan-gpe/vxlan_gpe.api @@ -13,6 +13,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + define vxlan_gpe_add_del_tunnel { u32 client_index; diff --git a/src/vnet/vxlan/vxlan.api b/src/vnet/vxlan/vxlan.api index 6c331a58223..64850f0449f 100644 --- a/src/vnet/vxlan/vxlan.api +++ b/src/vnet/vxlan/vxlan.api @@ -13,7 +13,9 @@ * limitations under the License. */ - define vxlan_add_del_tunnel +vl_api_version 1.0.0 + +define vxlan_add_del_tunnel { u32 client_index; u32 context; diff --git a/src/vpp/api/api.c b/src/vpp/api/api.c index 5d4a63b9061..7350936d061 100644 --- a/src/vpp/api/api.c +++ b/src/vpp/api/api.c @@ -2445,6 +2445,11 @@ setup_message_id_table (api_main_t * am) foreach_vl_msg_name_crc_memclnt; foreach_vl_msg_name_crc_vpe; #undef _ + +#define vl_api_version_tuple(n,mj, mi, p) \ + vl_msg_api_add_version (am, #n, mj, mi, p); +#include +#undef vl_api_version_tuple } diff --git a/src/vpp/api/vpe.api b/src/vpp/api/vpe.api index b8e581891df..f0f6f41f7eb 100644 --- a/src/vpp/api/vpe.api +++ b/src/vpp/api/vpe.api @@ -19,6 +19,8 @@ called through a shared memory interface. */ +vl_api_version 1.0.0 + /* * Note: API placement cleanup in progress * If you're looking for interface APIs, please diff --git a/src/vpp/stats/stats.api b/src/vpp/stats/stats.api index caf8f51543d..ec1ca663adc 100644 --- a/src/vpp/stats/stats.api +++ b/src/vpp/stats/stats.api @@ -18,6 +18,7 @@ This file defines the stats API */ +vl_api_version 1.0.0 /** \brief Want Stats, enable/disable ALL stats updates @param client_index - opaque cookie to identify the sender -- 2.16.6