2023-02-08 13:17:09 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2004-12-07 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* bgp_main.c: (main) The 2nd argument to openzlog has been removed.
* isis_main.c: (main) The 2nd argument to openzlog has been removed.
* ospf6_main.c: (main) The 2nd argument to openzlog has been removed.
Note that stdout logging will no longer be enabled by default when
not running as a daemon.
* ospf_main.c: (main) The 2nd argument to openzlog has been removed.
* rip_main.c: (main) The 2nd argument to openzlog has been removed.
* ripng_main.c: (main) The 2nd argument to openzlog has been removed.
* main.c: (main) The 2nd argument to openzlog has been removed.
So stdout logging will no longer be enabled by default.
* irdp_main.c: (irdp_finish) Reduce severity of shutdown message
from LOG_WARNING to LOG_INFO.
* vtysh.c: Make several functions static instead of global.
Added several commands to support destination-specific logging levels.
(vtysh_completion) This function is unused, so comment it out.
* basic.texi: Document new logging features. Separate basic config
commands from basic VTY commands.
* log.h: Replace struct zlog flags and maskpri fields with maxlvl
array to support individual logging levels for each destination.
Remove the 2nd argument to openzlog since the default logging config
should be standardized inside the library. Replaced the
zlog_set_flag and zlog_reset_flag functions with zlog_set_level.
And zlog_set_file now requires an additional log_level argument.
Declare zlog_proto_names for use inside command.c in the
"show logging" command. Added defines useful for command
construction.
* log.c: (vzlog) Decide where to send the message based on the
individual logging levels configured for each destination.
Remove support for ZLOG_STDERR since it was never actually used.
Support record-priority for terminal monitors.
(zlog_signal,zlog_backtrace_sigsafe) Support destination-specific
logging levels. Remove stderr support (was never used). Added
support for terminal monitor logging.
(_zlog_assert_failed) Increase message severity to LOG_EMERG.
(openzlog) Remove 2nd argument since default config should be
standardized in library. By default, terminal monitoring
is set to debug, and all other logging is disabled.
(zlog_set_flag,zlog_reset_flag) Removed.
(zlog_set_level) New function to replace zlog_set_flag and
zlog_reset_flag. Supports destination-specific logging levels.
(zlog_set_file,zlog_reset_file) Support file-specific logging level.
(zlog_rotate) Log an error message if fopen fails, and support
new file-specific logging level.
* command.h: Change DEFUN_CMD_FUNC_DECL and DEFUN_CMD_FUNC_TEXT so that
command functions will be static instead of global. Remove
declarations for config_exit and config_help. Define new macros
DEFUNSH_ATTR, DEFUNSH_HIDDEN, and DEFUNSH_DEPRECATED so we can
have deprecated commands in vtysh. Similarly, for completeness,
define macros ALIAS_SH, ALIAS_SH_HIDDEN, and ALIAS_SH_DEPRECATED.
Also, fix bug in ALIAS_ATTR macro (didn't matter because it
was never used).
* command.c: Make many functions static instead of global.
(facility_name,facility_match,level_match) New functions
to support enhanced destination-specific logging levels.
(config_write_host) Support new destination-specific logging levels.
(config_logmsg) Added new "logmsg" command to help test logging
system.
(show_logging) Added "show logging" command to show the current
configuration of the logging system.
(config_log_stdout_level) Support explicit stdout logging level.
(no_config_log_stdout) Now takes optional LEVEL arg.
(config_log_monitor,config_log_monitor_level,no_config_log_monitor)
New commands creating new "log monitor" commands to set terminal
monitoring log level.
(config_log_file_level) Support explicit file logging level.
(config_log_syslog_level) Support explicit syslog logging level.
(config_log_facility,no_config_log_facility) Implement new
"log facility" command.
(cmd_init) Add hooks for new commands: "show logging", "logmsg",
"log stdout <level>", "log monitor", "log monitor <level>",
"no log monitor", "log file <filename> <level>",
"no log file <filename> <level>", "log syslog <level>",
"log facility", and "no log facility".
* vty.h: Added a "level" argument to vty_log so it can support
"log record-priority". Declare new function vty_log_fixed for
use in signal handlers.
* vty.c: (vty_log,vty_log_out) Added a "level" argument to support
"log record-priority" for vty terminal monitors.
(vty_down_level) Use config_exit_cmd.func instead of calling
config_exit directly (since command functions will now be static
instead of global).
(vty_log_fixed) New function to send terminal monitor messages
from inside a signal handler.
2004-12-07 16:39:31 +01:00
|
|
|
/*
|
|
|
|
* Logging of zebra
|
2002-12-13 21:15:29 +01:00
|
|
|
* Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro
|
|
|
|
*/
|
|
|
|
|
2016-12-20 18:31:42 +01:00
|
|
|
#define FRR_DEFINE_DESC_TABLE
|
2009-09-16 01:52:42 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
#include <zebra.h>
|
|
|
|
|
2024-01-04 20:20:40 +01:00
|
|
|
#ifdef HAVE_GLIBC_BACKTRACE
|
|
|
|
#include <execinfo.h>
|
|
|
|
#endif /* HAVE_GLIBC_BACKTRACE */
|
|
|
|
|
2016-12-12 18:47:48 +01:00
|
|
|
#include "zclient.h"
|
2002-12-13 21:15:29 +01:00
|
|
|
#include "log.h"
|
|
|
|
#include "memory.h"
|
|
|
|
#include "command.h"
|
2018-06-14 15:13:18 +02:00
|
|
|
#include "lib_errors.h"
|
2019-01-25 14:40:27 +01:00
|
|
|
#include "lib/hook.h"
|
2019-05-14 16:27:30 +02:00
|
|
|
#include "printfrr.h"
|
2019-06-21 10:58:02 +02:00
|
|
|
#include "frr_pthread.h"
|
2018-06-14 15:13:18 +02:00
|
|
|
|
2017-08-24 16:09:48 +02:00
|
|
|
#ifdef HAVE_LIBUNWIND
|
|
|
|
#define UNW_LOCAL_ONLY
|
|
|
|
#include <libunwind.h>
|
|
|
|
#include <dlfcn.h>
|
|
|
|
#endif
|
|
|
|
|
2017-06-21 01:56:50 +02:00
|
|
|
/**
|
|
|
|
* Looks up a message in a message list by key.
|
|
|
|
*
|
|
|
|
* If the message is not found, returns the provided error message.
|
|
|
|
*
|
|
|
|
* Terminates when it hits a struct message that's all zeros.
|
|
|
|
*
|
|
|
|
* @param mz the message list
|
|
|
|
* @param kz the message key
|
|
|
|
* @param nf the message to return if not found
|
|
|
|
* @return the message
|
|
|
|
*/
|
|
|
|
const char *lookup_msg(const struct message *mz, int kz, const char *nf)
|
|
|
|
{
|
|
|
|
static struct message nt = {0};
|
|
|
|
const char *rz = nf ? nf : "(no message found)";
|
|
|
|
const struct message *pnt;
|
|
|
|
for (pnt = mz; memcmp(pnt, &nt, sizeof(struct message)); pnt++)
|
|
|
|
if (pnt->key == kz) {
|
|
|
|
rz = pnt->str ? pnt->str : rz;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return rz;
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2017-06-21 01:56:50 +02:00
|
|
|
/* For time string format. */
|
2021-11-11 20:33:41 +01:00
|
|
|
size_t frr_timestamp(int timestamp_precision, char *buf, size_t buflen)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2007-04-29 00:14:10 +02:00
|
|
|
static struct {
|
|
|
|
time_t last;
|
|
|
|
size_t len;
|
|
|
|
char buf[28];
|
|
|
|
} cache;
|
|
|
|
struct timeval clock;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2007-04-29 00:14:10 +02:00
|
|
|
gettimeofday(&clock, NULL);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2007-04-29 00:14:10 +02:00
|
|
|
/* first, we update the cache if the time has changed */
|
|
|
|
if (cache.last != clock.tv_sec) {
|
2020-03-05 17:42:12 +01:00
|
|
|
struct tm tm;
|
2007-04-29 00:14:10 +02:00
|
|
|
cache.last = clock.tv_sec;
|
2020-03-05 17:42:12 +01:00
|
|
|
localtime_r(&cache.last, &tm);
|
2007-04-29 00:14:10 +02:00
|
|
|
cache.len = strftime(cache.buf, sizeof(cache.buf),
|
2020-03-05 17:42:12 +01:00
|
|
|
"%Y/%m/%d %H:%M:%S", &tm);
|
2007-04-29 00:14:10 +02:00
|
|
|
}
|
|
|
|
/* note: it's not worth caching the subsecond part, because
|
|
|
|
chances are that back-to-back calls are not sufficiently close
|
|
|
|
together
|
|
|
|
for the clock not to have ticked forward */
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2007-04-29 00:14:10 +02:00
|
|
|
if (buflen > cache.len) {
|
|
|
|
memcpy(buf, cache.buf, cache.len);
|
|
|
|
if ((timestamp_precision > 0)
|
|
|
|
&& (buflen > cache.len + 1 + timestamp_precision)) {
|
|
|
|
/* should we worry about locale issues? */
|
2007-04-29 17:48:22 +02:00
|
|
|
static const int divisor[] = {0, 100000, 10000, 1000,
|
|
|
|
100, 10, 1};
|
|
|
|
int prec;
|
|
|
|
char *p = buf + cache.len + 1
|
|
|
|
+ (prec = timestamp_precision);
|
|
|
|
*p-- = '\0';
|
|
|
|
while (prec > 6)
|
|
|
|
/* this is unlikely to happen, but protect anyway */
|
|
|
|
{
|
|
|
|
*p-- = '0';
|
|
|
|
prec--;
|
|
|
|
}
|
|
|
|
clock.tv_usec /= divisor[prec];
|
2007-04-29 00:14:10 +02:00
|
|
|
do {
|
2007-04-29 17:48:22 +02:00
|
|
|
*p-- = '0' + (clock.tv_usec % 10);
|
|
|
|
clock.tv_usec /= 10;
|
|
|
|
} while (--prec > 0);
|
|
|
|
*p = '.';
|
|
|
|
return cache.len + 1 + timestamp_precision;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2007-04-29 00:14:10 +02:00
|
|
|
buf[cache.len] = '\0';
|
|
|
|
return cache.len;
|
|
|
|
}
|
|
|
|
if (buflen > 0)
|
|
|
|
buf[0] = '\0';
|
|
|
|
return 0;
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2019-06-03 18:04:32 +02:00
|
|
|
/*
|
|
|
|
* crash handling
|
|
|
|
*
|
|
|
|
* NB: only AS-Safe (async-signal) functions can be used here!
|
|
|
|
*/
|
2004-11-29 00:00:01 +01:00
|
|
|
|
2019-06-03 18:04:32 +02:00
|
|
|
/* Note: the goal here is to use only async-signal-safe functions. */
|
|
|
|
void zlog_signal(int signo, const char *action, void *siginfo_v,
|
|
|
|
void *program_counter)
|
|
|
|
{
|
|
|
|
siginfo_t *siginfo = siginfo_v;
|
|
|
|
time_t now;
|
|
|
|
char buf[sizeof("DEFAULT: Received signal S at T (si_addr 0xP, PC 0xP); aborting...")
|
|
|
|
+ 100];
|
|
|
|
struct fbuf fb = { .buf = buf, .pos = buf, .len = sizeof(buf) };
|
|
|
|
|
|
|
|
time(&now);
|
|
|
|
|
|
|
|
bprintfrr(&fb, "Received signal %d at %lld", signo, (long long)now);
|
|
|
|
if (program_counter)
|
|
|
|
bprintfrr(&fb, " (si_addr 0x%tx, PC 0x%tx)",
|
|
|
|
(ptrdiff_t)siginfo->si_addr,
|
|
|
|
(ptrdiff_t)program_counter);
|
|
|
|
else
|
|
|
|
bprintfrr(&fb, " (si_addr 0x%tx)",
|
|
|
|
(ptrdiff_t)siginfo->si_addr);
|
|
|
|
bprintfrr(&fb, "; %s\n", action);
|
|
|
|
|
2017-05-06 06:40:17 +02:00
|
|
|
zlog_sigsafe(fb.buf, fb.pos - fb.buf);
|
2019-06-03 18:04:32 +02:00
|
|
|
|
2017-05-06 06:40:17 +02:00
|
|
|
zlog_backtrace_sigsafe(LOG_CRIT, program_counter);
|
2019-06-03 18:04:32 +02:00
|
|
|
|
|
|
|
fb.pos = buf;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2022-03-01 22:18:12 +01:00
|
|
|
struct event *tc;
|
2017-06-15 18:05:19 +02:00
|
|
|
tc = pthread_getspecific(thread_current);
|
2013-11-18 23:52:02 +01:00
|
|
|
|
2019-06-03 18:04:32 +02:00
|
|
|
if (!tc)
|
|
|
|
bprintfrr(&fb, "no thread information available\n");
|
|
|
|
else
|
2020-04-28 09:30:50 +02:00
|
|
|
bprintfrr(&fb, "in thread %s scheduled from %s:%d %s()\n",
|
|
|
|
tc->xref->funcname, tc->xref->xref.file,
|
|
|
|
tc->xref->xref.line, tc->xref->xref.func);
|
2013-11-18 23:52:02 +01:00
|
|
|
|
2017-05-06 06:40:17 +02:00
|
|
|
zlog_sigsafe(fb.buf, fb.pos - fb.buf);
|
2004-11-26 19:11:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Log a backtrace using only async-signal-safe functions.
|
|
|
|
Needs to be enhanced to support syslog logging. */
|
2005-01-17 16:22:28 +01:00
|
|
|
void zlog_backtrace_sigsafe(int priority, void *program_counter)
|
2004-11-26 19:11:14 +01:00
|
|
|
{
|
2017-08-24 16:09:48 +02:00
|
|
|
#ifdef HAVE_LIBUNWIND
|
2019-06-03 18:04:32 +02:00
|
|
|
char buf[256];
|
|
|
|
struct fbuf fb = { .buf = buf, .len = sizeof(buf) };
|
2017-08-24 16:09:48 +02:00
|
|
|
unw_cursor_t cursor;
|
|
|
|
unw_context_t uc;
|
|
|
|
unw_word_t ip, off, sp;
|
|
|
|
Dl_info dlinfo;
|
|
|
|
|
2021-01-30 22:19:08 +01:00
|
|
|
memset(&uc, 0, sizeof(uc));
|
|
|
|
memset(&cursor, 0, sizeof(cursor));
|
|
|
|
|
2017-08-24 16:09:48 +02:00
|
|
|
unw_getcontext(&uc);
|
|
|
|
unw_init_local(&cursor, &uc);
|
|
|
|
while (unw_step(&cursor) > 0) {
|
|
|
|
char name[128] = "?";
|
|
|
|
|
|
|
|
unw_get_reg(&cursor, UNW_REG_IP, &ip);
|
|
|
|
unw_get_reg(&cursor, UNW_REG_SP, &sp);
|
|
|
|
|
2019-06-03 18:04:32 +02:00
|
|
|
if (!unw_get_proc_name(&cursor, buf, sizeof(buf), &off))
|
|
|
|
snprintfrr(name, sizeof(name), "%s+%#lx",
|
|
|
|
buf, (long)off);
|
2017-08-24 16:09:48 +02:00
|
|
|
|
2019-06-03 18:04:32 +02:00
|
|
|
fb.pos = buf;
|
|
|
|
if (unw_is_signal_frame(&cursor))
|
|
|
|
bprintfrr(&fb, " ---- signal ----\n");
|
|
|
|
bprintfrr(&fb, "%-30s %16lx %16lx", name, (long)ip, (long)sp);
|
|
|
|
if (dladdr((void *)ip, &dlinfo))
|
|
|
|
bprintfrr(&fb, " %s (mapped at %p)",
|
|
|
|
dlinfo.dli_fname, dlinfo.dli_fbase);
|
|
|
|
bprintfrr(&fb, "\n");
|
2017-05-06 06:40:17 +02:00
|
|
|
zlog_sigsafe(fb.buf, fb.pos - fb.buf);
|
2017-08-24 16:09:48 +02:00
|
|
|
}
|
2017-05-06 06:40:17 +02:00
|
|
|
#elif defined(HAVE_GLIBC_BACKTRACE)
|
2009-03-10 00:09:50 +01:00
|
|
|
void *array[64];
|
2017-05-06 06:40:17 +02:00
|
|
|
int size, i;
|
2019-06-03 18:04:32 +02:00
|
|
|
char buf[128];
|
|
|
|
struct fbuf fb = { .buf = buf, .pos = buf, .len = sizeof(buf) };
|
|
|
|
char **bt = NULL;
|
2004-11-23 19:19:14 +01:00
|
|
|
|
2013-11-19 15:00:06 +01:00
|
|
|
size = backtrace(array, array_size(array));
|
|
|
|
if (size <= 0 || (size_t)size > array_size(array))
|
2004-11-26 19:11:14 +01:00
|
|
|
return;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-05-06 06:40:17 +02:00
|
|
|
bprintfrr(&fb, "Backtrace for %d stack frames:", size);
|
|
|
|
zlog_sigsafe(fb.pos, fb.buf - fb.pos);
|
|
|
|
|
|
|
|
bt = backtrace_symbols(array, size);
|
|
|
|
|
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
fb.pos = buf;
|
|
|
|
if (bt)
|
|
|
|
bprintfrr(&fb, "%s", bt[i]);
|
|
|
|
else
|
|
|
|
bprintfrr(&fb, "[bt %d] 0x%tx", i,
|
|
|
|
(ptrdiff_t)(array[i]));
|
|
|
|
zlog_sigsafe(fb.buf, fb.pos - fb.buf);
|
2004-11-23 19:19:14 +01:00
|
|
|
}
|
2017-05-06 06:40:17 +02:00
|
|
|
if (bt)
|
|
|
|
free(bt);
|
2006-05-28 10:26:15 +02:00
|
|
|
#endif /* HAVE_STRACK_TRACE */
|
2004-11-26 19:11:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void zlog_backtrace(int priority)
|
|
|
|
{
|
2017-08-24 16:09:48 +02:00
|
|
|
#ifdef HAVE_LIBUNWIND
|
|
|
|
char buf[100];
|
2022-03-25 01:37:44 +01:00
|
|
|
unw_cursor_t cursor = {};
|
2017-08-24 16:09:48 +02:00
|
|
|
unw_context_t uc;
|
|
|
|
unw_word_t ip, off, sp;
|
|
|
|
Dl_info dlinfo;
|
|
|
|
|
|
|
|
unw_getcontext(&uc);
|
|
|
|
unw_init_local(&cursor, &uc);
|
|
|
|
zlog(priority, "Backtrace:");
|
|
|
|
while (unw_step(&cursor) > 0) {
|
|
|
|
char name[128] = "?";
|
|
|
|
|
|
|
|
unw_get_reg(&cursor, UNW_REG_IP, &ip);
|
|
|
|
unw_get_reg(&cursor, UNW_REG_SP, &sp);
|
|
|
|
|
|
|
|
if (unw_is_signal_frame(&cursor))
|
|
|
|
zlog(priority, " ---- signal ----");
|
|
|
|
|
|
|
|
if (!unw_get_proc_name(&cursor, buf, sizeof(buf), &off))
|
|
|
|
snprintf(name, sizeof(name), "%s+%#lx",
|
|
|
|
buf, (long)off);
|
|
|
|
|
|
|
|
if (dladdr((void *)ip, &dlinfo))
|
|
|
|
zlog(priority, "%-30s %16lx %16lx %s (mapped at %p)",
|
|
|
|
name, (long)ip, (long)sp,
|
|
|
|
dlinfo.dli_fname, dlinfo.dli_fbase);
|
|
|
|
else
|
|
|
|
zlog(priority, "%-30s %16lx %16lx",
|
|
|
|
name, (long)ip, (long)sp);
|
|
|
|
}
|
|
|
|
#elif defined(HAVE_GLIBC_BACKTRACE)
|
2004-11-26 19:11:14 +01:00
|
|
|
void *array[20];
|
|
|
|
int size, i;
|
|
|
|
char **strings;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2013-11-19 15:00:06 +01:00
|
|
|
size = backtrace(array, array_size(array));
|
|
|
|
if (size <= 0 || (size_t)size > array_size(array)) {
|
2018-08-06 18:36:50 +02:00
|
|
|
flog_err_sys(
|
2018-09-13 21:34:28 +02:00
|
|
|
EC_LIB_SYSTEM_CALL,
|
2020-03-27 12:35:23 +01:00
|
|
|
"Cannot get backtrace, returned invalid # of frames %d (valid range is between 1 and %lu)",
|
2018-08-06 18:36:50 +02:00
|
|
|
size, (unsigned long)(array_size(array)));
|
2004-11-26 19:11:14 +01:00
|
|
|
return;
|
|
|
|
}
|
2016-02-23 11:59:36 +01:00
|
|
|
zlog(priority, "Backtrace for %d stack frames:", size);
|
2004-11-26 19:11:14 +01:00
|
|
|
if (!(strings = backtrace_symbols(array, size))) {
|
2018-09-13 21:34:28 +02:00
|
|
|
flog_err_sys(EC_LIB_SYSTEM_CALL,
|
2018-08-06 18:36:50 +02:00
|
|
|
"Cannot get backtrace symbols (out of memory?)");
|
2004-11-26 19:11:14 +01:00
|
|
|
for (i = 0; i < size; i++)
|
2016-02-23 11:59:36 +01:00
|
|
|
zlog(priority, "[bt %d] %p", i, array[i]);
|
2004-11-26 19:11:14 +01:00
|
|
|
} else {
|
|
|
|
for (i = 0; i < size; i++)
|
2016-02-23 11:59:36 +01:00
|
|
|
zlog(priority, "[bt %d] %s", i, strings[i]);
|
2004-11-26 19:11:14 +01:00
|
|
|
free(strings);
|
|
|
|
}
|
2017-08-24 16:09:48 +02:00
|
|
|
#else /* !HAVE_GLIBC_BACKTRACE && !HAVE_LIBUNWIND */
|
|
|
|
zlog(priority, "No backtrace available on this platform.");
|
|
|
|
#endif
|
2004-11-23 19:19:14 +01:00
|
|
|
}
|
|
|
|
|
2013-11-18 23:52:02 +01:00
|
|
|
void zlog_thread_info(int log_level)
|
|
|
|
{
|
2022-03-01 22:18:12 +01:00
|
|
|
struct event *tc;
|
2017-06-15 18:05:19 +02:00
|
|
|
tc = pthread_getspecific(thread_current);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-06-15 18:05:19 +02:00
|
|
|
if (tc)
|
2016-02-23 11:59:36 +01:00
|
|
|
zlog(log_level,
|
2020-04-28 09:30:50 +02:00
|
|
|
"Current thread function %s, scheduled from file %s, line %u in %s()",
|
|
|
|
tc->xref->funcname, tc->xref->xref.file,
|
|
|
|
tc->xref->xref.line, tc->xref->xref.func);
|
2013-11-18 23:52:02 +01:00
|
|
|
else
|
2016-02-23 11:59:36 +01:00
|
|
|
zlog(log_level, "Current thread not known/applicable");
|
2013-11-18 23:52:02 +01:00
|
|
|
}
|
|
|
|
|
2015-05-27 03:45:30 +02:00
|
|
|
void memory_oom(size_t size, const char *name)
|
|
|
|
{
|
2017-05-06 06:40:17 +02:00
|
|
|
zlog(LOG_CRIT,
|
|
|
|
"out of memory: failed to allocate %zu bytes for %s object",
|
|
|
|
size, name);
|
|
|
|
zlog_backtrace(LOG_CRIT);
|
|
|
|
log_memstats(stderr, "log");
|
2015-05-27 03:45:30 +02:00
|
|
|
abort();
|
|
|
|
}
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2004-11-20 00:40:16 +01:00
|
|
|
/* Wrapper around strerror to handle case where it returns NULL. */
|
|
|
|
const char *safe_strerror(int errnum)
|
|
|
|
{
|
|
|
|
const char *s = strerror(errnum);
|
|
|
|
return (s != NULL) ? s : "Unknown error";
|
|
|
|
}
|
2005-10-01 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* zebra.h: Declare new functions zebra_route_string() and
zebra_route_char().
* log.c: (zroute_lookup,zebra_route_string,zebra_route_char) New
functions to map zebra route numbers to strings.
* zebra_vty.c: (route_type_str) Remove obsolete function: use new
library function zebra_route_string() instead. Note that there
are a few differences: for IPv6 routes, we now get "ripng" and
"ospf6" instead of the old behavior ("rip" and "ospf").
(route_type_char) Remove obsolete function: ues new library function
zebra_route_char() instead. Note that there is one difference:
the old function returned 'S' for a ZEBRA_ROUTE_SYSTEM route,
whereas the new one returns 'X'.
(vty_show_ip_route_detail,vty_show_ipv6_route_detail) Replace
route_type_str() with zebra_route_string().
(vty_show_ip_route,vty_show_ipv6_route) Replace route_type_char()
with zebra_route_char().
* bgp_vty.c: (bgp_config_write_redistribute) Use new library function
zebra_route_string instead of a local hard-coded table.
* ospf6_asbr.c: Remove local hard-coded tables zroute_name and
zroute_abname. Change the ZROUTE_NAME macro to use new library
function zebra_route_string(). Remove the ZROUTE_ABNAME macro.
(ospf6_asbr_external_route_show): Replace ZROUTE_ABNAME() with
a call to zebra_route_char(), and be sure to fix the format string,
since we now have a char instead of a char *.
* ospf6_zebra.c: Remove local hard-coded tables zebra_route_name and
zebra_route_abname. Note that the zebra_route_name[] table
contained mixed-case strings, whereas the zebra_route_string()
function returns lower-case strings.
(ospf6_zebra_read_ipv6): Change debug message to use new library
function zebra_route_string() instead of zebra_route_name[].
(show_zebra): Use new library function zebra_route_string() instead
of zebra_route_name[].
* ospf_dump.c: Remove local hard-coded table ospf_redistributed_proto.
(ospf_redist_string) New function implemented using new library
function zebra_route_string(). Note that there are a few differences
in the output that will result: the new function returns strings
that are lower-case, whereas the old table was mixed case. Also,
the old table mapped ZEBRA_ROUTE_OSPF6 to "OSPFv3", whereas the
new function returns "ospf6".
* ospfd.h: Remove extern struct message ospf_redistributed_proto[],
and add extern const char *ospf_redist_string(u_int route_type)
instead.
* ospf_asbr.c: (ospf_external_info_add) In two messages, use
ospf_redist_string instead of LOOKUP(ospf_redistributed_proto).
* ospf_vty.c: Remove local hard-coded table distribute_str.
(config_write_ospf_redistribute,config_write_ospf_distribute): Use
new library function zebra_route_string() instead of distribute_str[].
* ospf_zebra.c: (ospf_redistribute_set,ospf_redistribute_unset,
ospf_redistribute_default_set,ospf_redistribute_check)
In debug messages, use ospf_redist_string() instead of
LOOKUP(ospf_redistributed_proto).
* rip_zebra.c: (config_write_rip_redistribute): Remove local hard-coded
table str[]. Replace str[] with calls to new library function
zebra_route_string().
* ripd.c: Remove local hard-coded table route_info[].
(show_ip_rip) Replace uses of str[] with calls to new library
functions zebra_route_char and zebra_route_string.
* ripng_zebra.c: (ripng_redistribute_write) Remove local hard-coded
table str[]. Replace str[i] with new library function
zebra_route_string(i).
* ripngd.c: Remove local hard-coded table route_info[].
(show_ipv6_ripng) Use new library function zebra_route_char() instead
of table route_info[].
2005-10-01 19:38:06 +02:00
|
|
|
|
2006-05-15 18:56:51 +02:00
|
|
|
#define DESC_ENTRY(T) [(T)] = { (T), (#T), '\0' }
|
|
|
|
static const struct zebra_desc_table command_types[] = {
|
|
|
|
DESC_ENTRY(ZEBRA_INTERFACE_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_INTERFACE_DELETE),
|
|
|
|
DESC_ENTRY(ZEBRA_INTERFACE_ADDRESS_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_INTERFACE_ADDRESS_DELETE),
|
|
|
|
DESC_ENTRY(ZEBRA_INTERFACE_UP),
|
|
|
|
DESC_ENTRY(ZEBRA_INTERFACE_DOWN),
|
2017-06-13 14:59:32 +02:00
|
|
|
DESC_ENTRY(ZEBRA_INTERFACE_SET_MASTER),
|
2022-12-08 17:37:51 +01:00
|
|
|
DESC_ENTRY(ZEBRA_INTERFACE_SET_PROTODOWN),
|
2017-08-20 02:59:41 +02:00
|
|
|
DESC_ENTRY(ZEBRA_ROUTE_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_ROUTE_DELETE),
|
2017-11-09 19:55:46 +01:00
|
|
|
DESC_ENTRY(ZEBRA_ROUTE_NOTIFY_OWNER),
|
2006-05-15 18:56:51 +02:00
|
|
|
DESC_ENTRY(ZEBRA_REDISTRIBUTE_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_REDISTRIBUTE_DELETE),
|
|
|
|
DESC_ENTRY(ZEBRA_REDISTRIBUTE_DEFAULT_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_REDISTRIBUTE_DEFAULT_DELETE),
|
|
|
|
DESC_ENTRY(ZEBRA_ROUTER_ID_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_ROUTER_ID_DELETE),
|
|
|
|
DESC_ENTRY(ZEBRA_ROUTER_ID_UPDATE),
|
2012-01-21 19:50:19 +01:00
|
|
|
DESC_ENTRY(ZEBRA_HELLO),
|
2019-03-25 14:04:28 +01:00
|
|
|
DESC_ENTRY(ZEBRA_CAPABILITIES),
|
2015-05-20 02:40:34 +02:00
|
|
|
DESC_ENTRY(ZEBRA_NEXTHOP_REGISTER),
|
|
|
|
DESC_ENTRY(ZEBRA_NEXTHOP_UNREGISTER),
|
|
|
|
DESC_ENTRY(ZEBRA_NEXTHOP_UPDATE),
|
2015-10-22 19:14:00 +02:00
|
|
|
DESC_ENTRY(ZEBRA_INTERFACE_NBR_ADDRESS_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_INTERFACE_NBR_ADDRESS_DELETE),
|
|
|
|
DESC_ENTRY(ZEBRA_INTERFACE_BFD_DEST_UPDATE),
|
|
|
|
DESC_ENTRY(ZEBRA_BFD_DEST_REGISTER),
|
|
|
|
DESC_ENTRY(ZEBRA_BFD_DEST_DEREGISTER),
|
|
|
|
DESC_ENTRY(ZEBRA_BFD_DEST_UPDATE),
|
|
|
|
DESC_ENTRY(ZEBRA_BFD_DEST_REPLAY),
|
2017-08-21 03:10:50 +02:00
|
|
|
DESC_ENTRY(ZEBRA_REDISTRIBUTE_ROUTE_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_REDISTRIBUTE_ROUTE_DEL),
|
2016-05-27 02:06:08 +02:00
|
|
|
DESC_ENTRY(ZEBRA_VRF_UNREGISTER),
|
|
|
|
DESC_ENTRY(ZEBRA_VRF_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_VRF_DELETE),
|
2018-01-30 19:30:36 +01:00
|
|
|
DESC_ENTRY(ZEBRA_VRF_LABEL),
|
BGP: Trigger IPv6 router advertisements upon config of unnumbered neighbor
Instead of turning on IPv6 RA on every interface as soon as it has an IPv6
address, only enable it upon configuration of BGP neighbor. When the BGP
neighbor is deleted, signal that RAs can be turned off.
To support this, introduce new message interaction between BGP and Zebra.
Also, take appropriate actions in BGP upon interface add/del since the
unnumbered neighbor could exist prior to interface creation etc.
Only unnumbered IPv6 neighbors require RA, the /30 or /31 based neighbors
don't. However, to keep the interaction simple and not have to deal with
too many dynamic conditions (e.g., address deletes or neighbor change to/from
'v6only'), RAs on the interface are triggered upon any unnumbered neighbor
configuration.
BGP-triggered RAs will cause RAs to be initiated on the interface; however,
if BGP asks that RAs be stopped (upon delete of unnumbered neighbor), RAs
will continue to be exchanged if the operator has explicitly enabled.
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Ticket: CM-10640
Reviewed By: CCR-4589
Testing Done: Various manual and automated (refer to defect)
2016-05-02 22:53:38 +02:00
|
|
|
DESC_ENTRY(ZEBRA_BFD_CLIENT_REGISTER),
|
2019-03-25 14:04:28 +01:00
|
|
|
DESC_ENTRY(ZEBRA_BFD_CLIENT_DEREGISTER),
|
BGP: Trigger IPv6 router advertisements upon config of unnumbered neighbor
Instead of turning on IPv6 RA on every interface as soon as it has an IPv6
address, only enable it upon configuration of BGP neighbor. When the BGP
neighbor is deleted, signal that RAs can be turned off.
To support this, introduce new message interaction between BGP and Zebra.
Also, take appropriate actions in BGP upon interface add/del since the
unnumbered neighbor could exist prior to interface creation etc.
Only unnumbered IPv6 neighbors require RA, the /30 or /31 based neighbors
don't. However, to keep the interaction simple and not have to deal with
too many dynamic conditions (e.g., address deletes or neighbor change to/from
'v6only'), RAs on the interface are triggered upon any unnumbered neighbor
configuration.
BGP-triggered RAs will cause RAs to be initiated on the interface; however,
if BGP asks that RAs be stopped (upon delete of unnumbered neighbor), RAs
will continue to be exchanged if the operator has explicitly enabled.
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Ticket: CM-10640
Reviewed By: CCR-4589
Testing Done: Various manual and automated (refer to defect)
2016-05-02 22:53:38 +02:00
|
|
|
DESC_ENTRY(ZEBRA_INTERFACE_ENABLE_RADV),
|
2016-05-27 02:06:08 +02:00
|
|
|
DESC_ENTRY(ZEBRA_INTERFACE_DISABLE_RADV),
|
2022-04-26 14:52:53 +02:00
|
|
|
DESC_ENTRY(ZEBRA_NEXTHOP_LOOKUP_MRIB),
|
2017-02-21 12:27:44 +01:00
|
|
|
DESC_ENTRY(ZEBRA_INTERFACE_LINK_PARAMS),
|
2016-06-01 19:19:30 +02:00
|
|
|
DESC_ENTRY(ZEBRA_MPLS_LABELS_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_MPLS_LABELS_DELETE),
|
2019-08-08 20:57:13 +02:00
|
|
|
DESC_ENTRY(ZEBRA_MPLS_LABELS_REPLACE),
|
2020-07-20 13:43:54 +02:00
|
|
|
DESC_ENTRY(ZEBRA_SR_POLICY_SET),
|
|
|
|
DESC_ENTRY(ZEBRA_SR_POLICY_DELETE),
|
|
|
|
DESC_ENTRY(ZEBRA_SR_POLICY_NOTIFY_STATUS),
|
2016-08-11 02:04:20 +02:00
|
|
|
DESC_ENTRY(ZEBRA_IPMR_ROUTE_STATS),
|
2017-03-20 15:34:49 +01:00
|
|
|
DESC_ENTRY(ZEBRA_LABEL_MANAGER_CONNECT),
|
2018-06-07 15:28:12 +02:00
|
|
|
DESC_ENTRY(ZEBRA_LABEL_MANAGER_CONNECT_ASYNC),
|
2017-03-20 15:34:49 +01:00
|
|
|
DESC_ENTRY(ZEBRA_GET_LABEL_CHUNK),
|
|
|
|
DESC_ENTRY(ZEBRA_RELEASE_LABEL_CHUNK),
|
2019-03-25 14:04:28 +01:00
|
|
|
DESC_ENTRY(ZEBRA_FEC_REGISTER),
|
|
|
|
DESC_ENTRY(ZEBRA_FEC_UNREGISTER),
|
|
|
|
DESC_ENTRY(ZEBRA_FEC_UPDATE),
|
2017-06-28 10:51:10 +02:00
|
|
|
DESC_ENTRY(ZEBRA_ADVERTISE_DEFAULT_GW),
|
2019-02-04 02:24:59 +01:00
|
|
|
DESC_ENTRY(ZEBRA_ADVERTISE_SVI_MACIP),
|
2017-11-20 06:47:04 +01:00
|
|
|
DESC_ENTRY(ZEBRA_ADVERTISE_SUBNET),
|
2022-12-08 17:37:51 +01:00
|
|
|
DESC_ENTRY(ZEBRA_ADVERTISE_ALL_VNI),
|
2018-04-14 00:01:12 +02:00
|
|
|
DESC_ENTRY(ZEBRA_LOCAL_ES_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_LOCAL_ES_DEL),
|
2020-03-28 01:14:45 +01:00
|
|
|
DESC_ENTRY(ZEBRA_REMOTE_ES_VTEP_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_REMOTE_ES_VTEP_DEL),
|
|
|
|
DESC_ENTRY(ZEBRA_LOCAL_ES_EVI_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_LOCAL_ES_EVI_DEL),
|
2017-05-15 07:38:26 +02:00
|
|
|
DESC_ENTRY(ZEBRA_VNI_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_VNI_DEL),
|
2017-10-08 03:49:27 +02:00
|
|
|
DESC_ENTRY(ZEBRA_L3VNI_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_L3VNI_DEL),
|
2017-05-15 07:38:26 +02:00
|
|
|
DESC_ENTRY(ZEBRA_REMOTE_VTEP_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_REMOTE_VTEP_DEL),
|
2017-05-15 07:44:13 +02:00
|
|
|
DESC_ENTRY(ZEBRA_MACIP_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_MACIP_DEL),
|
2017-11-20 06:47:04 +01:00
|
|
|
DESC_ENTRY(ZEBRA_IP_PREFIX_ROUTE_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_IP_PREFIX_ROUTE_DEL),
|
2017-05-15 07:44:13 +02:00
|
|
|
DESC_ENTRY(ZEBRA_REMOTE_MACIP_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_REMOTE_MACIP_DEL),
|
2018-11-02 01:55:07 +01:00
|
|
|
DESC_ENTRY(ZEBRA_DUPLICATE_ADDR_DETECTION),
|
2017-05-15 17:09:28 +02:00
|
|
|
DESC_ENTRY(ZEBRA_PW_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_PW_DELETE),
|
|
|
|
DESC_ENTRY(ZEBRA_PW_SET),
|
|
|
|
DESC_ENTRY(ZEBRA_PW_UNSET),
|
|
|
|
DESC_ENTRY(ZEBRA_PW_STATUS_UPDATE),
|
2018-02-15 01:52:01 +01:00
|
|
|
DESC_ENTRY(ZEBRA_RULE_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_RULE_DELETE),
|
|
|
|
DESC_ENTRY(ZEBRA_RULE_NOTIFY_OWNER),
|
2018-03-05 17:57:29 +01:00
|
|
|
DESC_ENTRY(ZEBRA_TABLE_MANAGER_CONNECT),
|
|
|
|
DESC_ENTRY(ZEBRA_GET_TABLE_CHUNK),
|
|
|
|
DESC_ENTRY(ZEBRA_RELEASE_TABLE_CHUNK),
|
2018-03-07 13:21:14 +01:00
|
|
|
DESC_ENTRY(ZEBRA_IPSET_CREATE),
|
|
|
|
DESC_ENTRY(ZEBRA_IPSET_DESTROY),
|
|
|
|
DESC_ENTRY(ZEBRA_IPSET_ENTRY_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_IPSET_ENTRY_DELETE),
|
2019-03-25 14:04:28 +01:00
|
|
|
DESC_ENTRY(ZEBRA_IPSET_NOTIFY_OWNER),
|
|
|
|
DESC_ENTRY(ZEBRA_IPSET_ENTRY_NOTIFY_OWNER),
|
|
|
|
DESC_ENTRY(ZEBRA_IPTABLE_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_IPTABLE_DELETE),
|
|
|
|
DESC_ENTRY(ZEBRA_IPTABLE_NOTIFY_OWNER),
|
2018-10-05 00:42:57 +02:00
|
|
|
DESC_ENTRY(ZEBRA_VXLAN_FLOOD_CONTROL),
|
2019-03-19 21:56:46 +01:00
|
|
|
DESC_ENTRY(ZEBRA_VXLAN_SG_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_VXLAN_SG_DEL),
|
2019-07-02 20:20:34 +02:00
|
|
|
DESC_ENTRY(ZEBRA_VXLAN_SG_REPLAY),
|
2020-02-06 18:30:56 +01:00
|
|
|
DESC_ENTRY(ZEBRA_MLAG_PROCESS_UP),
|
|
|
|
DESC_ENTRY(ZEBRA_MLAG_PROCESS_DOWN),
|
|
|
|
DESC_ENTRY(ZEBRA_MLAG_CLIENT_REGISTER),
|
|
|
|
DESC_ENTRY(ZEBRA_MLAG_CLIENT_UNREGISTER),
|
|
|
|
DESC_ENTRY(ZEBRA_MLAG_FORWARD_MSG),
|
2022-12-08 17:37:51 +01:00
|
|
|
DESC_ENTRY(ZEBRA_NHG_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_NHG_DEL),
|
|
|
|
DESC_ENTRY(ZEBRA_NHG_NOTIFY_OWNER),
|
|
|
|
DESC_ENTRY(ZEBRA_EVPN_REMOTE_NH_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_EVPN_REMOTE_NH_DEL),
|
|
|
|
DESC_ENTRY(ZEBRA_SRV6_LOCATOR_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_SRV6_LOCATOR_DELETE),
|
|
|
|
DESC_ENTRY(ZEBRA_SRV6_MANAGER_GET_LOCATOR_CHUNK),
|
|
|
|
DESC_ENTRY(ZEBRA_SRV6_MANAGER_RELEASE_LOCATOR_CHUNK),
|
2024-03-23 15:49:43 +01:00
|
|
|
DESC_ENTRY(ZEBRA_SRV6_MANAGER_GET_LOCATOR),
|
2024-03-23 18:31:12 +01:00
|
|
|
DESC_ENTRY(ZEBRA_SRV6_MANAGER_GET_SRV6_SID),
|
|
|
|
DESC_ENTRY(ZEBRA_SRV6_MANAGER_RELEASE_SRV6_SID),
|
2019-12-17 23:00:52 +01:00
|
|
|
DESC_ENTRY(ZEBRA_ERROR),
|
2020-04-06 22:10:13 +02:00
|
|
|
DESC_ENTRY(ZEBRA_CLIENT_CAPABILITIES),
|
|
|
|
DESC_ENTRY(ZEBRA_OPAQUE_MESSAGE),
|
|
|
|
DESC_ENTRY(ZEBRA_OPAQUE_REGISTER),
|
2020-08-06 13:07:01 +02:00
|
|
|
DESC_ENTRY(ZEBRA_OPAQUE_UNREGISTER),
|
2020-05-28 18:08:29 +02:00
|
|
|
DESC_ENTRY(ZEBRA_NEIGH_DISCOVER),
|
2020-12-08 00:01:01 +01:00
|
|
|
DESC_ENTRY(ZEBRA_ROUTE_NOTIFY_REQUEST),
|
2020-09-14 15:35:45 +02:00
|
|
|
DESC_ENTRY(ZEBRA_CLIENT_CLOSE_NOTIFY),
|
2024-01-19 20:45:25 +01:00
|
|
|
DESC_ENTRY(ZEBRA_NEIGH_ADDED),
|
|
|
|
DESC_ENTRY(ZEBRA_NEIGH_REMOVED),
|
|
|
|
DESC_ENTRY(ZEBRA_NEIGH_GET),
|
|
|
|
DESC_ENTRY(ZEBRA_NEIGH_REGISTER),
|
|
|
|
DESC_ENTRY(ZEBRA_NEIGH_UNREGISTER),
|
2021-03-17 18:12:26 +01:00
|
|
|
DESC_ENTRY(ZEBRA_NEIGH_IP_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_NEIGH_IP_DEL),
|
2019-12-20 10:34:01 +01:00
|
|
|
DESC_ENTRY(ZEBRA_CONFIGURE_ARP),
|
|
|
|
DESC_ENTRY(ZEBRA_GRE_GET),
|
|
|
|
DESC_ENTRY(ZEBRA_GRE_UPDATE),
|
2022-12-08 17:37:51 +01:00
|
|
|
DESC_ENTRY(ZEBRA_GRE_SOURCE_SET),
|
|
|
|
DESC_ENTRY(ZEBRA_TC_QDISC_INSTALL),
|
|
|
|
DESC_ENTRY(ZEBRA_TC_QDISC_UNINSTALL),
|
|
|
|
DESC_ENTRY(ZEBRA_TC_CLASS_ADD),
|
|
|
|
DESC_ENTRY(ZEBRA_TC_CLASS_DELETE),
|
|
|
|
DESC_ENTRY(ZEBRA_TC_FILTER_ADD),
|
2023-05-31 22:22:16 +02:00
|
|
|
DESC_ENTRY(ZEBRA_TC_FILTER_DELETE),
|
|
|
|
DESC_ENTRY(ZEBRA_OPAQUE_NOTIFY)
|
|
|
|
};
|
2006-05-15 18:56:51 +02:00
|
|
|
#undef DESC_ENTRY
|
|
|
|
|
|
|
|
static const struct zebra_desc_table unknown = {0, "unknown", '?'};
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
static const struct zebra_desc_table *zroute_lookup(unsigned int zroute)
|
2005-10-01 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* zebra.h: Declare new functions zebra_route_string() and
zebra_route_char().
* log.c: (zroute_lookup,zebra_route_string,zebra_route_char) New
functions to map zebra route numbers to strings.
* zebra_vty.c: (route_type_str) Remove obsolete function: use new
library function zebra_route_string() instead. Note that there
are a few differences: for IPv6 routes, we now get "ripng" and
"ospf6" instead of the old behavior ("rip" and "ospf").
(route_type_char) Remove obsolete function: ues new library function
zebra_route_char() instead. Note that there is one difference:
the old function returned 'S' for a ZEBRA_ROUTE_SYSTEM route,
whereas the new one returns 'X'.
(vty_show_ip_route_detail,vty_show_ipv6_route_detail) Replace
route_type_str() with zebra_route_string().
(vty_show_ip_route,vty_show_ipv6_route) Replace route_type_char()
with zebra_route_char().
* bgp_vty.c: (bgp_config_write_redistribute) Use new library function
zebra_route_string instead of a local hard-coded table.
* ospf6_asbr.c: Remove local hard-coded tables zroute_name and
zroute_abname. Change the ZROUTE_NAME macro to use new library
function zebra_route_string(). Remove the ZROUTE_ABNAME macro.
(ospf6_asbr_external_route_show): Replace ZROUTE_ABNAME() with
a call to zebra_route_char(), and be sure to fix the format string,
since we now have a char instead of a char *.
* ospf6_zebra.c: Remove local hard-coded tables zebra_route_name and
zebra_route_abname. Note that the zebra_route_name[] table
contained mixed-case strings, whereas the zebra_route_string()
function returns lower-case strings.
(ospf6_zebra_read_ipv6): Change debug message to use new library
function zebra_route_string() instead of zebra_route_name[].
(show_zebra): Use new library function zebra_route_string() instead
of zebra_route_name[].
* ospf_dump.c: Remove local hard-coded table ospf_redistributed_proto.
(ospf_redist_string) New function implemented using new library
function zebra_route_string(). Note that there are a few differences
in the output that will result: the new function returns strings
that are lower-case, whereas the old table was mixed case. Also,
the old table mapped ZEBRA_ROUTE_OSPF6 to "OSPFv3", whereas the
new function returns "ospf6".
* ospfd.h: Remove extern struct message ospf_redistributed_proto[],
and add extern const char *ospf_redist_string(u_int route_type)
instead.
* ospf_asbr.c: (ospf_external_info_add) In two messages, use
ospf_redist_string instead of LOOKUP(ospf_redistributed_proto).
* ospf_vty.c: Remove local hard-coded table distribute_str.
(config_write_ospf_redistribute,config_write_ospf_distribute): Use
new library function zebra_route_string() instead of distribute_str[].
* ospf_zebra.c: (ospf_redistribute_set,ospf_redistribute_unset,
ospf_redistribute_default_set,ospf_redistribute_check)
In debug messages, use ospf_redist_string() instead of
LOOKUP(ospf_redistributed_proto).
* rip_zebra.c: (config_write_rip_redistribute): Remove local hard-coded
table str[]. Replace str[] with calls to new library function
zebra_route_string().
* ripd.c: Remove local hard-coded table route_info[].
(show_ip_rip) Replace uses of str[] with calls to new library
functions zebra_route_char and zebra_route_string.
* ripng_zebra.c: (ripng_redistribute_write) Remove local hard-coded
table str[]. Replace str[i] with new library function
zebra_route_string(i).
* ripngd.c: Remove local hard-coded table route_info[].
(show_ipv6_ripng) Use new library function zebra_route_char() instead
of table route_info[].
2005-10-01 19:38:06 +02:00
|
|
|
{
|
2018-03-27 21:13:34 +02:00
|
|
|
unsigned int i;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2012-09-26 10:39:10 +02:00
|
|
|
if (zroute >= array_size(route_types)) {
|
2018-09-13 21:34:28 +02:00
|
|
|
flog_err(EC_LIB_DEVELOPMENT, "unknown zebra route type: %u",
|
2018-09-13 21:38:57 +02:00
|
|
|
zroute);
|
2005-10-01 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* zebra.h: Declare new functions zebra_route_string() and
zebra_route_char().
* log.c: (zroute_lookup,zebra_route_string,zebra_route_char) New
functions to map zebra route numbers to strings.
* zebra_vty.c: (route_type_str) Remove obsolete function: use new
library function zebra_route_string() instead. Note that there
are a few differences: for IPv6 routes, we now get "ripng" and
"ospf6" instead of the old behavior ("rip" and "ospf").
(route_type_char) Remove obsolete function: ues new library function
zebra_route_char() instead. Note that there is one difference:
the old function returned 'S' for a ZEBRA_ROUTE_SYSTEM route,
whereas the new one returns 'X'.
(vty_show_ip_route_detail,vty_show_ipv6_route_detail) Replace
route_type_str() with zebra_route_string().
(vty_show_ip_route,vty_show_ipv6_route) Replace route_type_char()
with zebra_route_char().
* bgp_vty.c: (bgp_config_write_redistribute) Use new library function
zebra_route_string instead of a local hard-coded table.
* ospf6_asbr.c: Remove local hard-coded tables zroute_name and
zroute_abname. Change the ZROUTE_NAME macro to use new library
function zebra_route_string(). Remove the ZROUTE_ABNAME macro.
(ospf6_asbr_external_route_show): Replace ZROUTE_ABNAME() with
a call to zebra_route_char(), and be sure to fix the format string,
since we now have a char instead of a char *.
* ospf6_zebra.c: Remove local hard-coded tables zebra_route_name and
zebra_route_abname. Note that the zebra_route_name[] table
contained mixed-case strings, whereas the zebra_route_string()
function returns lower-case strings.
(ospf6_zebra_read_ipv6): Change debug message to use new library
function zebra_route_string() instead of zebra_route_name[].
(show_zebra): Use new library function zebra_route_string() instead
of zebra_route_name[].
* ospf_dump.c: Remove local hard-coded table ospf_redistributed_proto.
(ospf_redist_string) New function implemented using new library
function zebra_route_string(). Note that there are a few differences
in the output that will result: the new function returns strings
that are lower-case, whereas the old table was mixed case. Also,
the old table mapped ZEBRA_ROUTE_OSPF6 to "OSPFv3", whereas the
new function returns "ospf6".
* ospfd.h: Remove extern struct message ospf_redistributed_proto[],
and add extern const char *ospf_redist_string(u_int route_type)
instead.
* ospf_asbr.c: (ospf_external_info_add) In two messages, use
ospf_redist_string instead of LOOKUP(ospf_redistributed_proto).
* ospf_vty.c: Remove local hard-coded table distribute_str.
(config_write_ospf_redistribute,config_write_ospf_distribute): Use
new library function zebra_route_string() instead of distribute_str[].
* ospf_zebra.c: (ospf_redistribute_set,ospf_redistribute_unset,
ospf_redistribute_default_set,ospf_redistribute_check)
In debug messages, use ospf_redist_string() instead of
LOOKUP(ospf_redistributed_proto).
* rip_zebra.c: (config_write_rip_redistribute): Remove local hard-coded
table str[]. Replace str[] with calls to new library function
zebra_route_string().
* ripd.c: Remove local hard-coded table route_info[].
(show_ip_rip) Replace uses of str[] with calls to new library
functions zebra_route_char and zebra_route_string.
* ripng_zebra.c: (ripng_redistribute_write) Remove local hard-coded
table str[]. Replace str[i] with new library function
zebra_route_string(i).
* ripngd.c: Remove local hard-coded table route_info[].
(show_ipv6_ripng) Use new library function zebra_route_char() instead
of table route_info[].
2005-10-01 19:38:06 +02:00
|
|
|
return &unknown;
|
|
|
|
}
|
2006-05-15 18:56:51 +02:00
|
|
|
if (zroute == route_types[zroute].type)
|
2005-10-01 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* zebra.h: Declare new functions zebra_route_string() and
zebra_route_char().
* log.c: (zroute_lookup,zebra_route_string,zebra_route_char) New
functions to map zebra route numbers to strings.
* zebra_vty.c: (route_type_str) Remove obsolete function: use new
library function zebra_route_string() instead. Note that there
are a few differences: for IPv6 routes, we now get "ripng" and
"ospf6" instead of the old behavior ("rip" and "ospf").
(route_type_char) Remove obsolete function: ues new library function
zebra_route_char() instead. Note that there is one difference:
the old function returned 'S' for a ZEBRA_ROUTE_SYSTEM route,
whereas the new one returns 'X'.
(vty_show_ip_route_detail,vty_show_ipv6_route_detail) Replace
route_type_str() with zebra_route_string().
(vty_show_ip_route,vty_show_ipv6_route) Replace route_type_char()
with zebra_route_char().
* bgp_vty.c: (bgp_config_write_redistribute) Use new library function
zebra_route_string instead of a local hard-coded table.
* ospf6_asbr.c: Remove local hard-coded tables zroute_name and
zroute_abname. Change the ZROUTE_NAME macro to use new library
function zebra_route_string(). Remove the ZROUTE_ABNAME macro.
(ospf6_asbr_external_route_show): Replace ZROUTE_ABNAME() with
a call to zebra_route_char(), and be sure to fix the format string,
since we now have a char instead of a char *.
* ospf6_zebra.c: Remove local hard-coded tables zebra_route_name and
zebra_route_abname. Note that the zebra_route_name[] table
contained mixed-case strings, whereas the zebra_route_string()
function returns lower-case strings.
(ospf6_zebra_read_ipv6): Change debug message to use new library
function zebra_route_string() instead of zebra_route_name[].
(show_zebra): Use new library function zebra_route_string() instead
of zebra_route_name[].
* ospf_dump.c: Remove local hard-coded table ospf_redistributed_proto.
(ospf_redist_string) New function implemented using new library
function zebra_route_string(). Note that there are a few differences
in the output that will result: the new function returns strings
that are lower-case, whereas the old table was mixed case. Also,
the old table mapped ZEBRA_ROUTE_OSPF6 to "OSPFv3", whereas the
new function returns "ospf6".
* ospfd.h: Remove extern struct message ospf_redistributed_proto[],
and add extern const char *ospf_redist_string(u_int route_type)
instead.
* ospf_asbr.c: (ospf_external_info_add) In two messages, use
ospf_redist_string instead of LOOKUP(ospf_redistributed_proto).
* ospf_vty.c: Remove local hard-coded table distribute_str.
(config_write_ospf_redistribute,config_write_ospf_distribute): Use
new library function zebra_route_string() instead of distribute_str[].
* ospf_zebra.c: (ospf_redistribute_set,ospf_redistribute_unset,
ospf_redistribute_default_set,ospf_redistribute_check)
In debug messages, use ospf_redist_string() instead of
LOOKUP(ospf_redistributed_proto).
* rip_zebra.c: (config_write_rip_redistribute): Remove local hard-coded
table str[]. Replace str[] with calls to new library function
zebra_route_string().
* ripd.c: Remove local hard-coded table route_info[].
(show_ip_rip) Replace uses of str[] with calls to new library
functions zebra_route_char and zebra_route_string.
* ripng_zebra.c: (ripng_redistribute_write) Remove local hard-coded
table str[]. Replace str[i] with new library function
zebra_route_string(i).
* ripngd.c: Remove local hard-coded table route_info[].
(show_ipv6_ripng) Use new library function zebra_route_char() instead
of table route_info[].
2005-10-01 19:38:06 +02:00
|
|
|
return &route_types[zroute];
|
2012-09-26 10:39:10 +02:00
|
|
|
for (i = 0; i < array_size(route_types); i++) {
|
2006-05-15 18:56:51 +02:00
|
|
|
if (zroute == route_types[i].type) {
|
2005-10-01 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* zebra.h: Declare new functions zebra_route_string() and
zebra_route_char().
* log.c: (zroute_lookup,zebra_route_string,zebra_route_char) New
functions to map zebra route numbers to strings.
* zebra_vty.c: (route_type_str) Remove obsolete function: use new
library function zebra_route_string() instead. Note that there
are a few differences: for IPv6 routes, we now get "ripng" and
"ospf6" instead of the old behavior ("rip" and "ospf").
(route_type_char) Remove obsolete function: ues new library function
zebra_route_char() instead. Note that there is one difference:
the old function returned 'S' for a ZEBRA_ROUTE_SYSTEM route,
whereas the new one returns 'X'.
(vty_show_ip_route_detail,vty_show_ipv6_route_detail) Replace
route_type_str() with zebra_route_string().
(vty_show_ip_route,vty_show_ipv6_route) Replace route_type_char()
with zebra_route_char().
* bgp_vty.c: (bgp_config_write_redistribute) Use new library function
zebra_route_string instead of a local hard-coded table.
* ospf6_asbr.c: Remove local hard-coded tables zroute_name and
zroute_abname. Change the ZROUTE_NAME macro to use new library
function zebra_route_string(). Remove the ZROUTE_ABNAME macro.
(ospf6_asbr_external_route_show): Replace ZROUTE_ABNAME() with
a call to zebra_route_char(), and be sure to fix the format string,
since we now have a char instead of a char *.
* ospf6_zebra.c: Remove local hard-coded tables zebra_route_name and
zebra_route_abname. Note that the zebra_route_name[] table
contained mixed-case strings, whereas the zebra_route_string()
function returns lower-case strings.
(ospf6_zebra_read_ipv6): Change debug message to use new library
function zebra_route_string() instead of zebra_route_name[].
(show_zebra): Use new library function zebra_route_string() instead
of zebra_route_name[].
* ospf_dump.c: Remove local hard-coded table ospf_redistributed_proto.
(ospf_redist_string) New function implemented using new library
function zebra_route_string(). Note that there are a few differences
in the output that will result: the new function returns strings
that are lower-case, whereas the old table was mixed case. Also,
the old table mapped ZEBRA_ROUTE_OSPF6 to "OSPFv3", whereas the
new function returns "ospf6".
* ospfd.h: Remove extern struct message ospf_redistributed_proto[],
and add extern const char *ospf_redist_string(u_int route_type)
instead.
* ospf_asbr.c: (ospf_external_info_add) In two messages, use
ospf_redist_string instead of LOOKUP(ospf_redistributed_proto).
* ospf_vty.c: Remove local hard-coded table distribute_str.
(config_write_ospf_redistribute,config_write_ospf_distribute): Use
new library function zebra_route_string() instead of distribute_str[].
* ospf_zebra.c: (ospf_redistribute_set,ospf_redistribute_unset,
ospf_redistribute_default_set,ospf_redistribute_check)
In debug messages, use ospf_redist_string() instead of
LOOKUP(ospf_redistributed_proto).
* rip_zebra.c: (config_write_rip_redistribute): Remove local hard-coded
table str[]. Replace str[] with calls to new library function
zebra_route_string().
* ripd.c: Remove local hard-coded table route_info[].
(show_ip_rip) Replace uses of str[] with calls to new library
functions zebra_route_char and zebra_route_string.
* ripng_zebra.c: (ripng_redistribute_write) Remove local hard-coded
table str[]. Replace str[i] with new library function
zebra_route_string(i).
* ripngd.c: Remove local hard-coded table route_info[].
(show_ipv6_ripng) Use new library function zebra_route_char() instead
of table route_info[].
2005-10-01 19:38:06 +02:00
|
|
|
zlog_warn(
|
2020-03-27 12:35:23 +01:00
|
|
|
"internal error: route type table out of order while searching for %u, please notify developers",
|
2005-10-01 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* zebra.h: Declare new functions zebra_route_string() and
zebra_route_char().
* log.c: (zroute_lookup,zebra_route_string,zebra_route_char) New
functions to map zebra route numbers to strings.
* zebra_vty.c: (route_type_str) Remove obsolete function: use new
library function zebra_route_string() instead. Note that there
are a few differences: for IPv6 routes, we now get "ripng" and
"ospf6" instead of the old behavior ("rip" and "ospf").
(route_type_char) Remove obsolete function: ues new library function
zebra_route_char() instead. Note that there is one difference:
the old function returned 'S' for a ZEBRA_ROUTE_SYSTEM route,
whereas the new one returns 'X'.
(vty_show_ip_route_detail,vty_show_ipv6_route_detail) Replace
route_type_str() with zebra_route_string().
(vty_show_ip_route,vty_show_ipv6_route) Replace route_type_char()
with zebra_route_char().
* bgp_vty.c: (bgp_config_write_redistribute) Use new library function
zebra_route_string instead of a local hard-coded table.
* ospf6_asbr.c: Remove local hard-coded tables zroute_name and
zroute_abname. Change the ZROUTE_NAME macro to use new library
function zebra_route_string(). Remove the ZROUTE_ABNAME macro.
(ospf6_asbr_external_route_show): Replace ZROUTE_ABNAME() with
a call to zebra_route_char(), and be sure to fix the format string,
since we now have a char instead of a char *.
* ospf6_zebra.c: Remove local hard-coded tables zebra_route_name and
zebra_route_abname. Note that the zebra_route_name[] table
contained mixed-case strings, whereas the zebra_route_string()
function returns lower-case strings.
(ospf6_zebra_read_ipv6): Change debug message to use new library
function zebra_route_string() instead of zebra_route_name[].
(show_zebra): Use new library function zebra_route_string() instead
of zebra_route_name[].
* ospf_dump.c: Remove local hard-coded table ospf_redistributed_proto.
(ospf_redist_string) New function implemented using new library
function zebra_route_string(). Note that there are a few differences
in the output that will result: the new function returns strings
that are lower-case, whereas the old table was mixed case. Also,
the old table mapped ZEBRA_ROUTE_OSPF6 to "OSPFv3", whereas the
new function returns "ospf6".
* ospfd.h: Remove extern struct message ospf_redistributed_proto[],
and add extern const char *ospf_redist_string(u_int route_type)
instead.
* ospf_asbr.c: (ospf_external_info_add) In two messages, use
ospf_redist_string instead of LOOKUP(ospf_redistributed_proto).
* ospf_vty.c: Remove local hard-coded table distribute_str.
(config_write_ospf_redistribute,config_write_ospf_distribute): Use
new library function zebra_route_string() instead of distribute_str[].
* ospf_zebra.c: (ospf_redistribute_set,ospf_redistribute_unset,
ospf_redistribute_default_set,ospf_redistribute_check)
In debug messages, use ospf_redist_string() instead of
LOOKUP(ospf_redistributed_proto).
* rip_zebra.c: (config_write_rip_redistribute): Remove local hard-coded
table str[]. Replace str[] with calls to new library function
zebra_route_string().
* ripd.c: Remove local hard-coded table route_info[].
(show_ip_rip) Replace uses of str[] with calls to new library
functions zebra_route_char and zebra_route_string.
* ripng_zebra.c: (ripng_redistribute_write) Remove local hard-coded
table str[]. Replace str[i] with new library function
zebra_route_string(i).
* ripngd.c: Remove local hard-coded table route_info[].
(show_ipv6_ripng) Use new library function zebra_route_char() instead
of table route_info[].
2005-10-01 19:38:06 +02:00
|
|
|
zroute);
|
|
|
|
return &route_types[i];
|
|
|
|
}
|
|
|
|
}
|
2018-09-13 21:34:28 +02:00
|
|
|
flog_err(EC_LIB_DEVELOPMENT,
|
2018-09-13 21:38:57 +02:00
|
|
|
"internal error: cannot find route type %u in table!", zroute);
|
2005-10-01 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* zebra.h: Declare new functions zebra_route_string() and
zebra_route_char().
* log.c: (zroute_lookup,zebra_route_string,zebra_route_char) New
functions to map zebra route numbers to strings.
* zebra_vty.c: (route_type_str) Remove obsolete function: use new
library function zebra_route_string() instead. Note that there
are a few differences: for IPv6 routes, we now get "ripng" and
"ospf6" instead of the old behavior ("rip" and "ospf").
(route_type_char) Remove obsolete function: ues new library function
zebra_route_char() instead. Note that there is one difference:
the old function returned 'S' for a ZEBRA_ROUTE_SYSTEM route,
whereas the new one returns 'X'.
(vty_show_ip_route_detail,vty_show_ipv6_route_detail) Replace
route_type_str() with zebra_route_string().
(vty_show_ip_route,vty_show_ipv6_route) Replace route_type_char()
with zebra_route_char().
* bgp_vty.c: (bgp_config_write_redistribute) Use new library function
zebra_route_string instead of a local hard-coded table.
* ospf6_asbr.c: Remove local hard-coded tables zroute_name and
zroute_abname. Change the ZROUTE_NAME macro to use new library
function zebra_route_string(). Remove the ZROUTE_ABNAME macro.
(ospf6_asbr_external_route_show): Replace ZROUTE_ABNAME() with
a call to zebra_route_char(), and be sure to fix the format string,
since we now have a char instead of a char *.
* ospf6_zebra.c: Remove local hard-coded tables zebra_route_name and
zebra_route_abname. Note that the zebra_route_name[] table
contained mixed-case strings, whereas the zebra_route_string()
function returns lower-case strings.
(ospf6_zebra_read_ipv6): Change debug message to use new library
function zebra_route_string() instead of zebra_route_name[].
(show_zebra): Use new library function zebra_route_string() instead
of zebra_route_name[].
* ospf_dump.c: Remove local hard-coded table ospf_redistributed_proto.
(ospf_redist_string) New function implemented using new library
function zebra_route_string(). Note that there are a few differences
in the output that will result: the new function returns strings
that are lower-case, whereas the old table was mixed case. Also,
the old table mapped ZEBRA_ROUTE_OSPF6 to "OSPFv3", whereas the
new function returns "ospf6".
* ospfd.h: Remove extern struct message ospf_redistributed_proto[],
and add extern const char *ospf_redist_string(u_int route_type)
instead.
* ospf_asbr.c: (ospf_external_info_add) In two messages, use
ospf_redist_string instead of LOOKUP(ospf_redistributed_proto).
* ospf_vty.c: Remove local hard-coded table distribute_str.
(config_write_ospf_redistribute,config_write_ospf_distribute): Use
new library function zebra_route_string() instead of distribute_str[].
* ospf_zebra.c: (ospf_redistribute_set,ospf_redistribute_unset,
ospf_redistribute_default_set,ospf_redistribute_check)
In debug messages, use ospf_redist_string() instead of
LOOKUP(ospf_redistributed_proto).
* rip_zebra.c: (config_write_rip_redistribute): Remove local hard-coded
table str[]. Replace str[] with calls to new library function
zebra_route_string().
* ripd.c: Remove local hard-coded table route_info[].
(show_ip_rip) Replace uses of str[] with calls to new library
functions zebra_route_char and zebra_route_string.
* ripng_zebra.c: (ripng_redistribute_write) Remove local hard-coded
table str[]. Replace str[i] with new library function
zebra_route_string(i).
* ripngd.c: Remove local hard-coded table route_info[].
(show_ipv6_ripng) Use new library function zebra_route_char() instead
of table route_info[].
2005-10-01 19:38:06 +02:00
|
|
|
return &unknown;
|
|
|
|
}
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
const char *zebra_route_string(unsigned int zroute)
|
2005-10-01 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* zebra.h: Declare new functions zebra_route_string() and
zebra_route_char().
* log.c: (zroute_lookup,zebra_route_string,zebra_route_char) New
functions to map zebra route numbers to strings.
* zebra_vty.c: (route_type_str) Remove obsolete function: use new
library function zebra_route_string() instead. Note that there
are a few differences: for IPv6 routes, we now get "ripng" and
"ospf6" instead of the old behavior ("rip" and "ospf").
(route_type_char) Remove obsolete function: ues new library function
zebra_route_char() instead. Note that there is one difference:
the old function returned 'S' for a ZEBRA_ROUTE_SYSTEM route,
whereas the new one returns 'X'.
(vty_show_ip_route_detail,vty_show_ipv6_route_detail) Replace
route_type_str() with zebra_route_string().
(vty_show_ip_route,vty_show_ipv6_route) Replace route_type_char()
with zebra_route_char().
* bgp_vty.c: (bgp_config_write_redistribute) Use new library function
zebra_route_string instead of a local hard-coded table.
* ospf6_asbr.c: Remove local hard-coded tables zroute_name and
zroute_abname. Change the ZROUTE_NAME macro to use new library
function zebra_route_string(). Remove the ZROUTE_ABNAME macro.
(ospf6_asbr_external_route_show): Replace ZROUTE_ABNAME() with
a call to zebra_route_char(), and be sure to fix the format string,
since we now have a char instead of a char *.
* ospf6_zebra.c: Remove local hard-coded tables zebra_route_name and
zebra_route_abname. Note that the zebra_route_name[] table
contained mixed-case strings, whereas the zebra_route_string()
function returns lower-case strings.
(ospf6_zebra_read_ipv6): Change debug message to use new library
function zebra_route_string() instead of zebra_route_name[].
(show_zebra): Use new library function zebra_route_string() instead
of zebra_route_name[].
* ospf_dump.c: Remove local hard-coded table ospf_redistributed_proto.
(ospf_redist_string) New function implemented using new library
function zebra_route_string(). Note that there are a few differences
in the output that will result: the new function returns strings
that are lower-case, whereas the old table was mixed case. Also,
the old table mapped ZEBRA_ROUTE_OSPF6 to "OSPFv3", whereas the
new function returns "ospf6".
* ospfd.h: Remove extern struct message ospf_redistributed_proto[],
and add extern const char *ospf_redist_string(u_int route_type)
instead.
* ospf_asbr.c: (ospf_external_info_add) In two messages, use
ospf_redist_string instead of LOOKUP(ospf_redistributed_proto).
* ospf_vty.c: Remove local hard-coded table distribute_str.
(config_write_ospf_redistribute,config_write_ospf_distribute): Use
new library function zebra_route_string() instead of distribute_str[].
* ospf_zebra.c: (ospf_redistribute_set,ospf_redistribute_unset,
ospf_redistribute_default_set,ospf_redistribute_check)
In debug messages, use ospf_redist_string() instead of
LOOKUP(ospf_redistributed_proto).
* rip_zebra.c: (config_write_rip_redistribute): Remove local hard-coded
table str[]. Replace str[] with calls to new library function
zebra_route_string().
* ripd.c: Remove local hard-coded table route_info[].
(show_ip_rip) Replace uses of str[] with calls to new library
functions zebra_route_char and zebra_route_string.
* ripng_zebra.c: (ripng_redistribute_write) Remove local hard-coded
table str[]. Replace str[i] with new library function
zebra_route_string(i).
* ripngd.c: Remove local hard-coded table route_info[].
(show_ipv6_ripng) Use new library function zebra_route_char() instead
of table route_info[].
2005-10-01 19:38:06 +02:00
|
|
|
{
|
|
|
|
return zroute_lookup(zroute)->string;
|
|
|
|
}
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
char zebra_route_char(unsigned int zroute)
|
2005-10-01 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* zebra.h: Declare new functions zebra_route_string() and
zebra_route_char().
* log.c: (zroute_lookup,zebra_route_string,zebra_route_char) New
functions to map zebra route numbers to strings.
* zebra_vty.c: (route_type_str) Remove obsolete function: use new
library function zebra_route_string() instead. Note that there
are a few differences: for IPv6 routes, we now get "ripng" and
"ospf6" instead of the old behavior ("rip" and "ospf").
(route_type_char) Remove obsolete function: ues new library function
zebra_route_char() instead. Note that there is one difference:
the old function returned 'S' for a ZEBRA_ROUTE_SYSTEM route,
whereas the new one returns 'X'.
(vty_show_ip_route_detail,vty_show_ipv6_route_detail) Replace
route_type_str() with zebra_route_string().
(vty_show_ip_route,vty_show_ipv6_route) Replace route_type_char()
with zebra_route_char().
* bgp_vty.c: (bgp_config_write_redistribute) Use new library function
zebra_route_string instead of a local hard-coded table.
* ospf6_asbr.c: Remove local hard-coded tables zroute_name and
zroute_abname. Change the ZROUTE_NAME macro to use new library
function zebra_route_string(). Remove the ZROUTE_ABNAME macro.
(ospf6_asbr_external_route_show): Replace ZROUTE_ABNAME() with
a call to zebra_route_char(), and be sure to fix the format string,
since we now have a char instead of a char *.
* ospf6_zebra.c: Remove local hard-coded tables zebra_route_name and
zebra_route_abname. Note that the zebra_route_name[] table
contained mixed-case strings, whereas the zebra_route_string()
function returns lower-case strings.
(ospf6_zebra_read_ipv6): Change debug message to use new library
function zebra_route_string() instead of zebra_route_name[].
(show_zebra): Use new library function zebra_route_string() instead
of zebra_route_name[].
* ospf_dump.c: Remove local hard-coded table ospf_redistributed_proto.
(ospf_redist_string) New function implemented using new library
function zebra_route_string(). Note that there are a few differences
in the output that will result: the new function returns strings
that are lower-case, whereas the old table was mixed case. Also,
the old table mapped ZEBRA_ROUTE_OSPF6 to "OSPFv3", whereas the
new function returns "ospf6".
* ospfd.h: Remove extern struct message ospf_redistributed_proto[],
and add extern const char *ospf_redist_string(u_int route_type)
instead.
* ospf_asbr.c: (ospf_external_info_add) In two messages, use
ospf_redist_string instead of LOOKUP(ospf_redistributed_proto).
* ospf_vty.c: Remove local hard-coded table distribute_str.
(config_write_ospf_redistribute,config_write_ospf_distribute): Use
new library function zebra_route_string() instead of distribute_str[].
* ospf_zebra.c: (ospf_redistribute_set,ospf_redistribute_unset,
ospf_redistribute_default_set,ospf_redistribute_check)
In debug messages, use ospf_redist_string() instead of
LOOKUP(ospf_redistributed_proto).
* rip_zebra.c: (config_write_rip_redistribute): Remove local hard-coded
table str[]. Replace str[] with calls to new library function
zebra_route_string().
* ripd.c: Remove local hard-coded table route_info[].
(show_ip_rip) Replace uses of str[] with calls to new library
functions zebra_route_char and zebra_route_string.
* ripng_zebra.c: (ripng_redistribute_write) Remove local hard-coded
table str[]. Replace str[i] with new library function
zebra_route_string(i).
* ripngd.c: Remove local hard-coded table route_info[].
(show_ipv6_ripng) Use new library function zebra_route_char() instead
of table route_info[].
2005-10-01 19:38:06 +02:00
|
|
|
{
|
|
|
|
return zroute_lookup(zroute)->chr;
|
|
|
|
}
|
2006-05-15 18:56:51 +02:00
|
|
|
|
|
|
|
const char *zserv_command_string(unsigned int command)
|
|
|
|
{
|
2012-09-26 10:39:10 +02:00
|
|
|
if (command >= array_size(command_types)) {
|
2018-09-13 21:34:28 +02:00
|
|
|
flog_err(EC_LIB_DEVELOPMENT, "unknown zserv command type: %u",
|
2018-09-13 21:38:57 +02:00
|
|
|
command);
|
2006-05-15 18:56:51 +02:00
|
|
|
return unknown.string;
|
|
|
|
}
|
|
|
|
return command_types[command].string;
|
|
|
|
}
|
2007-05-02 18:05:35 +02:00
|
|
|
|
2023-03-09 14:36:51 +01:00
|
|
|
#define DESC_ENTRY(T) [(T)] = {(T), (#T), '\0'}
|
|
|
|
static const struct zebra_desc_table gr_client_cap_types[] = {
|
|
|
|
DESC_ENTRY(ZEBRA_CLIENT_GR_CAPABILITIES),
|
|
|
|
DESC_ENTRY(ZEBRA_CLIENT_ROUTE_UPDATE_COMPLETE),
|
|
|
|
DESC_ENTRY(ZEBRA_CLIENT_ROUTE_UPDATE_PENDING),
|
|
|
|
DESC_ENTRY(ZEBRA_CLIENT_GR_DISABLE),
|
|
|
|
DESC_ENTRY(ZEBRA_CLIENT_RIB_STALE_TIME),
|
|
|
|
};
|
|
|
|
#undef DESC_ENTRY
|
|
|
|
|
|
|
|
const char *zserv_gr_client_cap_string(uint32_t zcc)
|
|
|
|
{
|
|
|
|
if (zcc >= array_size(gr_client_cap_types)) {
|
|
|
|
flog_err(EC_LIB_DEVELOPMENT, "unknown zserv command type: %u",
|
|
|
|
zcc);
|
|
|
|
return unknown.string;
|
|
|
|
}
|
|
|
|
return gr_client_cap_types[zcc].string;
|
|
|
|
}
|
|
|
|
|
2007-05-02 18:05:35 +02:00
|
|
|
int proto_name2num(const char *s)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
|
2012-09-26 10:39:10 +02:00
|
|
|
for (i = 0; i < array_size(route_types); ++i)
|
2007-05-02 18:05:35 +02:00
|
|
|
if (strcasecmp(s, route_types[i].string) == 0)
|
|
|
|
return route_types[i].type;
|
|
|
|
return -1;
|
|
|
|
}
|
2009-09-16 01:52:42 +02:00
|
|
|
|
|
|
|
int proto_redistnum(int afi, const char *s)
|
|
|
|
{
|
|
|
|
if (!s)
|
|
|
|
return -1;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2009-09-16 01:52:42 +02:00
|
|
|
if (afi == AFI_IP) {
|
2016-12-16 06:39:44 +01:00
|
|
|
if (strmatch(s, "kernel"))
|
2009-09-16 01:52:42 +02:00
|
|
|
return ZEBRA_ROUTE_KERNEL;
|
2016-12-16 06:39:44 +01:00
|
|
|
else if (strmatch(s, "connected"))
|
2009-09-16 01:52:42 +02:00
|
|
|
return ZEBRA_ROUTE_CONNECT;
|
*: Introduce Local Host Routes to FRR
Create Local routes in FRR:
S 0.0.0.0/0 [1/0] via 192.168.119.1, enp39s0, weight 1, 00:03:46
K>* 0.0.0.0/0 [0/100] via 192.168.119.1, enp39s0, 00:03:51
O 192.168.119.0/24 [110/100] is directly connected, enp39s0, weight 1, 00:03:46
C>* 192.168.119.0/24 is directly connected, enp39s0, 00:03:51
L>* 192.168.119.224/32 is directly connected, enp39s0, 00:03:51
O 192.168.119.229/32 [110/100] via 0.0.0.0, enp39s0 inactive, weight 1, 00:03:46
C>* 192.168.119.229/32 is directly connected, enp39s0, 00:03:46
Create ability to redistribute local routes.
Modify tests to support this change.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-01-05 00:32:43 +01:00
|
|
|
else if (strmatch(s, "local"))
|
|
|
|
return ZEBRA_ROUTE_LOCAL;
|
2016-12-16 06:39:44 +01:00
|
|
|
else if (strmatch(s, "static"))
|
2009-09-16 01:52:42 +02:00
|
|
|
return ZEBRA_ROUTE_STATIC;
|
2016-12-16 06:39:44 +01:00
|
|
|
else if (strmatch(s, "rip"))
|
2009-09-16 01:52:42 +02:00
|
|
|
return ZEBRA_ROUTE_RIP;
|
2017-03-09 05:07:46 +01:00
|
|
|
else if (strmatch(s, "eigrp"))
|
|
|
|
return ZEBRA_ROUTE_EIGRP;
|
2016-12-16 06:39:44 +01:00
|
|
|
else if (strmatch(s, "ospf"))
|
2009-09-16 01:52:42 +02:00
|
|
|
return ZEBRA_ROUTE_OSPF;
|
2016-12-16 06:39:44 +01:00
|
|
|
else if (strmatch(s, "isis"))
|
2009-09-16 01:52:42 +02:00
|
|
|
return ZEBRA_ROUTE_ISIS;
|
2016-12-16 06:39:44 +01:00
|
|
|
else if (strmatch(s, "bgp"))
|
2009-09-16 01:52:42 +02:00
|
|
|
return ZEBRA_ROUTE_BGP;
|
2016-12-16 06:39:44 +01:00
|
|
|
else if (strmatch(s, "table"))
|
2015-05-20 03:03:42 +02:00
|
|
|
return ZEBRA_ROUTE_TABLE;
|
2016-12-16 06:39:44 +01:00
|
|
|
else if (strmatch(s, "vnc"))
|
bgpd: add L3/L2VPN Virtual Network Control feature
This feature adds an L3 & L2 VPN application that makes use of the VPN
and Encap SAFIs. This code is currently used to support IETF NVO3 style
operation. In NVO3 terminology it provides the Network Virtualization
Authority (NVA) and the ability to import/export IP prefixes and MAC
addresses from Network Virtualization Edges (NVEs). The code supports
per-NVE tables.
The NVE-NVA protocol used to communicate routing and Ethernet / Layer 2
(L2) forwarding information between NVAs and NVEs is referred to as the
Remote Forwarder Protocol (RFP). OpenFlow is an example RFP. For
general background on NVO3 and RFP concepts see [1]. For information on
Openflow see [2].
RFPs are integrated with BGP via the RF API contained in the new "rfapi"
BGP sub-directory. Currently, only a simple example RFP is included in
Quagga. Developers may use this example as a starting point to integrate
Quagga with an RFP of their choosing, e.g., OpenFlow. The RFAPI code
also supports the ability import/export of routing information between
VNC and customer edge routers (CEs) operating within a virtual
network. Import/export may take place between BGP views or to the
default zebera VRF.
BGP, with IP VPNs and Tunnel Encapsulation, is used to distribute VPN
information between NVAs. BGP based IP VPN support is defined in
RFC4364, BGP/MPLS IP Virtual Private Networks (VPNs), and RFC4659,
BGP-MPLS IP Virtual Private Network (VPN) Extension for IPv6 VPN . Use
of both the Encapsulation Subsequent Address Family Identifier (SAFI)
and the Tunnel Encapsulation Attribute, RFC5512, The BGP Encapsulation
Subsequent Address Family Identifier (SAFI) and the BGP Tunnel
Encapsulation Attribute, are supported. MAC address distribution does
not follow any standard BGB encoding, although it was inspired by the
early IETF EVPN concepts.
The feature is conditionally compiled and disabled by default.
Use the --enable-bgp-vnc configure option to enable.
The majority of this code was authored by G. Paul Ziemba
<paulz@labn.net>.
[1] http://tools.ietf.org/html/draft-ietf-nvo3-nve-nva-cp-req
[2] https://www.opennetworking.org/sdn-resources/technical-library
Now includes changes needed to merge with cmaster-next.
2016-05-07 20:18:56 +02:00
|
|
|
return ZEBRA_ROUTE_VNC;
|
2017-01-07 01:44:46 +01:00
|
|
|
else if (strmatch(s, "vnc-direct"))
|
bgpd: add L3/L2VPN Virtual Network Control feature
This feature adds an L3 & L2 VPN application that makes use of the VPN
and Encap SAFIs. This code is currently used to support IETF NVO3 style
operation. In NVO3 terminology it provides the Network Virtualization
Authority (NVA) and the ability to import/export IP prefixes and MAC
addresses from Network Virtualization Edges (NVEs). The code supports
per-NVE tables.
The NVE-NVA protocol used to communicate routing and Ethernet / Layer 2
(L2) forwarding information between NVAs and NVEs is referred to as the
Remote Forwarder Protocol (RFP). OpenFlow is an example RFP. For
general background on NVO3 and RFP concepts see [1]. For information on
Openflow see [2].
RFPs are integrated with BGP via the RF API contained in the new "rfapi"
BGP sub-directory. Currently, only a simple example RFP is included in
Quagga. Developers may use this example as a starting point to integrate
Quagga with an RFP of their choosing, e.g., OpenFlow. The RFAPI code
also supports the ability import/export of routing information between
VNC and customer edge routers (CEs) operating within a virtual
network. Import/export may take place between BGP views or to the
default zebera VRF.
BGP, with IP VPNs and Tunnel Encapsulation, is used to distribute VPN
information between NVAs. BGP based IP VPN support is defined in
RFC4364, BGP/MPLS IP Virtual Private Networks (VPNs), and RFC4659,
BGP-MPLS IP Virtual Private Network (VPN) Extension for IPv6 VPN . Use
of both the Encapsulation Subsequent Address Family Identifier (SAFI)
and the Tunnel Encapsulation Attribute, RFC5512, The BGP Encapsulation
Subsequent Address Family Identifier (SAFI) and the BGP Tunnel
Encapsulation Attribute, are supported. MAC address distribution does
not follow any standard BGB encoding, although it was inspired by the
early IETF EVPN concepts.
The feature is conditionally compiled and disabled by default.
Use the --enable-bgp-vnc configure option to enable.
The majority of this code was authored by G. Paul Ziemba
<paulz@labn.net>.
[1] http://tools.ietf.org/html/draft-ietf-nvo3-nve-nva-cp-req
[2] https://www.opennetworking.org/sdn-resources/technical-library
Now includes changes needed to merge with cmaster-next.
2016-05-07 20:18:56 +02:00
|
|
|
return ZEBRA_ROUTE_VNC_DIRECT;
|
2017-04-03 01:21:09 +02:00
|
|
|
else if (strmatch(s, "nhrp"))
|
2017-01-19 16:27:01 +01:00
|
|
|
return ZEBRA_ROUTE_NHRP;
|
2017-05-14 05:15:27 +02:00
|
|
|
else if (strmatch(s, "babel"))
|
|
|
|
return ZEBRA_ROUTE_BABEL;
|
2017-11-10 18:55:16 +01:00
|
|
|
else if (strmatch(s, "sharp"))
|
|
|
|
return ZEBRA_ROUTE_SHARP;
|
2018-03-22 15:01:08 +01:00
|
|
|
else if (strmatch(s, "openfabric"))
|
|
|
|
return ZEBRA_ROUTE_OPENFABRIC;
|
2020-06-17 14:11:35 +02:00
|
|
|
else if (strmatch(s, "table-direct"))
|
|
|
|
return ZEBRA_ROUTE_TABLE_DIRECT;
|
2009-09-16 01:52:42 +02:00
|
|
|
}
|
|
|
|
if (afi == AFI_IP6) {
|
2016-12-16 06:39:44 +01:00
|
|
|
if (strmatch(s, "kernel"))
|
2009-09-16 01:52:42 +02:00
|
|
|
return ZEBRA_ROUTE_KERNEL;
|
2016-12-16 06:39:44 +01:00
|
|
|
else if (strmatch(s, "connected"))
|
2009-09-16 01:52:42 +02:00
|
|
|
return ZEBRA_ROUTE_CONNECT;
|
*: Introduce Local Host Routes to FRR
Create Local routes in FRR:
S 0.0.0.0/0 [1/0] via 192.168.119.1, enp39s0, weight 1, 00:03:46
K>* 0.0.0.0/0 [0/100] via 192.168.119.1, enp39s0, 00:03:51
O 192.168.119.0/24 [110/100] is directly connected, enp39s0, weight 1, 00:03:46
C>* 192.168.119.0/24 is directly connected, enp39s0, 00:03:51
L>* 192.168.119.224/32 is directly connected, enp39s0, 00:03:51
O 192.168.119.229/32 [110/100] via 0.0.0.0, enp39s0 inactive, weight 1, 00:03:46
C>* 192.168.119.229/32 is directly connected, enp39s0, 00:03:46
Create ability to redistribute local routes.
Modify tests to support this change.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-01-05 00:32:43 +01:00
|
|
|
else if (strmatch(s, "local"))
|
|
|
|
return ZEBRA_ROUTE_LOCAL;
|
2016-12-16 06:39:44 +01:00
|
|
|
else if (strmatch(s, "static"))
|
2009-09-16 01:52:42 +02:00
|
|
|
return ZEBRA_ROUTE_STATIC;
|
2016-12-16 06:39:44 +01:00
|
|
|
else if (strmatch(s, "ripng"))
|
2009-09-16 01:52:42 +02:00
|
|
|
return ZEBRA_ROUTE_RIPNG;
|
2016-12-16 06:39:44 +01:00
|
|
|
else if (strmatch(s, "ospf6"))
|
2009-09-16 01:52:42 +02:00
|
|
|
return ZEBRA_ROUTE_OSPF6;
|
2016-12-16 06:39:44 +01:00
|
|
|
else if (strmatch(s, "isis"))
|
2009-09-16 01:52:42 +02:00
|
|
|
return ZEBRA_ROUTE_ISIS;
|
2016-12-16 06:39:44 +01:00
|
|
|
else if (strmatch(s, "bgp"))
|
2009-09-16 01:52:42 +02:00
|
|
|
return ZEBRA_ROUTE_BGP;
|
2016-12-16 06:39:44 +01:00
|
|
|
else if (strmatch(s, "table"))
|
2015-05-20 03:03:42 +02:00
|
|
|
return ZEBRA_ROUTE_TABLE;
|
2016-12-16 06:39:44 +01:00
|
|
|
else if (strmatch(s, "vnc"))
|
bgpd: add L3/L2VPN Virtual Network Control feature
This feature adds an L3 & L2 VPN application that makes use of the VPN
and Encap SAFIs. This code is currently used to support IETF NVO3 style
operation. In NVO3 terminology it provides the Network Virtualization
Authority (NVA) and the ability to import/export IP prefixes and MAC
addresses from Network Virtualization Edges (NVEs). The code supports
per-NVE tables.
The NVE-NVA protocol used to communicate routing and Ethernet / Layer 2
(L2) forwarding information between NVAs and NVEs is referred to as the
Remote Forwarder Protocol (RFP). OpenFlow is an example RFP. For
general background on NVO3 and RFP concepts see [1]. For information on
Openflow see [2].
RFPs are integrated with BGP via the RF API contained in the new "rfapi"
BGP sub-directory. Currently, only a simple example RFP is included in
Quagga. Developers may use this example as a starting point to integrate
Quagga with an RFP of their choosing, e.g., OpenFlow. The RFAPI code
also supports the ability import/export of routing information between
VNC and customer edge routers (CEs) operating within a virtual
network. Import/export may take place between BGP views or to the
default zebera VRF.
BGP, with IP VPNs and Tunnel Encapsulation, is used to distribute VPN
information between NVAs. BGP based IP VPN support is defined in
RFC4364, BGP/MPLS IP Virtual Private Networks (VPNs), and RFC4659,
BGP-MPLS IP Virtual Private Network (VPN) Extension for IPv6 VPN . Use
of both the Encapsulation Subsequent Address Family Identifier (SAFI)
and the Tunnel Encapsulation Attribute, RFC5512, The BGP Encapsulation
Subsequent Address Family Identifier (SAFI) and the BGP Tunnel
Encapsulation Attribute, are supported. MAC address distribution does
not follow any standard BGB encoding, although it was inspired by the
early IETF EVPN concepts.
The feature is conditionally compiled and disabled by default.
Use the --enable-bgp-vnc configure option to enable.
The majority of this code was authored by G. Paul Ziemba
<paulz@labn.net>.
[1] http://tools.ietf.org/html/draft-ietf-nvo3-nve-nva-cp-req
[2] https://www.opennetworking.org/sdn-resources/technical-library
Now includes changes needed to merge with cmaster-next.
2016-05-07 20:18:56 +02:00
|
|
|
return ZEBRA_ROUTE_VNC;
|
2017-01-07 01:44:46 +01:00
|
|
|
else if (strmatch(s, "vnc-direct"))
|
bgpd: add L3/L2VPN Virtual Network Control feature
This feature adds an L3 & L2 VPN application that makes use of the VPN
and Encap SAFIs. This code is currently used to support IETF NVO3 style
operation. In NVO3 terminology it provides the Network Virtualization
Authority (NVA) and the ability to import/export IP prefixes and MAC
addresses from Network Virtualization Edges (NVEs). The code supports
per-NVE tables.
The NVE-NVA protocol used to communicate routing and Ethernet / Layer 2
(L2) forwarding information between NVAs and NVEs is referred to as the
Remote Forwarder Protocol (RFP). OpenFlow is an example RFP. For
general background on NVO3 and RFP concepts see [1]. For information on
Openflow see [2].
RFPs are integrated with BGP via the RF API contained in the new "rfapi"
BGP sub-directory. Currently, only a simple example RFP is included in
Quagga. Developers may use this example as a starting point to integrate
Quagga with an RFP of their choosing, e.g., OpenFlow. The RFAPI code
also supports the ability import/export of routing information between
VNC and customer edge routers (CEs) operating within a virtual
network. Import/export may take place between BGP views or to the
default zebera VRF.
BGP, with IP VPNs and Tunnel Encapsulation, is used to distribute VPN
information between NVAs. BGP based IP VPN support is defined in
RFC4364, BGP/MPLS IP Virtual Private Networks (VPNs), and RFC4659,
BGP-MPLS IP Virtual Private Network (VPN) Extension for IPv6 VPN . Use
of both the Encapsulation Subsequent Address Family Identifier (SAFI)
and the Tunnel Encapsulation Attribute, RFC5512, The BGP Encapsulation
Subsequent Address Family Identifier (SAFI) and the BGP Tunnel
Encapsulation Attribute, are supported. MAC address distribution does
not follow any standard BGB encoding, although it was inspired by the
early IETF EVPN concepts.
The feature is conditionally compiled and disabled by default.
Use the --enable-bgp-vnc configure option to enable.
The majority of this code was authored by G. Paul Ziemba
<paulz@labn.net>.
[1] http://tools.ietf.org/html/draft-ietf-nvo3-nve-nva-cp-req
[2] https://www.opennetworking.org/sdn-resources/technical-library
Now includes changes needed to merge with cmaster-next.
2016-05-07 20:18:56 +02:00
|
|
|
return ZEBRA_ROUTE_VNC_DIRECT;
|
2017-04-03 01:21:09 +02:00
|
|
|
else if (strmatch(s, "nhrp"))
|
2017-01-19 16:27:01 +01:00
|
|
|
return ZEBRA_ROUTE_NHRP;
|
2017-05-14 05:15:27 +02:00
|
|
|
else if (strmatch(s, "babel"))
|
|
|
|
return ZEBRA_ROUTE_BABEL;
|
2017-11-10 18:55:16 +01:00
|
|
|
else if (strmatch(s, "sharp"))
|
|
|
|
return ZEBRA_ROUTE_SHARP;
|
2018-03-22 15:01:08 +01:00
|
|
|
else if (strmatch(s, "openfabric"))
|
|
|
|
return ZEBRA_ROUTE_OPENFABRIC;
|
2020-06-17 14:11:35 +02:00
|
|
|
else if (strmatch(s, "table-direct"))
|
|
|
|
return ZEBRA_ROUTE_TABLE_DIRECT;
|
2009-09-16 01:52:42 +02:00
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
2015-10-21 03:46:55 +02:00
|
|
|
|
2020-03-24 19:37:58 +01:00
|
|
|
void zlog_hexdump(const void *mem, size_t len)
|
2016-05-26 01:14:36 +02:00
|
|
|
{
|
2020-03-24 19:37:58 +01:00
|
|
|
char line[64];
|
|
|
|
const uint8_t *src = mem;
|
|
|
|
const uint8_t *end = src + len;
|
|
|
|
|
|
|
|
if (len == 0) {
|
|
|
|
zlog_debug("%016lx: (zero length / no data)", (long)src);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (src < end) {
|
|
|
|
struct fbuf fb = {
|
|
|
|
.buf = line,
|
|
|
|
.pos = line,
|
|
|
|
.len = sizeof(line),
|
|
|
|
};
|
|
|
|
const uint8_t *lineend = src + 8;
|
|
|
|
unsigned line_bytes = 0;
|
|
|
|
|
|
|
|
bprintfrr(&fb, "%016lx: ", (long)src);
|
|
|
|
|
|
|
|
while (src < lineend && src < end) {
|
|
|
|
bprintfrr(&fb, "%02x ", *src++);
|
|
|
|
line_bytes++;
|
|
|
|
}
|
|
|
|
if (line_bytes < 8)
|
|
|
|
bprintfrr(&fb, "%*s", (8 - line_bytes) * 3, "");
|
|
|
|
|
|
|
|
src -= line_bytes;
|
|
|
|
while (src < lineend && src < end && fb.pos < fb.buf + fb.len) {
|
|
|
|
uint8_t byte = *src++;
|
|
|
|
|
|
|
|
if (isprint(byte))
|
|
|
|
*fb.pos++ = byte;
|
|
|
|
else
|
|
|
|
*fb.pos++ = '.';
|
2015-10-21 03:46:55 +02:00
|
|
|
}
|
2020-03-24 19:37:58 +01:00
|
|
|
|
|
|
|
zlog_debug("%.*s", (int)(fb.pos - fb.buf), fb.buf);
|
2015-10-21 03:46:55 +02:00
|
|
|
}
|
|
|
|
}
|
2017-03-02 17:33:37 +01:00
|
|
|
|
|
|
|
const char *zlog_sanitize(char *buf, size_t bufsz, const void *in, size_t inlen)
|
|
|
|
{
|
|
|
|
const char *inbuf = in;
|
|
|
|
char *pos = buf, *end = buf + bufsz;
|
|
|
|
const char *iend = inbuf + inlen;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-03-02 17:33:37 +01:00
|
|
|
memset(buf, 0, bufsz);
|
|
|
|
for (; inbuf < iend; inbuf++) {
|
|
|
|
/* don't write partial escape sequence */
|
|
|
|
if (end - pos < 5)
|
|
|
|
break;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-03-02 17:33:37 +01:00
|
|
|
if (*inbuf == '\n')
|
|
|
|
snprintf(pos, end - pos, "\\n");
|
|
|
|
else if (*inbuf == '\r')
|
|
|
|
snprintf(pos, end - pos, "\\r");
|
|
|
|
else if (*inbuf == '\t')
|
|
|
|
snprintf(pos, end - pos, "\\t");
|
|
|
|
else if (*inbuf < ' ' || *inbuf == '"' || *inbuf >= 127)
|
|
|
|
snprintf(pos, end - pos, "\\x%02hhx", *inbuf);
|
|
|
|
else
|
|
|
|
*pos = *inbuf;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-03-02 17:33:37 +01:00
|
|
|
pos += strlen(pos);
|
|
|
|
}
|
|
|
|
return buf;
|
|
|
|
}
|