]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: properly set peer->last_update
authorQuentin Young <qlyoung@cumulusnetworks.com>
Mon, 6 Nov 2017 06:41:27 +0000 (01:41 -0500)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 30 Nov 2017 21:18:06 +0000 (16:18 -0500)
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 <qlyoung@cumulusnetworks.com>
bgpd/bgp_io.c

index 807f577a2dc85ae6d0972db9027276fa1ae6fb2a..a2ce18fa059adbce4d82aabc1989e8d8a8709e69 100644 (file)
@@ -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);