Commit graph

35 commits

Author SHA1 Message Date
Christian Hopps 4f9d162526 lib: suppress clang-analyzer false-positives
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-04-10 04:53:08 +00:00
Christian Hopps f9c759ee4e lib: nb: add list_entry_done() callback to free resources
The existing iteration callback only allows for a daemon to return a
pointer to objects that must already exist and must continue to exists
indefinitely.

To allow the daemon to return allocated iterator objects and for locking
it's container structures we need a callback to tell the daemon when FRR
is done using the returned value, so the daemon can free it (or unlock
etc)

That's what list_entry_done() is for.

Signed-off-by: Christian Hopps <chopps@labn.net>
2025-04-10 04:49:59 +00:00
Mark Stapp 27ba9956a1 lib,ripd: resolve clang SA warnings
Looks like there were a couple of SA warnings lurking; fix
them.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2025-04-08 14:41:27 -04:00
Christian Hopps 4663c3ef82 lib: suppress libyang logs during expected error result.
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-03-14 14:36:13 +00:00
Christian Hopps 48ceff2128 lib: northbound: also log debugs for new get callback
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-03-14 14:36:13 +00:00
Christian Hopps 2586c4c3ed lib: make sure we update the darr_strlen from pruned string.
This fixes a bug when handling of queries which include list nodes in
the xpath.

Signed-off-by: Christian Hopps <chopps@labn.net>
2025-03-14 08:37:46 +00:00
Christian Hopps 656c4692a0 lib: nb: fix bug with oper-state query on list data
The capacity of the xpath string was not guaranteed to be sufficient to hold all
the key predicates and so would truncate. Calculate the required space and
guarantee that it is available.

Signed-off-by: Christian Hopps <chopps@labn.net>
2025-02-26 13:38:42 +00:00
Christian Hopps bd68a01d9a lib: nb: notification add locking support for multi-threading
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-02-26 13:38:42 +00:00
Christian Hopps 915dcd220d lib: northbound: support pre-built oper state in libyang tree
This also fixes a bug with specific (position specified) queries on keyless
lists. If the `get_next` callback is using the parent entry it will probably
crash as the code is passing the list_entry as both parent and child in the
specific lookup case.

There may currently be no code that uses the parent entry if the child entry is
non-NULL, though.

Signed-off-by: Christian Hopps <chopps@labn.net>
2025-02-24 04:09:17 +00:00
Christian Hopps b9ff10b086 lib: nb: fix oper-state queries that involve choice/case nodes
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-02-22 16:25:31 +00:00
Christian Hopps 5f2a927d7b lib: northbound/mgmtd: add backend model support
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-14 18:48:59 +00:00
Christian Hopps 709b2ae23f lib: notify on datastore (oper-state) changes
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-13 23:40:52 -05:00
Christian Hopps 8a52b69ca4 lib: northbound: add basic oper-state update functions
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-13 23:40:52 -05:00
Donald Sharp cc07a4a200
Merge pull request #17772 from LabNConsulting/chopps/fix-oper-walk
improve error handling of operational state walk callback
2025-01-07 13:52:37 -05:00
Donald Sharp 96ab6ae32b
Merge pull request #17781 from LabNConsulting/chopps/fix-keyless-list-query
fix xpath query on keyless list with positional predicate
2025-01-07 13:17:37 -05:00
Christian Hopps 36f25da612 lib: northbound: add new get() callback to add lyd_node direclty
This allows eliminating the superfluous yang_data object (which
is getting created used to call lyd_new_term then deleted). Instead
just call lyd_new_term() in the callback directly.

Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-07 05:33:28 -05:00
Christian Hopps 2fb6519c52 lib: northbound oper: fix keyless position predicate queries
- i.e., `show /foos/foo[1]`

Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-07 01:24:14 -05:00
Christian Hopps 9aa2b04874 lib: change and improve walk finish callback function API
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-06 08:07:41 -05:00
Christian Hopps c5df98aece mgmtd: add ietf-yang-library support
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-09-17 22:27:36 -04:00
Christian Hopps 035843705b lib: fix clang SA warnings
Also, cleanup some unreachable code in `nb_op_sib_next()`.

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-09-07 22:12:03 -04:00
David Lamparter 552a0a3a28 lib: fix time_t print without cast
The gcc plugin wasn't warning about printing `suseconds_t` (which is
`time_t`, but in `struct timeval`.)  It needs to be printed with a cast,
just like `time_t`.  Luckily there is only one such usage.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-05-02 22:26:53 +02:00
Igor Ryzhov 1196d947d3 mgmtd: add support for native 'edit' operation
This operation basically implements support for RESTCONF operations. It
receives an xpath and a data tree in JSON/XML format, instead of a list
of (xpath, value) tuples as required by the current protobuf interface.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-03-26 17:00:15 +02:00
Igor Ryzhov 10eac0a54d lib: fix oper data leaf creation
When creating an initial tree trunk for oper data walk, if the xpath
represents a leaf, the leaf is created with an incorrect empty value.
If it doesn't actually exist in daemon's oper data, its value is not
overwritten later and an empty value is returned in the result.

For example, when requesting
`/frr-interface:lib/interface[name='eth0']/description`, the result is:
```
{
  "frr-interface:lib": {
    "interface": [
      {
        "name": "eth0",
        "description": ""
      }
    ]
  }
}
```
instead of an empty JSON that it should be.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-15 10:27:33 +02:00
Christian Hopps 008ba3e3fb
lib: fix coverity issue
** CID 1575595:  Null pointer dereferences  (REVERSE_INULL)

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-12 16:37:30 +00:00
Christian Hopps 7b7725f7b8
lib: change type of inner to struct lyd_node *, cleaner code
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-11 13:51:23 +00:00
Christian Hopps 32a4c4019e lib: implement missing YANG choice/case statements.
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-11 13:38:57 +00:00
Donatas Abraitis 4c875482a5
Merge pull request #15123 from LabNConsulting/chopps/fix-oper-state-memleak
lib: fix oper-state memleak
2024-01-10 12:16:37 +02:00
Christian Hopps 5519c0fbe6
lib: fix oper-state memleak
Fix memleak when a key-ed query was done for which the key didn't exist.

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-09 21:52:41 +00:00
Christian Hopps 1e4229fc1f lib: use libyang functions if they are present
Add configure.ac tests for libyang functions, if not present supply the
functionality ourselves in yang.[ch]

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-07 15:17:56 +00:00
Christian Hopps cf67a7e265 lib: mgmtd: implement full XPath 1.0 predicate functionality
Allow user to specify full YANG compatible XPath 1.0 predicates. This
allows for trimming results of generic queries using functions and other
non-key predicates from XPath 1.0

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-07 15:17:30 +00:00
Christian Hopps 00138ffb47 lib: fix clang SA warnings
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-07 15:04:18 +00:00
Donald Sharp 60f099657f
Merge pull request #15073 from LabNConsulting/chopps/fix-yang-key-queries
lib: fix specific entry queries
2024-01-02 10:06:22 -05:00
Christian Hopps 412eec1bed
lib: don't count on scheme key nodes being first children
Heard back from libyang folks that this is not something they consider part of
the API and/or are going to guarantee. So we cannot count on it. Expect keys at
any location on the child sibling list.

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-02 11:34:34 +00:00
Christian Hopps 7e6595698b
lib: fix specific entry queries
- fix key leaf queries
- fix specific list entry with non-key leaf top element

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-02 09:47:15 +00:00
Christian Hopps ad1ccb6e62 lib: northbound: add yielding and batching to oper-state queries
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 17:52:57 +00:00