Commit graph

6191 commits

Author SHA1 Message Date
Mark Stapp c65fdc9a49 lib: disable clang warning in parser yacc output
Disable a clang 'unused' warning in the yacc source
of command_parse.c.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2025-04-16 13:50:21 -04:00
Russ White 796e1af6e2
Merge pull request #18540 from LabNConsulting/chopps/list-entry-done
lib: nb: add list_entry_done() callback to free resources
2025-04-15 11:30:50 -04:00
Mark Stapp 81b472bd79 lib,bgpd: clean up clang warnings
Clean up a couple of clang compiler warnings (this was
clang 18)

Signed-off-by: Mark Stapp <mjs@cisco.com>
2025-04-14 15:32:08 -04:00
Philippe Guibert 27fa9ac4db lib, staticd, isisd: add B6.Encaps codepoint extensions
Add codepoint extensions for END.B6.Encaps instruction.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2025-04-11 09:36:29 +02:00
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
Mark Stapp 536944dc53 lib,ripd: clean up -Wshadow compiler warnings
Clean up compiler warnings; convert a linklist macro
to an inline to resolve one; clean up a side-effect in isisd.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2025-04-08 14:41:27 -04:00
Mark Stapp 028872bf40 lib: fix -Wshadow warnings in the lib modules
Fix various "shadow" warnings in lib.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2025-04-08 14:41:26 -04:00
David Lamparter d683c4d8de lib: don't shadow _once in frr_with_mutex
The `_once` loop variable will result in a `-Wshadow` warning when that
is turned on.  Use `__COUNTER__` to give these variables distinct names,
like is already done with `_mtx_`.

(and because I touched it, clang-format wants it reformatted... ohwell.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2025-04-08 14:41:26 -04:00
Donatas Abraitis 24ae7cd30a lib: Return duplicate ipv6 prefix-list entry test
Fixes: 8384d41144 ("lib: Return duplicate prefix-list entry test")

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2025-04-02 11:09:59 +03:00
Donald Sharp 2da251264d lib: Add a affinity_map_terminate() function
This function will clean up memory associated with affinity maps
on shutdown

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-03-30 17:54:34 -04:00
Donald Sharp d682f42d5b lib: show route-map should not print (null)
This command:
route-map FOOBAR permit 10
 set ipv6 next-hop prefer-global
 set community 5060:12345 additive
!

When you issue a `show route-map ...` command displays this:

route-map: FOOBAR Invoked: 0 (0 milliseconds total) Optimization: enabled Processed Change: false
 permit, sequence 5 Invoked 0 (0 milliseconds total)
  Match clauses:
  Set clauses:
    ipv6 next-hop prefer-global (null)
    community 5060:12345 additive
  Call clause:
  Action:
    Exit routemap

Modify the code so that it no longer displays the NULL when there
is nothing to display.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-03-26 14:35:13 -04:00
Mark Stapp 38fd34f363
Merge pull request #18482 from donaldsharp/eigrp_typesafe
Eigrp typesafe
2025-03-26 07:54:23 -04:00
Donatas Abraitis 8384d41144 lib: Return duplicate prefix-list entry test
If we do e.g.:

ip prefix-list PL_LoopbackV4 permit 10.1.0.32/32
ip prefix-list PL_LoopbackV4 permit 10.1.0.32/32
ip prefix-list PL_LoopbackV4 permit 10.1.0.32/32

We end up, having duplicate records with a different sequence number only.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2025-03-25 13:54:24 +02:00
Donald Sharp 5f9e26069e lib: expose comparision function to allow a typesafe conversion
The interface hash comparison function is needed in eigrpd.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-03-24 11:00:45 -04:00
Mark Stapp 556d3c445d
Merge pull request #18359 from soumyar-roy/soumya/streamsize
zebra: zebra crash for zapi stream
2025-03-21 11:30:16 -04:00
Donatas Abraitis 797e051222
Merge pull request #17986 from dmytroshytyi-6WIND/fix-static-30-01-2025
lib: fix static analysis error
2025-03-21 12:19:50 +02:00
Soumya Roy 860c1e4450 zebra: reduce memory usage by streams when redistributing routes
This commit undo 8c9b007a0c
stream lib has been modified to expand the stream if needed
Now for zapi route encode, we use expandable stream

Signed-off-by: Soumya Roy <souroy@nvidia.com>
2025-03-20 16:13:44 +00:00
Soumya Roy c0c46bad15 lib: Add support for stream buffer to expand
Issue:
 Currently, during encode time, if required memory is
 more than available space in stream buffer, stream buffer
 can't be expanded. This fix introduces new apis to support
 stream buffer expansion.

 Testing:
 Tested with zebra nexthop encoding with 512 nexthops, which triggers
 this new code changes, it works fine. Without fix, for same trigger
 it asserts.

 Signed-off-by: Soumya Roy <souroy@nvidia.com>
2025-03-20 16:13:34 +00:00
Nathan Bahr b6ae01f907 lib: Create VRF if needed
When creating a control plane protocol through NB, create the vrf
if needed instead of only looking up and asserting if it doesn't
exist yet.
Fixes 18429.

Signed-off-by: Nathan Bahr <nbahr@atcorp.com>
2025-03-19 16:08:56 +00: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 d58a8f473b lib: add darr_strlen_fixup() to update len based on NUL term
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-03-14 08:37:46 +00:00
Mark Stapp d0cb3ad7cb
Merge pull request #16614 from louis-6wind/fix-otable-heap-after-free
zebra: fix table heap-after-free crash
2025-03-11 14:03:14 -04:00
Russ White 27a504fcef
Merge pull request #18342 from anlancs/ospfd-minor-change
ospfd: minor change for style
2025-03-11 10:33:41 -04:00
Dmytro Shytyi 83de17ca9b
lib: call to 'calloc' has an allocation size of 0 bytes
w->sects = calloc(sizeof(PyObject *), w->ehdr->e_shnum);

Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
2025-03-11 11:16:01 +01:00
Louis Scalbert c6afe42455 lib, tests, zebra: keep table routes at vrf disabling
At VRF disabling, keep the route entries that was associated to its
table ID but not to the VRF itself. Kernel flushes these entries so we
need to reinstall them.

To do so, add a flag to mean that a route entry is owned by a table ID
and not by a VRF. If the VRF associated to the table ID is deleted, the
route entry must not be deleted.

Update to tests with new flag. 2057 is in hexa 0x809, meaning that the
new flag has been to some prefix.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2025-03-10 09:54:18 +01:00
Karthikeya Venkat Muppalla bb09c35592 lib: use memcpy in bf_copy
use memcpy in bf_copy() instead of copy word by word in for loop

Signed-off-by: Karthikeya Venkat Muppalla <kmuppalla@nvidia.com>
2025-03-07 11:59:20 -08:00
anlan_cs 2775cb77a8 lib: remove unused macro
This macro is unused and it leads to the compile error:

```
./ospfd/ospf_dump.h:78:60: error: pasting "OSPF_DEBUG_" and ""Global Graceful Restart - GR Mode\n"" does not give a valid preprocessing token
   78 | #define TERM_DEBUG_ON(a, b)      term_debug_ospf_ ## a |= (OSPF_DEBUG_ ## b)
```

Signed-off-by: anlan_cs <anlan_cs@126.com>
2025-03-07 10:17:18 +08:00
Donald Sharp c83af86991 lib: Document --command-log-always in help
The --command-log-always was not being listed as a valid
option for when the operator issues a <daemon> --help
command line.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-03-05 10:10:48 -05:00
Christian Hopps 5cf533ba74
Merge pull request #18268 from donaldsharp/yang_correct_vrf_issue
lib: Correct handling of /frr-vrf:lib/vrf/state/active
2025-03-05 01:19:05 -05:00
Mark Stapp b66145b8ca
Merge pull request #18030 from fdumontet6WIND/mem_alloc_stream
zebra: reduce memory usage by streams when redistributing routes
2025-03-03 11:09:47 -05:00
Philippe Guibert 52b1db86dc bgpd: add match ecommunity <exact|any> options
The exact-match and the any options are missing for the extended
communities. Add missing options that are present on the match
operations for communities and large-communities.

> route-map rmap permit 1
>  match extcommunity 1
> exit
> !
> route-map rmap permit 2
>  match extcommunity 2 any
> exit
> !
> route-map rmap permit 3
>  match extcommunity 3 exact-match
> exit

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2025-02-27 22:25:52 +01:00
Philippe Guibert c3084cacf4 bgpd: add 'match extcommunity-count' command to restrict comm count
Add a mechanism in route-map to filter out route-map which have a list
of extended communities greater than the given number.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2025-02-27 22:25:52 +01:00
Francois Dumontet 8c9b007a0c zebra: reduce memory usage by streams when redistributing routes
required stream size is evaluated as a fix part and variable one.
the variable one depend on the number of nexthops.

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
2025-02-27 16:51:05 +01:00
Donald Sharp 14c4678771 lib: Prevent crash in getting label chunk
ldpd has this crash:

(gdb) bt
0  __pthread_kill_implementation (no_tid=0, signo=11, threadid=140329211443648) at ./nptl/pthread_kill.c:44
1  __pthread_kill_internal (signo=11, threadid=140329211443648) at ./nptl/pthread_kill.c:78
2  __GI___pthread_kill (threadid=140329211443648, signo=signo@entry=11) at ./nptl/pthread_kill.c:89
3  0x00007fa0f0642476 in __GI_raise (sig=11) at ../sysdeps/posix/raise.c:26
4  0x00007fa0f0b51944 in core_handler (signo=11, siginfo=0x7fff562810b0, context=0x7fff56280f80) at lib/sigevent.c:268
5  <signal handler called>
6  0x00007fa0f0b9534d in lm_get_label_chunk (zclient=0x0, keep=0 '\000', base=0, chunk_size=64, start=0x7fff56281bdc, end=0x7fff56281be0) at lib/zclient.c:3667
7  0x0000564e0d1c011e in lde_get_label_chunk () at ldpd/lde.c:2211
8  0x0000564e0d1c05f8 in lde_get_next_label () at ldpd/lde.c:2318
9  0x0000564e0d1bcb29 in lde_update_label (fn=0x564e16653050) at ldpd/lde.c:783
10 0x0000564e0d1c1fbe in lde_kernel_update (fec=0x7fff56281cb0) at ldpd/lde_lib.c:422
11 0x0000564e0d1b96c0 in l2vpn_pw_init (pw=0x564e165d1fa0) at ldpd/l2vpn.c:242
12 0x0000564e0d1b2d32 in merge_l2vpn (xconf=0x564e166424f0, l2vpn=0x564e166160a0, xl=0x564e165eabb0) at ldpd/ldpd.c:1883
13 0x0000564e0d1b28ea in merge_l2vpns (conf=0x564e166424f0, xconf=0x564e16653650) at ldpd/ldpd.c:1813
14 0x0000564e0d1b1244 in merge_config (conf=0x564e166424f0, xconf=0x564e16653650) at ldpd/ldpd.c:1321
15 0x0000564e0d1bc485 in lde_dispatch_parent (thread=0x7fff56282060) at ldpd/lde.c:611
16 0x00007fa0f0b6cebc in event_call (thread=0x7fff56282060) at lib/event.c:2019
17 0x0000564e0d1baee7 in lde () at ldpd/lde.c:155
18 0x0000564e0d1ae4b8 in main (argc=0, argv=0x7fff56282298) at ldpd/ldpd.c:312
(gdb)

Since it is possible to be asking for label data before the zclient has
been connected, let's just return -1 in the case where zclient is not
initialized yet either, since this is effectively the same thing as
the sock being < 0.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-02-27 08:29:26 -05:00
Donald Sharp ad04988ad4 lib: Correct handling of /frr-vrf:lib/vrf/state/active
This value in the yang tree was returning NULL for
when the state of the vrf was not active.  It should
return a false.

Before:

eva# show mgmt get-data /frr-vrf:lib/vrf[name="vrf1"]
{
  "frr-vrf:lib": {
    "vrf": [
      {
        "name": "vrf1",
        "state": {
          "id": 4294967295
        }
eva# show mgmt get-data /frr-vrf:lib/vrf[name="BLUE"]
{
  "frr-vrf:lib": {
    "vrf": [
      {
        "name": "BLUE",
        "state": {
          "id": 68,
          "active": true
        },

After:

eva# show mgmt get-data /frr-vrf:lib/vrf[name="vrf1"]
{
  "frr-vrf:lib": {
    "vrf": [
      {
        "name": "vrf1",
        "state": {
          "id": 4294967295,
          "active": false
        }

eva# show mgmt get-data /frr-vrf:lib/vrf[name="BLUE"]
{
  "frr-vrf:lib": {
    "vrf": [
      {
        "name": "BLUE",
        "state": {
          "id": 68,
          "active": true
        },

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-02-26 16:01:04 -05:00
Donald Sharp f62ab436e6
Merge pull request #18237 from LabNConsulting/chopps/oper-walk-tree
support pre-built oper state in libyang tree
2025-02-26 11:19:11 -05:00
Donald Sharp 594f65d888
Merge pull request #18242 from kaffarell/master
fabricd: add option to treat dummy interfaces as loopback interfaces
2025-02-26 11:18:22 -05: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
Carmine Scarpitta feff426771 lib: Add ifindex to SRv6 SID context
The uA behavior is associated with an interface and the IP address of
the nexthop. However, the current SID context data structure only
includes the IP address. It lacks the interface.

This commit extends the SID context data structure by adding the
ifindex. This extension allows daemons to allocate uA SIDs with
the required interface and IP address.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2025-02-26 07:19:51 +01:00
Gabriel Goller 80e96712e4 zebra: add ZEBRA_IF_DUMMY flag for dummy interfaces
Introduce ZEBRA_IF_DUMMY interface flag to identify Linux dummy interfaces [0].
These interfaces behave similarly to loopback interfaces and can be
specially handled by daemons.

[0]: https://github.com/torvalds/linux/blob/master/drivers/net/dummy.c

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2025-02-25 10:13:34 +01: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
Russ White 3eedab0928
Merge pull request #18095 from opensourcerouting/zebra-check-class-e
Use ipv4 class E addresses (240.0.0.0/4) as connected routes by default
2025-02-18 08:31:31 -05:00
Carmine Scarpitta b85cf812c2
Merge pull request #17957 from pguibert6WIND/codepoint_add_some_flavors
isisd, lib: add some codepoints usually shared with other vendors
2025-02-18 11:06:51 +01:00
Jafar Al-Gharaibeh 4315f2eedb
Merge pull request #18082 from LabNConsulting/chopps/fix-yang-config-destroy
lib: nb: call child destroy CBs when YANG container is deleted
2025-02-17 20:35:49 -06:00