]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: turn off keepalives when sending NOTIFY
authorQuentin Young <qlyoung@cumulusnetworks.com>
Mon, 13 Nov 2017 22:59:04 +0000 (17:59 -0500)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 30 Nov 2017 21:18:07 +0000 (16:18 -0500)
This is necessary because otherwise between the time we wipe the output
buffer and the time we push the NOTIFY onto it, the KA generation thread
could have pushed a KEEPALIVE in the middle.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
bgpd/bgp_keepalives.c
bgpd/bgp_packet.c

index abe9739c98881519e52c48cdadec0c1da8c46d4c..afa280a799ff7db01569228a465ebb217c2e0490 100644 (file)
@@ -232,6 +232,11 @@ void bgp_keepalives_on(struct peer *peer)
        /* placeholder bucket data to use for fast key lookups */
        static struct pkat holder = {0};
 
+       if (!peerhash_mtx) {
+               zlog_warn("%s: call bgp_keepalives_init() first", __func__);
+               return;
+       }
+
        pthread_mutex_lock(peerhash_mtx);
        {
                holder.peer = peer;
@@ -251,6 +256,11 @@ void bgp_keepalives_off(struct peer *peer)
        /* placeholder bucket data to use for fast key lookups */
        static struct pkat holder = {0};
 
+       if (!peerhash_mtx) {
+               zlog_warn("%s: call bgp_keepalives_init() first", __func__);
+               return;
+       }
+
        pthread_mutex_lock(peerhash_mtx);
        {
                holder.peer = peer;
index fe633413c2bae7e69f52c0fdc1d17260a8905d56..09df0e35b60f8a824b2fd958272f27ad2b8be9d9 100644 (file)
@@ -58,6 +58,7 @@
 #include "bgpd/bgp_updgrp.h"
 #include "bgpd/bgp_label.h"
 #include "bgpd/bgp_io.h"
+#include "bgpd/bgp_keepalives.h"
 
 /**
  * Sets marker and type fields for a BGP message.
@@ -655,6 +656,14 @@ void bgp_notify_send_with_data(struct peer *peer, u_char code, u_char sub_code,
        /* Set BGP packet length. */
        length = bgp_packet_set_size(s);
 
+       /*
+        * Turn off keepalive generation for peer. This is necessary because
+        * otherwise between the time we wipe the output buffer and the time we
+        * push the NOTIFY onto it, the KA generation thread could have pushed
+        * a KEEPALIVE in the middle.
+        */
+       bgp_keepalives_off(peer);
+
        /* wipe output buffer */
        pthread_mutex_lock(&peer->io_mtx);
        {