From 362456a9bdc5ffc440bf776c3685ba81b8513f6e Mon Sep 17 00:00:00 2001 From: Benoît Ganne Date: Mon, 21 Jan 2019 17:41:25 +0100 Subject: Add 'show vlib graphviz' command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a new command to dump vlib graph as graphviz/dot file Change-Id: I43fc072cff8153ac500e5fbc6641a3705c2e995e Signed-off-by: Benoît Ganne --- src/vlib/format.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/vlib/format.c') 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 * -- cgit 1.2.3-korg