summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/log.c2
-rw-r--r--lib/monotime.h6
-rw-r--r--lib/northbound.c21
-rw-r--r--lib/northbound_cli.c21
-rw-r--r--lib/subdir.am5
-rw-r--r--lib/vty.c1
-rw-r--r--lib/zclient.c8
-rw-r--r--lib/zclient.h3
8 files changed, 48 insertions, 19 deletions
diff --git a/lib/log.c b/lib/log.c
index fb12c08aae..5c453569ee 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -239,7 +239,7 @@ void zlog_backtrace(int priority)
{
#ifdef HAVE_LIBUNWIND
char buf[100];
- unw_cursor_t cursor;
+ unw_cursor_t cursor = {};
unw_context_t uc;
unw_word_t ip, off, sp;
Dl_info dlinfo;
diff --git a/lib/monotime.h b/lib/monotime.h
index 15b6933955..89616c5427 100644
--- a/lib/monotime.h
+++ b/lib/monotime.h
@@ -81,9 +81,9 @@ static inline time_t monotime(struct timeval *tvo)
return ts.tv_sec;
}
-#define ONE_DAY_SECOND 60*60*24
-#define ONE_WEEK_SECOND ONE_DAY_SECOND*7
-#define ONE_YEAR_SECOND ONE_DAY_SECOND*365
+#define ONE_DAY_SECOND (60 * 60 * 24)
+#define ONE_WEEK_SECOND (ONE_DAY_SECOND * 7)
+#define ONE_YEAR_SECOND (ONE_DAY_SECOND * 365)
/* the following two return microseconds, not time_t!
*
diff --git a/lib/northbound.c b/lib/northbound.c
index 49adea6d53..2cc7ac6ea1 100644
--- a/lib/northbound.c
+++ b/lib/northbound.c
@@ -1649,10 +1649,12 @@ static int nb_oper_data_iter_container(const struct nb_node *nb_node,
uint32_t flags, nb_oper_data_cb cb,
void *arg)
{
+ const struct lysc_node *snode = nb_node->snode;
+
if (CHECK_FLAG(nb_node->flags, F_NB_NODE_CONFIG_ONLY))
return NB_OK;
- /* Presence containers. */
+ /* Read-only presence containers. */
if (nb_node->cbs.get_elem) {
struct yang_data *data;
int ret;
@@ -1662,15 +1664,24 @@ static int nb_oper_data_iter_container(const struct nb_node *nb_node,
/* Presence container is not present. */
return NB_OK;
- ret = (*cb)(nb_node->snode, translator, data, arg);
+ ret = (*cb)(snode, translator, data, arg);
if (ret != NB_OK)
return ret;
}
+ /* Read-write presence containers. */
+ if (CHECK_FLAG(snode->flags, LYS_CONFIG_W)) {
+ struct lysc_node_container *scontainer;
+
+ scontainer = (struct lysc_node_container *)snode;
+ if (CHECK_FLAG(scontainer->flags, LYS_PRESENCE)
+ && !yang_dnode_get(running_config->dnode, xpath))
+ return NB_OK;
+ }
+
/* Iterate over the child nodes. */
- return nb_oper_data_iter_children(nb_node->snode, xpath, list_entry,
- list_keys, translator, false, flags,
- cb, arg);
+ return nb_oper_data_iter_children(snode, xpath, list_entry, list_keys,
+ translator, false, flags, cb, arg);
}
static int
diff --git a/lib/northbound_cli.c b/lib/northbound_cli.c
index 1e25f6a1e2..56eac9dc32 100644
--- a/lib/northbound_cli.c
+++ b/lib/northbound_cli.c
@@ -1464,6 +1464,7 @@ DEFPY (show_yang_operational_data,
[{\
format <json$json|xml$xml>\
|translate WORD$translator_family\
+ |with-config$with_config\
}]",
SHOW_STR
"YANG information\n"
@@ -1473,13 +1474,15 @@ DEFPY (show_yang_operational_data,
"JavaScript Object Notation\n"
"Extensible Markup Language\n"
"Translate operational data\n"
- "YANG module translator\n")
+ "YANG module translator\n"
+ "Merge configuration data\n")
{
LYD_FORMAT format;
struct yang_translator *translator = NULL;
struct ly_ctx *ly_ctx;
struct lyd_node *dnode;
char *strp;
+ uint32_t print_options = LYD_PRINT_WITHSIBLINGS;
if (xml)
format = LYD_XML;
@@ -1507,13 +1510,21 @@ DEFPY (show_yang_operational_data,
yang_dnode_free(dnode);
return CMD_WARNING;
}
+
+ if (with_config && yang_dnode_exists(running_config->dnode, xpath)) {
+ struct lyd_node *config_dnode =
+ yang_dnode_get(running_config->dnode, xpath);
+ if (config_dnode != NULL) {
+ lyd_merge_tree(&dnode, yang_dnode_dup(config_dnode),
+ LYD_MERGE_DESTRUCT);
+ print_options |= LYD_PRINT_WD_ALL;
+ }
+ }
+
(void)lyd_validate_all(&dnode, ly_ctx, 0, NULL);
/* Display the data. */
- if (lyd_print_mem(&strp, dnode, format,
- LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL)
- != 0
- || !strp) {
+ if (lyd_print_mem(&strp, dnode, format, print_options) != 0 || !strp) {
vty_out(vty, "%% Failed to display operational data.\n");
yang_dnode_free(dnode);
return CMD_WARNING;
diff --git a/lib/subdir.am b/lib/subdir.am
index b505e235ca..d1df9cb3d9 100644
--- a/lib/subdir.am
+++ b/lib/subdir.am
@@ -523,6 +523,11 @@ lib/clippy-command_parse.$(OBJEXT): lib/command_lex.h
lib/lib_clippy-command_lex.$(OBJEXT): lib/command_parse.h
lib/lib_clippy-command_parse.$(OBJEXT): lib/command_lex.h
+DISTCLEANFILES += lib/command_lex.h \
+ lib/command_lex.c \
+ lib/command_parse.h \
+ lib/command_parse.c
+
rt_enabled =
if BABELD
diff --git a/lib/vty.c b/lib/vty.c
index 78ef9894de..619d51e1ce 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -2033,6 +2033,7 @@ static int vtysh_do_pass_fd(struct vty *vty)
struct cmsghdr *cmh = CMSG_FIRSTHDR(&mh);
ssize_t ret;
+ memset(&u.buf, 0, sizeof(u.buf));
cmh->cmsg_level = SOL_SOCKET;
cmh->cmsg_type = SCM_RIGHTS;
cmh->cmsg_len = CMSG_LEN(sizeof(int));
diff --git a/lib/zclient.c b/lib/zclient.c
index f6c5a8af08..0c34214151 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -768,9 +768,9 @@ static void zclient_connect(struct thread *t)
}
enum zclient_send_status zclient_send_rnh(struct zclient *zclient, int command,
- const struct prefix *p,
- bool connected,
- bool resolve_via_def, vrf_id_t vrf_id)
+ const struct prefix *p, safi_t safi,
+ bool connected, bool resolve_via_def,
+ vrf_id_t vrf_id)
{
struct stream *s;
@@ -779,7 +779,7 @@ enum zclient_send_status zclient_send_rnh(struct zclient *zclient, int command,
zclient_create_header(s, command, vrf_id);
stream_putc(s, (connected) ? 1 : 0);
stream_putc(s, (resolve_via_def) ? 1 : 0);
- stream_putw(s, SAFI_UNICAST);
+ stream_putw(s, safi);
stream_putw(s, PREFIX_FAMILY(p));
stream_putc(s, p->prefixlen);
switch (PREFIX_FAMILY(p)) {
diff --git a/lib/zclient.h b/lib/zclient.h
index 092754f602..7e1283d830 100644
--- a/lib/zclient.h
+++ b/lib/zclient.h
@@ -1071,7 +1071,8 @@ extern enum zclient_send_status zclient_route_send(uint8_t, struct zclient *,
struct zapi_route *);
extern enum zclient_send_status
zclient_send_rnh(struct zclient *zclient, int command, const struct prefix *p,
- bool connected, bool resolve_via_default, vrf_id_t vrf_id);
+ safi_t safi, bool connected, bool resolve_via_default,
+ vrf_id_t vrf_id);
int zapi_nexthop_encode(struct stream *s, const struct zapi_nexthop *api_nh,
uint32_t api_flags, uint32_t api_message);
extern int zapi_route_encode(uint8_t, struct stream *, struct zapi_route *);