From: Quentin Young Date: Mon, 12 Jun 2017 20:20:50 +0000 (+0000) Subject: bgpd: re-add update-group write triggers X-Git-Tag: frr-4.0-dev~120^2~26 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=2fc102e16bc2e430bf56198ca9ff73666b483693;p=mirror%2Ffrr.git bgpd: re-add update-group write triggers Removed in earlier version where the I/O pthread busy-waited for packets to be posted to an output queue. Now that it's poll()-based, it's necessary once again. Although this time we can say what we're actually doing instead of a side effect of a write job. Signed-off-by: Quentin Young --- diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c index 585c6cebbc..a45353b375 100644 --- a/bgpd/bgp_updgrp.c +++ b/bgpd/bgp_updgrp.c @@ -53,6 +53,7 @@ #include "bgpd/bgp_updgrp.h" #include "bgpd/bgp_route.h" #include "bgpd/bgp_filter.h" +#include "bgpd/bgp_io.h" /******************** * PRIVATE FUNCTIONS @@ -1867,6 +1868,21 @@ void peer_af_announce_route(struct peer_af *paf, int combine) subgrp->peer_count - 1); } +void subgroup_trigger_write(struct update_subgroup *subgrp) +{ + struct peer_af *paf; + + /* For each peer in the subgroup, schedule a job to pull packets from + * the + * subgroup output queue into their own output queue. This action will + * trigger a write job on the I/O thread. */ + SUBGRP_FOREACH_PEER(subgrp, paf) + if (paf->peer->status == Established) + thread_add_timer_msec(bm->master, bgp_generate_updgrp_packets, + paf->peer, 0, + &paf->peer->t_generate_updgrp_packets); +} + int update_group_clear_update_dbg(struct update_group *updgrp, void *arg) { UPDGRP_PEER_DBG_OFF(updgrp); diff --git a/bgpd/bgp_updgrp.h b/bgpd/bgp_updgrp.h index 3e503a8be7..97afe7a11a 100644 --- a/bgpd/bgp_updgrp.h +++ b/bgpd/bgp_updgrp.h @@ -442,6 +442,7 @@ extern void bgp_adj_out_unset_subgroup(struct bgp_node *rn, char withdraw, u_int32_t addpath_tx_id); void subgroup_announce_table(struct update_subgroup *subgrp, struct bgp_table *table); +extern void subgroup_trigger_write(struct update_subgroup *subgrp); extern int update_group_clear_update_dbg(struct update_group *updgrp, void *arg); diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c index 1ec9915ee5..705cb152f0 100644 --- a/bgpd/bgp_updgrp_adv.c +++ b/bgpd/bgp_updgrp_adv.c @@ -483,6 +483,7 @@ void bgp_adj_out_unset_subgroup(struct bgp_node *rn, { struct bgp_adj_out *adj; struct bgp_advertise *adv; + bool trigger_write; if (DISABLE_BGP_ANNOUNCE) return; @@ -500,9 +501,16 @@ void bgp_adj_out_unset_subgroup(struct bgp_node *rn, adv->rn = rn; adv->adj = adj; + /* Note if we need to trigger a packet write */ + trigger_write = + BGP_ADV_FIFO_EMPTY(&subgrp->sync->withdraw); + /* Add to synchronization entry for withdraw * announcement. */ BGP_ADV_FIFO_ADD(&subgrp->sync->withdraw, &adv->fifo); + + if (trigger_write) + subgroup_trigger_write(subgrp); } else { /* Remove myself from adjacency. */ BGP_ADJ_OUT_DEL(rn, adj); diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c index 77b3ce1937..de4a85ca24 100644 --- a/bgpd/bgp_updgrp_packet.c +++ b/bgpd/bgp_updgrp_packet.c @@ -1148,6 +1148,7 @@ void subgroup_default_update_packet(struct update_subgroup *subgrp, bgp_packet_set_size(s); (void)bpacket_queue_add(SUBGRP_PKTQ(subgrp), s, &vecarr); + subgroup_trigger_write(subgrp); } void subgroup_default_withdraw_packet(struct update_subgroup *subgrp) @@ -1240,6 +1241,7 @@ void subgroup_default_withdraw_packet(struct update_subgroup *subgrp) bgp_packet_set_size(s); (void)bpacket_queue_add(SUBGRP_PKTQ(subgrp), s, NULL); + subgroup_trigger_write(subgrp); } static void