* New clixon-config@2022-02-11.yang revision
* Added option: `CLICON_LOG_STRING_LIMIT`
This commit is contained in:
parent
396680d0b3
commit
6ae749c9dd
11 changed files with 1204 additions and 9 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# Clixon Changelog
|
||||
|
||||
* [5.6.0](#560) Expected: Matrch 2022
|
||||
* [5.6.0](#560) Expected: March 2022
|
||||
* [5.5.0](#550) 20 January 2022
|
||||
* [5.4.0](#540) 30 November 2021
|
||||
* [5.3.0](#530) 27 September 2021
|
||||
|
|
@ -49,6 +49,13 @@ Users may have to change how they access the system
|
|||
* `configure --with-wwwdir=<dir>` is removed
|
||||
* Command field of clixon-lib:process-control RPC reply used CDATA encoding but now uses regular XML encoding
|
||||
|
||||
### Minor features
|
||||
|
||||
* New `clixon-config@2022-02-11.yang` revision
|
||||
* Added option: `CLICON_LOG_STRING_LIMIT`
|
||||
* Limit the length of log and debug messages. Some log messages are dependendent on sizes that can be very large, such as packet lengths. This new option constrains the length of all messgaes. By default no limits.
|
||||
|
||||
|
||||
### Corrected Bugs
|
||||
|
||||
* Fixed: input RPC validation of choice (non-case)
|
||||
|
|
|
|||
|
|
@ -509,6 +509,7 @@ main(int argc,
|
|||
size_t cligen_buflen;
|
||||
size_t cligen_bufthreshold;
|
||||
int dbg;
|
||||
size_t sz;
|
||||
|
||||
/* In the startup, logs to stderr & syslog and debug flag set later */
|
||||
clicon_log_init(__PROGRAM__, LOG_INFO, logdst);
|
||||
|
|
@ -691,6 +692,9 @@ main(int argc,
|
|||
cligen_bufthreshold = clicon_option_int(h, "CLICON_CLI_BUF_THRESHOLD");
|
||||
cbuf_alloc_set(cligen_buflen, cligen_bufthreshold);
|
||||
|
||||
if ((sz = clicon_option_int(h, "CLICON_LOG_STRING_LIMIT")) != 0)
|
||||
clicon_log_string_limit_set(sz);
|
||||
|
||||
#ifndef HAVE_LIBXML2
|
||||
if (clicon_yang_regexp(h) == REGEXP_LIBXML2){
|
||||
clicon_err(OE_FATAL, 0, "CLICON_YANG_REGEXP set to libxml2, but HAVE_LIBXML2 not set (Either change CLICON_YANG_REGEXP to posix, or run: configure --with-libxml2))");
|
||||
|
|
|
|||
|
|
@ -649,6 +649,9 @@ main(int argc,
|
|||
nr = clicon_option_int(h, "CLICON_CLI_HELPSTRING_LINES");
|
||||
cligen_helpstring_lines_set(cli_cligen(h), nr);
|
||||
|
||||
if ((nr = clicon_option_int(h, "CLICON_LOG_STRING_LIMIT")) != 0)
|
||||
clicon_log_string_limit_set(nr);
|
||||
|
||||
/* Setup signal handlers */
|
||||
cli_signal_init(h);
|
||||
|
||||
|
|
|
|||
|
|
@ -662,6 +662,7 @@ main(int argc,
|
|||
size_t cligen_buflen;
|
||||
size_t cligen_bufthreshold;
|
||||
int dbg = 0;
|
||||
size_t sz;
|
||||
|
||||
/* Create handle */
|
||||
if ((h = clicon_handle_init()) == NULL)
|
||||
|
|
@ -791,6 +792,9 @@ main(int argc,
|
|||
cligen_bufthreshold = clicon_option_int(h, "CLICON_CLI_BUF_THRESHOLD");
|
||||
cbuf_alloc_set(cligen_buflen, cligen_bufthreshold);
|
||||
|
||||
if ((sz = clicon_option_int(h, "CLICON_LOG_STRING_LIMIT")) != 0)
|
||||
clicon_log_string_limit_set(sz);
|
||||
|
||||
/* Set default namespace according to CLICON_NAMESPACE_NETCONF_DEFAULT */
|
||||
xml_nsctx_namespace_netconf_default(h);
|
||||
|
||||
|
|
|
|||
|
|
@ -312,6 +312,7 @@ main(int argc,
|
|||
cxobj *xerr = NULL;
|
||||
char *wwwuser;
|
||||
char *inline_config = NULL;
|
||||
size_t sz;
|
||||
|
||||
/* In the startup, logs to stderr & debug flag set later */
|
||||
clicon_log_init(__PROGRAM__, LOG_INFO, logdst);
|
||||
|
|
@ -438,6 +439,9 @@ main(int argc,
|
|||
cligen_bufthreshold = clicon_option_int(h, "CLICON_CLI_BUF_THRESHOLD");
|
||||
cbuf_alloc_set(cligen_buflen, cligen_bufthreshold);
|
||||
|
||||
if ((sz = clicon_option_int(h, "CLICON_LOG_STRING_LIMIT")) != 0)
|
||||
clicon_log_string_limit_set(sz);
|
||||
|
||||
/* Set default namespace according to CLICON_NAMESPACE_NETCONF_DEFAULT */
|
||||
xml_nsctx_namespace_netconf_default(h);
|
||||
|
||||
|
|
|
|||
|
|
@ -1210,6 +1210,7 @@ restconf_clixon_init(clicon_handle h,
|
|||
cxobj *xrestconf = NULL;
|
||||
cxobj *xerr = NULL;
|
||||
int ret;
|
||||
size_t sz;
|
||||
|
||||
/* Set default namespace according to CLICON_NAMESPACE_NETCONF_DEFAULT */
|
||||
xml_nsctx_namespace_netconf_default(h);
|
||||
|
|
@ -1219,6 +1220,9 @@ restconf_clixon_init(clicon_handle h,
|
|||
cligen_bufthreshold = clicon_option_int(h, "CLICON_CLI_BUF_THRESHOLD");
|
||||
cbuf_alloc_set(cligen_buflen, cligen_bufthreshold);
|
||||
|
||||
if ((sz = clicon_option_int(h, "CLICON_LOG_STRING_LIMIT")) != 0)
|
||||
clicon_log_string_limit_set(sz);
|
||||
|
||||
/* Add (hardcoded) netconf features in case ietf-netconf loaded here
|
||||
* Otherwise it is loaded in netconf_module_load below
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@ int clicon_log_init(char *ident, int upto, int flags);
|
|||
int clicon_log_exit(void);
|
||||
int clicon_log_opt(char c);
|
||||
int clicon_log_file(char *filename);
|
||||
int clicon_log_string_limit_set(size_t sz);
|
||||
size_t clicon_log_string_limit_get(void);
|
||||
int clicon_get_logflags(void);
|
||||
int clicon_log(int level, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
int clicon_debug(int dbglevel, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
|
|
|
|||
|
|
@ -73,6 +73,9 @@ static int _logflags = 0x0;
|
|||
/* Set to open file to write debug messages directly to file */
|
||||
static FILE *_logfile = NULL;
|
||||
|
||||
/* Truncate debug strings to this length. 0 means unlimited */
|
||||
static int _clixon_log_trunc = 0;
|
||||
|
||||
/*! Initialize system logger.
|
||||
*
|
||||
* Make syslog(3) calls with specified ident and gates calls of level upto specified level (upto).
|
||||
|
|
@ -165,6 +168,23 @@ clicon_get_logflags(void)
|
|||
return _logflags;
|
||||
}
|
||||
|
||||
/*! Truncate log/debug string length
|
||||
*/
|
||||
int
|
||||
clicon_log_string_limit_set(size_t sz)
|
||||
{
|
||||
_clixon_log_trunc = sz;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*! Get truncate log/debug string length
|
||||
*/
|
||||
size_t
|
||||
clicon_log_string_limit_get(void)
|
||||
{
|
||||
return _clixon_log_trunc;
|
||||
}
|
||||
|
||||
/*! Mimic syslog and print a time on file f
|
||||
*/
|
||||
static int
|
||||
|
|
@ -254,22 +274,28 @@ clicon_log_str(int level,
|
|||
* @code
|
||||
clicon_log(LOG_NOTICE, "%s: dump to dtd not supported", __PROGRAM__);
|
||||
* @endcode
|
||||
* @see clicon_log_init and clicon_log_str
|
||||
* @see clicon_log_init clicon_log_str
|
||||
* @see clicon_log_xml
|
||||
*/
|
||||
int
|
||||
clicon_log(int level,
|
||||
const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
int len;
|
||||
size_t len;
|
||||
char *msg = NULL;
|
||||
int retval = -1;
|
||||
size_t trunc;
|
||||
|
||||
/* first round: compute length of debug message */
|
||||
va_start(args, format);
|
||||
len = vsnprintf(NULL, 0, format, args);
|
||||
va_end(args);
|
||||
|
||||
/* Truncate long debug strings */
|
||||
if ((trunc = clicon_log_string_limit_get()) && trunc < len)
|
||||
len = trunc;
|
||||
|
||||
/* allocate a message string exactly fitting the message length */
|
||||
if ((msg = malloc(len+1)) == NULL){
|
||||
fprintf(stderr, "malloc: %s\n", strerror(errno)); /* dont use clicon_err here due to recursion */
|
||||
|
|
@ -349,9 +375,10 @@ clicon_debug(int dbglevel,
|
|||
const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
int len;
|
||||
size_t len;
|
||||
char *msg = NULL;
|
||||
int retval = -1;
|
||||
size_t trunc;
|
||||
|
||||
if (dbglevel > _clixon_debug) /* compare debug mask with global variable */
|
||||
return 0;
|
||||
|
|
@ -360,7 +387,11 @@ clicon_debug(int dbglevel,
|
|||
len = vsnprintf(NULL, 0, format, args);
|
||||
va_end(args);
|
||||
|
||||
/* allocate a message string exactly fitting the messgae length */
|
||||
/* Truncate long debug strings */
|
||||
if ((trunc = clicon_log_string_limit_get()) && trunc < len)
|
||||
len = trunc;
|
||||
|
||||
/* allocate a message string exactly fitting the message length */
|
||||
if ((msg = malloc(len+1)) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "malloc");
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -2339,10 +2339,11 @@ clicon_log_xml(int level,
|
|||
const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
int len;
|
||||
size_t len;
|
||||
char *msg = NULL;
|
||||
cbuf *cb = NULL;
|
||||
int retval = -1;
|
||||
size_t trunc;
|
||||
|
||||
/* Print xml as cbuf */
|
||||
if ((cb = cbuf_new()) == NULL){
|
||||
|
|
@ -2357,6 +2358,10 @@ clicon_log_xml(int level,
|
|||
len = vsnprintf(NULL, 0, format, args);
|
||||
va_end(args);
|
||||
|
||||
/* Truncate long debug strings */
|
||||
if ((trunc = clicon_log_string_limit_get()) && trunc < len)
|
||||
len = trunc;
|
||||
|
||||
/* allocate a message string exactly fitting the message length */
|
||||
if ((msg = malloc(len+1)) == NULL){
|
||||
fprintf(stderr, "malloc: %s\n", strerror(errno)); /* dont use clicon_err here due to recursion */
|
||||
|
|
|
|||
|
|
@ -41,8 +41,7 @@ datarootdir = @datarootdir@
|
|||
# Also mandatory standard YANGs (see ../mandatory)
|
||||
YANG_INSTALLDIR = @YANG_INSTALLDIR@
|
||||
|
||||
YANGSPECS = clixon-config@2021-07-11.yang # 5.3
|
||||
YANGSPECS = clixon-config@2021-12-05.yang # 5.5
|
||||
YANGSPECS = clixon-config@2022-02-11.yang # 5.6
|
||||
YANGSPECS += clixon-lib@2021-12-05.yang # 5.5
|
||||
YANGSPECS += clixon-rfc5277@2008-07-01.yang
|
||||
YANGSPECS += clixon-xml-changelog@2019-03-21.yang
|
||||
|
|
|
|||
1132
yang/clixon/clixon-config@2022-02-11.yang
Normal file
1132
yang/clixon/clixon-config@2022-02-11.yang
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue