From af1e1dc69e68f8cdea21f1bf8623ab22394594f4 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Mon, 6 Nov 2017 14:15:36 -0500 Subject: [PATCH] bgpd: re-add write trigger logic Apparently I didn't fully understand how subgroup packets make their way out to individual peers. Turns out (on the base branch) we just busy poll while waiting for packets to make their way onto subgroup queues. While this needs to be fixed in the future, for now readding this logic fixes performance issues with convergence. --- bgpd/bgp_packet.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index 31918236ef..b28612922f 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -305,6 +305,59 @@ int bgp_nlri_parse(struct peer *peer, struct attr *attr, return -1; } +/* The next action for the peer from a write perspective */ +static void bgp_write_proceed_actions(struct peer *peer) +{ + afi_t afi; + safi_t safi; + struct peer_af *paf; + struct bpacket *next_pkt; + struct update_subgroup *subgrp; + + for (afi = AFI_IP; afi < AFI_MAX; afi++) + for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { + paf = peer_af_find(peer, afi, safi); + if (!paf) + continue; + subgrp = paf->subgroup; + if (!subgrp) + continue; + + next_pkt = paf->next_pkt_to_send; + if (next_pkt && next_pkt->buffer) { + BGP_TIMER_ON(peer->t_generate_updgrp_packets, + bgp_generate_updgrp_packets, 0); + return; + } + + /* No packets readily available for AFI/SAFI, are there + * subgroup packets + * that need to be generated? */ + if (bpacket_queue_is_full(SUBGRP_INST(subgrp), + SUBGRP_PKTQ(subgrp)) + || subgroup_packets_to_build(subgrp)) { + BGP_TIMER_ON(peer->t_generate_updgrp_packets, + bgp_generate_updgrp_packets, 0); + return; + } + + /* No packets to send, see if EOR is pending */ + if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { + if (!subgrp->t_coalesce + && peer->afc_nego[afi][safi] + && peer->synctime + && !CHECK_FLAG(peer->af_sflags[afi][safi], + PEER_STATUS_EOR_SEND) + && safi != SAFI_MPLS_VPN) { + BGP_TIMER_ON( + peer->t_generate_updgrp_packets, + bgp_generate_updgrp_packets, 0); + return; + } + } + } +} + /** * Enqueue onto the peer's output buffer any packets which are pending for the * update group it is a member of. @@ -407,6 +460,8 @@ int bgp_generate_updgrp_packets(struct thread *thread) } } while (s); + bgp_write_proceed_actions(peer); + return 0; } -- 2.39.5