From 5c075a907dee4776236d71c5c89eabf5e6e0f2b3 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Mon, 6 Nov 2017 01:41:27 -0500 Subject: bgpd: properly set peer->last_update Instead of checking whether the post-write number of updates sent was greater than the pre-write number of updates sent, it was comparing post to zero. In effect this meant every time we wrote a packet it was counted as an update for route advertisement timer purposes. Signed-off-by: Quentin Young --- bgpd/bgp_io.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'bgpd/bgp_io.c') diff --git a/bgpd/bgp_io.c b/bgpd/bgp_io.c index 807f577a2..a2ce18fa0 100644 --- a/bgpd/bgp_io.c +++ b/bgpd/bgp_io.c @@ -370,10 +370,14 @@ static uint16_t bgp_write(struct peer *peer) int num; int update_last_write = 0; unsigned int count = 0; - unsigned int oc = 0; + uint32_t oc; + uint32_t uo; uint16_t status = 0; uint32_t wpkt_quanta_old; + // save current # updates sent + oc = atomic_load_explicit(&peer->update_out, memory_order_relaxed); + // cache current write quanta wpkt_quanta_old = atomic_load_explicit(&peer->bgp->wpkt_quanta, memory_order_relaxed); @@ -449,11 +453,12 @@ static uint16_t bgp_write(struct peer *peer) done : { /* Update last_update if UPDATEs were written. */ - if (peer->update_out > oc) + uo = atomic_load_explicit(&peer->update_out, memory_order_relaxed); + if (uo > oc) atomic_store_explicit(&peer->last_update, bgp_clock(), memory_order_relaxed); - /* If we TXed any flavor of packet update last_write */ + /* If we TXed any flavor of packet */ if (update_last_write) atomic_store_explicit(&peer->last_write, bgp_clock(), memory_order_relaxed); -- cgit v1.2.3