diff options
| author | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2021-10-04 18:10:58 -0300 |
|---|---|---|
| committer | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2021-10-05 10:22:27 -0300 |
| commit | 0f538858c2bd22072539c8dbd4ad87601b0fc8ac (patch) | |
| tree | e18f343d4fc786b76a3f90415b63ffa65ce290a8 | |
| parent | fd7abfa80b85190bbb790730d11f1d31e7c45669 (diff) | |
lib: prevent gRPC assert on missing YANG node
`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>
| -rw-r--r-- | lib/northbound_grpc.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/northbound_grpc.cpp b/lib/northbound_grpc.cpp index 71f07dfe86..e227d0385c 100644 --- a/lib/northbound_grpc.cpp +++ b/lib/northbound_grpc.cpp @@ -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) |
