From a61567a916da2c58cc16a4d161238b8a7b1d9e3e Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Fri, 17 Jun 2022 12:18:58 +0200 Subject: [PATCH] SNMP: Fixed leafref index issue and table min-column issue for mult index --- CHANGELOG.md | 4 +--- apps/snmp/snmp_handler.c | 5 ++++- apps/snmp/snmp_main.c | 6 ++++-- apps/snmp/snmp_register.c | 2 +- include/clixon_custom.h | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee377faf..53898bd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,9 +49,7 @@ * `--enable-netsnmp` * `--with-mib-generated-yang-dir=DIR` * Current limitations: - * Only static tables - * No advanced table indexes, (only integers) - * Memory leaks + * Table add rows/columns via netsnmp API ## 5.7.0 Expected: May 2022 diff --git a/apps/snmp/snmp_handler.c b/apps/snmp/snmp_handler.c index 952f38a7..a9cc5f9a 100644 --- a/apps/snmp/snmp_handler.c +++ b/apps/snmp/snmp_handler.c @@ -489,11 +489,14 @@ snmp_table_get(clicon_handle h, while ((ys = yn_each(yt, ys)) != NULL) { if (yang_keyword_get(ys) != Y_LEAF) continue; + /* reset oid */ + oidleaflen = MAX_OID_LEN; if ((ret = yangext_oid_get(ys, oidleaf, &oidleaflen, NULL)) < 0) goto done; if (ret == 0) goto done; - assert(oidtlen + 1 == oidleaflen); + if (oidtlen + 1 != oidleaflen) /* Indexes may be from other OID scope, skip those */ + continue; if (oids[oidleaflen-1] == oidleaf[oidleaflen-1]) break; } diff --git a/apps/snmp/snmp_main.c b/apps/snmp/snmp_main.c index 0a0fbc6c..654dee22 100644 --- a/apps/snmp/snmp_main.c +++ b/apps/snmp/snmp_main.c @@ -35,9 +35,11 @@ * It assumes a netsnmp damon is running. * - If netsnmp does not run, clixon_snmp will not start * - If netsnmp dies, clixon_snmp will exit - * - If netsnmp is restarted, so should clixon_snmp be + * - If netsnmp is restarted, clixon_snmp should also be restarted * It is possible to be more resilient, such as setting a timer and trying again, in fact, libnetsnmp - * has some such mechanisms + * has some such mechanisms but these are NOT implemented + * @see RFC 6643 Translation of Structure of Management Information Version 2 (SMIv2) + * MIB Modules to YANG Modules */ #ifdef HAVE_CONFIG_H diff --git a/apps/snmp/snmp_register.c b/apps/snmp/snmp_register.c index d9338a30..f3589a00 100644 --- a/apps/snmp/snmp_register.c +++ b/apps/snmp/snmp_register.c @@ -312,7 +312,7 @@ mibyang_table_register(clicon_handle h, goto done; } } - table_info->min_column = cvec_len(cvk); + table_info->min_column = 1; /* Count columns */ yleaf = NULL; diff --git a/include/clixon_custom.h b/include/clixon_custom.h index b50ea485..a2eb628e 100644 --- a/include/clixon_custom.h +++ b/include/clixon_custom.h @@ -166,4 +166,4 @@ /*! Re-register table entries when quering */ -#undef SNMP_TABLE_DYNAMIC +#define SNMP_TABLE_DYNAMIC