summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2025-01-07lib: northbound oper: fix keyless position predicate queriesChristian Hopps
- i.e., `show /foos/foo[1]` Signed-off-by: Christian Hopps <chopps@labn.net>
2024-12-21Merge pull request #17684 from opensourcerouting/fix/json_time_no_newlineJafar Al-Gharaibeh
bgpd, lib: Use frrstr_time() when using ctime_r()
2024-12-20Merge pull request #17672 from raja-rajasekar/rajasekarr/batch_huge_cfgJafar Al-Gharaibeh
lib: Fix to optimize the time taken while batching huge configs
2024-12-20Merge pull request #17648 from LabNConsulting/fix-darr-sprintfMark Stapp
Fix 2 darr (dynamic-array) bugs
2024-12-20lib: Add a wrapper for time_to_string() to print time in JSON outputsDonatas Abraitis
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-18lib: Fix to optimize the time taken while batching huge configsRajasekar Raja
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-17Merge pull request #17615 from opensourcerouting/fix/ip_prefix_list_show_prefixRuss White
lib: Take ge/le into consideration when checking the prefix with the prefix-list
2024-12-15lib: darr: fix bug with nested macro useChristian Hopps
- 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-15lib: mgmtd: use less common macro scoped variable namesChristian Hopps
- 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-15lib: darr: use the FRR printf formatterChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-12-12zebra,pimd,lib: Modify ZEBRA_NEXTHOP_LOOKUP_MRIBNathan Bahr
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-10lib: Take ge/le into consideration when checking the prefix with the prefix-listDonatas Abraitis
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-04Merge pull request #17585 from donaldsharp/zclient_speedupJafar Al-Gharaibeh
lib: Speed up reconnection attempts for zapi
2024-12-04lib: Speed up reconnection attempts for zapiDonald Sharp
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-04Merge pull request #17556 from opensourcerouting/fix/add_route_map_action_reasonRuss White
lib: Print the reason why the route-map and/or the index parsing is done
2024-12-04Merge pull request #17571 from donaldsharp/fix_bsd_sockopt_problemDonatas Abraitis
Fix bsd sockopt problem
2024-12-04lib: Print the reason why the route-map and/or the index parsing is doneDonatas Abraitis
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-03lib,vtysh: Use backoff setsockopt option for freebsdDonald Sharp
Commit: 9112fb367b1ae0168b4e7a81f41c2ca621979199 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-03lib: Allow setsockopt functions to return size setDonald Sharp
When finding a send/receive buffer size that is usable let's report how big we were able to set it. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-12-03lib: Fix session re-establishmentDonald Sharp
Currently if you have this sequence of events: a) BGP starts b) BGP reads cli that has bfd configuration c) BGP attempts to install bfd configuration but fails because zebra is not connected to yet d) BGP connects to zebra e) BGP receives resend bfd code from bfdd f) BGP was not sending down the unsent data to bfd, never causing the bfd session to be established. So effectively bfd was attempting to install but failed and then when it was asked to replay everything it decided that the bfd information for a particular peer was actually installed and does not need to be resent. Modify the code such that the bfd code now tracks failed installation and allows the resend of data to bfdd. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-25lib: Remove route_node_match_ipv[4|6] not being usedDonald Sharp
These functions are not being used. Let's just remove them from our code base. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-22lib, zebra: Do not have duplicate memory type problemsDonald Sharp
In zebra_mpls.c it has a usage of MTYPE_NH_LABEL which is defined in both lib/nexthop.c and zebra/zebra_mpls.c. The usage in zebra_mpls.c is a realloc. This leads to a crash: (gdb) bt 0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=126487246404032) at ./nptl/pthread_kill.c:44 1 __pthread_kill_internal (signo=6, threadid=126487246404032) at ./nptl/pthread_kill.c:78 2 __GI___pthread_kill (threadid=126487246404032, signo=signo@entry=6) at ./nptl/pthread_kill.c:89 3 0x0000730a1b442476 in __GI_raise (sig=6) at ../sysdeps/posix/raise.c:26 4 0x0000730a1b94fb18 in core_handler (signo=6, siginfo=0x7ffeed1e07b0, context=0x7ffeed1e0680) at lib/sigevent.c:268 5 <signal handler called> 6 __pthread_kill_implementation (no_tid=0, signo=6, threadid=126487246404032) at ./nptl/pthread_kill.c:44 7 __pthread_kill_internal (signo=6, threadid=126487246404032) at ./nptl/pthread_kill.c:78 8 __GI___pthread_kill (threadid=126487246404032, signo=signo@entry=6) at ./nptl/pthread_kill.c:89 9 0x0000730a1b442476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 10 0x0000730a1b4287f3 in __GI_abort () at ./stdlib/abort.c:79 11 0x0000730a1b9984f5 in _zlog_assert_failed (xref=0x730a1ba59480 <_xref.16>, extra=0x0) at lib/zlog.c:789 12 0x0000730a1b8f8908 in mt_count_free (mt=0x576e0edda520 <MTYPE_NH_LABEL>, ptr=0x576e36617b80) at lib/memory.c:74 13 0x0000730a1b8f8a59 in qrealloc (mt=0x576e0edda520 <MTYPE_NH_LABEL>, ptr=0x576e36617b80, size=16) at lib/memory.c:112 14 0x0000576e0ec85e2e in nhlfe_out_label_update (nhlfe=0x576e368895f0, nh_label=0x576e3660e9b0) at zebra/zebra_mpls.c:1462 15 0x0000576e0ec833ff in lsp_install (zvrf=0x576e3655fb50, label=17, rn=0x576e366197c0, re=0x576e3660a590) at zebra/zebra_mpls.c:224 16 0x0000576e0ec87c34 in zebra_mpls_lsp_install (zvrf=0x576e3655fb50, rn=0x576e366197c0, re=0x576e3660a590) at zebra/zebra_mpls.c:2215 17 0x0000576e0ecbb427 in rib_process_update_fib (zvrf=0x576e3655fb50, rn=0x576e366197c0, old=0x576e36619660, new=0x576e3660a590) at zebra/zebra_rib.c:1084 18 0x0000576e0ecbc230 in rib_process (rn=0x576e366197c0) at zebra/zebra_rib.c:1480 19 0x0000576e0ecbee04 in process_subq_route (lnode=0x576e368e0270, qindex=8 '\b') at zebra/zebra_rib.c:2661 20 0x0000576e0ecc0711 in process_subq (subq=0x576e3653fc80, qindex=META_QUEUE_BGP) at zebra/zebra_rib.c:3226 21 0x0000576e0ecc07f9 in meta_queue_process (dummy=0x576e3653fae0, data=0x576e3653fb80) at zebra/zebra_rib.c:3265 22 0x0000730a1b97d2a9 in work_queue_run (thread=0x7ffeed1e3f30) at lib/workqueue.c:282 23 0x0000730a1b96b039 in event_call (thread=0x7ffeed1e3f30) at lib/event.c:1996 24 0x0000730a1b8e4d2d in frr_run (master=0x576e36277e10) at lib/libfrr.c:1232 25 0x0000576e0ec35ca9 in main (argc=7, argv=0x7ffeed1e4208) at zebra/main.c:536 Clearly replacing a label stack is an operation that should be owned by lib/nexthop.c. So lets move this function into there and have zebra_mpls.c just call the function to replace the label stack. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-19Merge pull request #17156 from opensourcerouting/eradicate-strncpyDonald Sharp
*: remove remaining `strncpy()` users
2024-11-12Merge pull request #17297 from mjstapp/mjs_ifp_tableDonald Sharp
zebra, lib: use internal rbtree for per-NS tree of ifps
2024-11-08lib: Initialize mbefore for route_map_apply_ext()Donatas Abraitis
CID 1601478: Uninitialized variables (UNINIT) Using uninitialized value "mbefore.real.tv_usec" when calling "event_consumed_time". Fixes: 3e3a666331e1e44683b17ab1fd78afc47c5d2677 ("lib: Add ability to track time in individual routemaps") Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-05lib: Add ability to track time in individual routemapsDonald Sharp
Add the abilty to track how much time is spent in routemaps. Example of the new output: eva# show route-map ZEBRA: route-map: FOO Invoked: 1000000 (323 milliseconds total) Optimization: enabled Processed Change: false deny, sequence 10 Invoked 1000000 (320 milliseconds total) Match clauses: Set clauses: Call clause: Action: Exit routemap Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-01Merge pull request #17312 from donaldsharp/remove_in6addr_cmpDonatas Abraitis
Remove in6addr cmp
2024-11-01Merge pull request #17280 from donaldsharp/remove_event_master_free_unusedDonatas Abraitis
Remove event master free unused
2024-11-01Merge pull request #17194 from ↵Russ White
LabNConsulting/aceelindem/ospf-ls-refresh-interval-fix ospfd: Fix opaque LSA refresh interval and modify LSA cmds.
2024-10-31lib: Remove counter and a functionDonald Sharp
The `alloc` counter was tracking the current active number of events in the system and if it went to 0 when freeing a new one it would assert. This assert is a duplicate of what would happen with the XFREE in the same situation. As such it is not necessary. Also remove the `event_master_free_unused` function from the system. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-31lib: Remove wheel name it is no longer usedDonald Sharp
With commit: 60a3efec2458d9a1531f8204d0e4a91729d3fc00 The ability for the wheel code to display the name of what wheel was actually being run was removed from the system. Since we can no longer do this and it's been 4 years since it's been in, let's just remove this bit of dead code. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-31lib: In sockunion.c convert v6 memcmp's to IPV6_ADDR_CMPDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-31lib, tests: Remove in6addr_cmp function from the systemDonald Sharp
This function should just be memcmp. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-31lib: Replace usage of in6addr_cmp with memcmpDonald Sharp
memcmp will return and act exactly the same as in6addr_cmp but it does it significantly faster than how in6addr_cmp does it. Let this be a lesson for implementing something that is a duplicate of what is provided by the c library. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-29lib,zebra: remove table node from ifp structMark Stapp
Finish removing the table route_node from the ifp struct. Signed-off-by: Mark Stapp <mjs@cisco.com>
2024-10-27Merge pull request #17160 from ↵Jafar Al-Gharaibeh
opensourcerouting/fix/keep_zebra_on-rib-process_in_frr.conf lib, zebra: Keep `zebra on-rib-process script` in frr.conf
2024-10-25ospfd: Fix opaque LSA refresh interval and modify LSA cmds.Acee Lindem
The configured OSPF refresh interval was not being used for opaque LSA (it always used the constant). Also, modified the timers lsa min-arrival command to have a maximum of 5000 msecs as well as providing a path for backward command compatibility. Added missing user documentation for both timers lsa min-arrival and timers throttle lsa all. Signed-off-by: Acee Lindem <acee@lindem.com>
2024-10-24Merge pull request #17155 from opensourcerouting/memstats-zlogDonald Sharp
lib: `debug memstats-at-exit` improvements
2024-10-22Revert "lib: Attach stdout to child only if --log=stdout and stdout FD is a tty"Donald Sharp
This reverts commit 0e3c5e8e5907321b35201f0985c1d3f4a1b0e639.
2024-10-22lib: remove `strncpy()` useDavid Lamparter
`checkpatch` has sufficiently annoyed me to fix this. Includes free overflow guard in CSV code. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-18lib, 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>
2024-10-17lib: Correctly handle ppoll pfds.events == 0Donald Sharp
The frrevent system is spitting out this message in bgpd: 20:40:15 mem1-roc-f2-b1-r5-t2-d4 bgpd[13166]: [XETTR-D5MR0][EC 100663316] Attempting to process an I/O event but for fd: 214(8) no thread to handle this! This is because as each io event is processed, it is possible that a .events is set to 0. This can leave a situation where we ask ppoll to handle anything that happens on a fd with a .events of 0, in this situation ppoll can return POLLERR, which indicates that something bad has happened on the fd. Let's set the ppoll fds.fd value to -1 when there are no more events to be processed. ppoll specifically calls out that it will just skip this particular one. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-17lib: refactor memstats logging, fix ACTIVEATEXITDavid Lamparter
Move the various destinations handling into lib/memory.c, include "normal" logging as target, and make `ACTIVEATEXIT` properly non-error as it was intended to be. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-17lib: do not log_memstats() in crash handlerDavid Lamparter
`log_memstats()` is not AS-safe. It can hang the crash handler (or set your PC on fire, or cause the sun to go supernova - according to POSIX specs, anyway.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-17lib: zlog stays running on shutdownDavid Lamparter
No `zlog_fini()`, please. Getting log messages until the end is more important than leaking memory allocated for zlog targets. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-17lib: actually propagate MGROUP argsDavid Lamparter
Well, this was only checked for exit status, which we didn't really observe... so, uh, yeah, not particularly noticeable it wasn't even wired up... clang-format off/on added to not get formatting wrecked on this. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-17Merge pull request #17136 from opensourcerouting/clang-sa-19Donald Sharp
*: fix clang-19 SA
2024-10-16Merge pull request #16452 from louis-6wind/fix-ipv4-mapped-ipv6-displayRuss White
lib, test: fix display ipv4 mapped ipv6 addresses
2024-10-16Merge pull request #17076 from ↵Donatas Abraitis
donaldsharp/rnh_and_redistribution_nexthop_num_fix *: Fix up improper handling of nexthops for nexthop tracking
2024-10-16Merge pull request #16946 from opensourcerouting/fix/match_src-peerRuss White
bgpd: Implement match src-peer ... command