summaryrefslogtreecommitdiff
path: root/zebra/zserv.c
AgeCommit message (Collapse)Author
2024-12-03zebra: separate zebra ZAPI server open and acceptMark Stapp
Separate zebra's ZAPI server socket handling into two phases: an early phase that opens the socket, and a later phase that starts listening for client connections. Signed-off-by: Mark Stapp <mjs@cisco.com> (cherry picked from commit 506097a1b96974c261411edd25330ceaf90fa3db)
2023-07-04Merge pull request #13333 from donaldsharp/vrf_bitmap_cleanupDonatas Abraitis
*: Rearrange vrf_bitmap_X api to reduce memory footprint
2023-06-27zebra: Free Zebra client resourcesDonatas Abraitis
Memory leaks started flowing: ``` AddressSanitizer Topotests Part 0: 15 KB -> 283 KB AddressSanitizer Topotests Part 1: 1 KB -> 495 KB AddressSanitizer Topotests Part 2: 13 KB -> 478 KB AddressSanitizer Topotests Part 3: 39 KB -> 213 KB AddressSanitizer Topotests Part 4: 30 KB -> 836 KB AddressSanitizer Topotests Part 5: 0 bytes -> 356 KB AddressSanitizer Topotests Part 6: 86 KB -> 783 KB AddressSanitizer Topotests Part 7: 0 bytes -> 354 KB AddressSanitizer Topotests Part 8: 0 bytes -> 62 KB AddressSanitizer Topotests Part 9: 408 KB -> 518 KB ``` ``` Direct leak of 3584 byte(s) in 1 object(s) allocated from: #0 0x7f1957b02d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) #1 0x559895c55df0 in qcalloc lib/memory.c:105 #2 0x559895bc1cdf in zserv_client_create zebra/zserv.c:743 #3 0x559895bc1cdf in zserv_accept zebra/zserv.c:880 #4 0x559895cf3438 in event_call lib/event.c:1995 #5 0x559895c3901c in frr_run lib/libfrr.c:1213 #6 0x559895a698f1 in main zebra/main.c:472 #7 0x7f195635ec86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) ``` Fixes b20acd0 ("bgpd: Use synchronous way to get labels from Zebra") Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-06-26*: Rearrange vrf_bitmap_X api to reduce memory footprintDonald Sharp
When running all daemons with config for most of them, FRR has sharpd@janelle:~/frr$ vtysh -c "show debug hashtable" | grep "VRF BIT HASH" | wc -l 3570 3570 hashes for bitmaps associated with the vrf. This is a very large number of hashes. Let's do two things: a) Reduce the created size of the actually created hashes to 2 instead of 32. b) Delay generation of the hash *until* a set operation happens. As that no hash directly implies a unset value if/when checked. This reduces the number of hashes to 61 in my setup for normal operation. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-06-20zebra: Ignore non GR-aware zclient handling for BGPDonatas Abraitis
This is for synchronous client (label/table manager) - aka session_id == 1. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-06-20zebra: Show session id when printing an error when the client disconnectsDonatas Abraitis
Before: ``` 2023/06/18 22:00:42 ZEBRA: [VXKFG-8SJRV][EC 4043309121] Client 'bgp' encountered an error and is shutting down. 2023/06/18 22:00:42 ZEBRA: [VXKFG-8SJRV][EC 4043309121] Client 'bgp' encountered an error and is shutting down. ``` After: ``` 2023/06/18 22:06:44 ZEBRA: [N5M5Y-J5BPG][EC 4043309121] Client 'bgp' (session id 0) encountered an error and is shutting down. 2023/06/18 22:06:44 ZEBRA: [N5M5Y-J5BPG][EC 4043309121] Client 'bgp' (session id 1) encountered an error and is shutting down. ``` Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-06-01zebra: No need to set msg to NULLDonald Sharp
The msg value is always reset to something new before it is used inside the mutex. No need to set it to NULL. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-29zebra: remove current_afi as that it is no longer usedDonald Sharp
After the restructure of the gr code to allow zebra_gr to have individual cleanups of afi, this is no longer necessary. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-29zebra: GR code could potentially stop runningDonald Sharp
When GR is running and attempting to clear up a node if the node that is currently saved and we are coming back to happens to be deleted during the time zebra suspends the GR code due to hitting the node limit then zebra GR code will just completely stop processing and potentially leave stale nodes around forever. Let's just remove this hole and process what we can. Can you imagine trying to debug this after the fact? If we remove a node then that counts toward the maximum to process of ZEBRA_MAX_STALE_ROUTE_COUNT. This should prevent any non-processing with a slightly larger cost of having to look at a few nodes repeatedly Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert event.h to frrevent.hDonald Sharp
We should probably prevent any type of namespace collision with something else. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert THREAD_XXX macros to EVENT_XXX macrosDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert thread_timer_remain_XXX to event_timer_remain_XXXDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert thread_cancelXXX to event_cancelXXXDonald Sharp
Modify the code base so that thread_cancel becomes event_cancel Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert thread_add_XXX functions to event_add_XXXDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Rename `struct thread` to `struct event`Donald Sharp
Effectively a massive search and replace of `struct thread` to `struct event`. Using the term `thread` gives people the thought that this event system is a pthread when it is not Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Rename thread.[ch] to event.[ch]Donald Sharp
This is a first in a series of commits, whose goal is to rename the thread system in FRR to an event system. There is a continual problem where people are confusing `struct thread` with a true pthread. In reality, our entire thread.c is an event system. In this commit rename the thread.[ch] files to event.[ch]. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-02-09*: auto-convert to SPDX License IDsDavid Lamparter
Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-01-06zebra: do not load/store wider-than-ptr atomicsDavid Lamparter
Most 32-bit architectures cannot do atomic loads and stores of data wider than their pointer size, i.e. 32 bit. Funnily enough they generally *can* do a CAS2, i.e., 64-bit compare-and-swap, but while a CAS can emulate atomic add/bitops, loads and stores aren't available. Replace with a mutex; since this is 99% used from the zserv thread, the mutex should take the local-to-thread fast path anyway. And while one atomic might be faster than a mutex lock/unlock, we're doing several here, and at some point a mutex wins on speed anyway. This fixes build on armel, mipsel, m68k, powerpc, and sh4. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-01-03zebra: fix a couple of typosMark Stapp
Fix a couple of typos in vty prompt and output text. Signed-off-by: Mark Stapp <mjs@labn.net>
2022-12-05zebra: use real MTYPEs for various objectsMark Stapp
Don't use MTYPE_TMP for many things in zebra: add specific mem types. Signed-off-by: Mark Stapp <mjs@labn.net>
2022-08-24zebra: Convert time to uint64_t for zclient data structuresDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-20*: frr_with_mutex change to follow our standardDonald Sharp
convert: frr_with_mutex(..) to: frr_with_mutex (..) To make all our code agree with what clang-format is going to produce Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-02*: Fix spelling of GracefullDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-23*: Change thread->func to return void instead of intDonald Sharp
The int return value is never used. Modify the code base to just return a void instead. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-11-17zebra: Expand v4/v6 route spaceDonald Sharp
At some scale we eventually run out of room displaying v4/v6 route totals for `show zebra client summ`: janelle# show zebra client summ Name Connect Time Last Read Last Write IPv4 Routes IPv6 Routes -------------------------------------------------------------------------------- bgp 04w0d18h 00:00:19 00:01:2411729127/4052681 2037786/903094 This total over ran the space in just a little over a week of uptime. Expand to have a bit more room. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-10-07zebra: Display how long zebra is expected to wait for GRDonald Sharp
When a client sends to zebra that GR mode is being turned on. The client also passes down the time zebra should hold onto the routes. Display this time with the output of the `show zebra client` command as well. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-10-07zebra: GR data was being printed 2 times for `show zebra client`Donald Sharp
When issuing the `show zebra client` command data about Graceful Restart state is being printed 2 times. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-07-21zebra: On client shutdown cleanup any vrf labels associated with itDonald Sharp
When a vrf label is created by a client and the client disconnects we should clean up any vrf labels associated with that client. eva# show mpls table Inbound Label Type Nexthop Outbound Label ----------------------------------------------- 1000 SHARP RED - eva# exit sharpd@eva ~/f/zebra (label_destruction)> ps -ef | grep frr root 4017793 1 0 13:57 ? 00:00:00 /usr/lib/frr/watchfrr -d -F datacenter --log file:/var/log/frr/watchfrr.log --log-level debug zebra bgpd ospfd isisd pimd eigrpd sharpd staticd frr 4017824 1 0 13:57 ? 00:00:00 /usr/lib/frr/zebra -d -F datacenter --log file:/tmp/zebra.log -r --graceful_restart 60 -A 127.0.0.1 -s 90000000 frr 4017829 1 0 13:57 ? 00:00:00 /usr/lib/frr/bgpd -d -F datacenter -M rpki -A 127.0.0.1 frr 4017836 1 0 13:57 ? 00:00:00 /usr/lib/frr/ospfd -d -F datacenter -A 127.0.0.1 frr 4017839 1 0 13:57 ? 00:00:00 /usr/lib/frr/isisd -d -F datacenter -A 127.0.0.1 frr 4017842 1 0 13:57 ? 00:00:00 /usr/lib/frr/pimd -d -F datacenter -A 127.0.0.1 frr 4017865 1 0 13:57 ? 00:00:00 /usr/lib/frr/eigrpd -d -F datacenter -A 127.0.0.1 frr 4017869 1 0 13:57 ? 00:00:00 /usr/lib/frr/sharpd -d -F datacenter -A 127.0.0.1 frr 4017888 1 0 13:57 ? 00:00:00 /usr/lib/frr/staticd -d -F datacenter -A 127.0.0.1 sharpd 4018624 3938423 0 14:02 pts/10 00:00:00 grep --color=auto frr sharpd@eva ~/f/zebra (label_destruction)> sudo kill -9 4017869 sharpd@eva ~/f/zebra (label_destruction)> sudo vtysh -c "show mpls table" sharpd@eva ~/f/zebra (label_destruction)> Fixes: #1787 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-06-10zebra: Move individual lines to table in `show zebra client` commandDonald Sharp
Move some individual add/delete lines to the table format in the `show zebra client` command Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-06-10zebra: Add message counts for `show zebra client`Donald Sharp
There were counters FRR was keeping but never displaying. Add them in. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-04-23*: drop zassert.hDavid Lamparter
It's not actually working properly... Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-04-09zebra: link layer config and notification, implementation in zebraPhilippe Guibert
zebra implements zebra api for configuring link layer information. that can be an arp entry (for ipv4) or ipv6 neighbor discovery entry. This can also be an ipv4/ipv6 entry associated to an underlay ipv4 address, as it is used in gre point to multipoint interfaces. this api will also be used as monitoring. an hash list is instantiated into zebra (this is the vrf bitmap). each client interested in those entries in a specific vrf, will listen for following messages: entries added, removed, or who-has messages. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-02-04zebra: Display instance id as part of `show zebra client summ`Donald Sharp
When displaying `show zebra client summ` when we have instances running, display the instance number as well. New Output: sharpd@eva ~/frr7 (instance_data)> vtysh -c "show zebra client summ" Name Connect Time Last Read Last Write IPv4 Routes IPv6 Routes -------------------------------------------------------------------------------- ospf[1] 00:00:02 00:00:02 00:00:02 0/0 0/0 ospf[5] 00:00:02 00:00:02 00:00:02 0/0 0/0 sharp 00:00:02 00:00:02 00:00:02 0/0 0/0 static 00:00:02 00:00:02 00:00:02 0/0 0/0 Routes column shows (added+updated)/deleted Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-12-10zebra: Allow `show zebra client` to give clues about route update statusDonald Sharp
When entering `show zebra client` allow the display of the client->notify_status for route updates. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-12-07zebra: Adding zapi client close notificationKaren Schoener
When zebra detects a client close, send a zapi client close notification. Signed-off-by: Karen Schoener <karen@voltanet.io>
2020-10-22:* Convert prefix2str to %pFXDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-09-28zebra: handle proto NHG uninstall client disconnectStephen Worley
Add code to handle proto-based NHG uninstalling after the owning client disconnects. This is handled the same way as rib_score_proto() but for now we are ignoring instance. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-08-25zebra: remove fuzzing stuffJakub Urbańczyk
The fuzzing code that is in the master branch is outdated and unused, so it is worth to remove it to improve readablity of the code. All the code related to the fuzzing is in the `fuzz` branch. Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-08-10Merge pull request #6483 from sylane/router-id-v6Donald Sharp
zebra: add IPv6 router-id
2020-08-05zebra: Ethernet segment management and support for MAC-ECMPAnuradha Karuppiah
1. Local ethernet segments are configured in zebra by attaching a local-es-id and sys-mac to a access interface - >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ! interface hostbond1 evpn mh es-id 1 evpn mh es-sys-mac 00:00:00:00:01:11 ! >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> This info is then sent to BGP and used for the generation of EAD-per-ES routes. 2. Access VLANs associated with an (ES) access port are translated into ES-EVI objects and sent to BGP. This is used by BGP for the generation of EAD-EVI routes. 3. Remote ESs are imported by BGP and sent to zebra. A list of VTEPs is maintained per-remote ES in zebra. This list is used for the creation of the L2-NHG that is used for forwarding traffic. 4. MAC entries with a non-zero ESI destination use the L2-NHG associated with the ESI for forwarding traffic over the VxLAN overlay. Please see zebra_evpn_mh.h for the datastruct organization details. Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-07-17zebra: add IPv6 router-idSebastien Merle
* add a vrf sub-command `[no] ipv6 router-id X:X::X:X`. * add command `[no] ipv6 router-id X:X::X:X [vrf NAME]` for backward compatibility. * add a vrf sub-command `[no] ip router-id A.B.C.D` and make the old one without `ip` an alias for it. * add a command `[no] ip router-id A.B.C.D [vrf NAME]` for backward comptibility and make the old one without `ip` an alias for it. * add command `show ip router-id [vrf NAME]` and make the old one without `ip` an alias for it. * add command `show ipv6 router-id [vrf NAME]`. * add ZAPI commands `ZEBRA_ROUTER_ID_V6_ADD`, `ZEBRA_ROUTER_ID_V6_DELETE` and `ZEBRA_ROUTER_ID_V6_UPDATE` for deamons to get notified of the IPv6 router-id. * update zebra documentation. Signed-off-by: Sebastien Merle <sebastien@netdef.org>
2020-06-10sharpd,zebra: unicast support for zapi messagesMark Stapp
Distinguish between unicast and broadcast opaque messages in zebra handler code. Add cli and internal api changes to have sharpd send unicast opaque messages. Add opaque cli commands to the sharp user doc. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-02zebra: add zserv_send_batch apiMark Stapp
Add a zserv api to send a batch (a fifo) of messages to a zapi client. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-02zebra: don't print stale text if no GR infoMark Stapp
Don't print GR show output header if no GR info is present for a zapi client. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-02zebra: call zapi message handler with a batchMark Stapp
The zapi code processes a batch of incoming messages, using a fifo. Hand the entire batch into the main zebra handling code, and let it loop through the individual messages. Divert the special OPAQUE messages from the normal processing flow, and offer them to the new zebra_opaque module instead. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-02zebra: add lock and busy counter for zclientsMark Stapp
Add a mutex used to manage the list of zclients. Add a busy counter to the zapi client session, so that we can use a client session from another pthread. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-05-28zebra, lib: bugfix on zebra packet debuggingWesley Coakley
`debug zebra packet detail` dumps the full message whereas it had been dropping exactly 10 bytes, the size of the zebra header Signed-off-by: Wesley Coakley <wcoakley@cumulusnetworks.com>
2020-04-16lib,zebra: add a session id for zapi sessionsMark Stapp
Distinguish zapi sessions, for daemons who use more than one, by adding a session id. The tuple of proto + instance is not adequate to support clients who use multiple zapi sessions. Include the id in the client show output if it's present. Add a bit of info about this to the developer doc. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-04-14zebra: use %u for unsigned when printing countersQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-03-09lib, *: add a common time interval formatting apiMark Stapp
Add a common api that formats a time interval into a string with different output for short and longer intervals. We do this in several places, for cli/ui output. Signed-off-by: Mark Stapp <mjs@voltanet.io>