summaryrefslogtreecommitdiffstats
path: root/src/vpp/vnet
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2018-04-04 22:43:54 +0200
committerDave Barach <openvpp@barachs.net>2018-04-09 13:33:06 +0000
commit67d4c24b0a8d63c4b5a38d5c9c1ce72b75879f54 (patch)
tree74a18bea729d38b333e750c219849bebff8f35b2 /src/vpp/vnet
parent7bf3f9f70e8395c13ed235cb48ec1787b07cf2d9 (diff)
Autodetect plugin path
dpdk plugin self-disables if there are no hugepages available Change-Id: Ib286e1a370deeb21248e6e961573ef9c68759b4c Signed-off-by: Damjan Marion <damarion@cisco.com> Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vpp/vnet')
-rw-r--r--src/vpp/vnet/main.c54
1 files changed, 48 insertions, 6 deletions
diff --git a/src/vpp/vnet/main.c b/src/vpp/vnet/main.c
index b330f60fafe..6e136e19201 100644
--- a/src/vpp/vnet/main.c
+++ b/src/vpp/vnet/main.c
@@ -20,7 +20,53 @@
#include <vnet/ethernet/ethernet.h>
#include <vpp/app/version.h>
#include <vpp/api/vpe_msg_enum.h>
+#include <limits.h>
+/*
+ * Load plugins from /usr/lib/vpp_plugins by default
+ */
+char *vlib_plugin_path = "/usr/lib/vpp_plugins";
+char *vlib_plugin_app_version = VPP_BUILD_VER;
+
+static void
+vpp_find_plugin_path ()
+{
+ extern char *vat_plugin_path;
+ char *p, path[PATH_MAX];
+ int rv;
+ u8 *s;
+
+ /* find executable path */
+ if ((rv = readlink ("/proc/self/exe", path, PATH_MAX - 1)) == -1)
+ return;
+
+ /* readlink doesn't provide null termination */
+ path[rv] = 0;
+
+ /* strip filename */
+ if ((p = strrchr (path, '/')) == 0)
+ return;
+ *p = 0;
+
+ /* strip bin/ */
+ if ((p = strrchr (path, '/')) == 0)
+ return;
+ *p = 0;
+
+ s = format (0, "%s/lib/vpp_plugins", path);
+#if uword_bits == 64
+ s = format (s, ":%s/lib64/vpp_plugins", path);
+#endif
+ vec_add1 (s, 0);
+ vlib_plugin_path = (char *) s;
+
+ s = format (0, "%s/lib/vpp_api_test_plugins", path);
+#if uword_bits == 64
+ s = format (s, ":%s/lib64/vpp_api_test_plugins", path);
+#endif
+ vec_add1 (s, 0);
+ vat_plugin_path = (char *) s;
+}
static void
vpe_main_init (vlib_main_t * vm)
@@ -39,6 +85,8 @@ vpe_main_init (vlib_main_t * vm)
* Create the binary api plugin hashes before loading plugins
*/
vat_plugin_hash_create ();
+
+ vpp_find_plugin_path ();
}
/*
@@ -46,12 +94,6 @@ vpe_main_init (vlib_main_t * vm)
*/
char *vlib_default_runtime_dir = "vpp";
-/*
- * Load plugins from /usr/lib/vpp_plugins by default
- */
-char *vlib_plugin_path = "/usr/lib/vpp_plugins";
-char *vlib_plugin_app_version = VPP_BUILD_VER;
-
int
main (int argc, char *argv[])
{