]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: prevent gRPC assert on missing YANG node
authorRafael Zalamena <rzalamena@opensourcerouting.org>
Mon, 4 Oct 2021 21:10:58 +0000 (18:10 -0300)
committerRafael Zalamena <rzalamena@opensourcerouting.org>
Tue, 5 Oct 2021 13:22:27 +0000 (10:22 -0300)
`yang_dnode_get` will `assert` if no YANG node/model exist, so lets test for
its existence first before trying to access it.

This `assert` is only acceptable for internal FRR usage otherwise we
might miss typos or unmatching YANG models nodes/leaves. For gRPC usage
we should let users attempt to use non existing models without
`assert`ing.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
lib/northbound_grpc.cpp

index 71f07dfe86d283697de7eb6e1483ead76707d33d..e227d0385c4c140520247c9e8927d0c7fe44d893 100644 (file)
@@ -344,6 +344,10 @@ static struct lyd_node *get_dnode_config(const std::string &path)
 {
        struct lyd_node *dnode;
 
+       if (!yang_dnode_exists(running_config->dnode,
+                              path.empty() ? NULL : path.c_str()))
+               return NULL;
+
        dnode = yang_dnode_get(running_config->dnode,
                               path.empty() ? NULL : path.c_str());
        if (dnode)