summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
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
2024-10-16lib, test: fix display ipv4 mapped ipv6 addressesLouis Scalbert
Display ipv4 mapped ipv6 addresses in the format ::ffff:A.B.C.D. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-10-16lib: fix invalid use of errno in PTMDavid Lamparter
errno is only valid if there was an actual error. A zero return value isn't an error, it's either EOF or an empty datagram depending on context. Fix the logic. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16lib: guard close() in netns codeDavid Lamparter
clang-SA complains that ns->fd could be invalid. Add a guard. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16lib: make clang-SA not choke on defun_lex.lDavid Lamparter
The flex-generated code is disabled for clang-SA builds already, but that means that function prototypes are missing too. Just add dummy function prototypes so clang-SA can process the file. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16*: clang-SA switch-enum initializer workaroundsDavid Lamparter
In these cases the value assigned by the switch block is used directly rather than returned. Mark the initial/default value as used so clang-SA doesn't complain about it. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16*: clang-SA friendly switch-enum-return-stringDavid Lamparter
clang-19's SA complains about unused initializers for this kind of "switch (enum) { return string }" kind of code. Use direct string return values to avoid the issue. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-15Merge pull request #17038 from opensourcerouting/feature/bgp_set_metric_internalRuss White
bgpd: Derive and set MED from IGP or AIGP
2024-10-15*: Fix up improper handling of nexthops for nexthop trackingDonald Sharp
Currently FRR needs to send a uint16_t value for the number of nexthops as well it needs the ability to properly decode all of this. Find and handle all the places that this happens. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-15Merge pull request #17058 from opensourcerouting/fix/apply_route_maps_earlierRuss White
lib: Apply and generate route-map commands earlier before any other protocol
2024-10-15bgpd: Implement `set metric aigp` commandDonatas Abraitis
Same as `set metric igp`, but in this case accumulated IGP metric is being sent as MED attribute. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-10-15bgpd: Implement `set metric igp` commandDonatas Abraitis
Set metric automatically from the path info (IGP protocol). Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-10-10bgpd: 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>
2024-10-10lib: Apply and generate route-map commands earlier before any other protocolDonatas Abraitis
If e.g. BGP neighbor is using a route-map at the boot, that is not yet created, then the log is spammed with `The route-map 'X' does not exist`. Processing earlier, should do the trick. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
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-27bgpd: Implement `match src-peer ...` commandDonatas Abraitis
To match source peer on the outgoing direction. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>