Commit graph

6199 commits

Author SHA1 Message Date
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
Christian Hopps d03ecf4562 lib: nb: call child destroy CBs when YANG container is deleted
Previously the code was only calling the child destroy callbacks if the target
deleted node was a non-presence container. We now add a flag to the callback
structure to instruct northbound to perform the rescursive delete for code that
wishes for this to happen.

- Fix wrong relative path lookup in keychain destroy callback

Signed-off-by: Christian Hopps <chopps@labn.net>
2025-02-14 18:14:30 +00:00
Philippe Guibert 53263b4b62 isisd, lib: add some codepoints usually shared with other vendors
Some codepoints can not be read by interoperating with CISCO.
This is because PSP/USP flavor are used by default, and the display of
the isis output has to be adapted.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2025-02-14 15:40:42 +01:00
David Schweizer 1eef3a77e3
lib,zebra: Allow class E prefixes in RIB
Changes allow ipv4 class E addresses and prefixes in the 240.0.0.0/4
range to be configured on interfaces, imported from the kernel routing
table and redistributed as connected routes in zebra by default.

Changes also fix routes with class E prefixes in kernel routing table
getting rejected by zebra during early daemon startup.

Drivin this change in default behavior are cloud providers (with
customers still using obsolete ipv4 protocol, i.e. Azure, AWS) running
out of ip space and abusing class E for addressing instances (announced
via BGP) over tunneling connections back to customers on premise
infrastructure.

Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
2025-02-14 15:05:08 +01:00
Donald Sharp 8a661e5152
Merge pull request #18064 from cscarpitta/fix/fix_srv6_sid_parameters
staticd: Fix SRv6 SID installation and deletion
2025-02-13 13:37:22 -05:00
Carmine Scarpitta caeef98e73
Merge pull request #18023 from pguibert6WIND/srv6_route_dump
lib: fix false context information for SRv6 route
2025-02-13 18:57:44 +01:00
Donald Sharp 9623612fc0
Merge pull request #18094 from opensourcerouting/event-tardy-bfd
lib (+bfd): improve late timer warnings
2025-02-12 09:29:54 -05:00
Donald Sharp f64104bd97
Merge pull request #18060 from opensourcerouting/lib-crashlog-signals
lib: crash handlers must be allowed on threads
2025-02-11 12:25:28 -05:00
David Lamparter 236a5c8ddb lib: thread -> event in formatting
Make it consistent and call it `event` when formatting something to
display.  Much less confusing for some user seeing it too, since threads
aren't involved.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2025-02-11 12:16:17 +01:00
David Lamparter ff76fb21d7 lib: improve late timer warnings
Refactor the "timer getting executed too late" warning:

- warning threshold is now adjustable
- check is performed when event actually executes, rather than when it's
  thrown on ready list
- ignore_late_timer replaced with threshold = 0
- system load averages printed in log message
- warning ratelimited to once per 10s rather than once per poll()

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2025-02-11 12:16:08 +01:00
David Lamparter a97be61de8
Merge pull request #17775 from gromit1811/pr_journald_bugfix 2025-02-10 09:27:50 +01:00
Carmine Scarpitta 312f7b3f8c lib: Add sidStructure in SRv6 SIDs JSON output
The `show ipv6 route json` command displays the IPv6 routing table in
JSON format, including SRv6 SIDs. For each SRv6 SID, it provides
behavior and SID attributes. However, it does not include the SID
structure.

This commit adds the SID structure to the SRv6 SID JSON output.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2025-02-08 22:31:19 +01:00
David Lamparter 13a6ac5b4c lib: crash handlers must be allowed on threads
Blocking all signals on non-main threads is not the way to go, at least
the handlers for SIGSEGV, SIGBUS, SIGILL, SIGABRT and SIGFPE need to run
so we get backtraces.  Otherwise the process just exits.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2025-02-07 13:37:43 +01:00
Philippe Guibert 658bf0281d lib: fix false context information for SRv6 route
The seg6local route dumped by 'show ipv6 route' makes think that the USP
flavor is supported, whereas it is not the case. This information is a
context information, and for End, the context information should be
empty.

> # show ipv6 route
> [..]
> I>* fc00:0:4::/128 [115/0] is directly connected, sr0, seg6local End USP, weight 1, 00:49:01

Fix this by suppressing the USP information from the output.

Fixes: e496b42030 ("bgpd: prefix-sid srv6 l3vpn service tlv")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2025-02-06 08:21:56 +01:00
Donald Sharp 0b42b4ce6d
Merge pull request #17901 from opensourcerouting/nexthop_hashing
lib: actually hash all 16 bytes of IPv6 addresses, not just 4
2025-02-05 09:14:58 -05:00
Russ White 4349cab51b
Merge pull request #17953 from donaldsharp/limit_ip_protocol
lib: Remove System routes from ip protocol route map choices
2025-02-04 11:43:10 -05:00
Russ White f9e11d6974
Merge pull request #17943 from opensourcerouting/clear-event-cpu-uaf
lib: fix use after free in `clear event cpu`
2025-02-04 06:57:52 -05:00
Russ White adeb30d8f3
Merge pull request #17336 from forrestchu/sbfd
implement SBFD
2025-02-04 06:36:43 -05:00
Mark Stapp e13a4485bf libs: return from change_caps if no caps
When called without caps/privs, just return from "change_caps"
instead of exiting - it's possible that a process may not need
privs, but a lib (for example) may use the api.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2025-01-31 13:13:48 -05:00
David Lamparter 001fcfa1dd lib: clean up nexthop hashing mess
We were hashing 4 bytes of the address.  Even for IPv6 addresses.

Oops.

The reason this was done was to try to make it faster, but made a
complex maze out of everything.  Time for a refactor.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2025-01-29 16:48:37 +01:00
David Lamparter 4a0e1419a6 lib: guard against padding garbage in ZAPI read
When reading in a nexthop from ZAPI, only set the fields that actually
have meaning.  While it shouldn't happen to begin with, we can otherwise
carry padding garbage into the unused leftover union bytes.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2025-01-29 16:48:37 +01:00
Donald Sharp fb8e399e4f lib: Remove System routes from ip protocol route map choices
Do not allow system routes to be selected for ip protocol

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-01-29 09:31:53 -05:00
Russ White bd82864d03
Merge pull request #17941 from opensourcerouting/fix-dst-src
static: fix botched staticd YANG conversion for dst-src
2025-01-28 12:23:06 -05:00
David Lamparter cae176e10a lib: fix use after free in clear event cpu
Freeing any item here means freeing someone's `event->hist`, leaving a
dangling pointer there.  Which will immediately be written to because
we're executing in a CLI function under the `vty_read` event, whose
`event->hist` is then updated.

Deallocating `event->hist` anywhere other than shutting down the whole
event loop is a bad idea to begin with, just zero out the stats instead.

Fixes: FRRouting/frr#16419
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2025-01-28 16:40:25 +01:00
David Lamparter 2af780650f lib, zebra: carry source prefix in route_notify
When a daemon wants to know about its routes, make it possible to have
that work for dst-src routes.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2025-01-28 15:40:17 +01:00
David Lamparter 3671ce36fd staticd: fix botched staticd YANG for dst-src
The staticd YANG conversion completely f*cked up dst-src routes.
Stupidly enough, the correct thing is much simpler as seen by the amount
of deletes in this commit.

This does, unfortunately, involve a rather annoying YANG edge case with
what should reasonably be an optional leaf as part of a list key, which
is not possible.  It uses `::/0` as unconditional filler instead, since
that is semantically correct.

The `test_yang_mgmt` topotest needed to be adjusted after this to add
`src-prefix='::/0'`.

Fixes: 88fa5104a0 ("staticd : Configuration northbound implementation")
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2025-01-28 15:40:17 +01:00
Rafael Zalamena 5846339eae bgpd,lib: document the table id / instance usage
Document where relevant about the instance overload to table ID so users
know what to expect.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2025-01-23 15:13:01 -03:00
Rafael Zalamena 28a9ca3405 lib,zebra: VRF table-direct support
Implement the necessary data structures and code changes to support sending
table-direct routes to protocols running in different VRFs.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2025-01-23 14:37:09 -03:00
Rafael Zalamena dfdc12e164 lib: abstract instance redistribution management
Use the linked list `del` callback to free memory instead of manually calling.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2025-01-23 14:37:09 -03:00
wumu.zsl e766b68a18 bfdd: Fix CI build issue on kernel with no IPV6_HDRINCL
Signed-off-by: wumu.zsl <wumu.zsl@alibaba-inc.com>
2025-01-23 03:25:02 +00:00
wumu.zsl 0ef6003167 bfdd: add bfdname info when notify bfd status to PTM
Signed-off-by: wumu.zsl <wumu.zsl@alibaba-inc.com>
2025-01-23 02:59:55 +00:00
wumu.zsl c4f9964aec bfdd: add bfdname in bfd_key
sbfd will use bfdname for key hash, We introduced a bfd-name for every sbfd session, normal BFD sessions can leave it as NULL.
A unique bfd-name can be used to identify a sbfd session quickly. This is quite useful in our Srv6 deployment for path protection case.
For example, if use the sbfd session to protect the SRv6 path A-B-D, we would assign the name 'path-a-b-d' or 'a-b-d' to the session.

Signed-off-by: wumu.zsl <wumu.zsl@alibaba-inc.com>
2025-01-22 15:00:24 +00:00
Christian Hopps fb5a71fa95 lib: fix coverity use after free issue: CID 1620101
The code doesn't push more than one group (currently) so wouldn't hit the
bug yet, nice catch by coverity.

Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-21 16:27:44 +00:00
Philippe Guibert 084ebc9473
Merge pull request #16894 from wenwang00/project-phoenixwing-ysj
staticd: Add support for SRv6 Static SIDs
2025-01-20 09:20:15 +01:00
Christian Hopps 60666745a8 lib: fix dnode_create to use correct libyang function.
The previous use of `lyd_new_path()` returns the first node created, rather
than the xpath target node. The code is lucky in the sense that it is
normally only creating a single node rather than a branch. Fix this to
use `lyd_new_path2()` which returns the target node to actually implement
the semantics expected by callers of `dnode_create()` (i.e., returning the
newly created target node).

Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-18 23:39:32 +00:00
Christian Hopps 597d79a89e lib: improve error handling for datastore notifications
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-18 16:14:29 +00:00
Christian Hopps 94f70c2100 lib: mgmt_be_client handles datastore notification using CBs
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-18 16:13:54 +00:00
Christian Hopps 2375a11b08 lib: yang: add yang_parse_data function
This is similar to notify and RPC parsers, but this is for normal datastore
data. This is initially used in handling datastore notifications being sent to
another backend client[s].

Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-18 16:13:53 +00:00
Yuqing Zhao 4d958078b8 lib: Add CLI node for SRv6 static SIDs
Signed-off-by: Yuqing Zhao <galadriel.zyq@alibaba-inc.com>
2025-01-18 10:28:49 +00:00
Yuqing Zhao 7aefc15f64 lib, isisd: Move DEFAULT_SRV6_IFNAME to global srv6.h header
This commit moves DEFAULT_SRV6_IFNAME from isis_srv6.h to srv6.h
because there are other daemons that might want to use it (e.g. staticd).

Signed-off-by: Yuqing Zhao <galadriel.zyq@alibaba-inc.com>
2025-01-18 10:28:49 +00:00
Yuqing Zhao 2025a0c617 lib: Add a function to print SRv6 Endpoint Behavior Codepoints
Signed-off-by: Yuqing Zhao <galadriel.zyq@alibaba-inc.com>
2025-01-18 10:28:49 +00:00
Donatas Abraitis 705e6f881b
Merge pull request #17836 from pguibert6WIND/limit_comm_list_count
limit community list count
2025-01-17 12:44:24 +02:00
Igor Ryzhov 300f8dbda4 lib: introduce global -w option for VRF netns backend
Current -n option is only for zebra and mgmtd. All other daemons receive
the VRF backend configuration from zebra upon connection to it. This
leads to a potential race condition - daemons need to know the backend
before they start reading their config, but they can be not connected to
zebra yet at this point. As the VRF backend cannot change during runtime,
let's introduce a new global -w option for setting netns backend, to
make sure that all daemons know their VRF backend immediately after
start.

The reason for introducing a new option instead of making -n global is
that ospfd already uses -n for another purposes.

Signed-off-by: Igor Ryzhov <idryzhov@gmail.com>
2025-01-15 23:38:27 +02:00
Igor Ryzhov 6f214d97d1 lib, zebra: move ns context intialization to zebra
vrf->ns_ctxt is only ever used in zebra, so move its initialization to
zebra's callback. Ideally this pointer shouldn't even be a part of
library's vrf struct, and moved to zebra-specific struct, but this is
the first step.

Signed-off-by: Igor Ryzhov <idryzhov@gmail.com>
2025-01-15 23:38:27 +02:00
Igor Ryzhov 4877f2f685 lib: remove VRF_BACKEND_UNKNOWN
The backend type cannot be unknown. It is configured to VRF_LITE by
default in zebra anyway, so just init to VRF_LITE in the lib and remove
the UNKNOWN type.

Signed-off-by: Igor Ryzhov <idryzhov@gmail.com>
2025-01-15 23:38:27 +02: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
Donald Sharp 5f35096123
Merge pull request #17796 from LabNConsulting/chopps/datastore-notifications
operational-state (datastore) change notifications
2025-01-14 13:47:28 -05:00
Philippe Guibert f19b8668b3 bgpd: add 'match community-count' command to restrict comm count
Add a mechanism in route-map to filter out route-map which have a list
of communities greater than the given number.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2025-01-14 13:59:42 +01:00
Christian Hopps c88b48929c lib: fix new (incorrect) CLANG SA warnings
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-13 23:40:52 -05:00
Christian Hopps 255026c2ce mgmtd: add notify selectors to filter datastore notifications
- Additionally push the selectors down to the backends

Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-13 23:40:52 -05: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 80c6f98ea7 lib: if: track oper-state inline
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-13 23:40:52 -05:00
Christian Hopps e64966876c lib: vrf: track oper-state inline
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
Donatas Abraitis a39aa3eb37 lib: Adopt Lua stuff for Lua 5.4
lua_pcall() returns LUA_ERRGCMM in 5.3 which is already deprecated.

The constant LUA_ERRGCMM was removed.
Errors in finalizers are never propagated; instead, they generate a warning.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2025-01-13 16:34:15 +02:00
Donatas Abraitis 0b48c8e134
Merge pull request #17807 from louis-6wind/fix-bgp-orf-crash
bgpd: fix crash in displaying json orf prefix-list
2025-01-09 22:57:51 +02:00
Louis Scalbert 5100d842f6 lib: remove interface dead code
Remove interface dead code.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2025-01-09 18:38:28 +01:00
Louis Scalbert 8ccf60921b bgpd: fix crash in displaying json orf prefix-list
bgpd crashes when there is several entries in the prefix-list. No
backtrace is provided because the issue was catched from a code review.

Fixes: 856ca177c4 ("Added json formating support to show-...-neighbors-... bgp commands.")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2025-01-09 18:35:18 +01:00
Louis Scalbert b7e843d7e8 bgpd: fix bgp orf prefix-list json prefix
0x<address>FX was displayed instead of the prefix.

Fixes: b219dda129 ("lib: Convert usage of strings to %pFX and %pRN")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2025-01-09 18:35:18 +01:00
Jafar Al-Gharaibeh 465d286819
Merge pull request #17798 from mjstapp/fix_remove_clear_thread
libs: remove deprecated 'clear thread' cli
2025-01-09 09:01:33 -06:00
Mark Stapp cb119907f0 libs: remove deprecated 'clear thread' cli
Remove a deprecated 'clear thread cpu' command.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2025-01-08 10:17:51 -05:00
Martin Buck 59ee9d2a79 lib: Handle call to zlog_5424_cycle() without valid FD properly
In zlog_5424_cycle(), struct zlt_5424 *zlt only points to valid memory when
the passed file descriptor is >= 0 (and passing -1 seems to be a supported
use case). So we shouldn't try to compute the address of its zt member when
zlt is NULL.

Signed-off-by: Martin Buck <mb-tmp-tvguho.pbz@gromit.dyndns.org>
2025-01-08 13:30:40 +01:00
Martin Buck 9951da394a lib: Try to open 5424 log destination when changing log threshold
When changing the log threshold (prio_min) using zlog_5424_apply_meta(), try
to open the log destination using zlog_5424_open() if we haven't done so
before. Without this, we might never open the destination at all, because
when zlog_5424_apply_dst() gets called (which so far was the only initial
caller of zlog_5424_open()), chances are that prio_min is still at its
initial value of ZLOG_DISABLED, causing it to skip the call to
zlog_5424_open().

Signed-off-by: Martin Buck <mb-tmp-tvguho.pbz@gromit.dyndns.org>
2025-01-08 13:30:40 +01:00
Martin Buck 4ed9147d98 lib: Fix privs syscaps (pset_t) allocation
Don't over-allocate syscaps in zcaps2sys(): This is just a single struct
(pset_t) with a count and a pointer to an array of capabilities, not an
array. So only allocate a single pset_t, not num copies of it.

The allocation size of syscaps->caps then needs to be based on the number of
Linux capabilities (count), but that is already handled properly a few lines
below.

Note that this fix is mostly cosmetic and for correctness. There was no
potential for memory corruption, because num is guaranteed to be nonzero. So
at least the one required pset_t was always allocated (but potentially much
more).

Signed-off-by: Martin Buck <mb-tmp-tvguho.pbz@gromit.dyndns.org>
2025-01-08 10:38:56 +01: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
Donald Sharp 0a52c233d3
Merge pull request #17782 from LabNConsulting/chopps/new-notify-msg-fmt
New YANG notify msg fmt
2025-01-07 13:15:40 -05:00
Donald Sharp 1a7923e7bc
Merge pull request #17783 from LabNConsulting/chopps/new-oper-get-callback
Add new oper state get callback
2025-01-07 13:11:26 -05:00
Russ White 7f2be9a595
Merge pull request #17474 from sougata-github-nvidia/rib_ip_protocol_cleanup
zebra: Fix ip protocol route-map issue.
2025-01-07 08:45:07 -05:00
Christian Hopps 4379066fdd lib: if.c use new get() oper callback
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-07 06:59:15 -05:00
Christian Hopps 0ca710bb5f lib: add impl of NOTIF message ops (notif, replace, delete, patch)
- needed for supporting backend datastore notifications

Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-07 05:34:09 -05:00
Christian Hopps 30777991c0 lib: add NOTIF message ops (notification, replace, delete, patch)
- needed for supporting backend datastore notifications

Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-07 05:34:06 -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
Sougata Barik 86b294698f zebra: Fix ip protocol route-map issue.
"ip/ipv6 protocol any route-map <route map>" cli is setting
wrong route type ( ZEBRA_ROUTE_MAX ), It should set route type
ZEBRA_ROUTE_ALL.

Ticket: #4101560

Signed-off-by: Sougata Barik <sougatab@nvidia.com>
2025-01-06 17:02:21 +05:30
Jafar Al-Gharaibeh e62c2f10bc
Merge pull request #17684 from opensourcerouting/fix/json_time_no_newline
bgpd, lib: Use frrstr_time() when using ctime_r()
2024-12-21 22:59:58 -06:00
Jafar Al-Gharaibeh c5123ff2b0
Merge pull request #17672 from raja-rajasekar/rajasekarr/batch_huge_cfg
lib: Fix to optimize the time taken while batching huge configs
2024-12-20 14:00:02 -06:00
Mark Stapp abefc604f7
Merge pull request #17648 from LabNConsulting/fix-darr-sprintf
Fix 2 darr (dynamic-array) bugs
2024-12-20 11:10:18 -05:00
Donatas Abraitis b3e1ceaf88 lib: Add a wrapper for time_to_string() to print time in JSON outputs
newline is not expected to be printed in JSON outputs, e.g.:

```
"lastUpdate":{"epoch":1734490463,"string":"Wed Dec 18 04:54:23 2024\n"
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-12-20 17:12:12 +02:00
Rajasekar Raja 6f132af67b lib: Fix to optimize the time taken while batching huge configs
Issue: When the incoming config has say 30K entries of a prefix-lists,
current implementation is to schedule the configs to be batched and
only after batching the entire config, the processing of the configs
take place. As part of batching this config, we perform string
concatenation to save all the configs in the buffer which over time
results in taking longer time.

Ex: Imagine each line of config is 50 chars. With a delimiter of ‘- ‘ we end
up adding 52 chars to buffer for each command i.e. 52*30000 = 156K of chars.
Strlcat is an expensive operation and every time we strlcat, we have to
traverse at end of string to append new char.
Because of this, we end up adding extra 6-8 secs for accepting the config.

Fix: The idea here is to bring back something similar to the backoff
count implemented as part of 20e9a402 (lib: introduce configuration
back-off timer for YANG-modeled commands).

Essentially we keep a cap of 5000 per batch. So once 5000k config
commands are batched, we process them, clear the buffer, set the count
to 0 and then continue processing the rest of the config.

option1 file has 30K entries of prefix-list
Without Fix:
root@mlx-3700-20:mgmt:/var/log/raja/frr# time sudo vtysh -f option1
<SNIP>..............
Waiting for children to finish applying config...
[25191|staticd] done
[25189|watchfrr] done
[25178|ospfd] done
[25190|pbrd] done
[25181|bgpd] done
[25175|zebra] done

real    0m20.123s
user    0m9.384s
sys     0m2.403s

With Fix:
root@mlx-3700-20:mgmt:/var/log/raja/frr# time sudo vtysh -f option1
<SNIP>..............
Waiting for children to finish applying config...
[19887|staticd] done
[19885|watchfrr] done
[19886|pbrd] done
[19874|ospfd] done
[19877|bgpd] done
[19871|zebra] done

real	0m12.168s
user	0m7.511s
sys	0m1.981s

Issue: 3589101

Ticket# 3589101

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2024-12-18 11:53:06 -08:00
Russ White acea7d5d7d
Merge pull request #17615 from opensourcerouting/fix/ip_prefix_list_show_prefix
lib: Take ge/le into consideration when checking the prefix with the prefix-list
2024-12-17 11:30:01 -05:00
Christian Hopps fb85d18f59 lib: darr: fix bug with nested macro use
- WHen declaring macro scoped variables, can run into problem if the macro
variable passed in has the same name as the new variable introduced in the inner
scope. We don't get a warning and the uses will be wrong.

e.g.,

```

{
    int __len = 10;
    foo(__len); // => 10 and not 15 as we wanted.
}
```

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-12-15 22:01:56 -05:00
Christian Hopps a65cdb60a3 lib: mgmtd: use less common macro scoped variable names
- ran into problem with darr macros and nested macros using the same name
variables as passed in variables in an out scope. Make these macro scoped
variables more unique as well.

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-12-15 22:01:56 -05:00
Christian Hopps 73e54e4168 lib: darr: use the FRR printf formatter
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-12-15 21:51:27 -05:00
Nathan Bahr 4250eae00d zebra,pimd,lib: Modify ZEBRA_NEXTHOP_LOOKUP_MRIB
Modified ZEBRA_NEXTHOP_LOOKUP_MRIB to include the SAFI from which to do the lookup.
This generalizes the API away from MRIB specifically and allows the user to decide how it should do lookups.
Rename ZEBRA_NEXTHOP_LOOKUP_MRIB to ZEBRA_NEXTHOP_LOOKUP now that it is more generalized.
This change is in preperation to remove multicast lookup mode completely from zebra.

Signed-off-by: Nathan Bahr <nbahr@atcorp.com>
2024-12-12 13:50:31 +00:00
Donatas Abraitis dd4c2acc2e lib: Take ge/le into consideration when checking the prefix with the prefix-list
Without the fix:

```
show ip prefix-list test_1 10.20.30.96/27 first-match
 <no result>

show ip prefix-list test_2 192.168.1.2/32 first-match
 <no result>
```

With the fix:

```
ip prefix-list test_1 seq 10 permit 10.20.30.64/26 le 27
!
end
donatas# show ip prefix-list test_1 10.20.30.96/27
   seq 10 permit 10.20.30.64/26 le 27 (hit count: 1, refcount: 0)
donatas# show ip prefix-list test_1 10.20.30.64/27
   seq 10 permit 10.20.30.64/26 le 27 (hit count: 2, refcount: 0)
donatas# show ip prefix-list test_1 10.20.30.64/28
donatas# show ip prefix-list test_1 10.20.30.126/26
   seq 10 permit 10.20.30.64/26 le 27 (hit count: 3, refcount: 0)
donatas# show ip prefix-list test_1 10.20.30.126/30
donatas#
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-12-10 16:28:26 +02:00
Jafar Al-Gharaibeh e814b000c3
Merge pull request #17585 from donaldsharp/zclient_speedup
lib: Speed up reconnection attempts for zapi
2024-12-04 21:59:33 -06:00
Donald Sharp fe180581bd lib: Speed up reconnection attempts for zapi
Currently the zapi reconnection is once every 10 seconds
for the first 3 times and then once every 60 seconds from then
on out.  We are seeing interesting behavior under loaded systems
where zebra is just slow to come up and daemons are spending a long
time waiting to connect.  Let's just make things a bit more aggressive.

Change the code to attempt to reconnect once every second for 30 seconds
and then change to once every 5 seconds from then on out.

This should help with non-integrated configuration on system startup.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-12-04 16:14:34 -05:00
Russ White f1ab0a0c2f
Merge pull request #17556 from opensourcerouting/fix/add_route_map_action_reason
lib: Print the reason why the route-map and/or the index parsing is done
2024-12-04 08:09:48 -05:00
Donatas Abraitis 75e9b1b090
Merge pull request #17571 from donaldsharp/fix_bsd_sockopt_problem
Fix bsd sockopt problem
2024-12-04 14:46:08 +02:00
Donatas Abraitis 5b976f00f6 lib: Print the reason why the route-map and/or the index parsing is done
This would give more details why at some point we return deny, no match, etc.

Before this we have sometimes (I don't know why), e.g.:

```
Route-map: null, prefix: 192.168.2.0/24, result: deny
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-12-04 08:27:13 +02:00
Donald Sharp 959dbe27cd lib,vtysh: Use backoff setsockopt option for freebsd
Commit: 9112fb367b

Introduced the idea of setting the socket buffer
send/receive sizes.  BSD's in general have the fun
issue of not allowing nearly as large as a size as
linux.  Since the above commit was developed on linux
and not run on bsd it was never tested.  Modify the
codebase to use the backoff setsockopt that we have
in the code base and use the returned values to allow
us to notice what was set and respond appropriately.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-12-03 18:49:59 -05:00