From aa6920e0a80d8271be1dda59f613a1d2b0e1d3e6 Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Mon, 27 Jun 2016 09:25:13 -0400 Subject: [PATCH] More janitorial work Install vpp api header files in /usr/include/vpp-api, instead of /usr/include/api. Someone will eventually complain if we continue with the status quo. Generate /usr/bin/vpp_plugin_configure, to correctly configure standalone plugin compilation against header files installed from the dev package. If a plugin's CFLAGS don't precisely match the installed vpp engine binary, subtle misbehavior can and will occur. Example: the ip4/ip6 main_t structure size / member offsets depend on DPDK=[0|1]. Screw that one up, and your brand-new configurable ip feature will mysteriously fail to appear, even though the plugin loads perfectly. Change-Id: I20c97fe1042808a79935863209d995c31953b98c Signed-off-by: Dave Barach --- vpp-api-test/vat/api_format.c | 10 ++--- vpp-api/java/Makefile.am | 8 ++-- vpp-api/java/japi/vppjni.c | 10 ++--- vpp-api/java/jvpp/jvpp.c | 10 ++--- vpp-api/python/Makefile.am | 4 +- vpp-api/python/pneum/pneum.c | 8 ++-- vpp-api/python/pneum/test_pneum.c | 4 +- vpp/Makefile.am | 50 ++++++++++++++++------ vpp/api/n1k_harness.c | 66 ----------------------------- vpp/stats/stats.c | 8 ++-- vpp/vnet/main.c | 2 +- vpp/{api => vpp-api}/api.c | 10 ++--- vpp/{api => vpp-api}/custom_dump.c | 6 +-- vpp/{api => vpp-api}/gmon.c | 0 vpp/{api => vpp-api}/summary_stats_client.c | 8 ++-- vpp/{api => vpp-api}/test_client.c | 10 ++--- vpp/{api => vpp-api}/test_ha.c | 8 ++-- vpp/{api => vpp-api}/vpe.api | 0 vpp/{api => vpp-api}/vpe_all_api_h.h | 2 +- vpp/{api => vpp-api}/vpe_msg_enum.h | 2 +- vppapigen/node.c | 10 ++--- 21 files changed, 98 insertions(+), 138 deletions(-) delete mode 100644 vpp/api/n1k_harness.c rename vpp/{api => vpp-api}/api.c (99%) rename vpp/{api => vpp-api}/custom_dump.c (99%) rename vpp/{api => vpp-api}/gmon.c (100%) rename vpp/{api => vpp-api}/summary_stats_client.c (98%) rename vpp/{api => vpp-api}/test_client.c (99%) rename vpp/{api => vpp-api}/test_ha.c (97%) rename vpp/{api => vpp-api}/vpe.api (100%) rename vpp/{api => vpp-api}/vpe_all_api_h.h (96%) rename vpp/{api => vpp-api}/vpe_msg_enum.h (96%) diff --git a/vpp-api-test/vat/api_format.c b/vpp-api-test/vat/api_format.c index 50654aa5634..b00dcccd31a 100644 --- a/vpp-api-test/vat/api_format.c +++ b/vpp-api-test/vat/api_format.c @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include #include @@ -49,19 +49,19 @@ #include "vat/json_format.h" #define vl_typedefs /* define message structures */ -#include +#include #undef vl_typedefs /* declare message handlers for each api */ #define vl_endianfun /* define message structures */ -#include +#include #undef vl_endianfun /* instantiate all the print functions we know about */ #define vl_print(handle, ...) #define vl_printfun -#include +#include #undef vl_printfun uword unformat_sw_if_index (unformat_input_t * input, va_list * args) @@ -12188,7 +12188,7 @@ void vat_api_hookup (vat_main_t *vam) #undef vl_api_version #define vl_api_version(n,v) static u32 vpe_api_version = v; -#include +#include #undef vl_api_version void vl_client_add_api_signatures (vl_api_memclnt_create_t *mp) diff --git a/vpp-api/java/Makefile.am b/vpp-api/java/Makefile.am index cb841ee2fc9..c06caf5459c 100644 --- a/vpp-api/java/Makefile.am +++ b/vpp-api/java/Makefile.am @@ -54,7 +54,7 @@ japi/org_openvpp_vppjapi_vppConn.h: \ japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java \ japi/org/openvpp/vppjapi/vppConn.java \ japi/org/openvpp/vppjapi/vppApiCallbacks.java \ - ../../vpp/api/vpe.api.h + ../../vpp/vpp-api/vpe.api.h $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppVersion.java ; \ $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppVersion ; \ $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppInterfaceDetails.java ; \ @@ -79,8 +79,8 @@ japi/org_openvpp_vppjapi_vppConn.h: \ japi/vppapi.c: japi/org_openvpp_vppjapi_vppConn.h pushd .. ; dir=`pwd` ; popd ; \ instdir=`echo $${dir} | sed -e 's:build-root/build:build-root/install:'` ; \ - vppapigen --input $${instdir}/../vpp/api/vpe.api --jni japi/vppapi.c --app vpe ; \ - vppapigen --input $${instdir}/../vpp/api/vpe.api --java japi/vppApi.java --app vpe ; \ + vppapigen --input $${instdir}/../vpp/vpp-api/vpe.api --jni japi/vppapi.c --app vpe ; \ + vppapigen --input $${instdir}/../vpp/vpp-api/vpe.api --java japi/vppApi.java --app vpe ; \ $(JAVAC) -classpath . -d . japi/vppApi.java ; \ $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppApi ; \ $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppApiCallbacks.java ; \ @@ -112,7 +112,7 @@ JAVAROOT = . BUILT_SOURCES += jvpp/org_openvpp_jvpp_VppJNIConnection.h jvpp/jvpp.c -jvpp/org_openvpp_jvpp_VppJNIConnection.h: $(prefix)/../vpp/api/vpe.api +jvpp/org_openvpp_jvpp_VppJNIConnection.h: $(prefix)/../vpp/vpp-api/vpe.api @echo " jVpp API"; \ cp -rf @srcdir@/jvpp/* -t jvpp/; \ mkdir -p jvpp/gen/target/org/openvpp/jvpp; \ diff --git a/vpp-api/java/japi/vppjni.c b/vpp-api/java/japi/vppjni.c index f1b8eda110f..2b58b360015 100644 --- a/vpp-api/java/japi/vppjni.c +++ b/vpp-api/java/japi/vppjni.c @@ -16,7 +16,7 @@ #include #define vl_api_version(n,v) static u32 vpe_api_version = (v); -#include +#include #undef vl_api_version #include @@ -26,19 +26,19 @@ #include #include -#include +#include #define vl_typedefs /* define message structures */ -#include +#include #undef vl_typedefs #define vl_endianfun -#include +#include #undef vl_endianfun /* instantiate all the print functions we know about */ #define vl_print(handle, ...) #define vl_printfun -#include +#include #undef vl_printfun #ifndef VPPJNI_DEBUG diff --git a/vpp-api/java/jvpp/jvpp.c b/vpp-api/java/jvpp/jvpp.c index 00c50f95beb..37aef8032cd 100644 --- a/vpp-api/java/jvpp/jvpp.c +++ b/vpp-api/java/jvpp/jvpp.c @@ -16,7 +16,7 @@ #include #define vl_api_version(n,v) static u32 vpe_api_version = (v); -#include +#include #undef vl_api_version #include @@ -24,19 +24,19 @@ #include #include -#include +#include #define vl_typedefs /* define message structures */ -#include +#include #undef vl_typedefs #define vl_endianfun -#include +#include #undef vl_endianfun /* instantiate all the print functions we know about */ #define vl_print(handle, ...) #define vl_printfun -#include +#include #undef vl_printfun #ifndef VPPJNI_DEBUG diff --git a/vpp-api/python/Makefile.am b/vpp-api/python/Makefile.am index b96ff3d9201..4d2d221d231 100644 --- a/vpp-api/python/Makefile.am +++ b/vpp-api/python/Makefile.am @@ -33,11 +33,11 @@ libpneum_la_CPPFLAGS = BUILT_SOURCES += vpp_papi.py -vpp_papi.py: $(prefix)/../vpp/api/vpe.api pneum/api-gen.py +vpp_papi.py: $(prefix)/../vpp/vpp-api/vpe.api pneum/api-gen.py @echo " PYTHON API"; \ $(CC) $(CPPFLAGS) -E -P -C -x c $< \ | vppapigen --input - --python defs_$@; \ - echo "#include " \ + echo "#include " \ | $(CC) $(CPPFLAGS) -E -P -x c - | grep VL_API \ | @srcdir@/pneum/api-gen.py -i defs_$@ > @srcdir@/vpp_papi/$@ diff --git a/vpp-api/python/pneum/pneum.c b/vpp-api/python/pneum/pneum.c index 971c79bf6aa..ac518493163 100644 --- a/vpp-api/python/pneum/pneum.c +++ b/vpp-api/python/pneum/pneum.c @@ -31,16 +31,16 @@ #include #include -#include +#include #include "pneum.h" #define vl_typedefs /* define message structures */ -#include +#include #undef vl_typedefs #define vl_endianfun /* define message structures */ -#include +#include #undef vl_endianfun typedef struct { @@ -63,7 +63,7 @@ void vlib_cli_output (struct vlib_main_t * vm, char * fmt, ...) } #define vl_api_version(n,v) static u32 vpe_api_version = v; -#include +#include #undef vl_api_version void vl_client_add_api_signatures (vl_api_memclnt_create_t *mp) diff --git a/vpp-api/python/pneum/test_pneum.c b/vpp-api/python/pneum/test_pneum.c index 18627b3f2c5..b3131953e8f 100644 --- a/vpp-api/python/pneum/test_pneum.c +++ b/vpp-api/python/pneum/test_pneum.c @@ -36,13 +36,13 @@ #include #include -#include +#include #include #include #include "pneum.h" #define vl_typedefs /* define message structures */ -#include +#include #undef vl_typedefs volatile int sigterm_received = 0; diff --git a/vpp/Makefile.am b/vpp/Makefile.am index 4c28fb795db..5577c0755e0 100644 --- a/vpp/Makefile.am +++ b/vpp/Makefile.am @@ -30,25 +30,25 @@ vpp_SOURCES = \ stats/stats.c vpp_SOURCES += \ - api/api.c \ - api/custom_dump.c + vpp-api/api.c \ + vpp-api/custom_dump.c # comment out to disable stats upload to gmond vpp_SOURCES += \ - api/gmon.c + vpp-api/gmon.c nobase_include_HEADERS = \ - api/vpe_all_api_h.h \ - api/vpe_msg_enum.h \ - api/vpe.api.h + vpp-api/vpe_all_api_h.h \ + vpp-api/vpe_msg_enum.h \ + vpp-api/vpe.api.h # install the API definition, so we can produce java bindings, etc. -apidir = $(prefix)/api -api_DATA = api/vpe.api +apidir = $(prefix)/vpp-api +api_DATA = vpp-api/vpe.api -BUILT_SOURCES += api/vpe.api.h app/version.h +BUILT_SOURCES += vpp-api/vpe.api.h app/version.h app/version.o: app/version.h @@ -62,6 +62,32 @@ app/version.h: @echo "#define VPP_BUILD_TOPDIR \"$$(git rev-parse --show-toplevel)\"" >> $@ @echo "#define VPP_BUILD_VER \"$$(../../scripts/version)\"" >> $@ +# Generate a plugin configuration script. Misconfiguring a +# plugin can cause very subtle problems. + +bin_SCRIPTS = vpp_plugin_configure + +BUILT_SOURCES += vpp_plugin_configure + +.PHONY: vpp_plugin_configure + +vpp_plugin_configure: + @echo "PLUGIN CONFIGURE " $@ + @echo "#!/bin/bash" > $@ + @echo " " >> $@ + @echo "set +eu" >> $@ + @echo " " >> $@ + @echo "if [ -f ./configure ] ; then" >> $@ + @echo " CFLAGS='$(CFLAGS) $(AM_CFLAGS) -I/usr/include/vpp-dpdk' ./configure --with-plugin-toolkit" >> $@ + @echo "else" >> $@ + @echo " if [ -f ../configure ] ; then" >> $@ + @echo " CFLAGS='$(CFLAGS) $(AM_CFLAGS) -I/usr/include/vpp-dpdk' ../configure --with-plugin-toolkit" >> $@ + @echo " else" >> $@ + @echo " echo Couldnt find ./configure or ../configure " >> $@ + @echo " exit 1" >> $@ + @echo " fi" >> $@ + @echo "fi" >> $@ + vpp_LDADD = -lvlibapi -lvlibmemory -lvlib_unix -lvlib vpp_LDADD += -lvnet @@ -97,13 +123,13 @@ SUFFIXES = .api.h .api noinst_PROGRAMS += test_client -test_client_SOURCES = api/test_client.c +test_client_SOURCES = vpp-api/test_client.c test_client_LDADD = -lvlibmemoryclient -lvlibapi -lsvm -lvppinfra \ -lpthread -lm -lrt noinst_PROGRAMS += test_client test_ha -test_ha_SOURCES = api/test_ha.c +test_ha_SOURCES = vpp-api/test_ha.c test_ha_LDADD = -lvlibmemoryclient -lvlibapi -lsvmdb -lsvm -lvppinfra \ -lpthread -lm -lrt @@ -111,6 +137,6 @@ test_ha_LDADD = -lvlibmemoryclient -lvlibapi -lsvmdb -lsvm -lvppinfra \ noinst_PROGRAMS += summary_stats_client -summary_stats_client_SOURCES = api/summary_stats_client.c +summary_stats_client_SOURCES = vpp-api/summary_stats_client.c summary_stats_client_LDADD = -lvlibmemoryclient -lvlibapi -lsvm -lvppinfra \ -lpthread -lm -lrt diff --git a/vpp/api/n1k_harness.c b/vpp/api/n1k_harness.c deleted file mode 100644 index 4a5df4bdc2c..00000000000 --- a/vpp/api/n1k_harness.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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. - */ -#include -#include - -void vlib_cli_output (void * vm, char * fmt, ...) -{ clib_warning ("%s", fmt); } - -/* - * build system finesse hack - * since we can't build everything in one build system, this - * hack exists to make sure that the invoked program runs against - * the right libraries. - */ - -int main (int argc, char ** argv) -{ - void *handle, *main_handle; - int (*fp)(int argc, char **argv); - int rv; - - /* n1k_harness */ - - if (argc < 2) { - fformat (stderr, "usage: %s [...]\n", - argv[0]); - exit (1); - } - - handle = dlopen (argv[1], 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()); - exit(1); - } - - main_handle = dlsym (handle, "plugin_main"); - if (main_handle == 0) { - clib_warning ("plugin_main(int argc, char **argv) missing...\n"); - exit(1); - } - - fp = main_handle; - - rv = (*fp)(argc-2, argv+2); - - return rv; -} diff --git a/vpp/stats/stats.c b/vpp/stats/stats.c index 566655d2905..2d366fa5ee2 100644 --- a/vpp/stats/stats.c +++ b/vpp/stats/stats.c @@ -22,23 +22,23 @@ stats_main_t stats_main; #include -#include +#include #define f64_endian(a) #define f64_print(a,b) #define vl_typedefs /* define message structures */ -#include +#include #undef vl_typedefs #define vl_endianfun /* define message structures */ -#include +#include #undef vl_endianfun /* instantiate all the print functions we know about */ #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) #define vl_printfun -#include +#include #undef vl_printfun #define foreach_stats_msg \ diff --git a/vpp/vnet/main.c b/vpp/vnet/main.c index a1c5427f06e..6795407466a 100644 --- a/vpp/vnet/main.c +++ b/vpp/vnet/main.c @@ -19,7 +19,7 @@ #include #include -#include +#include #if DPDK #include diff --git a/vpp/api/api.c b/vpp/vpp-api/api.c similarity index 99% rename from vpp/api/api.c rename to vpp/vpp-api/api.c index 302b7d4ea50..2ea92df019e 100644 --- a/vpp/api/api.c +++ b/vpp/vpp-api/api.c @@ -101,23 +101,23 @@ #include #include -#include +#include #define f64_endian(a) #define f64_print(a,b) #define vl_typedefs /* define message structures */ -#include +#include #undef vl_typedefs #define vl_endianfun /* define message structures */ -#include +#include #undef vl_endianfun /* instantiate all the print functions we know about */ #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) #define vl_printfun -#include +#include #undef vl_printfun #define REPLY_MACRO(t) \ @@ -7059,7 +7059,7 @@ void * get_unformat_vnet_sw_interface (void) #undef vl_api_version #define vl_api_version(n,v) static u32 vpe_api_version = v; -#include +#include #undef vl_api_version int vl_msg_api_version_check (vl_api_memclnt_create_t * mp) diff --git a/vpp/api/custom_dump.c b/vpp/vpp-api/custom_dump.c similarity index 99% rename from vpp/api/custom_dump.c rename to vpp/vpp-api/custom_dump.c index 123883fb6c8..ac90a56f83d 100644 --- a/vpp/api/custom_dump.c +++ b/vpp/vpp-api/custom_dump.c @@ -38,14 +38,14 @@ #include #include -#include +#include #define vl_typedefs /* define message structures */ -#include +#include #undef vl_typedefs #define vl_endianfun /* define message structures */ -#include +#include #undef vl_endianfun #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) diff --git a/vpp/api/gmon.c b/vpp/vpp-api/gmon.c similarity index 100% rename from vpp/api/gmon.c rename to vpp/vpp-api/gmon.c diff --git a/vpp/api/summary_stats_client.c b/vpp/vpp-api/summary_stats_client.c similarity index 98% rename from vpp/api/summary_stats_client.c rename to vpp/vpp-api/summary_stats_client.c index 90b99f65db2..97e9f9d16fe 100644 --- a/vpp/api/summary_stats_client.c +++ b/vpp/vpp-api/summary_stats_client.c @@ -49,7 +49,7 @@ #include #include -#include +#include #include @@ -57,17 +57,17 @@ #define f64_print(a,b) #define vl_typedefs /* define message structures */ -#include +#include #undef vl_typedefs #define vl_endianfun /* define message structures */ -#include +#include #undef vl_endianfun /* instantiate all the print functions we know about */ #define vl_print(handle, ...) #define vl_printfun -#include +#include #undef vl_printfun vl_shmem_hdr_t *shmem_hdr; diff --git a/vpp/api/test_client.c b/vpp/vpp-api/test_client.c similarity index 99% rename from vpp/api/test_client.c rename to vpp/vpp-api/test_client.c index b3bf02eae83..92cf4531083 100644 --- a/vpp/api/test_client.c +++ b/vpp/vpp-api/test_client.c @@ -47,7 +47,7 @@ #include #include -#include +#include #include #include @@ -56,17 +56,17 @@ #define f64_print(a,b) #define vl_typedefs /* define message structures */ -#include +#include #undef vl_typedefs #define vl_endianfun /* define message structures */ -#include +#include #undef vl_endianfun /* instantiate all the print functions we know about */ #define vl_print(handle, ...) #define vl_printfun -#include +#include #undef vl_printfun vl_shmem_hdr_t *shmem_hdr; @@ -1523,7 +1523,7 @@ int main (int argc, char ** argv) #undef vl_api_version #define vl_api_version(n,v) static u32 vpe_api_version = v; -#include +#include #undef vl_api_version void vl_client_add_api_signatures (vl_api_memclnt_create_t *mp) diff --git a/vpp/api/test_ha.c b/vpp/vpp-api/test_ha.c similarity index 97% rename from vpp/api/test_ha.c rename to vpp/vpp-api/test_ha.c index 0c66394b07b..b3b39fea645 100644 --- a/vpp/api/test_ha.c +++ b/vpp/vpp-api/test_ha.c @@ -49,7 +49,7 @@ #include #include -#include +#include #include @@ -57,17 +57,17 @@ #define f64_print(a,b) #define vl_typedefs /* define message structures */ -#include +#include #undef vl_typedefs #define vl_endianfun /* define message structures */ -#include +#include #undef vl_endianfun /* instantiate all the print functions we know about */ #define vl_print(handle, ...) #define vl_printfun -#include +#include #undef vl_printfun vl_shmem_hdr_t *shmem_hdr; diff --git a/vpp/api/vpe.api b/vpp/vpp-api/vpe.api similarity index 100% rename from vpp/api/vpe.api rename to vpp/vpp-api/vpe.api diff --git a/vpp/api/vpe_all_api_h.h b/vpp/vpp-api/vpe_all_api_h.h similarity index 96% rename from vpp/api/vpe_all_api_h.h rename to vpp/vpp-api/vpe_all_api_h.h index a5be7b58ead..ca6776c6d90 100644 --- a/vpp/api/vpe_all_api_h.h +++ b/vpp/vpp-api/vpe_all_api_h.h @@ -21,4 +21,4 @@ #include /* Here are the vpe forwarder specific API definitions */ -#include +#include diff --git a/vpp/api/vpe_msg_enum.h b/vpp/vpp-api/vpe_msg_enum.h similarity index 96% rename from vpp/api/vpe_msg_enum.h rename to vpp/vpp-api/vpe_msg_enum.h index 79616a1bde8..fa194ee0eff 100644 --- a/vpp/api/vpe_msg_enum.h +++ b/vpp/vpp-api/vpe_msg_enum.h @@ -20,7 +20,7 @@ #define vl_msg_id(n,h) n, typedef enum { VL_ILLEGAL_MESSAGE_ID=0, -#include +#include VL_MSG_FIRST_AVAILABLE, } vl_msg_id_t; #undef vl_msg_id diff --git a/vppapigen/node.c b/vppapigen/node.c index 30a3b017190..449540c3858 100644 --- a/vppapigen/node.c +++ b/vppapigen/node.c @@ -1976,24 +1976,24 @@ void generate_jni_top_boilerplate(FILE *fp) fprintf (fp, "#define vl_api_version(n,v) static u32 %s_api_version %s = v;\n", vlib_app_name, "__attribute__((unused))"); - fprintf (fp, "#include \n", vlib_app_name); + fprintf (fp, "#include \n", vlib_app_name); fprintf (fp, "#undef vl_api_version\n\n"); fprintf (fp, "#include \n"); fprintf (fp, "#include \n\n", java_class); - fprintf (fp, "#include \n", vlib_app_name); + fprintf (fp, "#include \n", vlib_app_name); fprintf (fp, "#define vl_typedefs /* define message structures */\n"); - fprintf (fp, "#include \n", vlib_app_name); + fprintf (fp, "#include \n", vlib_app_name); fprintf (fp, "#undef vl_typedefs\n\n"); fprintf (fp, "#define vl_endianfun \n"); - fprintf (fp, "#include \n", vlib_app_name); + fprintf (fp, "#include \n", vlib_app_name); fprintf (fp, "#undef vl_endianfun\n\n"); fprintf (fp, "#define vl_print(handle, ...)\n"); fprintf (fp, "#define vl_printfun\n"); - fprintf (fp, "#include \n", vlib_app_name); + fprintf (fp, "#include \n", vlib_app_name); fprintf (fp, "#undef vl_printfun\n\n"); } -- 2.16.6