summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven <sluong@cisco.com>2018-04-25 11:29:00 -0700
committerDamjan Marion <dmarion.lists@gmail.com>2018-04-26 18:05:53 +0000
commit526ea3e1286d11c9319b53812756fe9a9eb44edf (patch)
treeb1944951ecec4913b540a8750ac7e9ae618122bb /src
parentb66be270c78f4ba950712ee461c3fa27ea3bce1d (diff)
vlib: set log tap level <level> does not work for some keywords
While some levels such as debug and emerg work, others don't. See below. DBGvpp# set log class tap level warn set log class tap level warn set logging class: unknown input `level warn' DBGvpp# set log class tap level debug set log class tap level debug DBGvpp# set log class tap level info set log class tap level info set logging class: unknown input `level info' DBGvpp# set log class tap level err set log class tap level err DBGvpp# set log class tap level crit set log class tap level crit set logging class: unknown input `level crit' DBGvpp# set log class tap level emerg set log class tap level emerg DBGvpp# Cause: The reason for the failure for the shorter keywords is level_str is unformatted with %v which is not null terminated. For example, the character after "info" could be anything in level_str. The memcmp with size of the macro keyword __##uc which includes the null character or 5 in this case and thus the comparison fails. Fix: Use %s which insure level_str is null terminated. Use strcmp to rule out false positve match like "debugxxx" against keyword "debug". Change-Id: I7a2d97a0f7f618df105da7eca791618dce04d21e Signed-off-by: Steven <sluong@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vlib/log.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/vlib/log.c b/src/vlib/log.c
index aa6fe0c7401..1160c04a16d 100644
--- a/src/vlib/log.c
+++ b/src/vlib/log.c
@@ -399,11 +399,11 @@ unformat_vlib_log_level (unformat_input_t * input, va_list * args)
vlib_log_level_t *level = va_arg (*args, vlib_log_level_t *);
u8 *level_str = NULL;
uword rv = 1;
- if (unformat (input, "%v", &level_str))
+ if (unformat (input, "%s", &level_str))
{
#define _(v, uc, lc) \
const char __##uc[] = #lc; \
- if (!memcmp (level_str, __##uc, sizeof (__##uc))) \
+ if (!strcmp ((const char *) level_str, __##uc)) \
{ \
*level = VLIB_LOG_LEVEL_##uc; \
rv = 1; \