Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rajasekarr/backpressure bgp zebra #15390

Conversation

raja-rajasekar
Copy link
Contributor

No description provided.

@raja-rajasekar raja-rajasekar force-pushed the rajasekarr/backpressure_bgp_zebra branch from c06a3b1 to ccf66cf Compare February 20, 2024 19:28
@github-actions github-actions bot added the rebase PR needs rebase label Feb 20, 2024
Currently, the way zebra works is it creates pthread per client (BGP is
of interest in this case) and this thread loops itself in zserv_read()
to check for any incoming data. If there is one, then it reads,
validates and adds it in the ibuf_fifo signalling the main thread to
process the message. The main thread when it gets a change, processes
the message, and invokes the function pointer registered in the header
command. (Ex: zserv_handlers).

Finally, if all of this was successful, this task reschedules itself and
loops in zserv_read() again

However, if there are already items on the ibuf FIFO, that means zebra is
slow in processing. And with the current mechanism if Zebra main is busy,
the ibuf FIFO keeps growing holding up the memory.

Show memory zebra:(Example: 3456 FIFO elements hoarding ~160 MB of data)
--- qmem libfrr ---
Stream                  :       44 variable   3432352    15042 161243800
Stream FIFO             :       45     72        3240       48      3456

Fix:
 - Stop doing the read events when we know there are X number of items
   on the FIFO already.(X - zebra zapi-packets <1-10000> (Default-1000)
 - In zserv_read(), determine the number of items on the zserv->ibuf_fifo.
   Subtract this from the work items and only pull the number of items off
   that would take us to X items on the ibuf_fifo again.
 - If the number of items in the ibuf_fifo has reached to the maximum
    * Either initially when zserv_read() is called (or)
    * when processing the remainders of the incoming buffer
   the zserv_read which runs in client’s pthread expects the zebra main to
   schedule a wake up in zserv_process_message after the processing of all
   the items on the buffer.

Ticket: #3390099

Signed-off-by: Rajasekar Raja <[email protected]>
@raja-rajasekar raja-rajasekar force-pushed the rajasekarr/backpressure_bgp_zebra branch from ccf66cf to c3d2ea5 Compare February 20, 2024 20:19
Modify the bgp master to hold a type safe list for bgp_dests that need
to be passed to zebra.

Future commits will use this.

Ticket: #3390099

Signed-off-by: Donald Sharp <[email protected]>
Signed-off-by: Rajasekar Raja <[email protected]>
@raja-rajasekar raja-rajasekar force-pushed the rajasekarr/backpressure_bgp_zebra branch 3 times, most recently from 5e9a493 to 7102764 Compare February 21, 2024 05:07
donaldsharp and others added 3 commits February 21, 2024 10:12
Since installing/withdrawing routes into zebra is going to be changed
around to be dest based in a list,
 - Retrieve the afi/safi to use based upon the dest's afi/safi
   instead of passing it in.
 - Prefix is known by the dest. Remove this arg as well

Ticket: #3390099

Signed-off-by: Donald Sharp <[email protected]>
Signed-off-by: Rajasekar Raja <[email protected]>
BGP is now keeping a list of dests with the dest having a pointer
to the bgp_path_info that it will be working on.

1) When bgp receives a prefix, process it, add the bgp_dest of the
prefix into the new Fifo list if not present, update the flags (Ex:
earlier if the prefix was advertised and now it is a withdrawn),
increment the ref_count and DO NOT advertise the install/withdraw
to zebra yet.

2) Schedule an event to wake up to invoke the new function which will
walk the list one by one and installs/withdraws the routes into zebra.
  a) if BUFFER_EMPTY, process the next item on the list
  b) if BUFFER_PENDING, bail out and the callback in
  zclient_flush_data() will invoke the same function when BUFFER_EMPTY

Changes
 - rename old bgp_zebra_announce to bgp_zebra_announce_actual
 - rename old bgp_zebra_withdrw to bgp_zebra_withdraw_actual
 - Handle new fifo list cleanup in bgp_exit()
 - New funcs: bgp_handle_route_announcements_to_zebra() and
   bgp_zebra_route_install()
 - Define a callback function to invoke
   bgp_handle_route_announcements_to_zebra() when BUFFER_EMPTY in
   zclient_flush_data()

The current change deals with bgp installing routes via
bgp_process_main_one()

Ticket: #3390099

Signed-off-by: Donald Sharp <[email protected]>
Signed-off-by: Rajasekar Raja <[email protected]>
Current changes deals with EVPN routes installation to zebra.

In evpn_route_select_install() we invoke evpn_zebra_install/uninstall
which sends zclient_send_message(). Making similar changes as previous
commit to handle evpn part of the code.

Ticket: #3390099

Signed-off-by: Rajasekar Raja <[email protected]>
@donaldsharp
Copy link
Member

each component will get it's own PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants