summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2024-10-27lib, zebra: Keep `zebra on-rib-process script` in frr.confDonatas Abraitis
After the change: ``` $ grep on-rib-process /etc/frr/frr.conf zebra on-rib-process script script4 $ systemctl restart frr $ vtysh -c 'show run' | grep on-rib-process zebra on-rib-process script script4 ``` Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org> (cherry picked from commit 1fe1f8d87c4ab46ae18536a2418c05ae5fd95185)
2024-10-22Revert "lib: Attach stdout to child only if --log=stdout and stdout FD is a tty"Donald Sharp
This reverts commit 0e3c5e8e5907321b35201f0985c1d3f4a1b0e639. (cherry picked from commit 6a36b9ef49bfce59a7e674df233265da6d275257)
2024-10-11bgpd: Move some non BGP-specific route-map functions to libDonatas Abraitis
They are managed under `frr-route-map`, not under `frr-bgp-route-map`. Fixes: https://github.com/FRRouting/frr/issues/17055 Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org> (cherry picked from commit b9a9be492e8dde39a0040bd1140893ccab83c2be)
2024-10-07Merge pull request #17015 from ↵Igor Ryzhov
LabNConsulting/chopps/load-internal-ietf-yang-library lib: add flag to have libyang load internal ietf-yang-library module
2024-10-07lib: add flag to have libyang load internal ietf-yang-library moduleChristian Hopps
Mgmtd makes use of libyang's internal ietf-yang-library module to add support for said module to FRR management. Previously, mgmtd was loading this module explicitly; however, that required that libyang's `ietf-yang-library.yang` module definition file be co-located with FRR's yang files so that it (and ietf-datastore.yang) would be found when searched for by libyang using FRRs search path. This isn't always the case depending on how the user compiles and installs libyang so mgmtd was failing to run in some cases. Instead of doing it the above way we simply tell libyang to load it's internal version of ietf-yang-library when we initialize the libyang context. This required adding a boolean to a couple of the init functions which is why so many files are touched (although all the changes are minimal). Signed-off-by: Christian Hopps <chopps@labn.net>
2024-10-06lib,zebra: remove unused ZEBRA_VRF_UNREGISTERDonna Sharp
Signed-off-by: Donna Sharp <dksharp5@gmail.com>
2024-10-03lib: remove unused bfd definesLouis Scalbert
Remove unused bfd defines Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-10-01lib: nexthop code should use uint16_t for nexthop countingDonald Sharp
It's possible to specify via the cli and configure how many nexthops that are allowed on the system. If you happen to have > 255 then things are about to get interesting otherwise. Let's allow up to 65k nexthops (ha!) Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-30lib: fix calloc warning on recent compilerRafael Zalamena
Fix the following compiler warning: ``` lib/elf_py.c: In function _elffile_load_: lib/elf_py.c:1310:34: warning: _calloc_ sizes specified with _sizeof_ in the earlier argument and not in the later argument [-Wcalloc-transposed-args] 1310 | w->sects = calloc(sizeof(PyObject *), w->ehdr->e_shnum); | ^~~~~~~~ lib/elf_py.c:1310:34: note: earlier argument should specify number of elements, later size of each element ``` Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2024-09-24Merge pull request #16909 from donaldsharp/helpJafar Al-Gharaibeh
lib: Help text correction
2024-09-24lib: Removed unused RFP_DEFAULTS_NODEDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-24lib, zebra: TABLE_NODE is not usedDonald Sharp
No-one is using this, remove Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-24lib: Help text correctionDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-24lib: Load built-in Lua functionsDonatas Abraitis
We can't use even `string()` function because built-in functions are not loaded. Testing with: ``` $ cat /etc/frr/scripts/zebra.lua function on_rib_process_dplane_results(ctx) log.warn(string.upper("testas")) return {} end ``` This results to "TESTAS" in the logs. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-09-19Merge pull request #16738 from odivlad/fix-stdout-forkDonatas Abraitis
lib: Attach stdout to child only if --log=stdout and stdout FD is a tty
2024-09-17mgmtd: add ietf-yang-library supportChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-09-17lib: mgmtd: add `changed` and `created` to edit-reply msgChristian Hopps
- This is used for various return values in RESTCONF Signed-off-by: Christian Hopps <chopps@labn.net>
2024-09-17lib: mgmtd: cleanup error value for native messagingChristian Hopps
- Now if positive it's libyang LY_ERR, otherwise it's `-errno` value. Signed-off-by: Christian Hopps <chopps@labn.net>
2024-09-17lib: constify yang_resolve_snode_xpath resultsChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net> ang
2024-09-15lib: Include SID structure in seg6local nexthopCarmine Scarpitta
Include SID structure information in seg6local nexthop data structure. Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-09-10lib: Attach stdout to child only if --log=stdout and stdout FD is a ttyVladislav Odintsov
Prior to this commit stdout of a process started in a daemon mode was attached to a calling process. As a result a calling process hung for infinity. Signed-off-by: Vladislav Odintsov <vlodintsov@k2.cloud>
2024-09-10Merge pull request #15259 from dmytroshytyi-6WIND/nexthop_resolutionRuss White
zebra: add LSP entry to nexthop via recursive (part 2)
2024-09-07lib: fix clang SA warningsChristian Hopps
Also, cleanup some unreachable code in `nb_op_sib_next()`. Signed-off-by: Christian Hopps <chopps@labn.net>
2024-09-01*: Create termtable specific temp memoryDonald Sharp
When trying to track down a MTYPE_TMP memory leak it's harder to search for it when you happen to have some usage of ttable_dump. Let's just give it it's own memory type so that we can avoid confusion in the future. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-29Merge pull request #16664 from mjstapp/igor_debug_simplifyJafar Al-Gharaibeh
*: simplify frrlib debug
2024-08-28Merge pull request #16672 from raja-rajasekar/vty_out_mem_spike_srujanaMark Stapp
lib: Memory spike reduction for sh cmds at scale
2024-08-28lib: Add a helper function to dump Lua stackDonatas Abraitis
Very handy for debugging. In Lua script just use "log.trace(table)": ``` function on_rib_process_dplane_results(ctx) log.trace(ctx.rinfo.zd_ng) end ``` You will get something like: ``` Aug 28 17:04:36 donatas-laptop zebra[3782199]: [GCZ7N-MM9D9] { 1: { type: 2 weight: 1 flags: 5 backup_idx: 0 vrf_id: 0 nh_encap_type: 0 gate: { value: 5.87967e+08 string: "192.168.11.35" } nh_label_type: 0 srte_color: 0 ifindex: 0 backup_num: 0 } 2: { type: 3 weight: 1 flags: 3 backup_idx: 0 vrf_id: 0 nh_encap_type: 0 nh_label_type: 0 srte_color: 0 ifindex: 4 backup_num: 0 } } ``` Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-08-28lib: Start from 1, not 0 when creating Lua tables for nexthopsDonatas Abraitis
Lua technically enumerates arrays from 1, not 0. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-08-27lib: Memory spike reduction for sh cmds at scaleSrujana
The output buffer vty->obuf is a linked list where each element is of 4KB. Currently, when a huge sh command like <show ip route json> is executed on a large scale, all the vty_outs are processed and the entire data is accumulated. After the entire vty execution, vtysh_flush proceeses and puts this data in the socket (131KB at a time). Problem here is the memory spike for such heavy duty show commands. The fix here is to chunkify the output on VTY shell by flushing it intermediately for every 128 KB of output accumulated and free the memory allocated for the buffer data. This way, we achieve ~25-30% reduction in the memory spike. Fixes: #16498 Note: This is a continuation of MR #16498 Signed-off-by: Srujana <skanchisamud@nvidia.com> Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2024-08-27lib: common debug status outputIgor Ryzhov
Implement common code for debug status output and remove daemon-specific code that is duplicated everywhere. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-08-27lib: common debug config outputIgor Ryzhov
Implement common code for debug config output and remove daemon-specific code that is duplicated everywhere. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-08-27lib: rework debug initIgor Ryzhov
The debug library allows to register a `debug_set_all` callback which should enable all debugs in a daemon. This callback is implemented exactly the same in each daemon. Instead of duplicating the code, rework the lib to allow registration of each debug type, and implement the common code only once in the lib. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-08-23Merge pull request #16609 from donaldsharp/singleton_no_weightMark Stapp
Reduce the number of Singleton objects when using weight for NHG's
2024-08-23Merge pull request #16633 from Jafaral/fix-version-buildDonald Sharp
config: fix missing case when reporting version 'configured with'
2024-08-22config: fix missing case when reporting version 'configured with'Jafar Al-Gharaibeh
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2024-08-22lib: Ensure SA that root cannot be NULLDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-22lib, zebra: Modify nexthop_cmp to allow you to use weight or notDonald Sharp
Currently nexthop weight is a discriminator on whether or not a nexthop matches. There is a need to no use the weight as part of this comparison function so let's add a boolean to allow us to say use this or not. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-18Merge pull request #16602 from LabNConsulting/chopps/fix-warningsDonald Sharp
mgmtd: fix a couple compilation warnings.
2024-08-18lib: Fix compilation warningCarmine Scarpitta
Don't store unnecessary `len` returned by snprintf and snprintfrr function. Fixes the following compilation warnings: ``` error 15-Aug-2024 13:54:10 In file included from lib/bfd.c:16: error 15-Aug-2024 13:54:10 In file included from ./lib/zclient.h:22: error 15-Aug-2024 13:54:10 In file included from ./lib/nexthop.h:14: error 15-Aug-2024 13:54:10 ./lib/srv6.h:338:3: warning: Value stored to 'len' is never read [deadcode.DeadStores] error 15-Aug-2024 13:54:10 len += snprintf(str + len, size - len, " USP"); error 15-Aug-2024 13:54:10 ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error 15-Aug-2024 13:54:10 ./lib/srv6.h:343:3: warning: Value stored to 'len' is never read [deadcode.DeadStores] error 15-Aug-2024 13:54:10 len += snprintfrr(str + len, size - len, " nh6 %pI6", &ctx->nh6); error 15-Aug-2024 13:54:10 ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error 15-Aug-2024 13:54:10 ./lib/srv6.h:347:3: warning: Value stored to 'len' is never read [deadcode.DeadStores] error 15-Aug-2024 13:54:10 len += snprintfrr(str + len, size - len, " nh4 %pI4", &ctx->nh4); error 15-Aug-2024 13:54:10 ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error 15-Aug-2024 13:54:10 ./lib/srv6.h:354:3: warning: Value stored to 'len' is never read [deadcode.DeadStores] error 15-Aug-2024 13:54:10 len += snprintf(str + len, size - len, " vrf_id %u", error 15-Aug-2024 13:54:10 ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error 15-Aug-2024 13:54:10 ./lib/srv6.h:367:3: warning: Value stored to 'len' is never read [deadcode.DeadStores] error 15-Aug-2024 13:54:10 len += snprintf(str + len, size - len, " unknown(%s)", __func__); error 15-Aug-2024 13:54:10 ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-08-18mgmtd: fix a couple compilation warnings.Christian Hopps
Also an empty (thus non-replace) notify selectors message shouldn't clear the selectors, it should just do nothing. Signed-off-by: Christian Hopps <chopps@labn.net>
2024-08-15*: Fix spelling errors foundDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-12lib: Fix memory leak in snmp on shutdownDonald Sharp
The events list is storing a `struct event *` allocated as a MTYPE_TMP pointer, on shutdown ensure that it is properly free'd up. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-11Merge pull request #16542 from donaldsharp/vtysh_stupidly_largeDonatas Abraitis
lib: Don't print warning if not a daemon
2024-08-10Merge pull request #16551 from idryzhov/distrib-delDonald Sharp
lib: fix distribute-list deletion
2024-08-10Merge pull request #16511 from oplklum/masterChristian Hopps
Fix LYD_NEW_PATH_OUTPUT issue to support libyang v3.x
2024-08-09lib: Fix LYD_NEW_PATH_OUTPUT issue to support libyang v3.xLu.Mao
Fix the LYD_NEW_PATH_OUTPUT undeclared error to support the latest libyang v3.x version, and also compatible with old version. Signed-off-by: Lu Mao <lu.mao@molex.com>
2024-08-10lib: fix distribute-list deletionIgor Ryzhov
When a whole distribute-list is deleted (can be done only using API), all its children must be cleaned up manually. Fixes #16538 Signed-off-by: Igor Ryzhov <idryzhov@gmail.com>
2024-08-09Merge pull request #16539 from donaldsharp/tests_memory_shutDonatas Abraitis
Tests memory shut
2024-08-08Merge pull request #16535 from pguibert6WIND/srv6_nexthop_contextDonatas Abraitis
lib: add seg6localContext json attribute in nexthop information
2024-08-08lib: Don't print warning if not a daemonDonald Sharp
vtysh will print out the `stupidly large FD limit` upon every run of the program if the ulimit is set stupidly large. Prevent this from being displayed for vtysh. Fixes: #16516 Signed-off-by: Donald Sharp <sharpd@nvidia.com>