summaryrefslogtreecommitdiffstats
path: root/src/vlib/format.c
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2019-01-21 17:41:25 +0100
committerDamjan Marion <dmarion@me.com>2019-01-31 22:08:54 +0000
commit362456a9bdc5ffc440bf776c3685ba81b8513f6e (patch)
treedb06209bef7bd0fbf5dceb94c2126a782f369040 /src/vlib/format.c
parent35467f112acb21fe1ea287c7d8794b0859f149c0 (diff)
Add 'show vlib graphviz' command
Add a new command to dump vlib graph as graphviz/dot file Change-Id: I43fc072cff8153ac500e5fbc6641a3705c2e995e Signed-off-by: Benoît Ganne <bganne@cisco.com>
Diffstat (limited to 'src/vlib/format.c')
-rw-r--r--src/vlib/format.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/vlib/format.c b/src/vlib/format.c
index 79a4d6866db..ee730bd1c28 100644
--- a/src/vlib/format.c
+++ b/src/vlib/format.c
@@ -187,6 +187,30 @@ done:
return p != 0;
}
+/* Parse a filename to dump debug info */
+uword
+unformat_vlib_tmpfile (unformat_input_t * input, va_list * args)
+{
+ u8 **chroot_filename = va_arg (*args, u8 **);
+ u8 *filename;
+
+ if (!unformat (input, "%s", &filename))
+ return 0;
+
+ /* Brain-police user path input */
+ if (strstr ((char *) filename, "..") || index ((char *) filename, '/'))
+ {
+ vec_free (filename);
+ return 0;
+ }
+
+ *chroot_filename = format (0, "/tmp/%s%c", filename, 0);
+ vec_free (filename);
+
+ return 1;
+}
+
+
/*
* fd.io coding-style-patch-verification: ON
*