summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2022-04-20Merge pull request #11055 from donaldsharp/plist_crashDonatas Abraitis
lib: Prevent crash after shutdown request
2022-04-20Merge pull request #10961 from opensourcerouting/build-ms-extDonald Sharp
build: enable `-fms-extensions`
2022-04-19lib: Prevent crash after shutdown requestDonald Sharp
Recent commit e92508a741e03b8721ccb3424cbebe4d5476e9d changed the prefix_master->str to a RB tree. This introduced a condition whnere on shutdown the prefix list was removed from the master list and then operated on by passing around a name. Which was then used to lookup the prefix list again when we operated on the code. This change to a RB Tree first deleted the item from the RB tree first thus introducing this crash Crash: (gdb) bt index=0x556c07d59650, pentry=0x556c07d29380) at lib/routemap.c:2397 arg=0x7ffdbf84bc60) at lib/hash.c:267 event=RMAP_EVENT_PLIST_DELETED) at lib/routemap.c:2489 Grab the first item on the list, clean it and then remove it. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-19*: Fix spelling of seperatorDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-19*: Fix spelling of neccessaryDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-11lib: Remove deprecated routemap_optimization_cmdDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-07lib, pimd: add a bunch of address helpersDavid Lamparter
Just simple helpers to get a scope value, never-forward, and is-SSM for a given address. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-04build: first header *must* be zebra.h or config.hDavid Lamparter
This has already been a requirement for Solaris, it is still a requirement for some of the autoconf feature checks to work correctly, and it will be a requirement for `-fms-extensions`. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-02lib, yang: Fix spellinig of milisecondsDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-02*: Fix spelling of wetherDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-31isisd, lib, ospfd, pathd: Null out free'd pointerDonald Sharp
The commands: router isis 1 mpls-te on no mpls-te on mpls-te on no mpls-te on ! Will crash Valgrind gives us this: ==652336== Invalid read of size 8 ==652336== at 0x49AB25C: typed_rb_min (typerb.c:495) ==652336== by 0x4943B54: vertices_const_first (link_state.h:424) ==652336== by 0x493DCE4: vertices_first (link_state.h:424) ==652336== by 0x493DADC: ls_ted_del_all (link_state.c:1010) ==652336== by 0x47E77B: isis_instance_mpls_te_destroy (isis_nb_config.c:1871) ==652336== by 0x495BE20: nb_callback_destroy (northbound.c:1131) ==652336== by 0x495B5AC: nb_callback_configuration (northbound.c:1356) ==652336== by 0x4958127: nb_transaction_process (northbound.c:1473) ==652336== by 0x4958275: nb_candidate_commit_apply (northbound.c:906) ==652336== by 0x49585B8: nb_candidate_commit (northbound.c:938) ==652336== by 0x495CE4A: nb_cli_classic_commit (northbound_cli.c:64) ==652336== by 0x495D6C5: nb_cli_apply_changes_internal (northbound_cli.c:250) ==652336== Address 0x6f928e0 is 272 bytes inside a block of size 320 free'd ==652336== at 0x48399AB: free (vg_replace_malloc.c:538) ==652336== by 0x494BA30: qfree (memory.c:141) ==652336== by 0x493D99D: ls_ted_del (link_state.c:997) ==652336== by 0x493DC20: ls_ted_del_all (link_state.c:1018) ==652336== by 0x47E77B: isis_instance_mpls_te_destroy (isis_nb_config.c:1871) ==652336== by 0x495BE20: nb_callback_destroy (northbound.c:1131) ==652336== by 0x495B5AC: nb_callback_configuration (northbound.c:1356) ==652336== by 0x4958127: nb_transaction_process (northbound.c:1473) ==652336== by 0x4958275: nb_candidate_commit_apply (northbound.c:906) ==652336== by 0x49585B8: nb_candidate_commit (northbound.c:938) ==652336== by 0x495CE4A: nb_cli_classic_commit (northbound_cli.c:64) ==652336== by 0x495D6C5: nb_cli_apply_changes_internal (northbound_cli.c:250) ==652336== Block was alloc'd at ==652336== at 0x483AB65: calloc (vg_replace_malloc.c:760) ==652336== by 0x494B6F8: qcalloc (memory.c:116) ==652336== by 0x493D7D2: ls_ted_new (link_state.c:967) ==652336== by 0x47E4DD: isis_instance_mpls_te_create (isis_nb_config.c:1832) ==652336== by 0x495BB29: nb_callback_create (northbound.c:1034) ==652336== by 0x495B547: nb_callback_configuration (northbound.c:1348) ==652336== by 0x4958127: nb_transaction_process (northbound.c:1473) ==652336== by 0x4958275: nb_candidate_commit_apply (northbound.c:906) ==652336== by 0x49585B8: nb_candidate_commit (northbound.c:938) ==652336== by 0x495CE4A: nb_cli_classic_commit (northbound_cli.c:64) ==652336== by 0x495D6C5: nb_cli_apply_changes_internal (northbound_cli.c:250) ==652336== by 0x495D23E: nb_cli_apply_changes (northbound_cli.c:268) Let's null out the pointer. After this change. Valgrind no longer reports issues and isisd no longer crashes. Fixes: #10939 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-31bgpd: Show `match script SCRIPT` in running configDonatas Abraitis
Before: ``` route-map lua permit 10 exit ``` After: ``` route-map lua permit 10 match script rm exit ``` Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-03-30Merge pull request #10918 from opensourcerouting/fix/bgpd_crashDonald Sharp
bgpd: Fix Lua route-map crash
2022-03-29Merge pull request #10719 from opensourcerouting/nb-show-fixesRuss White
lib: fix and improve yang operational data display
2022-03-29bgpd: Do not print .lua extension twiceDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-03-27*: add SAFI argument to zclient_send_rnhDavid Lamparter
Just pushing that SAFI_UNICAST up 1 level to the caller. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-26lib: Ensure order of operations is expected with SECONDSDonald Sharp
These 3 values: ONE_DAY_SECOND ONE_WEEK_SECOND ONE_YEAR_SECOND Are defined based upon the number of seconds. Unfortunately doing math on these values say something like: days = t->tv_sec / ONE_DAY_SECOND; Once you go over about a day causes the order of operations to cause the multiplication to get messed up: 204 if (!t) (gdb) n 207 w = d = h = m = ms = 0; (gdb) set t->tv_sec = ONE_DAY_SECOND + 30 (gdb) n 208 memset(buf, 0, size); (gdb) 210 us = t->tv_usec; (gdb) 211 if (us >= 1000) { (gdb) 212 ms = us / 1000; (gdb) 213 us %= 1000; (gdb) 217 if (ms >= 1000) { (gdb) 222 if (t->tv_sec > ONE_WEEK_SECOND) { (gdb) 227 if (t->tv_sec > ONE_DAY_SECOND) { (gdb) 228 d = t->tv_sec / ONE_DAY_SECOND; (gdb) n 229 t->tv_sec -= d * ONE_DAY_SECOND; (gdb) n 232 if (t->tv_sec >= HOUR_IN_SECONDS) { (gdb) p d $6 = 2073600 (gdb) p t->tv_sec $7 = -179158953570 (gdb) Converting to adding paranthesis around around the ONE_DAY_SECOND causes the order of operations to work as expected. Fixes: #10880 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-25Merge pull request #10868 from donaldsharp/zlog_backtrace_uninitedDavid Lamparter
2022-03-25Merge pull request #10852 from mjstapp/fix_lib_distcleanDavid Lamparter
2022-03-24lib: Prevent uninitialized bytesDonald Sharp
When using zlog_backtrace I am seeing this: ==66286== Syscall param write(buf) points to uninitialised byte(s) ==66286== at 0x4CDF48A: syscall (in /lib/libc.so.7) ==66286== by 0x4A0D409: ??? (in /usr/local/lib/libunwind.so.8.0.1) ==66286== by 0x4A0D694: ??? (in /usr/local/lib/libunwind.so.8.0.1) ==66286== by 0x4A0E2F4: _ULx86_64_step (in /usr/local/lib/libunwind.so.8.0.1) ==66286== by 0x49662DB: zlog_backtrace (log.c:250) ==66286== by 0x2AFFA6: if_get_mtu (ioctl.c:163) ==66286== by 0x2B2D9D: ifan_read (kernel_socket.c:457) ==66286== by 0x2B2D9D: kernel_read (kernel_socket.c:1406) ==66286== by 0x499F46E: thread_call (thread.c:2002) ==66286== by 0x495D2B7: frr_run (libfrr.c:1196) ==66286== by 0x2B4098: main (main.c:471) ==66286== Address 0x7fc000000 is on thread 1's stack ==66286== in frame #4, created by zlog_backtrace (log.c:239) ==66286== Let's initialize some data Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-24lib: Fix `terminal monitor` uninited memory usage on freebsdDonald Sharp
When `terminal monitor` is issued I am seeing this for valgrind on freebsd: 2022/03/24 18:07:45 ZEBRA: [RHJDG-5FNSK][EC 100663304] can't open configuration file [/usr/local/etc/frr/zebra.conf] ==52993== Syscall param sendmsg(sendmsg.msg_control) points to uninitialised byte(s) ==52993== at 0x4CE268A: _sendmsg (in /lib/libc.so.7) ==52993== by 0x4B96245: ??? (in /lib/libthr.so.3) ==52993== by 0x4CDF329: sendmsg (in /lib/libc.so.7) ==52993== by 0x49A9994: vtysh_do_pass_fd (vty.c:2041) ==52993== by 0x49A9994: vtysh_flush (vty.c:2070) ==52993== by 0x499F4CE: thread_call (thread.c:2002) ==52993== by 0x495D317: frr_run (libfrr.c:1196) ==52993== by 0x2B4068: main (main.c:471) ==52993== Address 0x7fc000864 is on thread 1's stack ==52993== in frame #3, created by vtysh_flush (vty.c:2065) Fix by initializing the memory to `0` Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-23build: remove generated lib files during distcleanMark Stapp
Remove a couple of lex/yacc output files in lib/ during 'distclean'. Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2022-03-18lib, bgpd: changes for EAD-per-ES fragmentationAnuradha Karuppiah
The EAD-per-ES route carries ECs for all the ES-EVI RTs. As the number of VNIs increase all RTs do not fit into a standard BGP UPDATE (4K) so the route needs to be fragmented. Each fragment is associated with a separate RD and frag-id - 1. Local ES-per-EAD - ES route table - {ES-frag-ID, ESI, ET=0xffffffff, VTEP-IP} global route table - {RD-=ES-frag-RD, ESI, ET=0xffffffff} 2. Remote ES-per-EAD - VNI route table - {ESI, ET=0xffffffff, VTEP-IP} global route table - {RD-=ES-frag-RD, ESI, ET=0xffffffff} Note: The fragment ID is abandoned in the per-VNI routing table. At this point that is acceptable as we dont expect more than one-ES-per-EAD fragment to be imported into the per-VNI routing table. But that may need to be re-worked at a later point. CLI changes (sample with 4 VNIs per-fragment for experimental pruposes) - >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> root@torm-11:mgmt:~# vtysh -c "show bgp l2vpn evpn es 03:44:38:39:ff:ff:01:00:00:01" ESI: 03:44:38:39:ff:ff:01:00:00:01 Type: LR RD: 27.0.0.21:3 Originator-IP: 27.0.0.21 Local ES DF preference: 50000 VNI Count: 10 Remote VNI Count: 10 VRF Count: 3 MACIP EVI Path Count: 33 MACIP Global Path Count: 198 Inconsistent VNI VTEP Count: 0 Inconsistencies: - Fragments: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 27.0.0.21:3 EVIs: 4 27.0.0.21:13 EVIs: 4 27.0.0.21:22 EVIs: 2 VTEPs: 27.0.0.22 flags: EA df_alg: preference df_pref: 32767 27.0.0.23 flags: EA df_alg: preference df_pref: 32767 root@torm-11:mgmt:~# vtysh -c "show bgp l2vpn evpn es-evi vni 1002 detail" VNI: 1002 ESI: 03:44:38:39:ff:ff:01:00:00:01 Type: LR ES fragment RD: 27.0.0.21:13 >>>>>>>>>>>>>>>>>>>>>>>>> Inconsistencies: - VTEPs: 27.0.0.22(EV),27.0.0.23(EV) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PS: The number of EVIs per-fragment has been set to 128 and may need further tuning. Ticket: #2632967 Signed-off-by: Anuradha Karuppiah <anuradhak@nvidia.com>
2022-03-16lib: wheel's typo fixron
The wheel data structure is a array of list pointers but the alloc for it is using the sizeof (struct listnode *) as the amount to allocate. Even though the (struct listnode *) and (struct list *) sizes are the same, let's list the correct values. Signed-off-by: ron <lyq140hf2006@163.com>
2022-03-16Merge pull request #10797 from fabioantonini/sysrepo-2.0.41-supportDonald Sharp
support to sysrepo-2.0.41
2022-03-16lib: grpc: fix covevrity warningsChristian Hopps
One uninit warning and one missing lock warning, both were OK but let's make the tool happy. Signed-off-by: Christian Hopps <chopps@labn.net>
2022-03-16Merge pull request #10763 from donaldsharp/plist_speedupDonatas Abraitis
lib: Convert prefix_master->str to a RB Tree
2022-03-15lib: support to sysrepo-2.0.41Fabio Antonini
northbound_sysrepo.c fixed to use the newer APIs from sysrepo 2.0.41 Signed-off-by: Fabio Antonini <f.antonini@tiesse.com>
2022-03-15Merge pull request #10739 from LabNConsulting/chopps/fixgrpc-reorgDonald Sharp
grpc, lib: grpc cleanup/reorg
2022-03-15Merge pull request #10565 from lyq140/patch-threadDonald Sharp
lib: not thread off when schedule
2022-03-14lib: grpc: rework RPC handlers improve code clarityChristian Hopps
- split NewRpcState object into 2, a Unary and a Streaming variant, which then allows for the next. - move all state machine details inside these new state objects - use a template arg to allow for Streaming state tracking object creation and deletion w/o requiring this in each specific RPC hander. - Code is more rugged by design now. Thanks to Rafael Zalamena <rzalamena@opensourcerouting.org> for the cleanup ideas/motivation. Signed-off-by: Christian Hopps <chopps@labn.net>
2022-03-14Merge pull request #10738 from LabNConsulting/chopps/fixgrpcDonald Sharp
fixes for grpc module
2022-03-14lib: grpc: use candiate ID to delete rather than pointer to candiateChristian Hopps
- also be consistent in candidate IDs being uint64_t Signed-off-by: Christian Hopps <chopps@labn.net>
2022-03-14lib: call protobuf clean up on exitRafael Zalamena
Let's clean up the valgrind output even more by calling the protobuf shutdown function that deallocates all library used memory. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2022-03-13Merge pull request #10724 from opensourcerouting/lib-rotate-logsDonald Sharp
lib: rotate log file supplied by command line
2022-03-13Merge pull request #10716 from donaldsharp/routemap_rbtree_nonuniqDavid Lamparter
2022-03-13Merge pull request #10779 from opensourcerouting/typesafe-backflipDonald Sharp
lib: typesafe container reverse iterators
2022-03-12Merge pull request #10783 from donaldsharp/bgp_zebra_nhtDonatas Abraitis
Bgp zebra nht
2022-03-12*: When matching against a nexthop send and process what it matched againstDonald Sharp
Currently the nexthop tracking code is only sending to the requestor what it was requested to match against. When the nexthop tracking code was simplified to not need an import check and a nexthop check in b8210849b8ac1abe2d5d9a5ab2459abfde65efa5 for bgpd. It was not noticed that a longer prefix could match but it would be seen as a match because FRR was not sending up both the resolved route prefix and the route FRR was asked to match against. This code change causes the nexthop tracking code to pass back up the matched requested route (so that the calling protocol can figure out which one it is being told about ) as well as the actual prefix that was matched to. Fixes: #10766 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-12bgpd, lib, pimd: Remove sockopt_corkDonald Sharp
sockopt_cork is a no-op function that was cleaned up in 2017. Since then it's still not being used. At this point in time there is little point in keeping a dead function that will not be used because of vagaries between platforms Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-12lib: add `_last` and `_prev` on typesafe RB/DLISTDavid Lamparter
RB-tree and double-linked-list easily support backwards iteration, and an use case seems to have popped up. Let's make it accessible. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-11lib: Convert prefix_master->str to a RB TreeDonald Sharp
The prefix_master->str data structure was a sorted list of the prefix names. Not that big of a deal other than insertion and deletion is insanely expensive when you have a large number of unique prefix-lists. In my test config file that I discovered this, I have 587 unique prefix lists spread out acros ~26k lines of prefix-lists. When reading this config file into FRR the read time goes from 690 seconds to 650 seconds. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-11lib: add `%pFXh` to print prefix w/o prefixlenDavid Lamparter
Mostly for pimd, for the time being. May be removed again if unused. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-11lib: add JSON printfrr dict-key helperDavid Lamparter
`json_object_object_add()` adds keys/items to objects/dictionaries. Useful to have a printfrr based variant for the key there. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-10Merge pull request #10749 from opensourcerouting/live-log-polishDonald Sharp
lib, vtysh: apply some polish to live-log feature
2022-03-07lib, vtysh: report lost messages on live logDavid Lamparter
The vtysh live logs don't try to buffer messages when vtysh isn't reading them fast enough. Either the kernel has space and can accept messages without delay, or it doesn't and we continue on. While this is intentional (otherwise slow vtysh could block a routing daemon), at least give the user an indication if messages were dropped. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-07lib: add `monitor:<fd>` command line log targetDavid Lamparter
This provides direct raw log output with full metadata directly at startup regardless of configuration details. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-07lib: add a few more bits to live log headerDavid Lamparter
... and add some comments explaining the individual fields. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-07lib: support multiple `--log` optionsDavid Lamparter
Allow simultaneously enabling syslog, stdout and/or file logs. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-07lib: make live log sockets non-blockingDavid Lamparter
This was the intent here to begin with, not sure where I managed to forget this along the way... Signed-off-by: David Lamparter <equinox@opensourcerouting.org>